Node labeling

From CSBLwiki

Jump to: navigation, search

At this point there is no automated way to draw edge labels. But pylab can put text at arbitrary positions in the graph using the pylab.text() command. So something like this will do a crude job:

   import networkx as NX
   import pylab
   G=NX.XGraph()
   G.add_edges_from([('a','b','a+b'),('b','c','b+c'),('c','a','c+a')])
   pos=NX.spring_layout(G)
   NX.draw(G,pos)
   for (u,v,w) in G.edges():
       ux,uy=pos[u]
       vx,vy=pos[v]
       x=(ux+vx)/2.0
   y=(uy+vy)/2.0
   pylab.text(x,y,w)
   pylab.savefig("edges.eps")
   pylab.show()
Personal tools
Namespaces
Variants
Actions
Site
Choi lab
Resources
Toolbox