In [13]:
fin = open('synthetic/synth-cascades-7/only_zurich_friendship.out', 'r')
fout = open('synthetic/synth-cascades-7/synth-cascades-7.txt', 'w')
In [14]:
nodenum = 1
In [3]:
node_mapping = {}
In [15]:
for line in fin:
u1, u2 = map(int, line[:-1].split(','))
for u in [u1, u2]:
if u not in node_mapping.keys():
node_mapping[u] = nodenum
nodenum += 1
fout.write('%d,%d\n' % (node_mapping[u1], node_mapping[u2]))
In [16]:
fin.close()
fout.close()
In [16]:
In [17]:
fg = open('synthetic/synth-cascades-7/ground_truth.txt')
fgo = open('synthetic/synth-cascades-7/ground_truth_fixed.txt', 'w')
In [18]:
for line in fg:
source, target, weight = line[:-1].split()
fgo.write('%d,%d,%s\n' % (node_mapping[int(source)], node_mapping[int(target)], weight))
In [19]:
fg.close()
fgo.close()
In [ ]: