File: create_bandage_file.py

package info (click to toggle)
hinge 0.5.0-8
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,972 kB
  • sloc: cpp: 9,480; ansic: 8,826; python: 5,023; sh: 340; makefile: 10
file content (58 lines) | stat: -rwxr-xr-x 808 bytes parent folder | download | duplicates (3)
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
51
52
53
54
55
56
57
58
#!/usr/bin/python3

import sys 
import os



def run(inputfile,outputfile):


	nodes = {}
	arcs = {}

	with open(inputfile) as file:

	    for line in file:

			line_str = line[:-1]
			split_str = line_str.split(' ')

			node0 = int(split_str[0])
			node1 = int(split_str[1])

			# print node0,node1

			nodes[node0] = 1
			nodes[node1] = 1

			if node0 < node1:
				arcs[tuple([node0,node1])] = 1
			else:
				arcs[tuple([node1,node0])] = 1



	with open(outputfile, 'w') as fout:

		for node in nodes:
			fout.write("NODE "+str(node)+' 0 0 0 0 0\n')
			fout.write('AAA\n')
			fout.write('AAA\n')
			# print "NODE "+str(node)

		for arc in arcs:
			fout.write("ARC "+str(arc[0])+' '+str(arc[1])+' 0\n')

		



def main():

    run(sys.argv[1],sys.argv[2])
    return


if __name__ == '__main__':
    main()