pythonpython-3.xgraphgraphvizpygraphviz

How do I uniformly scale edge distance based on weight with graphviz in Python?


I have a graph where all the nodes are one degree of separation from the root node. All the edges have different weights however this doesn't seem to be taken into consideration when graphviz renders the final graph. All the nodes end up having the same distance from each other. How can I go about uniformly scaling the distance between nodes based on the weights?

To clarify. This is what I want

wanted outcome

but this is what I get

what I got

I have experimented with different engines as well as unflattening however it doesn't do the trick. The latter gets the look I want but it doesn't consider weights meaning that an arbitrary node gets placed further away.


Solution

  • The `len' attribute sets the edge length.

    So this input dot file

    digraph { a -> b [len = 1] a -> c [len = 3] a -> d [len = 2 ] }
    

    when laid out using this command

    neato -Tpng  input.dot > output.png
    

    gives

    enter image description here