Tree 如何使用点创建依赖关系树

Tree 如何使用点创建依赖关系树,tree,dependencies,dot,Tree,Dependencies,Dot,正在尝试创建依赖关系树。虽然我成功地将这些盒子连接在一起,但我未能以更具代表性的方式使其看起来像一棵树 digraph G{ m1[shape=box, color=grey, style=filled] m2[shape=box, color=grey, style=filled] m3[shape=box, color=grey, style=filled] m4[shape=box, color=grey, style=filled] m5[shape=box, color=grey, s

正在尝试创建依赖关系树。虽然我成功地将这些盒子连接在一起,但我未能以更具代表性的方式使其看起来像一棵树

digraph G{
m1[shape=box, color=grey, style=filled]
m2[shape=box, color=grey, style=filled]
m3[shape=box, color=grey, style=filled]
m4[shape=box, color=grey, style=filled]
m5[shape=box, color=grey, style=filled]
p1[shape=diamond,color=lightblue, style=filled]
p2[shape=diamond, color=lightblue, style=filled]
p3[shape=diamond, color=lightblue, style=filled]
p4[shape=diamond, color=lightblue, style=filled]
{rank=sink;x1;x2;x3;x4;}
{rank=source;y1;}
{rank=same;m3;p3;x11;x5;x6;x7;x8;}
node[shape=circle]
y1 -> x9
y1 -> m5
x10 -> m4
x10 -> p4
x9-> m3
x9-> p3
x6 ->m1
x6 ->p1
x5 ->m1
x5 ->p1
x8 -> m2
x8 -> p2
x7 -> m2
x7 -> p2
y1 -> x10
y1 -> x12  
x5 -> x1
x5 -> x2
x6 -> x1
x6 -> x2
x7 -> x3
x7 -> x4
x8 -> x3
x8 -> x4
x9 -> x6
x9 -> x5
x9 -> x11
x10 -> x8
x10 -> x7
}
我没能创造出像这样的东西
我觉得你的图表没那么糟糕。为了更接近你的模型图片,下面是可以做的:

  • 拉直边缘(
    spline=false
  • 增加节点之间的距离(
    ranksep=1
  • 添加不可见边以确保节点顺序
  • 个人偏好:使边从同一点开始(
    edge[tailport=s]
以下是修改后的图表:

digraph G{
splines=false;
ranksep=1;

node[shape=box, color=grey, style=filled];
m1;m2;m3;m4;m5;

node[shape=diamond,color=lightblue, style=filled]
p1;p2;p3;p4;

node[style=solid, color=black, shape=circle, width=0.6, height=0.6];
{
    rank=same;
    x9;x12;x10;m5;
}
{
    rank=same;
    edge[style=invis];
    p3->x11->x5->x6->m3;
    p4->x7->x8->m4;
}
{
    rank=same;
    edge[style=invis];
    p1->x1->x2->m1;
    p2->x3->x4->m2;
}

edge[tailport=s]; // also try adding: headport=n
y1 -> m5
y1 -> x9
y1 -> x12  
y1 -> x10
x10 -> m4
x10 -> p4
x9-> m3
x9-> p3
x6 ->m1
x6 ->p1
x5 ->m1
x5 ->p1
x8 -> m2
x8 -> p2
x7 -> m2
x7 -> p2
x5 -> x1
x5 -> x2
x6 -> x1
x6 -> x2
x7 -> x3
x7 -> x4
x8 -> x3
x8 -> x4
x9 -> x6
x9 -> x11
x9 -> x5
x10 -> x8
x10 -> x7
}


可能还有更多的事情要做,这取决于你到底想要什么。

谢谢!!似乎文档不足!!这就行了!!