Straight edge between clusters in Graphviz

Motti picture Motti · Jun 9, 2010 · Viewed 14.4k times · Source

I'm trying to have an edge between clusters in Graphviz where the edge does not affect the ranking.

This looks fine:

digraph {
  subgraph clusterX {
    A    
    B
  }

  subgraph clusterY {
    C
    D
  } 

  A -> B
  B -> C [constraint=false]
  C -> D
}

However when I add a label to the C -> D edge the B -> C edge tries to circumvent said label (which looks ugly).

digraph {
  subgraph clusterX {
    A    
    B
  }

  subgraph clusterY {
    C
    D
  } 

  A -> B
  B -> C [constraint=false]
  C -> D [label=yadda]
}

Any idea how I can keep the edge from B to C straight?

Answer

marapet picture marapet · Jan 12, 2011

The easiest way to achieve this is to add splines=false to the dot file - this forces the rendering of the edges to be straight lines:

digraph {
 splines=false;
 subgraph clusterX {
    A;
    B;
 }

 subgraph clusterY {
    C;
    D;
 } 

 A -> B;
 B -> C [constraint=false];
 C -> D [label=yadda];
}

Output:

graphviz output