Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:19:05

0001 #!/usr/local/bin/python
0002 
0003 from graph_tool.all import *
0004 from pylab import *
0005 
0006 print 'Graph-tool test program'
0007 
0008 g = load_graph("./my_test.graphml")
0009 
0010 print 'Graph is directed = %s '%(g.is_directed())
0011 print 'my_test.graphml loaded!'
0012 
0013 print 'Graph Veretx/Node and Edge properties:'
0014 g.list_properties()
0015 
0016 # --------------------------
0017 # Setup for graphViz output usage from graph-tool (best for directed graphs "dot")
0018 
0019 pT=g.edge_properties["pT"]
0020 E=g.edge_properties["E"]
0021 
0022 t=g.vertex_properties["t"]
0023 label=g.vertex_properties["label"]
0024 
0025 # easy here to change the color scales ... (how to do directly in dot format not clear, certainly not easy via a script)
0026 E.a=1/(E.a/10)
0027 
0028 gdict={'rankdir' : 'LR'} #or top botton 'TB'
0029 edict={'dir' : 'forward', 'arrowhead' : 'normal','arrowsize' : '1.0','label' : pT}
0030 vdict={'shape' : "plain", 'label' : label}
0031 
0032 graphviz_draw(g,layout="dot",gprops=gdict, vprops=vdict, eprops=edict, ecmap=matplotlib.cm.autumn, penwidth=E, ecolor=E, vcolor="#ffffff", output="my_test_fancy.pdf")
0033 
0034 # vcolor=t,vcmap=matplotlib.cm.gist_gray
0035 # vnorm=True,
0036 
0037 # --------------------------
0038 
0039 # ##! python
0040 
0041 #for e in g.edges():
0042 #    print(e)
0043 
0044 #edges = g.get_edges()
0045 
0046 #for e in g.edges():
0047 #    print '%s and pT= %s'%(e,g.edge_properties.pT[e])
0048 
0049 #deg = g.degree_property_map("in")
0050 
0051 # --------------------------
0052 
0053 #graph_draw(g,edge_pen_width=pT,output="test-draw.pdf")
0054 
0055 #pos=planar_layout(g)
0056 
0057 #graph_draw(g, pos=pos,output="test-draw.pdf")
0058 
0059 #pos = radial_tree_layout(g, g.vertex(0))
0060 #graph_draw(g, pos=pos, output="graph-draw-radial.pdf")
0061 
0062 #g.save("test.dot")
0063 
0064 #tree = min_spanning_tree(g)
0065 #graph_draw(g, edge_color=tree, output="min_tree.pdf")