I'm creating a switch topology with subgraphs.
How is below possible to re-organize so Bridge1 is on the top, Bridge2 is below, etc...
Thanks in advance!
I
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
It looks like your post is mostly code; please add some more details.
digraph G {
node [shape=box,style=filled];
newrank=True;
rankdir=TB;
subgraph cluster_1 {
label="Bridge1\n8001.5254aabbcce6";
rank=same;
rstp_1_1[label="port1\nD\n20000"];
rstp_1_2[label="port2\nR\n20000"];
rstp_1_3[label="port3\nD\n20000"];
rstp_1_4[label="port4\nD\n20000"];
}
subgraph cluster_2 {
label="Bridge2\n8001.5254aabbcca6";
rank=same;
rstp_2_1[label="port1\nD\n20000"];
rstp_2_2[label="port2\nD\n20000"];
rstp_2_3[label="port3\nD\n20000"];
rstp_2_4[label="port4\nR\n20000"];
}
subgraph cluster_3 {
label="Bridge3\n8001.5254aabbcc6c";
rank=same;
bgcolor=red;
rstp_3_1[label="port1\nD\n0"];
rstp_3_2[label="port2\nD\n0"];
rstp_3_3[label="port3\nD\n0"];
rstp_3_4[label="port4\nD\n0"];
}
subgraph cluster_4 {
label="Bridge4\n8001.5254aabbccba";
rank=same;
rstp_4_1[label="port1\nD\n20000"];
rstp_4_2[label="port2\nD\n20000"];
rstp_4_3[label="port3\nR\n20000"];
rstp_4_4[label="port4\nD\n20000"];
}
subgraph cluster_5 {
label="Bridge5\n8001.5254aabbccb2";
rank=same;
rstp_5_1[label="port1\nD\n20000"];
rstp_5_2[label="port2\nD\n20000"];
rstp_5_3[label="port3\nR\n20000"];
rstp_5_4[label="port4\nD\n20000"];
}
rstp_1_2 -> rstp_5_2 [arrowhead=none];
rstp_2_3 -> rstp_5_3 [arrowhead=none];
rstp_2_4 -> rstp_3_4 [arrowhead=none];
rstp_3_3 -> rstp_4_3 [arrowhead=none];
rstp_4_4 -> rstp_5_4 [arrowhead=none];
}
I have added below after rankdir=TB and it did the job:
rstp_1_1->rstp_2_1 [style=invis];
rstp_2_1->rstp_3_1 [style=invis];
rstp_3_1->rstp_4_1 [style=invis];
rstp_4_1->rstp_5_1 [style=invis];
rstp_5_1->rstp_6_1 [style=invis];
rstp_6_1->rstp_7_1 [style=invis];
rstp_7_1->rstp_8_1 [style=invis];
rstp_8_1->rstp_9_1 [style=invis];
rstp_9_1->rstp_10_1 [style=invis];
Related
I am trying to inverse the position of two nodes (producción & funciones) that are inside a cluster (cluster_fp). Instead of producción on top and funciones at bottom, I need funciones on top and producción at bottom. How can I achieve that? They are in a cluster just because I thought it is the right approach, but probably it isn't. Because my reputation, I can't post images directly, so I leave the links to i.stack.imgur.com.
Code:
digraph tríada {
rankdir=LR;
edge [arrowhead=none];
label="* socialmente reconocido";
labeljust=left;
subgraph cluster_sinonimia_oa {
style=dashed;
label="sinonimia obra-texto";
subgraph cluster_texto {
style=striped;
label=texto;
selección [shape=rect];
}
obra [shape=rect, style=striped];
supuesto [label="supuesto\nexistencial", shape=plain];
}
subgraph cluster_autor {
style=striped;
label="autor*";
máquinas [shape=hexagon];
subgraph cluster_fp {
label="";
style=invis;
funciones [label="atribución o\napropiación", shape=plain];
producción [shape=plain];
}
subgraph cluster_sinonimia_nepa {
style=dashed;
label="sinonimia nombre-entidad-persona-autor";
personas [shape=hexagon];
entidad [shape=rect];
real [shape=diamond];
ficticia [shape=diamond];
nula [shape=diamond];
denotación [shape=plain];
nombre [shape=rect];
}
}
{personas máquinas} -> real [arrowhead=normal];
{real ficticia nula} -> entidad [arrowhead=normal];
nombre -> funciones -> obra -> supuesto -> selección -> producción -> entidad -> denotación -> nombre;
}
Live on dreampuf.github.io
Thanks!
Based on lots of experiments, the problem seems to be that dot's algorithm "weights" a multi-node edge more than a two-node edge.
Here is a much-edited input file that produces your desired output:
digraph tríada {
rankdir=LR;
edge [arrowhead=none];
label="* socialmente reconocido";
labeljust=left;
subgraph cluster_autor {
style=striped;
label="autor*";
subgraph cluster_sinonimia_nepa {
style=dashed;
label="sinonimia nombre-entidad-persona-autor";
personas [shape=hexagon];
entidad [shape=rect];
real [shape=diamond];
ficticia [shape=diamond];
nula [shape=diamond];
denotación [shape=plain];
nombre [shape=rect];
node [label="" shape=point width=.01]
// bogus1 & bogus2 are needed to flip/swap/invert the funciones & producción nodes
bogus1 bogus2
}
subgraph cluster_fp {
label="";
style=invis;
funciones [label="atribución o\napropiación", shape=plain];
producción [shape=plain];
}
máquinas [shape=hexagon];
{personas máquinas} -> real [arrowhead=normal];
{real ficticia nula} -> entidad [arrowhead=normal];
entidad -> denotación -> nombre
}
subgraph cluster_sinonimia_oa {
style=dashed;
label="sinonimia obra-texto";
subgraph cluster_texto {
style=striped;
label=texto;
selección [shape=rect];
}
obra [shape=rect, style=striped];
supuesto [label="supuesto\nexistencial", shape=plain];
}
nombre -> funciones -> obra -> supuesto -> selección
producción -> selección
entidad -> bogus1 [headclip=false ]
bogus1 -> bogus2 [tailclip=false, headclip=false]
bogus2 -> producción [tailclip=false]
}
(Yes, most of the edits were unnecessary)
I’ve been struggling for awhile on how to keep subgraph within rectangle instead of “Tetris” shapes when edge is being added and layout becomes more complex.
on Layer 2 in the codes below you’ll clearly notice “C”-shaped subgraph.
Is it possible to fix the subgraph’s shape ratio to rectangle as an ascii or any attribute to handle this?
digraph G {
subgraph cluster_0 {
subgraph cluster_3 {
label="Layer 3";
"3-1" -> "3-2" -> "3-3";
}
subgraph cluster_2 {
label="Layer 2";
"2-1" -> "2-2" -> "2-3";
}
subgraph cluster_1 {
label="Layer 1";
"1-1" -> "1-2" -> "1-3";
}
}
"1-1" -> "2-1";
"1-3" -> "2-1";
"1-1" -> "2-2";
"1-2" -> "2-2";
"1-2" -> "2-3";
"1-3" -> "2-3";
"2-1" -> {"3-1" "3-2"};
"2-3" -> {"3-1" "3-3"};
}
here is an img explanation:
.
How can I force graphviz to always generate the same layout?
Given a graph:
digraph {
subgraph clusterA {
subgraph clusterB {
"B.001"
"B.002"
"B.003"
"B.004"
}
subgraph clusterC {
"C.001"
"C.002"
"C.003"
}
}
subgraph clusterD {
subgraph clusterE {
"E.001"
}
subgraph clusterF {
"F.001"
"F.002"
"F.003"
}
subgraph clusterG {
"G.001"
"G.002"
}
}
subgraph clusterH {
"H.001"
}
"G.002" -> "F.003"
"F.001" -> "C.003"
"G.002" -> "F.002"
"G.002" -> "D.001"
}
When I pass it to dot it sometimes generates results with layout like this one:
and sometimes like this one:
Obviously the first one looks much better and I would like graphviz to stick to this one.
I tried to pass my graph through fdp and unflatten, but it doesn't change anything.
I tried a lot different render-solutions online and cli. I can't see another output then your second one. But if you prefer the first one, just switch the order of ClusterB and ClusterC.
digraph {
rankdir=TB
subgraph clusterA {
subgraph clusterC {
"C.001"
"C.002"
"C.003"
}
subgraph clusterB {
"B.001"
"B.002"
"B.003"
"B.004"
}
}
subgraph clusterD {
subgraph clusterE {
"E.001"
}
subgraph clusterF {
"F.001"
"F.002"
"F.003"
}
subgraph clusterG {
"G.001"
"G.002"
}
}
subgraph clusterH {
"H.001"
}
"G.002" -> "F.003"
"F.001" -> "C.003"
"G.002" -> "F.002"
"G.002" -> "D.001"
}
I'm trying to create a flow control graph in graphviz, but I can't get the nodes to stay in the order. I tried prefixing them with a number as that is the only way I could get clusters to go in the right order (by trial an error), but this doesn't work for nodes.
I gave a weight of 100 to the nodes for ordering (which I intend to make invisible once they actually WORK) to no avail.
digraph G {
rankdir=LR;
splines=ortho;
subgraph cluster_I {
color=lightgrey;
style=filled;
label="Incoming Numbers";
newrank="true";
node [color=white,
style=filled];
"thisExtention" [color=lightskyblue1,
shape=square,
style="rounded, filled",
label="Extension 20"];
"+15412362468" [color=azure,
shape=rectangle,
style="rounded, filled"];
"+15412362468" -> "thisExtention" [tailport=e];
"+12069732753" [color=azure,
shape=rectangle,
style="rounded, filled"];
"+12069732753" -> "thisExtention" [tailport=e];
"+441134037186" [color=azure,
shape=rectangle,
style="rounded, filled"];
"+441134037186" -> "thisExtention" [tailport=e];
{
rank=same;
"+15412362468";
"+12069732753";
"+441134037186";
}
}
subgraph cluster_A {
color=blue;
subgraph cluster_1W {
color=lightgrey;
style=filled;
"actionstart" [label="Start Inbound Action Steps\n(can be interrupted by menu dial)"];
"thisExtention" -> "actionstart" [tailport=e];
}
subgraph cluster_2G {
color=aquamarine2;
style=filled;
"2if" [color=azure,
shape=diamond,
label="IF MENUKEY does equal 4"];
"3if" [color=azure,
shape=diamond,
label="IF SUM does equal 2\nAND INSIDE “BUSINESS HOURS”"];
"4ring" [color=azure,
shape=rectangle,
label="ring"];
"6playrecording" [color=azure,
shape=rectangle,
label="playrecording"];
}
subgraph cluster_3Y {
color=salmon1;
style=filled;
"7else" [color=azure,
shape=diamond,
label=ELSE];
"8playrecording" [color=azure,
shape=rectangle,
label="playrecording"];
}
subgraph cluster_W4 {
color=lightgrey;
style=filled;
"9transfer" [color=azure,
shape=rectangle,
label="transfer"];
}
subgraph cluster_5G {
color=aquamarine2;
style=filled;
"10else" [color=azure,
shape=diamond,
label=ELSE];
"11hangup" [color=azure,
shape=rectangle,
label="hangup"];
}
subgraph cluster_O {
color=lightgray;
style=filled;
label="Dial Menu";
"17ring" [color=azure,
shape=rectangle,
label="DIAL (#):\nring"];
"18set" [color=azure,
shape=rectangle,
label="DIAL ①:\nset"];
"19playrecording" [color=azure,
shape=rectangle,
label="DIAL ②:\nplayrecording"];
"20huntgroup" [color=azure,
shape=rectangle,
label="DIAL ③:\nRing HuntGroup: test hunt group"];
"21transfer" [color=azure,
shape=rectangle,
label="DIAL ④:\ntransfer"];
"22huntgroup" [color=azure,
shape=rectangle,
label="DIAL ⑤:\nRing HuntGroup: test hunt group"];
}
{
rank="same";
"actionstart";
"2if";
"3if";
"4ring";
"6playrecording";
"7else";
"8playrecording";
"9transfer";
"10else";
"11hangup";
"17ring";
"18set";
"19playrecording";
"20huntgroup";
"21transfer";
"22huntgroup";
}
"actionstart" -> "2if" [weight=100];
"2if" -> "3if" [weight=100];
"3if" -> "4ring" [weight=100];
"4ring" -> "6playrecording" [weight=100];
"6playrecording" -> "7else" [weight=100];
"7else" -> "8playrecording" [weight=100];
"8playrecording" -> "9transfer" [weight=100];
"9transfer" -> "10else" [weight=100];
"10else" -> "11hangup" [weight=100];
"11hangup" -> "17ring" [weight=100];
"17ring" -> "18set" [weight=100];
"18set" -> "19playrecording" [weight=100];
"19playrecording" -> "20huntgroup" [weight=100];
"20huntgroup" -> "21transfer" [weight=100];
"21transfer" -> "22huntgroup" [weight=100];
}
subgraph columnthree {
"Extension 10" [shape=square,
style="rounded, filled",
fillcolor=lightskyblue1];
"9transfer" -> "Extension 10" [weight=0,
tailport=e];
"HuntGroup 2" [shape=septagon,
style="filled",
fillcolor=lightcyan1];
"20huntgroup" -> "HuntGroup 2" [weight=0,
tailport=e];
"Extension 10" [shape=square,
style="rounded, filled",
fillcolor=lightskyblue1];
"21transfer" -> "Extension 10" [weight=0,
tailport=e];
"HuntGroup 2" [shape=septagon,
style="filled",
fillcolor=lightcyan1];
"22huntgroup" -> "HuntGroup 2" [weight=0,
tailport=e];
}
}
I'm trying to get multiple clusters of nodes to space evenly in Graphviz.
I think the image best explains what I'm trying to do:
As you can see from the image, there is extra spacing between layers 2 and 3. The space between 2 and 3 should be the same as the space between 1 and 2.
The spacing also needs to scale with more than 3 layers. When I tried more than 3 layers, the 4th layer is spaced as bad as the 3rd layer.
Here is my graph file:
digraph G {
nodesep=1.25;
splines=false;
node[width=1, shape=circle];
edge[style=invis];
subgraph cluster_1 {
label="Layer 1";
"1-1" -> "1-2" -> "1-3";
}
subgraph cluster_2 {
label="Layer 2";
"2-1" -> "2-2" -> "2-3";
}
subgraph cluster_3 {
label="Layer 3";
"3-1" -> "3-2" -> "3-3";
}
edge[style=solid, penwidth=1, constraint=false];
"1-1" -> "2-1";
"1-3" -> "2-1";
"1-1" -> "2-2";
"1-2" -> "2-2";
"1-2" -> "2-3";
"1-3" -> "2-3";
"2-1" -> "3-1";
"2-3" -> "3-1";
"2-1" -> "3-2";
"2-2" -> "3-2";
"2-2" -> "3-3";
"2-3" -> "3-3";
}
How can I go about getting my spacing symmetrical? Any help would be much appreciated. Thanks.
Update:
I have managed to get the spacing even, but it is not a perfect solution.
By placing an invisible node with invisible edges above the graph and connecting it to the top node in each layer, the layers space evenly. However, this node messes up spacing for things that need to be added above the image shown. So, is there a better way to do this?
Adding an Outer Cluster
Bounding box of outer cluster shown for clarity
Nesting the clusters cluster_1, cluster_2, and cluster_3 inside another cluster causes the layout engine to space them evenly.
Working With the Layout Engine
However, the bottom to top rankdir reverses the left to right display ordering to (cluster_3, cluster_2, cluster_1). Reversing the order in the source file fixes [kludges over] that.
Working Code
digraph G {
nodesep=1.25;
splines=false;
clusterrank=local;
node[width=1, shape=circle];
edge[style=invis];
subgraph cluster_0 {
subgraph cluster_3 {
label="Layer 3";
"3-1" -> "3-2" -> "3-3";
}
subgraph cluster_2 {
label="Layer 2";
"2-1" -> "2-2" -> "2-3";
}
subgraph cluster_1 {
label="Layer 1";
"1-1" -> "1-2" -> "1-3";
}
}
edge[style=solid, penwidth=1, constraint=false];
"1-1" -> "2-1";
"1-3" -> "2-1";
"1-1" -> "2-2";
"1-2" -> "2-2";
"1-2" -> "2-3";
"1-3" -> "2-3";
"2-1" -> {"3-1" "3-2"};
"2-3" -> {"3-1" "3-3"};
"2-2" -> {"3-2" "3-3"};
}
Notes
The new outer cluster can be styled so that it's bounding box is not visible.