Block diagram layout with dot/graphviz
我想用点实现以下模型:
到目前为止,我已经掌握了很多:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | digraph G { graph [rankdir = LR, splines=ortho] unit [shape=box, width = 2, height = 10]; more_different_unit [shape=box, height=4]; other_unit [shape=box, height=4]; unit -> other_unit [label ="foo"]; unit -> other_unit [label ="bar"]; unit -> other_unit [label ="bar"]; unit -> other_unit [label ="bar"]; unit -> other_unit [label ="bar"]; unit -> other_unit [label ="bar"]; unit -> more_different_unit [label ="bar"]; unit -> more_different_unit [label ="bar"]; unit -> more_different_unit [label ="bar"]; unit -> more_different_unit [label ="bar"]; unit -> more_different_unit [label ="bar"]; unit -> more_different_unit [label ="bar"]; } |
我这样编译:
dot -Gsplines=none test.gv | neato -n -Gsplines=ortho -Tpng -otest.png
这让我很接近,但是我想知道几件事。
我如何才能在Foo的左侧和右侧获得块,而不仅仅是右侧?我还没弄清楚。
是否可以在边缘上方或下方始终放置边缘标签?
如何将右侧节点向左对齐,并将左侧节点向右对齐?一种可能是使它们具有相同的宽度,这没关系。
谢谢!!
更新:
基于接受的答案,我现在正在执行以下正是我所需要的操作,再次通过管道连接到neato的点生成,如上所述:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | digraph G { graph [rankdir = LR, splines=ortho]; node[shape=record]; Bar[label="Bar", height=2]; Foo[label="Foo", height=4]; Bew[label="Bew", height=2]; Gate[label="Gate", height=2]; Bar -> Foo [label="Bar2Foo"]; Bar -> Foo [label="Bar2Foo"]; Bar -> Foo [label="Bar2Foo"]; Foo -> Bew [label="Foo2Bew"]; Foo -> Bew [label="Foo2Bew"]; Bew -> Foo [label="Bew2Foo"]; Foo -> Gate [label="Foo2Gate"]; Foo -> Gate [label="Foo2Gate"]; } |
这会让您入门吗?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | digraph G { graph [rankdir = LR]; node[shape=record]; Bar[label="{ "Bar"|{<p1>pin 1|<p2>2|<p3>3|<p4>4|<p5>5} }"]; Foo[label="{ {<data0>data0|<data1>data1|<data2>data2|<data3>data3|<data4>data4}|"Foo" |{<out0>out0|<out1>out1|<out2>out2|<GND>gnd|<ex0>ex0|<hi>hi|<lo>lo} }"]; Bew[label="{ {<clk>clk|<syn>syn|<mux0>mux0|<mux1>mux1|<signal>signal}|"Bew" |{<out0>out0|<out1>out1|<out2>out2} }"]; Bar:p1 -> Foo:data0; Bar:p2 -> Foo:data1; Bar:p3 -> Foo:data2; Bar:p4 -> Foo:data3; Bar:p5 -> Foo:data4; Foo:out0 -> Bew:mux0; Foo:out1 -> Bew:mux1; Bew:clk -> Foo:ex0; Gate[label="{ {a|b}|OR|{a\\|b} }"]; Foo:hi -> Gate:a; Foo:lo -> Gate:b; Gate:ab -> Bew:signal; } |
blockquote>
blockquote>请注意,我使用不间断空格作为获取对齐方式的简单方法(我认为我在vim中做了 C-kSpaceSpace sub>,导致十六进制
00a0 char)您还可以在标签定义中使用HTML,因此可以使用字体,颜色和创建"空格":http://www.graphviz.org/doc/info/shapes.html#html
我想使用HTML节点更容易对齐标签。