Question

I'm drawing a bipartite graph in graphviz and I want it to have two columns of nodes connected by straight lines (to match a style used elsewhere). I can mostly get what I want (see image) but the columns are too close together which makes the edges needlessly hard to follow.

I've tried to add a very low weight connection between the top two nodes in the hope it would push the two subgraphs apart but that doesn't work (and often messes up the rest of the layout). Is there a way of moving the right hand column of nodes further to the right.

Here is an example showing the problem I'm seeing

digraph with two subgraphs too close together

and here is the code I used to generate this graph

graph G {
      splines=false;
      node[shape=circle, style=filled]
      subgraph cluster_1 {
      subgraph cluster_1r {
         a12 [label="a",fillcolor=lightgrey]
         b12 [label="b",fillcolor=lightgrey]
         c12 [label="c",fillcolor=lightgrey]
         d12 [label="d",fillcolor=lightgrey]
         e12 [label="e",fillcolor=lightgrey]
         a12--b12--c12--d12--e12 [style=invis]
         }
      subgraph cluster_1l {
         a11 [label="a",fillcolor=white]
         b11 [label="b",fillcolor=white]
         c11 [label="c",fillcolor=white]
         d11 [label="d",fillcolor=white]
         e11 [label="e",fillcolor=white]
         a11--b11--c11--d11--e11 [style=invis]
         }
         c11--a12 [constraint=false]
         c11--b12 [constraint=false]
         d11--b12 [constraint=false]
         e11--a12 [constraint=false]
         e11--b12 [constraint=false]
     }
}
Was it helpful?

Solution

Adding an invisible node in between the two columns works fine. Basically I added this

subgraph cluster_1m {
   color=invis;          
   a12m [style=invisible]
   }

in between the two subgraphs. This feels quite crude though so any more elegant solutions would be welcomed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top