4

I want to generate something like this - the alignment of the nodes is the important thing, not the angle of the edges:

+--------------+
|              |
+--------------+
   |        |
   V        V
+-----+  +-----+  <--- alignment at top
|     |  |     |
|     |->|     |
|     |  |     |
+-----+  |     |
   |     |     |
   V     |     |
+-----+  |     |
|     |  |     |
|     |->|     |
|     |  |     |
+-----+  +-----+  <--- alignment at bottom
   |        |
   V        V
+--------------+
|              |
+--------------+

The best I've been able to come up with is to stick the two left nodes into a cluster subgraph with a white (=> invisible) border, and set the weight of one of the edges to 0. But it's still not quite right:

digraph G {

    // scale things down for example
    size="5,5" 
    rankdir=TD
    ranksep=1
    nodesep=1

    node [shape=box]

    node [width=5 height=2]
    top

    subgraph cluster_left
    {
        color=white
        node [width=2 height=2]
        left1
        left2
    }

    node [width=2 height=5]
    right

    node [width=5 height=2]
    bottom

    top->left1
    top->right

    left1->left2
    left1->right
    left2->right [weight=0]

    left2->bottom
    right->bottom
}

This comes out like this - poorly aligned:

Any ideas on how to get what I want?

Barry Kelly
  • 41,404
  • 5
  • 117
  • 189

1 Answers1

5

I did it with neato and this script :

digraph G {
  layout="neato"
  // scale things down for example
  size="5,5" 
  rankdir=TD
  ranksep=1
  nodesep=1

  node [shape=box]

  top[pos="5,10!", width=5, height=2]

  left1[pos="3.5,7!", width=2, height=2]
  left2[pos="3.5,4!", width=2, height=2]

  right[pos="6.5,5.5!", width=2, height=5]

  bottom[pos="5,1!", width=5, height=2]

  top->left1
  top->right

  left1->left2
  left1->right
  left2->right

  left2->bottom
  right->bottom
}

Here is the result :

alt text

greg
  • 844
  • 4
  • 11
  • I'll give you the cookie. I eventually did it in a similar way, using neato, but I actually wrote a python script to generate the file I passed on to neato because for some reason my position coordinates needed to be in points (so needed to be multiplied by 72). It's a pity though that one can't use dot itself to position the boxes by treating a subgraph as a single block for layout purposes in the outer hierarchy. – Barry Kelly Nov 16 '10 at 02:55