CMS 3D CMS Logo

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.

00019                                 :
00020     fin = open(infile,'r')
00021     fout = open(outfile,'w')
00022     tree = {}
00023     count = 0
00024     
00025     for line in fin.xreadlines():
00026 
00027         a = line.split()
00028         id = int(a.pop(0))
00029         tot = int(a.pop(0))
00030         if tot < cutoff: break
00031         head = int(a.pop(0))
00032         
00033         for node in a:
00034             val = int(node)
00035             key = (head,val)
00036                 
00037             n = tree.get(key)
00038             if n == None:
00039                 tree[key] = Int(tot)
00040             else:
00041                 n.inc(tot)
00042             head = val
00043             
00044         count += 1
00045 
00046     for node in tree.items():
00047         # print node
00048         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.