nidi3 / graphviz-java

Use graphviz with pure java
Apache License 2.0
937 stars 107 forks source link

wrong rendering result when using [dir="back"] #160

Open UltraBuk opened 4 years ago

UltraBuk commented 4 years ago

Hello, I use your great project for the visualization of algorithms. Unfortunately there seem to be some problems when reading the command [dir="back"], because the corresponding edge (node0:n -> node1:n) is not flipped as expected.

I use version 0.16.0, the GraphvizV8Engine and the following dot code (with http://www.webgraphviz.com/ the rendering is fine, so the code must be ok):

digraph binSearch { graph [ranksep="0.05", nodesep="0.05"]; subgraph cluster { {rank=same node0 node1 node2 node3 node4} {rank=sink 0 1 2 3 4} } node0[label=6, shape=square] node1[label=18, shape=square] node2[label=22, shape=square] node3[label=26, shape=square] node4[label=27, shape=square] 0 [shape=none, height=0.05, width=0.05] 1 [shape=none, height=0.05, width=0.05] 2 [shape=none, height=0.05, width=0.05] 3 [shape=none, height=0.05, width=0.05] 4 [shape=none, height=0.05, width=0.05] 0 -> node0 [style=invis] 1 -> node1 [style=invis] 2 -> node2 [style=invis] 3 -> node3 [style=invis] 4 -> node4 [style=invis] node0:n -> node1:n [style=invis] node1:n -> node2:n [style=invis] node2:n -> node3:n [style=invis] node3:n -> node4:n [style=invis] start[label="Vergleich mit Schlüssel 10", shape=none] start:s -> node4:n node1:n -> node4:n [dir="back"] node0:n -> node1:n [dir="back"] }

It would be cool if you could have a look at it. Thanks a lot :)

nidi3 commented 4 years ago

That's really strange. I tried it with native dot and I get the same error. So to me it looks like a bug in certain versions of dot. I'll see if I can update the version used in graphviz-java. Until then I'd propose inversing the edge instead of using dir=back

jeremydouglass commented 4 years ago

possibly relevant:

Graphviz arrowhead doesn't work when dir=back ... not all combinations of dir, arrowhead and arrowtail are valid. https://stackoverflow.com/a/50830845/7207622

nidi3 commented 4 years ago

I checked it with the newest graphviz version 2.44.0 and the problem is still there. Would be very interesting to know what http://www.webgraphviz.com/ is doing.