1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

edge width vs. strokewidth

Posted by Michael Dalby on Jun 05, 2008

In graphs, is there a way to distinguish the width of the strokes for edges vs. the width of stroke for node outlines -- and control them separately programatically? Or could there be? This would be very useful to indicate strength (or other qualities) of connection by varying the width of edges.

Thanks.


 
Posted by Tom De Smedt on Jun 09, 2008

Edges will always use the strokewidth from the default style. If you want the nodes to have a different strokewidth, you need to create a new style and apply it to the nodes:

Assuming g is a graph object:

g.styles.default.strokewidth = 0.5
s = g.styles.create("node")
s.strokewidth = 3
for node in g.nodes:
    node.style = "node"
You can't set the width of each individual edge, this is a speed optimization. If you want to do this you'll need to take a look at the edges() and edge() command in the style.py in the library and start modifying from there.

The graph.draw() command also has a weighted parameter which, when True, gives a subtle indication of an edge's weight.