CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
TreeToEdges Namespace Reference

Classes

class  Int
 

Functions

def runme
 

Variables

tuple cutoff = int(sys.argv[3])
 
list infile = sys.argv[1]
 
list outfile = sys.argv[2]
 

Function Documentation

def TreeToEdges.runme (   infile,
  outfile,
  cutoff 
)

Definition at line 18 of file TreeToEdges.py.

18 
19 def runme(infile,outfile,cutoff):
20  fin = open(infile,'r')
21  fout = open(outfile,'w')
22  tree = {}
23  count = 0
24 
25  for line in fin.xreadlines():
26 
27  a = line.split()
28  id = int(a.pop(0))
29  tot = int(a.pop(0))
30  if tot < cutoff: break
31  head = int(a.pop(0))
32 
33  for node in a:
34  val = int(node)
35  key = (head,val)
36 
37  n = tree.get(key)
38  if n == None:
39  tree[key] = Int(tot)
40  else:
41  n.inc(tot)
42  head = val
43 
44  count += 1
45 
46  for node in tree.items():
47  # print node
48  print >>fout, node[1], ' ', node[0][0], ' ', node[0][1]

Variable Documentation

tuple TreeToEdges.cutoff = int(sys.argv[3])

Definition at line 56 of file TreeToEdges.py.

list TreeToEdges.infile = sys.argv[1]

Definition at line 54 of file TreeToEdges.py.

list TreeToEdges.outfile = sys.argv[2]

Definition at line 55 of file TreeToEdges.py.