How to create a cyclic graph using GraphViz DOT?

I tried to create a simple circular graph with this DOT input file:

digraph { rankdir=LR; node0 [label = "0", group="bottom"]; node1 [label = "1", group="bottom"]; node2 [label = "2", group="top"]; node3 [label = "3", group="top"]; node0 -> node1; node1 -> node0; node2 -> node3; node3 -> node2; } 

and so far so good, this leads to:

First try at a cyclic graph

but now I want to add the following additions to the nodes:

 node0 -> node3; node3 -> node0; node2 -> node1; node1 -> node2; 

and, surprisingly, this leads to:

Unsatisfactory horizontal node placement

If I remove rankdir=LR; I get a vertical graph. I need a simple circular graph, since the placement of a node in space is related to what they refer to. Thus, the new joints should be vertical, and the nodes should form a square. Is it possible to achieve the use of DOT?

+5
source share
1 answer

Perhaps the use of DOT can be achieved; I haven't played with him for a couple of years, so I'm a little rusty. However, your data is displayed as a neat diamond if you use a circular program with a dot sister, which should be part of the usual GraphViz installation.

+3
source

Source: https://habr.com/ru/post/1208140/


All Articles