1

I have a small process graph that I want to lay out nicely. The graph should be aligned to the top and go from left to right. In some cases, the nodes and relationships don't position themselves as expected.

The following graphviz code can be used in the web editor: http://magjac.com/graphviz-visual-editor/

Case 1 (Works fine):

Graphviz Code

strict digraph {
    node [fillcolor=yellow, style="rounded,filled", shape=diamond]
    rankdir="LR";
    graph [ordering=out, nodesep=0.3, ranksep=1];
    ordering="out";
    splines=polyline;
    
    "C"-> "D";
    "A"-> "B"[weight = 2];
    "B"-> "C";
    "A"-> "D";
    "C"-> "E";
}

Result: Case 1

Case 2 (Strange behavior when adding a relation from C to a new node F):

Graphviz Code

strict digraph {
    node [fillcolor=yellow, style="rounded,filled", shape=diamond]
    rankdir="LR";
    graph [ordering=out, nodesep=0.3, ranksep=1];
    ordering="out";
    splines=polyline;
    
    "C"-> "D";
    "A"-> "B"[weight = 2];
    "B"-> "C";
    "A"-> "D";
    "C"-> "E";
    "C"-> "F";
}

Result: Case 2

Question: I expected the edge from "A" to "D" to be drawn as in case 1. How can i change the code, so that my expected result is visualized?

Case 3 (Strange behavioe when adding more weights)

Graphviz Code

strict digraph {
    node [fillcolor=yellow, style="rounded,filled", shape=diamond]
    rankdir="LR";
    graph [ordering=out, nodesep=0.3, ranksep=1];
    ordering="out";
    splines=polyline;
    
    "C"-> "D" [weight = 10];
    "A"-> "B"[weight = 5];
    "B"-> "C"[weight = 10];
    "A"-> "D"  [weight = 2];
     "C"-> "E";
    "C"-> "F";
}

Result: Case 3

Question: I expected the edge from "A" to "D" to be drawn as in case 1. How can i change the code, so that my expected result is visualized?

2 Answers2

0

If you want to know "why", read this document https://www.graphviz.org/pdf/dotguide.pdf and then read the code.
Stackoverflow is better suited for "My current Graphviz input produces graph X, how can I get it to produce Y?"

sroush
  • 5,375
  • 2
  • 5
  • 11
  • Thank you for your comment. I updated the questions to "How can i change the code, so that my expected result is visualized?" - That is what i want to achieve. – Florian Eichin Apr 05 '23 at 05:25
0

Why do you set ordering=out so that the edges cross? Is the following a better visualization of the result, the graph does not have any edge crossings.

strict digraph {
    node [fillcolor=yellow, style="rounded,filled", shape=diamond]
    rankdir="LR";
    graph [nodesep=0.3, ranksep=1];
    splines=polyline;
    
    "C"-> "D" [weight = 10];
    "A"-> "B"[weight = 5];
    "B"-> "C"[weight = 10];
    "A"-> "D"  [weight = 2];
     "C"-> "E"[weight=10]
    "C"-> "F";
}