Graphviz: how to prevent clusters from overriding rank = source statement

enter image description here

The following code displays the graph above:

digraph G { //---graph config fontname=Helvetica rankdir = RL splines = polyline compound = true //concentrate = true labeljust = c labelloc = t ranksep=0.5 nodesep=0.5 //size="10,10" ratio=compress edge [ minlen=1 arrowsize=0.75 labeldistance=5 fontname=Helvetica fontsize=12 fontcolor=black labelfontsize=12 labelfontcolor=red labelfontname=Helvetica ] node [ fontname=Helvetica fontsize=12 fontcolor=black regular=true shape=diamond // width=0.25 // height=0.25 ] // --- # nodes {// records node [shape=record, width=1] b10 [label=" { R-7 | 5 } | B/10 "] b20 [label=" { R-6 | 10 } | B/20 "] b30 [label=" { R-5 | 10 } | B/30 "] d10 [label=" { R-10 | 15 } | D/10 "] d20 [label=" { R-9 | 10 } | D/20 "] d30 [label=" { R-8 | 10 } | D/30 "] a20 [label=" { R-2 | 5 } | A/20 "] a30 [label=" { R-1 | 10 } | A/30 "] } {// circles node [shape=circle] e [label="E"] c [label="C"] } {// box node [shape=box] a [label="A"] } //--- # edges { edge [weight = 1000] //straight c -> b10 -> b20 -> b30 e -> d10 -> d20 -> d30 a20 -> a30 -> a //combination {b30 d30} -> a20 } //--- # Clusters // subgraph cluster_1{ // label="a " // e d10 d20 // } // subgraph cluster_2{ // label="b " // c b10 b20 b30 // } // subgraph cluster_3{ // label="c " // a30 a20 // } // --- # bugfixes {// c before e edge [style=invis] c -> e {rank=source ec} // force same rank before other nodes } } 

It is just as good and clean as I want. However, I want to be able to mark and comment on some sections of the structure, and you must be the right means for this.

If you uncomment the CLUSTERS section of the code, you will receive the following code and the corresponding schedule:

 digraph G { //---graph config fontname=Helvetica rankdir = RL splines = polyline compound = true //concentrate = true labeljust = c labelloc = t ranksep=0.5 nodesep=0.5 //size="10,10" ratio=compress edge [ minlen=1 arrowsize=0.75 labeldistance=5 fontname=Helvetica fontsize=12 fontcolor=black labelfontsize=12 labelfontcolor=red labelfontname=Helvetica ] node [ fontname=Helvetica fontsize=12 fontcolor=black regular=true shape=diamond // width=0.25 // height=0.25 ] // --- # nodes {// records node [shape=record, width=1] b10 [label=" { R-7 | 5 } | B/10 "] b20 [label=" { R-6 | 10 } | B/20 "] b30 [label=" { R-5 | 10 } | B/30 "] d10 [label=" { R-10 | 15 } | D/10 "] d20 [label=" { R-9 | 10 } | D/20 "] d30 [label=" { R-8 | 10 } | D/30 "] a20 [label=" { R-2 | 5 } | A/20 "] a30 [label=" { R-1 | 10 } | A/30 "] } {// circles node [shape=circle] e [label="E"] c [label="C"] } {// box node [shape=box] a [label="A"] } //--- # edges { edge [weight = 1000] //straight c -> b10 -> b20 -> b30 e -> d10 -> d20 -> d30 a20 -> a30 -> a //combination {b30 d30} -> a20 } //--- # Clusters subgraph cluster_1{ label="a " e d10 d20 } subgraph cluster_2{ label="b " c b10 b20 b30 } subgraph cluster_3{ label="c " a30 a20 } // --- # bugfixes {// c before e edge [style=invis] c -> e {rank=source ec} // force same rank before other nodes } } 

enter image description here

As you can see from the bugfixes section at the end of the code, I want the C and E nodes to definitely display with the same rank “above” all other nodes.

Furhtermore, I want the top and bottom sequence of records to be connected with nice straight lines, as in the first example. The weight of the ribs I presented does not help.

Does anyone know how to fix this problem and how to make Graphviz to create a clean, clean graph, as in example # 1, with only three spanning fields and corresponding inscriptions?

+4
source share
1 answer

I tried to change only what was needed:

  • Added additional cluster without label and style=invis (for d30)
  • Changed the order of nodes for cluster b above cluster
  • The edge is removed.
  • Fixed removal of fixes.
  • Some deleted lines

Here is what I get with the recent version of Graphviz (2.29):

enter image description here

Not perfect, but much closer.

 digraph G { //---graph config fontname=Helvetica rankdir = RL splines = polyline compound = true //concentrate = true labeljust = c labelloc = t ranksep=0.5 nodesep=0.5 //size="10,10" ratio=compress edge [ minlen=1 arrowsize=0.75 labeldistance=5 fontname=Helvetica fontsize=12 fontcolor=black labelfontsize=12 labelfontcolor=red labelfontname=Helvetica ] node [ fontname=Helvetica fontsize=12 fontcolor=black regular=true shape=diamond // width=0.25 // height=0.25 ] // --- # nodes {// records node [shape=record, width=1] d10 [label=" { R-10 | 15 } | D/10 "] d20 [label=" { R-9 | 10 } | D/20 "] d30 [label=" { R-8 | 10 } | D/30 "] b10 [label=" { R-7 | 5 } | B/10 "] b20 [label=" { R-6 | 10 } | B/20 "] b30 [label=" { R-5 | 10 } | B/30 "] a20 [label=" { R-2 | 5 } | A/20 "] a30 [label=" { R-1 | 10 } | A/30 "] } {// circles node [shape=circle] e [label="E"] c [label="C"] } {// box node [shape=box] a [label="A"] } //--- # edges { //straight c -> b10 -> b20 -> b30 e -> d10 -> d20 -> d30 a20 -> a30 -> a //combination {b30 d30} -> a20} //--- # Clusters subgraph cluster_1{ label="a " e d10 d20 } subgraph cluster_2{ label="b " c b10 b20 b30 } subgraph cluster_3{ label="c " a30 a20 } subgraph cluster_4{ label="" style=invis d30 } } 
+2
source

All Articles