-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.py
More file actions
89 lines (35 loc) · 1.26 KB
/
Copy pathtest2.py
File metadata and controls
89 lines (35 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from random import shuffle
def graphConv(fileName):
graph = [None]*2
#edges, nodes in graph w/ respective neighbors
graph[0] = [] #all edges in 2-slot-array-format
graph[1] = {} #nodes in graph, w/ keys of node-names leading to 2-slot-arrays of (# neighbors, arrays of their neighbors)
flag = False
with open(fileName,'r') as file:
for line in file:
if flag == False:
flag = True
continue
else:
edge = line.split()
e1 = int(edge[1])
e2 = int(edge[2])
graph[0].append([e1,e2])
if e1 not in graph[1]:
init = [e2]
graph[1][e1] = [0,init]
else:
graph[1][e1][1].append(e2)
if e2 not in graph[1]:
init = [e1]
graph[1][e2] = [0,init]
else:
graph[1][e2][1].append(e1)
for node in graph[1]:
graph[1][node][0] = len(graph[1][node][1])
#print(graph[0][17800:])
#print(graph[1][328])
return graph
def test():
bench = graphConv("frb30-15-1.txt")
test()