2017-02-13 69 views
0

My图表:如何在graphviz中制作此图?

enter image description here

我可以通过设置每个顶点的坐标做到这一点。但我不知道如何设置像素坐标。

我尝试这样做:

digraph { 
node [shape=circle] 
edge [arrowhead=none] 
rankdir = BT; 
0 -> {1; 2;} 
1 -> {3; 4;} 
2 -> {4; 8;} 
3 -> {9; 5;} 
4 -> {5; 10;} 
5 -> 11 
6 -> {7; 12; 8;} 
7 -> {9; 10} 
8 -> {10; 14} 
9 -> {15; 11} 
10 -> {11; 16} 
11 -> 17 
12 -> {13; 14} 
13 -> {15; 16} 
14 -> 16 
15 -> 17 
16 -> 17 
0 [pos = "5,0!"] 
1 [pos = "4,1!"] 
2 [pos = "6,1!"] 
3 [pos = "3,2!"] 
4 [pos = "5,2!"] 
5 [pos = "4,3!"] 
6 [pos = "6,3!"] 
7 [pos = "4,4!"] 
8 [pos = "6,4!"] 
9 [pos = "3,5!"] 
10 [pos = "5,5!"] 
11 [pos = "4,6!"] 
12 [pos = "6,6!"] 
13 [pos = "4,7!"] 
14 [pos = "6,7!"] 
15 [pos = "3,8!"] 
16 [pos = "5,8!"] 
17 [pos = "4,9!"] 
} 

我改名为节点与数量的字母。

结果:

enter image description here

回答

1

ex2.dot文件:

digraph { 
node [ shape=circle, fixedsize=true, width=0.3 ] 
edge [ arrowhead=none ] 
0 -> {1; 3; 6;} 
1 -> {2; 4; 7;} 
2 -> {5; 8;} 
3 -> {4; 9;} 
4 -> {5; 10;} 
5 -> 11 
6 -> {7; 9; 12;} 
7 -> {8; 10; 13;} 
8 -> {14; 11;} 
9 -> {10; 15;} 
10 -> {11; 16;} 
11 -> 17 
12 -> {13; 15} 
13 -> {14; 16} 
14 -> 17 
15 -> 16 
16 -> 17 
0 [ pos = "6.00,0.00!" ] 
1 [ pos = "5.10,0.30!" ] 
2 [ pos = "4.20,0.60!" ] 
3 [ pos = "6.60,0.60!" ] 
4 [ pos = "5.70,0.90!" ] 
5 [ pos = "4.80,1.20!" ] 
6 [ pos = "6.30,1.53!" ] 
7 [ pos = "5.40,1.83!" ] 
8 [ pos = "4.50,2.13!" ] 
9 [ pos = "6.90,2.13!" ] 
10 [ pos = "6.00,2.43!" ] 
11 [ pos = "5.10,2.73!" ] 
12 [ pos = "6.60,3.06!" ] 
13 [ pos = "5.70,3.36!" ] 
14 [ pos = "4.80,3.66!" ] 
15 [ pos = "7.20,3.66!" ] 
16 [ pos = "6.30,3.96!" ] 
17 [ pos = "5.40,4.26!" ] 
} 

命令:

dot -Kfdp -n -Tpng -o ex2.dot.png ex2.dot 

结果:

enter image description here