Hi all,
The graph sometimes renders but mostly fails with the above error code and I am not sure why.
I am using the Graphviz Python API.
https://graphviz.readthedocs.io/en/stable/api.html
The version of Graphviz is 12.0.0.
The purpose is to move the every single node such that the node layers align at the top and not the center.
G = Digraph (
graph_attr = {
"rankdir":"BT",
"splines":"ortho",
"nodesep" : "1",
"ranksep" : "1",
"pad" : "3",
"margin" : "0"
},
node_attr = {
"shape":"plaintext",
"margin" : "1,1",
"fontsize": "3",
"pin": "true",
"fixedsize":"true",
"shape":"rect"
},
engine="neato"
)
for n in g.nodes:
x1 = n._bbox[0].x/1000
x2 = n._bbox[1].x/1000
y1 = n._bbox[0].y/1000
y2 = n._bbox[1].y/1000
width = x2 - x1
height = y2 - y1
pos[n.name] = "%.3f, %.3f!"%((x1+(width/2))*72, (-y1)*72)
# This line below often fails
# pos[n.name] = "%.3f, %.3f!"%((x1+(width/2))*72, (-y1-(height/2))*72)
G.node(
n.name,
n.name,
width = "%.3f"%width,
height = "%.3f"%height,
pos = pos[n.name]
)
for e in g.edges:
G.edge(e.start, e.end)
G.format = "svg"
G.filename = "%s.dot"%str(uuid4())
G.render(neato_no_op=1, directory = directory)
From:
This is the output for the above.
digraph {
graph [margin=0 nodesep=1 pad=3 rankdir=BT ranksep=1 splines=ortho]
node [fixedsize=true fontsize=3 margin="1,1" pin=true shape=rect]
0 [label=0 height=0.075 pos="170.586, -514.620!" width=0.365]
1 [label=1 height=0.270 pos="100.602, -455.760!" width=0.364]
2 [label=2 height=0.270 pos="138.510, -455.760!" width=0.364]
3 [label=3 height=0.270 pos="214.326, -455.760!" width=0.364]
4 [label=4 height=0.270 pos="290.142, -455.760!" width=0.364]
5 [label=5 height=0.270 pos="328.050, -455.760!" width=0.365]
6 [label=6 height=0.270 pos="365.958, -455.760!" width=0.364]
7 [label=7 height=0.270 pos="403.866, -455.760!" width=0.365]
8 [label=8 height=0.270 pos="62.694, -455.760!" width=0.364]
9 [label=9 height=0.270 pos="24.786, -455.760!" width=0.364]
10 [label=10 height=0.270 pos="252.234, -455.760!" width=0.365]
11 [label=11 height=0.270 pos="176.418, -455.760!" width=0.365]
12 [label=12 height=0.105 pos="142.884, -488.700!" width=0.162]
13 [label=13 height=0.105 pos="166.212, -488.700!" width=0.162]
14 [label=14 height=0.105 pos="212.868, -488.700!" width=0.162]
15 [label=15 height=0.105 pos="259.524, -488.700!" width=0.162]
16 [label=16 height=0.105 pos="282.852, -488.700!" width=0.162]
17 [label=17 height=0.105 pos="306.180, -488.700!" width=0.162]
18 [label=18 height=0.105 pos="329.508, -488.700!" width=0.162]
19 [label=19 height=0.105 pos="119.556, -488.700!" width=0.162]
20 [label=20 height=0.105 pos="96.228, -488.700!" width=0.162]
21 [label=21 height=0.105 pos="236.196, -488.700!" width=0.162]
22 [label=22 height=0.105 pos="189.540, -488.700!" width=0.162]
23 [label=23 height=0.420 pos="231.822, -527.040!" width=1.013]
24 [label=24 height=0.300 pos="406.782, -378.000!" width=0.364]
25 [label=25 height=0.300 pos="444.690, -378.000!" width=0.365]
26 [label=26 height=0.270 pos="427.194, -305.640!" width=0.364]
27 [label=27 height=0.285 pos="389.286, -306.180!" width=0.365]
28 [label=28 height=0.270 pos="503.010, -305.640!" width=0.364]
29 [label=29 height=0.285 pos="351.378, -306.180!" width=0.364]
30 [label=30 height=0.270 pos="465.102, -305.640!" width=0.365]
31 [label=31 height=0.165 pos="344.088, -414.180!" width=0.162]
32 [label=32 height=0.165 pos="367.416, -414.180!" width=0.162]
33 [label=33 height=0.165 pos="390.744, -414.180!" width=0.162]
34 [label=34 height=0.165 pos="460.728, -414.180!" width=0.162]
35 [label=35 height=0.165 pos="437.400, -414.180!" width=0.162]
36 [label=36 height=0.165 pos="484.056, -414.180!" width=0.162]
37 [label=37 height=0.165 pos="507.384, -414.180!" width=0.162]
38 [label=38 height=0.165 pos="414.072, -414.180!" width=0.162]
39 [label=39 height=0.165 pos="402.408, -341.820!" width=0.162]
40 [label=40 height=0.105 pos="449.064, -339.660!" width=0.162]
41 [label=41 height=0.165 pos="472.392, -341.820!" width=0.162]
42 [label=42 height=0.105 pos="379.080, -339.660!" width=0.162]
43 [label=43 height=0.165 pos="425.736, -341.820!" width=0.162]
44 [label=44 height=0.285 pos="351.378, -162.540!" width=0.364]
45 [label=45 height=0.285 pos="465.102, -162.540!" width=0.365]
46 [label=46 height=0.285 pos="427.194, -162.540!" width=0.364]
47 [label=47 height=0.285 pos="389.286, -162.540!" width=0.365]
48 [label=48 height=0.270 pos="503.010, -162.000!" width=0.364]
49 [label=49 height=0.270 pos="389.286, -228.960!" width=0.365]
50 [label=50 height=0.270 pos="427.194, -228.960!" width=0.364]
51 [label=51 height=0.270 pos="465.102, -228.960!" width=0.365]
52 [label=52 height=0.105 pos="379.080, -196.020!" width=0.162]
53 [label=53 height=0.105 pos="449.064, -196.020!" width=0.162]
54 [label=54 height=0.105 pos="425.736, -196.020!" width=0.162]
55 [label=55 height=0.105 pos="402.408, -196.020!" width=0.162]
56 [label=56 height=0.105 pos="472.392, -196.020!" width=0.162]
57 [label=57 height=0.165 pos="390.744, -264.060!" width=0.162]
58 [label=58 height=0.165 pos="414.072, -264.060!" width=0.162]
59 [label=59 height=0.165 pos="437.400, -264.060!" width=0.162]
60 [label=60 height=0.165 pos="460.728, -264.060!" width=0.162]
61 [label=61 height=0.270 pos="351.378, -85.320!" width=0.364]
62 [label=62 height=0.270 pos="465.102, -85.320!" width=0.365]
63 [label=63 height=0.270 pos="427.194, -85.320!" width=0.364]
64 [label=64 height=0.270 pos="503.010, -85.320!" width=0.364]
65 [label=65 height=0.270 pos="389.286, -85.320!" width=0.365]
66 [label=66 height=0.165 pos="351.378, -18.900!" width=0.364]
67 [label=67 height=0.165 pos="465.102, -18.900!" width=0.365]
68 [label=68 height=0.165 pos="427.194, -18.900!" width=0.364]
69 [label=69 height=0.165 pos="389.286, -18.900!" width=0.365]
70 [label=70 height=0.165 pos="503.010, -18.900!" width=0.364]
71 [label=71 height=0.165 pos="379.080, -120.420!" width=0.162]
72 [label=72 height=0.165 pos="449.064, -120.420!" width=0.162]
73 [label=73 height=0.165 pos="425.736, -120.420!" width=0.162]
74 [label=74 height=0.165 pos="472.392, -120.420!" width=0.162]
75 [label=75 height=0.165 pos="402.408, -120.420!" width=0.162]
76 [label=76 height=0.165 pos="379.080, -50.220!" width=0.162]
77 [label=77 height=0.165 pos="449.064, -50.220!" width=0.162]
78 [label=78 height=0.165 pos="425.736, -50.220!" width=0.162]
79 [label=79 height=0.165 pos="402.408, -50.220!" width=0.162]
80 [label=80 height=0.165 pos="472.392, -50.220!" width=0.162]
81 [label=81 height=0.075 pos="599.238, -514.620!" width=0.365]
82 [label=82 height=0.270 pos="794.610, -455.760!" width=0.365]
83 [label=83 height=0.270 pos="756.702, -455.760!" width=0.364]
84 [label=84 height=0.270 pos="642.978, -455.760!" width=0.365]
85 [label=85 height=0.270 pos="491.346, -455.760!" width=0.364]
86 [label=86 height=0.270 pos="453.438, -455.760!" width=0.365]
87 [label=87 height=0.270 pos="529.254, -455.760!" width=0.365]
88 [label=88 height=0.270 pos="567.162, -455.760!" width=0.364]
89 [label=89 height=0.270 pos="605.070, -455.760!" width=0.364]
90 [label=90 height=0.270 pos="718.794, -455.760!" width=0.364]
91 [label=91 height=0.270 pos="832.518, -455.760!" width=0.364]
92 [label=92 height=0.270 pos="680.886, -455.760!" width=0.364]
93 [label=93 height=0.105 pos="734.832, -488.700!" width=0.162]
94 [label=94 height=0.105 pos="711.504, -488.700!" width=0.162]
95 [label=95 height=0.105 pos="641.520, -488.700!" width=0.162]
96 [label=96 height=0.105 pos="548.208, -488.700!" width=0.162]
97 [label=97 height=0.105 pos="524.880, -488.700!" width=0.162]
98 [label=98 height=0.105 pos="571.536, -488.700!" width=0.162]
99 [label=99 height=0.105 pos="594.864, -488.700!" width=0.162]
100 [label=100 height=0.105 pos="618.192, -488.700!" width=0.162]
101 [label=101 height=0.105 pos="688.176, -488.700!" width=0.162]
102 [label=102 height=0.105 pos="758.160, -488.700!" width=0.162]
103 [label=103 height=0.105 pos="664.848, -488.700!" width=0.162]
104 [label=104 height=0.420 pos="660.474, -527.040!" width=1.013]
105 [label=105 height=0.165 pos="427.194, -574.020!" width=1.985]
44 -> 71
71 -> 61
45 -> 72
72 -> 62
46 -> 73
73 -> 63
48 -> 74
74 -> 64
47 -> 75
75 -> 65
61 -> 76
76 -> 66
62 -> 77
77 -> 67
63 -> 78
78 -> 68
65 -> 79
79 -> 69
64 -> 80
80 -> 70
49 -> 52
52 -> 44
50 -> 53
53 -> 45
50 -> 54
54 -> 46
50 -> 55
55 -> 47
51 -> 56
56 -> 48
11 -> 57
57 -> 49
29 -> 58
58 -> 49
27 -> 59
59 -> 50
27 -> 60
60 -> 51
4 -> 31
31 -> 24
5 -> 32
32 -> 24
86 -> 33
33 -> 24
85 -> 34
34 -> 24
7 -> 35
35 -> 25
87 -> 36
36 -> 25
88 -> 37
37 -> 25
6 -> 38
38 -> 25
24 -> 39
39 -> 26
25 -> 40
40 -> 27
25 -> 41
41 -> 28
24 -> 42
42 -> 29
24 -> 43
43 -> 30
0 -> 12
12 -> 1
0 -> 13
13 -> 2
0 -> 14
14 -> 3
0 -> 15
15 -> 4
0 -> 16
16 -> 5
0 -> 17
17 -> 6
0 -> 18
18 -> 7
0 -> 19
19 -> 8
0 -> 20
20 -> 9
0 -> 21
21 -> 10
0 -> 22
22 -> 11
81 -> 93
93 -> 82
81 -> 94
94 -> 83
81 -> 95
95 -> 84
81 -> 96
96 -> 85
81 -> 97
97 -> 86
81 -> 98
98 -> 87
81 -> 99
99 -> 88
81 -> 100
100 -> 89
81 -> 101
101 -> 90
81 -> 102
102 -> 91
81 -> 103
103 -> 92
}
To:
This is the output for the above.
digraph {
graph [margin=0 nodesep=1 pad=3 rankdir=BT ranksep=1 splines=ortho]
node [fixedsize=true fontsize=3 margin="1,1" pin=true shape=rect]
0 [label=0 height=0.300 pos="406.782, -367.200!" width=0.364]
1 [label=1 height=0.300 pos="444.690, -367.200!" width=0.365]
2 [label=2 height=0.270 pos="389.286, -295.920!" width=0.365]
3 [label=3 height=0.285 pos="503.010, -295.920!" width=0.364]
4 [label=4 height=0.270 pos="427.194, -295.920!" width=0.364]
5 [label=5 height=0.285 pos="465.102, -295.920!" width=0.365]
6 [label=6 height=0.270 pos="351.378, -295.920!" width=0.364]
7 [label=7 height=0.165 pos="390.744, -408.240!" width=0.162]
8 [label=8 height=0.165 pos="344.088, -408.240!" width=0.162]
9 [label=9 height=0.165 pos="367.416, -408.240!" width=0.162]
10 [label=10 height=0.165 pos="414.072, -408.240!" width=0.162]
11 [label=11 height=0.165 pos="460.728, -408.240!" width=0.162]
12 [label=12 height=0.165 pos="484.056, -408.240!" width=0.162]
13 [label=13 height=0.165 pos="507.384, -408.240!" width=0.162]
14 [label=14 height=0.165 pos="437.400, -408.240!" width=0.162]
15 [label=15 height=0.165 pos="402.408, -335.880!" width=0.162]
16 [label=16 height=0.105 pos="472.392, -335.880!" width=0.162]
17 [label=17 height=0.165 pos="425.736, -335.880!" width=0.162]
18 [label=18 height=0.105 pos="449.064, -335.880!" width=0.162]
19 [label=19 height=0.165 pos="379.080, -335.880!" width=0.162]
20 [label=20 height=0.270 pos="389.286, -75.600!" width=0.365]
21 [label=21 height=0.270 pos="427.194, -75.600!" width=0.364]
22 [label=22 height=0.270 pos="503.010, -75.600!" width=0.364]
23 [label=23 height=0.270 pos="351.378, -75.600!" width=0.364]
24 [label=24 height=0.270 pos="465.102, -75.600!" width=0.365]
25 [label=25 height=0.165 pos="389.286, -12.960!" width=0.365]
26 [label=26 height=0.165 pos="427.194, -12.960!" width=0.364]
27 [label=27 height=0.165 pos="503.010, -12.960!" width=0.364]
28 [label=28 height=0.165 pos="465.102, -12.960!" width=0.365]
29 [label=29 height=0.165 pos="351.378, -12.960!" width=0.364]
30 [label=30 height=0.165 pos="402.408, -114.480!" width=0.162]
31 [label=31 height=0.165 pos="425.736, -114.480!" width=0.162]
32 [label=32 height=0.165 pos="472.392, -114.480!" width=0.162]
33 [label=33 height=0.165 pos="379.080, -114.480!" width=0.162]
34 [label=34 height=0.165 pos="449.064, -114.480!" width=0.162]
35 [label=35 height=0.165 pos="402.408, -44.280!" width=0.162]
36 [label=36 height=0.165 pos="425.736, -44.280!" width=0.162]
37 [label=37 height=0.165 pos="472.392, -44.280!" width=0.162]
38 [label=38 height=0.165 pos="449.064, -44.280!" width=0.162]
39 [label=39 height=0.165 pos="379.080, -44.280!" width=0.162]
40 [label=40 height=0.075 pos="599.238, -511.920!" width=0.365]
41 [label=41 height=0.270 pos="832.518, -446.040!" width=0.364]
42 [label=42 height=0.270 pos="642.978, -446.040!" width=0.365]
43 [label=43 height=0.270 pos="794.610, -446.040!" width=0.365]
44 [label=44 height=0.270 pos="491.346, -446.040!" width=0.364]
45 [label=45 height=0.270 pos="453.438, -446.040!" width=0.365]
46 [label=46 height=0.270 pos="567.162, -446.040!" width=0.364]
47 [label=47 height=0.270 pos="529.254, -446.040!" width=0.365]
48 [label=48 height=0.270 pos="756.702, -446.040!" width=0.364]
49 [label=49 height=0.270 pos="680.886, -446.040!" width=0.364]
50 [label=50 height=0.270 pos="718.794, -446.040!" width=0.364]
51 [label=51 height=0.270 pos="605.070, -446.040!" width=0.364]
52 [label=52 height=0.105 pos="758.160, -484.920!" width=0.162]
53 [label=53 height=0.105 pos="641.520, -484.920!" width=0.162]
54 [label=54 height=0.105 pos="734.832, -484.920!" width=0.162]
55 [label=55 height=0.105 pos="548.208, -484.920!" width=0.162]
56 [label=56 height=0.105 pos="524.880, -484.920!" width=0.162]
57 [label=57 height=0.105 pos="594.864, -484.920!" width=0.162]
58 [label=58 height=0.105 pos="571.536, -484.920!" width=0.162]
59 [label=59 height=0.105 pos="711.504, -484.920!" width=0.162]
60 [label=60 height=0.105 pos="664.848, -484.920!" width=0.162]
61 [label=61 height=0.105 pos="688.176, -484.920!" width=0.162]
62 [label=62 height=0.105 pos="618.192, -484.920!" width=0.162]
63 [label=63 height=0.420 pos="660.474, -511.920!" width=1.013]
64 [label=64 height=0.075 pos="170.586, -511.920!" width=0.365]
65 [label=65 height=0.270 pos="24.786, -446.040!" width=0.364]
66 [label=66 height=0.270 pos="138.510, -446.040!" width=0.364]
67 [label=67 height=0.270 pos="62.694, -446.040!" width=0.364]
68 [label=68 height=0.270 pos="328.050, -446.040!" width=0.365]
69 [label=69 height=0.270 pos="290.142, -446.040!" width=0.364]
70 [label=70 height=0.270 pos="403.866, -446.040!" width=0.365]
71 [label=71 height=0.270 pos="365.958, -446.040!" width=0.364]
72 [label=72 height=0.270 pos="176.418, -446.040!" width=0.365]
73 [label=73 height=0.270 pos="252.234, -446.040!" width=0.365]
74 [label=74 height=0.270 pos="100.602, -446.040!" width=0.364]
75 [label=75 height=0.270 pos="214.326, -446.040!" width=0.364]
76 [label=76 height=0.105 pos="96.228, -484.920!" width=0.162]
77 [label=77 height=0.105 pos="166.212, -484.920!" width=0.162]
78 [label=78 height=0.105 pos="119.556, -484.920!" width=0.162]
79 [label=79 height=0.105 pos="282.852, -484.920!" width=0.162]
80 [label=80 height=0.105 pos="259.524, -484.920!" width=0.162]
81 [label=81 height=0.105 pos="329.508, -484.920!" width=0.162]
82 [label=82 height=0.105 pos="306.180, -484.920!" width=0.162]
83 [label=83 height=0.105 pos="189.540, -484.920!" width=0.162]
84 [label=84 height=0.105 pos="236.196, -484.920!" width=0.162]
85 [label=85 height=0.105 pos="142.884, -484.920!" width=0.162]
86 [label=86 height=0.105 pos="212.868, -484.920!" width=0.162]
87 [label=87 height=0.420 pos="231.822, -511.920!" width=1.013]
88 [label=88 height=0.285 pos="389.286, -152.280!" width=0.365]
89 [label=89 height=0.285 pos="427.194, -152.280!" width=0.364]
90 [label=90 height=0.285 pos="503.010, -152.280!" width=0.364]
91 [label=91 height=0.285 pos="465.102, -152.280!" width=0.365]
92 [label=92 height=0.270 pos="351.378, -152.280!" width=0.364]
93 [label=93 height=0.270 pos="427.194, -219.240!" width=0.364]
94 [label=94 height=0.270 pos="465.102, -219.240!" width=0.365]
95 [label=95 height=0.270 pos="389.286, -219.240!" width=0.365]
96 [label=96 height=0.105 pos="402.408, -192.240!" width=0.162]
97 [label=97 height=0.105 pos="425.736, -192.240!" width=0.162]
98 [label=98 height=0.105 pos="472.392, -192.240!" width=0.162]
99 [label=99 height=0.105 pos="449.064, -192.240!" width=0.162]
100 [label=100 height=0.105 pos="379.080, -192.240!" width=0.162]
101 [label=101 height=0.165 pos="414.072, -258.120!" width=0.162]
102 [label=102 height=0.165 pos="437.400, -258.120!" width=0.162]
103 [label=103 height=0.165 pos="460.728, -258.120!" width=0.162]
104 [label=104 height=0.165 pos="390.744, -258.120!" width=0.162]
105 [label=105 height=0.165 pos="427.194, -568.080!" width=1.985]
88 -> 30
30 -> 20
89 -> 31
31 -> 21
90 -> 32
32 -> 22
92 -> 33
33 -> 23
91 -> 34
34 -> 24
20 -> 35
35 -> 25
21 -> 36
36 -> 26
22 -> 37
37 -> 27
24 -> 38
38 -> 28
23 -> 39
39 -> 29
93 -> 96
96 -> 88
94 -> 97
97 -> 89
94 -> 98
98 -> 90
94 -> 99
99 -> 91
95 -> 100
100 -> 92
5 -> 101
101 -> 93
51 -> 102
102 -> 93
3 -> 103
103 -> 94
3 -> 104
104 -> 95
45 -> 7
7 -> 0
69 -> 8
8 -> 0
68 -> 9
9 -> 0
44 -> 10
10 -> 0
70 -> 11
11 -> 1
47 -> 12
12 -> 1
46 -> 13
13 -> 1
71 -> 14
14 -> 1
0 -> 15
15 -> 2
1 -> 16
16 -> 3
1 -> 17
17 -> 4
0 -> 18
18 -> 5
0 -> 19
19 -> 6
40 -> 52
52 -> 41
40 -> 53
53 -> 42
40 -> 54
54 -> 43
40 -> 55
55 -> 44
40 -> 56
56 -> 45
40 -> 57
57 -> 46
40 -> 58
58 -> 47
40 -> 59
59 -> 48
40 -> 60
60 -> 49
40 -> 61
61 -> 50
40 -> 62
62 -> 51
64 -> 76
76 -> 65
64 -> 77
77 -> 66
64 -> 78
78 -> 67
64 -> 79
79 -> 68
64 -> 80
80 -> 69
64 -> 81
81 -> 70
64 -> 82
82 -> 71
64 -> 83
83 -> 72
64 -> 84
84 -> 73
64 -> 85
85 -> 74
64 -> 86
86 -> 75
}
I appreciate the help.
Thanks.