Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NetworkX node attribute drawing

Im using networkx for visualization. I see when I use the function draw_networkx_edge_labels I can retrieve the labels for edges.

I want to print the attribute on node ( instead of the label).. try everything almost . still stuck. If i have 5 attributes per node, is there anyway I can print a specific attribute on each node ? For example, if a car node has attributes: size, price, company, .. I want to print the size of the car on each node ?

Don't know whether can output this on graph.

like image 765
SDR Avatar asked Oct 20 '10 22:10

SDR


1 Answers

You can do it by specifying the labels= keyword

import pylab import networkx as nx G=nx.Graph() G.add_node('Golf',size='small') G.add_node('Hummer',size='huge') G.add_edge('Golf','Hummer') labels = nx.get_node_attributes(G, 'size')  nx.draw(G,labels=labels,node_size=1000) pylab.show() 
like image 79
Aric Avatar answered Sep 28 '22 18:09

Aric