Question

I need to draw a bipartite graph. It has about 500 nodes.

Currently I am trying to do it with graphviz. The graph has two types of nodes. I want that the first type is on the left side and another nodes on the right side of a plot. If I do plain plot with dot then it is a skinny strip of two rows of nodes. These rows are too close to each other, so it is hard to recognize any separate edges between nodes. I tried other layout algorithms like circo. I like that nodes are on a circle, but I don't know how to split nodes on right and left semicircles.

The perfect output I would like is next: nodes are spread along a circle but two types of nodes belong to separate hemicircles. I there a way to do it using graph viz?

Would you suggest a better tool, if it is too hard to do in graphviz?

Was it helpful?

Solution

You can increase the spacing between rows in dot using the ranksep attribute. For getting two halves of the graph separated, it might make sense to create two hidden nodes (style=invis) with fixed positions, then connect (using style=invis edges) each "real" node to the fixed node for its half of the diagram. You would probably want to use neato for this, probably with overlap=false as a graph attribute. Here is a simple example (using non-invisible styles to show how the layout looks):

graph test {
  overlap=false; splines=true
  edge [style=dotted, weight=10, len=.2]
  subgraph cluster_left {
    left [pos="-1,0!", color=red /* , style=invis */]
    a -- left
    b -- left
  }
  subgraph cluster_right {
    right [pos="1,0!", color=blue /* , style=invis */]
    c -- right
    d -- right
    e -- right
  }
  edge [style="", weight=1, len=1]
  a -- b
  b -- d
  d -- e
  c -- e
  b -- e
}

For a semicircle, setting weight=1000, len=1 in the first edge line and using fdp instead of neato seems to produce something close (there are still a few nodes that have edge lengths that are slightly off). You need more nodes to see the effect (I put in extra nodes that are like b and e but with numeric suffixes on their names for testing).

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