0

I'm doing triangulation of a polygon by bracket structure. I also have a generated .dot file, but most of graphs don't look like a polygon.

graph {
    nodesep=0.6
    layout="circo";
    node [shape = circle];
    1--2[color="red"];
    2--3;
    3--4;
    4--5;
    5--6;
    1--6;
    1--4;
    4--6;
    2--4;
}

Which is rendered as follows:

Which is rendered as follows

So, if you put 6--1--2 together, there wouldn't be any intersections.

albert
  • 8,285
  • 3
  • 19
  • 32

2 Answers2

0

Looks like it doesn't conform to it's own specification. From https://manpages.debian.org/jessie/graphviz/circo.1.en.html:

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.

From what I understand, the graph is outerplanar, so the layout should be planar, i.e. drawn in such a way that no edges cross each other.

Looks like a bug to me.

See also Graphviz: how to arrange nodes with circo layout.

magjac
  • 857
  • 1
  • 8
  • 12
0

If you use sfdp instead of circo it produces better graphs for your use case.

graph {
    splines = false;
    nodesep=0.6
    node [shape = circle];
    1--2[color="red"];
    2--3;
    3--4;
    4--5;
    5--6;
    1--6;
    1--4;
    4--6;
    2--4;
}

I ran the following:

$ sfdp -Tpng b.dot -o b.png

Which produced:

enter image description here

tk421
  • 5,775
  • 6
  • 23
  • 34