-
Notifications
You must be signed in to change notification settings - Fork 0
/
sums.py
35 lines (32 loc) · 1.07 KB
/
sums.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
# For testing results
import os
import sys
def sumWeightsTargetVals(tvfname):
total = 0
with open(tvfname) as tvf:
for line in tvf:
src, dst, weight = line.split(' ')
total += float(weight)
return total
def sumWeightsNetwork(networkfname):
with open(networkfname) as networkf:
processEdge = False
total = 0
for line in networkf:
if processEdge:
src, dst, weight = line.split(' ')
total += float(weight)
elif line.find('*Edges ') == 0:
processEdge = True
return total
if __name__ == '__main__':
total = 0
for filename in os.listdir(sys.argv[1]):
if filename.startswith('.'):
continue
subt = sumWeightsTargetVals(sys.argv[1] + filename + '/TargetVals.txt')
print subt
total += subt
print 'Final total is %d' % total
# print 'Network total is %g' % sumWeightsNetwork(prefix + '/network.txt')
#print 'Target edge total is %g' % sumWeightsTargetVals(prefix + '/TargetVals.txt')