Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to layout complete graphs circularly using Dot and Graphviz?

How can I layout nodes in a graph "circularly", similar to the graphs in the following figure:

enter image description here

like image 504
Behrang Avatar asked Sep 20 '25 12:09

Behrang


1 Answers

Graphviz offers the circo layout engine for circular layouts.

circo draws graphs using a circular layout (see Six and Tollis, GD ’99 and ALENEX ’99, and Kaufmann and Wiese, GD ’02.) The tool identifies biconnected components and draws the nodes of the component on a circle. The block-cutpoint tree is then laid out using a recursive radial algorithm. Edge crossings within a circle are minimized by placing as many edges on the circle’s perimeter as possible. In particular, if the component is outerplanar, the component will have a planar layout. If a node belongs to multiple non-trivial biconnected components, the layout puts the node in one of them. By default, this is the first non-trivial component found in the search from the root component.

A simple example for K3 would be:

graph K3 {
    layout=circo;
    node[shape=point, color=red];
    a--b--c--a;
}

However, most of the graphs will be oriented differently than on your image. The K3 example would yield this:

K3

To test other layout engines online you can use GraphvizOnline.

like image 110
marapet Avatar answered Sep 23 '25 19:09

marapet