Graphviz:更改子图簇内的节点间距

时间:2017-08-26 00:01:00

标签: graphviz

有经验但没有Graphviz的专家。

我分享的示例代码和图片是较大图表的一部分,我将其拉出来使问题和示例更清晰。

图表按等级分开,从左向右流动。在图像示例中,您可以很好地看到三个排名和节点空间,但我想在子图中收紧它们。

我已经尝试了六种语法选项,但它们都不允许我缩小子图中节点之间的垂直距离而没有其他地方。

不确定如何将nodesep隔离到子图群集。

感谢您的帮助。

Sample subgraph

test.cpp: In function ‘int main()’:
test.cpp:17:10: error: invalid conversion from ‘int*’ to ‘int’ [-fpermissive]
  printp(p);  // why doesn't this print the address of p?
          ^
test.cpp:5:6: note:   initializing argument 1 of ‘void printp(int&)’
 void printp(int& test)
      ^~~~~~
test.cpp:17:10: error: cannot bind rvalue ‘(int)p’ to ‘int&’
  printp(p);  // why doesn't this print the address of p?

1 个答案:

答案 0 :(得分:0)

如果确定要拧紧的这些节点在同一级别上,则可以用表格替换它们。在表格中,您可以删除外边界并设置 cellspacing 属性以控制单元格之间的距离。

要使这些伪节点边缘化,必须为每个单元格设置 port 属性,然后将这些端口作为headport属性或node1 -> {pseudonode1;pseudonode2;node3}语法引用。 / p>

您唯一的不便便是,无法使用语法digraph G { graph [rankdir=LR, ranksep=.8, nodesep=.25]; edge [dir=forward, color=black]; node [shape=rectangle, fontsize=12, fontname="Times-Roman", height=.45]; {edge [color=firebrick1] v_Automobile ->{"Locational"; "Consumption"; "Governmental"};}; {edge [color=blue2] v_Body ->{"BioMetric"; "Networked IoT"; "Medical"};}; {edge [color=darkviolet] v_Citizen ->{"Associative"; "Conversaional"; "Governmental"; "Political"};}; {edge [color=lightskyblue] v_Consumer ->{"Consumption"; "Educational"; "Employment"; "Governmental"; "Locational"; "Medical"; "Transactional"};}; {edge [color=crimson] v_Home ->{"Consumption"; "Emanative"; "Locational"; "Networked IoT"};}; {edge [color=blue2] "BioMetric" -> tight:Camera;}; {edge [color=blue2] "BioMetric" -> tight:Apps;}; {edge [color=blue2] "BioMetric" ->{"CCTV"};}; {edge [color=crimson] "Consumption" ->"Smart Meter"}; {edge [color=blue2] "Medical" ->tight:Apps}; {edge [color=darkviolet] "Political" ->"Ballot"}; {edge [color=lightskyblue] "Transactional" -> tight:Browser}; {edge [color=lightskyblue] "Transactional" -> tight:Apps;}; {edge [color=lightskyblue] "Transactional" -> {"Reward Cards"; "Paypoint"};}; subgraph cluster_SmartPhone {label = "Smart Phone"; dirType=none; tight [ shape=none label=< <table border="0" cellborder="1" cellspacing="10"> <tr> <td port="Camera">Camera</td> </tr> <tr> <td port="Apps">Apps</td> </tr> <tr> <td port="Browser">Browser</td> </tr> <tr> <td port="GPS">GPS</td> </tr> </table> > ] }; v_Automobile [label="Automobile", penwidth=2, color=firebrick1]; v_Body [label="Body", penwidth=2, color=blue2]; v_Citizen [label="Citizen", penwidth=2, color=darkviolet]; v_Consumer [label="Consumer", penwidth=2, color=lightskyblue]; v_Home [label="Home", penwidth=2, color=crimson]; } 到包含这些伪节点的多个节点边缘,因为 headport 是边缘的属性。因此,您必须分别声明这些边缘。

您使用此技术的示例将如下所示:

getDates.pipe(distinctUntilChanged())
  .subscribe(data => console.log("This will only hit if data changed"));

结果: