-
Notifications
You must be signed in to change notification settings - Fork 0
/
dict.py
50 lines (46 loc) · 1.52 KB
/
dict.py
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
39
40
41
42
43
44
45
46
47
48
49
50
import csv, pprint
arc_caps1 = {}
arc_caps2 = {}
with open('DS9_Network_Arc_Data.csv', 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=' ', quotechar='|')
next(reader)
for row in reader:
arc = row[0].split(",")
#print(arc)
if int(arc[0]) not in arc_caps1.keys():
arc_caps1[int(arc[0])] = {int(arc[1]):int(arc[2])}
else:
arc_caps1[int(arc[0])][int(arc[1])] = int(arc[2])
print("\nArc Capacities")
# pprint.pprint(arc_caps1)
print(arc_caps1)
node_demand = {}
with open('DS9_Network_Node_Data.csv', 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=' ', quotechar='|')
next(reader)
for row in reader:
a=row[0].split(",")
node_demand[int(a[0])] = int(a[1])
print("\nDemands per Node")
# pprint.pprint(node_demand)
print(node_demand)
# arc = row[0].split(",")
# if int(arc[0]) not in arc_caps.keys():
# arc_caps[int(arc[0])] = {int(arc[1]):int(arc[2])}
# else:
# arc_caps[int(arc[0])][int(arc[1])] = int(arc[2])
# pprint.pprint(arc_caps)
groups = {}
with open('DS9_Network_Node_Data.csv', 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=' ', quotechar='|')
next(reader)
for row in reader:
arc = row[0].split(",")
#print(arc[2], arc[0])
if int(arc[2]) not in groups:
groups[int(arc[2])] = [int(arc[0])]
else:
groups[int(arc[2])].append(int(arc[0]))
print("\nGroups of Nodes")
# pprint.pprint(groups)
print(groups)