graphvizdotgraph-layout

Graph rendering software, which respects relative order of Nodes and Edges


I am generating a (GraphViz) "dot" file for a given set of nodes, and edges. The nodes are ordered in y-dimension with rank=same, in x-dimension within the rank. The edges are sorted in the order they should be drawn. Unfortunately "dot" does not respect the order in the x-dimension. If it would, I would achieve a crossing-free layout for plane digraphs. No matter if they are cyclic, or acyclic.

My questions:

  1. How can I tell "dot" to respect the relative order of nodes and edges
  2. Is there an alternative to "dot", which respects the relative order, i.e. accepts the layout, and does the physical rendering.

Sample.dot

Sorry, was not able to upload the dot file.Sample.dot file


Solution

  • Thanks a lot. I thougt "rank=same;0;8;" implicitly means the same as "rank=same;0->8 [style=invis];". Anyways, my concern was not the crossing edge. This seems to be a bug, because there is enough place left to (6) and (2) to draw a line. One has to move everything a little to right. My algorithm generates an order such that every tree (green) edge can be drawn down/right, every cross (orange) edge down/left, and every back (red) edge up/left. With no crossings, if the graph is plane. In order to achieve this, (8) must be drawn to the right of (0). I am really happy, because exactly this happens, if I use your technique.

    digraph {
        graph [charset=latin1, size ="19,46, 11,12"]
        node [shape=box, fontname="Comic Sans MS", fontsize=8, height=0.2, width=0.2, ordering=out]
    { rank=same; 0 -> 8 [style=invis]; }
    { rank=same; 1; }
    { rank=same; 2; }
    { rank=same; 5 -> 9; [style=invis]; }
    { rank=same; 6 -> 7 -> 10; [style=invis]; }
    { rank=same;3; }
    { rank=same;4; }
    0 -> 1 [color=green]
    1 -> 2 [color=green]
    8 -> 2 [color=orange]
    2 -> 5 [color=green]
    5 -> 6 [color=green]
    6 -> 2 [color=red, tailport=w, headport=w]
    5 -> 7 [color=green]
    7 -> 4 [color=green]
    2 -> 3 [color=green]
    2 -> 9 [color=green]
    9 -> 10 [color=green]
    10 -> 3 [color=orange]
    3 -> 4 [color=orange]
     }
    

    and the layout of it1