File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ def visualize(self):
168168
169169 G = nx .DiGraph ()
170170
171- for node in self .nodes :
171+ for node in self .nodes . values () :
172172 G .add_node (node .name )
173173
174174 for edge in self .edges :
@@ -202,10 +202,11 @@ def visualize(self):
202202 pos [node ] = (pos [node ][0 ] - x_center , pos [node ][1 ])
203203
204204 # Scale the layout
205- max_x = max (abs (p [0 ]) for p in pos .values ())
206- max_y = max (abs (p [1 ]) for p in pos .values ())
207- scale = min (0.8 / max_x , 0.8 / max_y )
208- pos = {node : (x * scale , y * scale ) for node , (x , y ) in pos .items ()}
205+ max_x = max (abs (p [0 ]) for p in pos .values ()) if pos else 1
206+ max_y = max (abs (p [1 ]) for p in pos .values ()) if pos else 1
207+ if max_x > 0 and max_y > 0 :
208+ scale = min (0.8 / max_x , 0.8 / max_y )
209+ pos = {node : (x * scale , y * scale ) for node , (x , y ) in pos .items ()}
209210
210211 else :
211212 print ("Warning: The graph contains cycles. Visualization will use a spring layout." )
You can’t perform that action at this time.
0 commit comments