Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
graph_fancy.py
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file graph_fancy.py
1 #!/usr/local/bin/python
2 
3 from graph_tool.all import *
4 from pylab import *
5 
6 print 'Graph-tool test program'
7 
8 g = load_graph("./my_test.graphml")
9 
10 print 'Graph is directed = %s '%(g.is_directed())
11 print 'my_test.graphml loaded!'
12 
13 print 'Graph Veretx/Node and Edge properties:'
14 g.list_properties()
15 
16 # --------------------------
17 # Setup for graphViz output usage from graph-tool (best for directed graphs "dot")
18 
19 pT=g.edge_properties["pT"]
20 E=g.edge_properties["E"]
21 
22 t=g.vertex_properties["t"]
23 label=g.vertex_properties["label"]
24 
25 # easy here to change the color scales ... (how to do directly in dot format not clear, certainly not easy via a script)
26 E.a=1/(E.a/10)
27 
28 gdict={'rankdir' : 'LR'} #or top botton 'TB'
29 edict={'dir' : 'forward', 'arrowhead' : 'normal','arrowsize' : '1.0','label' : pT}
30 vdict={'shape' : "plain", 'label' : label}
31 
32 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")
33 
34 # vcolor=t,vcmap=matplotlib.cm.gist_gray
35 # vnorm=True,
36 
37 # --------------------------
38 
39 # ##! python
40 
41 #for e in g.edges():
42 # print(e)
43 
44 #edges = g.get_edges()
45 
46 #for e in g.edges():
47 # print '%s and pT= %s'%(e,g.edge_properties.pT[e])
48 
49 #deg = g.degree_property_map("in")
50 
51 # --------------------------
52 
53 #graph_draw(g,edge_pen_width=pT,output="test-draw.pdf")
54 
55 #pos=planar_layout(g)
56 
57 #graph_draw(g, pos=pos,output="test-draw.pdf")
58 
59 #pos = radial_tree_layout(g, g.vertex(0))
60 #graph_draw(g, pos=pos, output="graph-draw-radial.pdf")
61 
62 #g.save("test.dot")
63 
64 #tree = min_spanning_tree(g)
65 #graph_draw(g, edge_color=tree, output="min_tree.pdf")