39

I am building a dot file to represent computer hardware and the physical connections to a network switch and displays. I have it looking ok when processed by the dot program but I think I really want it processed by neato to create a more "free form" picture as it starts to grom. Right now when I run my large file with neato, everything is overlapping.

I am trying to figure out the syntax on where to define the overlap attribute. Below is a subset of my dot file.

graph g {  
    node [shape=record,height=.1];  
    PC8[label="{{<GigE1>GigE1|<GigE2>GigE2}|{<name>PC8}|{<dvi1>dvi1|<dvi2>dvi2|<dvi3>dvi3|<dvi4>dvi4}}"];  
    PC9[label="{{<GigE1>GigE1|<GigE2>GigE2}|{<name>PC9}|{<dvi1>dvi1|<dvi2>dvi2|<dvi3>dvi3|<dvi4>dvi4}}"];
    C1[label = "{{<dvi1>dvi1}|{<name>C1}}"];  
    C2[label = "{{<dvi1>dvi1}|{<name>C2}}"];  
    C3[label = "{{<dvi1>dvi1}|{<name>C3}}"];  
    C4[label = "{{<dvi1>dvi1}|{<name>C4}}"];  
    D1[label = "{{<dvi1>dvi1}|{<name>D1}}"];  
    D2[label = "{{<dvi1>dvi1}|{<name>D2}}"];  
    "PC8":dvi1 -- "C1":dvi1;  
    "PC8":dvi2 -- "C2":dvi1;  
    "PC8":dvi3 -- "C3":dvi1;  
    "PC8":dvi4 -- "C4":dvi1;  
    "PC9":dvi1 -- "D1":dvi1;  
    "PC9":dvi2 -- "D2":dvi1;  
}
marapet
  • 49,690
  • 10
  • 152
  • 168
Chris Williams
  • 443
  • 1
  • 4
  • 6
  • 6
    Well, as with most questions...soon after I posted the I figured out the answer. I needed to add graph [overlap=false]; at the top of the file. – Chris Williams Jun 24 '09 at 17:44
  • 4
    Why don't you post that as an answer? http://stackoverflow.com/questions/252194/how-to-earn-the-self-learner-badge – jjclarkson Jun 24 '09 at 17:48

2 Answers2

48

Well, as with most questions...soon after I posted the I figured out the answer. I needed to add graph [overlap=false]; at the top of the file.

Do it like this:

graph g {
    overlap = false;

    node [shape=record,height=.1];
    /* ... */
}
Iain Samuel McLean Elder
  • 16,665
  • 10
  • 59
  • 76
Phil H
  • 18,593
  • 6
  • 62
  • 99
  • 1
    Actually, you need to add it inside the outermost graph definition. That is, after the first line of the file as presented, not as the very first line. – wfaulk Jun 28 '13 at 15:55
  • 2
    I've made this a community wiki, as none of my original answer text is left after edits! – Phil H Feb 12 '14 at 08:32
1

Setting overlap to false will work for neato as the community wiki answer says; however, if the graph exhibits any kind of regularity or symmetry, [overlap=false] will often mess it up by jiggling the nodes around to make them not overlap.

Use [overlap=false] as a last resort.

All node overlaps that are outputted from neato can be viewed as occurring because the nodes are too big relative to the edges. You can make any overlaps go away by making the nodes smaller and preserve symmetry in the graph drawing by setting [overlap=scale]. Quoting the Neato user manual:

To improve clarity, it is sometimes helpful to eliminate overlapping nodes or edges. One way to eliminate node overlaps is just to scale up the layout (in terms of the center points of the nodes) as much as needed. This is enabled by setting the graph attribute overlap=scale. This transformation preserves the overall geometric relationships in the layout, but in bad cases can require high scale factors

As the documentation says [overlap=scale] can result in graph drawings that are unacceptably large, but if it does not its output is generally going to be better looking than [overlap=false].

jwezorek
  • 3,125
  • 1
  • 19
  • 30