I'm trying to draw a graph with circle topology.
Here is what I'm expecting to see:
Here is my gv file:
digraph g1 {
layout="circo";
node [shape = doublecircle]; N4 N6;
node [shape = circle];
N0 -> N1 [ label = "{1,0}"];
N1 -> N2 [ label = "{1,0}"];
N2 -> N3 [ label = "{1,0}"];
N3 -> N4 [ label = "{1,0}"];
N4 -> N5 [ label = "{1,0}"];
N5 -> N6 [ label = "{1,0}"];
N6 -> N0 [ label = "{1,0}"];
N0 -> N4 [ label = "{1,0}"];
N1 -> N5 [ label = "{1,0}"];
N2 -> N6 [ label = "{1,0}"];
N3 -> N0 [ label = "{1,0}"];
N4 -> N1 [ label = "{1,0}"];
N5 -> N2 [ label = "{1,0}"];
N6 -> N3 [ label = "{1,0}"];
}
And here is an output image for graph above:
How can I arrange nodes in graphviz to make it look like 1?
If the goal is to have a graph which respects the order of the nodes, it's not that simple. You could calculate the position of the nodes with an external script and render it with neato.
Or you could first layout the nodes with the edges which determine the correct order of the nodes only:
digraph g1 {
node [shape = doublecircle]; N4 N6;
node [shape = circle];
edge[label="{1,0}"];
N0 -> N1 -> N2 -> N3 -> N4 -> N5 -> N6 -> N0;
}
with:
circo graph.gv > tempgraph.gv
Then add the remaining edges to tempgraph.gv
- just copy-paste the following before the closing }
:
N0 -> N4 [ label = "{1,0}"];
N1 -> N5 [ label = "{1,0}"];
N2 -> N6 [ label = "{1,0}"];
N3 -> N0 [ label = "{1,0}"];
N4 -> N1 [ label = "{1,0}"];
N5 -> N2 [ label = "{1,0}"];
N6 -> N3 [ label = "{1,0}"];
And render it with neato
and the -n
option:
neato -n tempgraph.gv -Tpng -O
You may want to fine-tune the position of the labels:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With