问题
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?
回答1:
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 :
来源:https://stackoverflow.com/questions/4176468/lining-up-multiple-short-nodes-in-parallel-with-a-single-tall-node-in-graphviz