Aligning multiple short nodes in parallel with one high node in GraphViz

I want to generate something like this - aligning nodes is an important thing, not the edge angle:

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

The best I could come up with was to insert 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 is 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
}

It looks like this: aligns poorly:

xzEuc.png

Any ideas on how to get what I want?

+3
source share
1 answer

I did this with neato and this is a 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

+3
source

Source: https://habr.com/ru/post/1774755/


All Articles