Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with densely connected graphs with neato

Tags:

graphviz

neato

I have the following dot/neato file...

graph G
{

  node [color=Red]

  r01
  r02

  r03

  r04
  r05

  r06
  r07
  r08
  r09

  r10
  r11

  node [color=Blue]

  p01
  p02

  p03

  p04
  p05
  p06

  p07
  p08
  p09
  p10
  p11

  p12
  p13

  r01 -- r02
  r01 -- p01
  r01 -- p02
  r02 -- p01
  r02 -- p02
  p01 -- p02

  r03 -- p03

  r04 -- r05
  r04 -- p04
  r04 -- p05
  r04 -- p06
  r05 -- p04
  r05 -- p06
  p04 -- p05
  p04 -- p06

  r06 -- r07
  r06 -- r08
  r06 -- r09
  r06 -- p07
  r06 -- p08
  r06 -- p09
  r06 -- p10
  r06 -- p11
  r07 -- r08
  r07 -- r09
  r07 -- p07
  r07 -- p08
  r07 -- p09
  r07 -- p10
  r07 -- p11
  r08 -- r09
  r08 -- p07
  r08 -- p08
  r08 -- p09
  r08 -- p10
  r08 -- p11
  r09 -- p07
  r09 -- p08
  r09 -- p09
  r09 -- p10
  r09 -- p11
  p07 -- p08
  p07 -- p09
  p07 -- p10
  p07 -- p11
  p08 -- p09
  p08 -- p10
  p08 -- p11
  p09 -- p10
  p09 -- p11
  p10 -- p11

  r10 -- r11
  r10 -- p12
  r10 -- p13
  r11 -- p12
  r11 -- p13
  p12 -- p13
}

...from which I create this graphic using neato.

neato -Tpng -o graph-g.png graph-g.txt

Overall, neato does a decent job, but the largest connected component in the graph looks pretty ridiculous. What can I do to make this look better? My criteria are that no nodes should overlap and there should be enough distance between connected nodes so that you can see a bit of the edge between them.

like image 323
Daniel Standage Avatar asked Oct 06 '11 04:10

Daniel Standage


2 Answers

If you add the following to the top of your graph:

overlap=false;
splines=true;

The result is:

graphviz output no overlap with splines

Not only the nodes do not overlap anymore, but also the edges are routed around the nodes.

like image 109
marapet Avatar answered Nov 19 '22 17:11

marapet


Graphviz has an overlap attribute (look for it here) that can sometimes be applied successfully.

When I insert overlap = false above your first node attribute the following image is the result.

Graph using overlap = false

When I instead insert overlap = scalexy in the same location, I get the following.

Graph using overlap = scalexy

Unfortunately, you still have edges passing through node p11. Hopefully, a way to address that can also be found.

You can see an example of overlap = false gone bad near the bottom of this page.

like image 44
David Alber Avatar answered Nov 19 '22 18:11

David Alber