views:

129

answers:

1

I am not using GraphViz because I am having problems with making it play nice with Networkx. I know this is weird, but I've tried many suggestions to fix this problem, but I just seem to have some of the worst luck in the world. Therefore the problem that I have must be solved withing Networkx without using GraphViz.

My program reads a document and and tries to draw something of a MindMap based on the contents of the document. However, Networkx seems to have a default size when it comes to actually drawing the node. This is bad for me because a lot of text goes into each of my nodes. I need a way to increase the display-size of my nodes (arbitrarily, based on the size of the text that belongs in that node).

I have tried looking at the Networkx site, other questions on SO and about 200 search results from Google, with no luck.

I would really appreciate any help that you can provide

Thank you

A: 

Try nx.draw(G, node_size=size), where size can be a scalar or an array of length equal to the number of nodes.

Nick_V
if this is an overly simple question, but I'm very new to Networkx. When you say that size can be an array of length equal to the number of nodes, what is each element in the array? Is it a scalar representing the size of a specific node? If so, how does Networkx know to correlate each index of the array with the appropriate node. After all, not all nodes will be of the same size in my graph.
inspectorG4dget
Good question. Last time I tried, I created a simple list similar to sizes = [ x*2 for x in G ]. Here, the node names were integers. For more complex examples, either add a node's size to the list as the node is added to the graph, or loop through the nodes.
Nick_V
Turns out that if you create a list (L) of node display sizes of the same length as G.nodes(), then the size of G.nodes()[i] is set to be L[i]
inspectorG4dget