As suggested by notEvil.
Fixes https://github.com/jrfonseca/xdot.py/issues/94
| ... | ... |
@@ -488,11 +488,12 @@ class XDotParser(DotParser): |
| 488 | 488 |
pos = attrs['pos'] |
| 489 | 489 |
except KeyError: |
| 490 | 490 |
# Node without pos attribute, most likely a subgraph. We need to |
| 491 |
- # create a Node object nevertheless, so that any edges to/from it |
|
| 492 |
- # don't get lost. |
|
| 493 |
- # TODO: Extract the position from subgraph > graph > bb attribute. |
|
| 494 |
- node = elements.Node(id, 0.0, 0.0, 0.0, 0.0, [], None, None) |
|
| 495 |
- self.node_by_name[id] = node |
|
| 491 |
+ # create a Node object nevertheless, when one doesn't exist |
|
| 492 |
+ # already, so that any edges to/from it don't get lost. |
|
| 493 |
+ if id not in self.node_by_name: |
|
| 494 |
+ # TODO: Extract the position from subgraph > graph > bb attribute. |
|
| 495 |
+ node = elements.Node(id, 0.0, 0.0, 0.0, 0.0, [], None, None) |
|
| 496 |
+ self.node_by_name[id] = node |
|
| 496 | 497 |
return |
| 497 | 498 |
|
| 498 | 499 |
x, y = self.parse_node_pos(pos) |