<jupyter_start><jupyter_text>Origins and Destinations {1}: Seabrook (NH);{2,4,5}: NH;{3}: Haverhill;{6,8}: Lawrence;{7,9}: Georgetown;{10,11}: Lowell;{12,15}: Salem;{13,14}: Peabody;{16,17,18,19}: Burlington;{20}: Littleton;{21}: Lexington;{22}: Boston;{23,24,25,26,27,28}: Waltham;{29}: Quincy;{30,31,32,33,34}: Marlborough & Framingham;{35,71}: Milford;{36}: Franklin;{37,38,39,40,41}: Westwood & Quincy;{42}: Dedham;{43,44,45,46,47}: Foxborough;{48,74}: Taunton;{49,73}: Plymouth;{50,51}: Cape Cod;{52}: Dartmouth;{53}: Fall River;{54,68,70}: RI;{55,56}: VT;{57}: Westminster;{58}: Leominster;{59,60,72}: Worcester;{61}: Amherst;{62,63,64,65,66}: CT;{67}: Webster;{69}: Uxbridge<jupyter_code># aggregate Origins and Destinations
with open('../temp_files/od_nodes_journal.txt') as input_file:
    input_content = input_file.readlines()
od_nodes_dict = {}
od_nodesList_dict = {}
for line_idx in range(len(input_content)):
    line_extracted = input_content[line_idx].split(':')[0].replace('{', '').replace('}', '').split(',')
    od_nodes_dict[line_idx] = set([int(line_extracted[idx]) for idx in range(len(line_extracted))])
    od_nodesList_dict[line_idx] = list(od_nodes_dict[line_idx])
od_nodes_dict, od_nodesList_dict
zdump(od_nodes_dict, '../temp_files/od_nodes_dict_journal.pkz')
zdump(od_nodesList_dict, '../temp_files/od_nodesList_dict_journal.pkz')
# create "fictitious" O-D pair labels
# create a dictionary mapping O-D pairs to labels

import json

n = 74  # number of nodes

OD_pair_label_dict = {}
OD_pair_label_dict_ = {}

label = 0
for i in range(n + 1)[1:]:
    for j in range(n + 1)[1:]:
        if i != j:
            key = (i, j)
            OD_pair_label_dict[str(key)] = label
            OD_pair_label_dict_[str(label)] = key
            label += 1
        
zdump(OD_pair_label_dict, '../temp_files/OD_pair_label_dict_journal.pkz')
zdump(OD_pair_label_dict_, '../temp_files/OD_pair_label_dict__journal.pkz')

from collections import defaultdict


# number of links
m = 258

# create link labels
# create a dictionary mapping directed links to labels
link_label_dict = {}
link_label_dict_ = {}

link_list = [str(ini_node_dict[i]) + '->' + str(ter_node_dict[i]) for i in range(len(ini_node_dict))]

for i in range(m):
    link_label_dict[str(i)] = link_list[i]

for i in range(m):
    link_label_dict_[link_list[i]] = i

zdump(link_label_dict, '../temp_files/link_label_dict_journal.pkz')
zdump(link_label_dict_, '../temp_files/link_label_dict_journal_.pkz')
OD_pair_label_dict, OD_pair_label_dict_, len(OD_pair_label_dict), len(OD_pair_label_dict_)
link_label_dict, link_label_dict_, len(link_label_dict), len(link_label_dict_)
for idx in range(len(link_label_dict)):
    print(idx, link_label_dict[str(idx)])
##### obtain link_length_dict_journal
import json

with open('../temp_files/link_day_minute_Jan_dict_journal_JSON_adjusted.json', 'r') as json_file:
    link_day_minute_Jan_dict_journal_JSON_adjusted = json.load(json_file)
link_length_dict_journal = {}

for link_idx in range(m):
    key = 'link_' + str(link_idx) + '_' + str(1)
    link_length_dict_journal[str(link_idx)] = \
    link_day_minute_Jan_dict_journal_JSON_adjusted[key]['length']
    
with open('../temp_files/link_length_dict_journal.json', 'w') as json_file:
    json.dump(link_length_dict_journal, json_file)
link_length_dict_journal<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1561570493753718, 'fraction_numerical': 0.045211183819155266, 'mean_word_length': 6.310869565217391, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '525829', 'license': 'MIT', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1293, 'n_words': 216, 'path': '02_network_labels_journal18/01_print_OD_pair_link_labels_journal.ipynb', 'repo_name': 'jingzbu/InverseVITraffic', 'size': '3362'}