我正在尝试在 graphviz 中获取嵌套子图。
Graphviz版本是2.38.0(20140413.2041)
这是代码:
digraph G {
subgraph cluster_win {
style=filled;
color=lightgrey;
label = "Windows"
subgraph extra_enabled {
fillcolor = "#EDF1F2";
color = "#028d35";
label="Subdirectory extra included";
node [style=filled,color=white];
config_debug1 [label = "Configure Debug"];
config_release1 [label = "Configure Release"];
build_debug1 [label = "Build"];
build_release1 [label = "Build"];
config_debug1 -> build_debug1;
config_release1 -> build_release1;
shape=rect;
style=rounded;
}
subgraph extra_disabled {
label = "Subdirectory extra excluded";
config_debug2 [label = "Configure Debug"];
config_release2 [label = "Configure Release"];
build_debug2 [label = "Build"];
build_release2 [label = "Build"];
config_debug2 -> build_debug2;
config_release2 -> build_release2;
}
checkout [style=filled, color=white];
checkout -> extra_enabled;
checkout -> extra_disabled;
}
start -> checkout;
start [label="git push"; shape=Mdiamond];
}
Run Code Online (Sandbox Code Playgroud)
Graphviz 绘制了两个普通节点“extra_enabled”和“extra_disabled”。但是,我希望它们是子图,包含节点“配置发布”、“配置调试”、“构建”和另一个“构建”。
我该如何修复它?
你需要做两件事:
cluster_将其应用到您的代码中
digraph G {
subgraph cluster_win {
style=filled;
color=lightgrey;
label = "Windows "
subgraph cluster_extra_enabled {
fillcolor = "#EDF1F2";
color = "#028d35";
label="Subdirectory extra included";
node [style=filled,color=white];
config_debug1 [label = "Configure Debug"];
config_release1 [label = "Configure Release"];
build_debug1 [label = "Build"];
build_release1 [label = "Build"];
config_debug1 -> build_debug1;
config_release1 -> build_release1;
shape=rect;
style=rounded;
}
subgraph cluster_extra_disabled {
label = "Subdirectory extra excluded";
config_debug2 [label = "Configure Debug"];
config_release2 [label = "Configure Release"];
build_debug2 [label = "Build"];
build_release2 [label = "Build"];
config_debug2 -> build_debug2;
config_release2 -> build_release2;
}
checkout [style=filled, color=white];
checkout -> config_debug1;
checkout -> config_release2;
}
start -> checkout;
start [label="git push"; shape=Mdiamond];
}
Run Code Online (Sandbox Code Playgroud)
我明白了
这可能接近你想要的。请注意,我在标签“Windows”中添加了一些空格,以使其避开箭头。您也可以使用labeljust. 还有一些方法可以使边缘结束于簇的边界,但这需要我进行更多的编辑,但我不确定您是否需要它。