summaryrefslogtreecommitdiff
path: root/monkey
diff options
context:
space:
mode:
Diffstat (limited to 'monkey')
-rw-r--r--monkey/graph.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/monkey/graph.py b/monkey/graph.py
index cbe44f7..20a8a98 100644
--- a/monkey/graph.py
+++ b/monkey/graph.py
@@ -47,10 +47,10 @@ class Node(object):
def graphviz(nodes, label=str, pos=None, node_attr=None, edge_attr=None):
# Generate node descriptions.
node_str = ''
- node_id = {}
+ gv_nodes = {}
for node in nodes:
- node_id[node] = len(node_id)
- node_str += '\t{} [label="{}"'.format(node_id[node], label(node).replace('"', '\\"'))
+ gv_nodes[id(node)] = len(gv_nodes)
+ node_str += '\t{} [label="{}"'.format(gv_nodes[id(node)], label(node).replace('"', '\\"'))
if pos:
node_str += ', ' + 'pos="{},{}"'.format(*pos(node))
if node_attr:
@@ -60,9 +60,9 @@ def graphviz(nodes, label=str, pos=None, node_attr=None, edge_attr=None):
# Generate edge descriptions (breadth-first).
edge_str = ''
for node in nodes:
- a = node_id[node]
+ a = gv_nodes[id(node)]
for child in node.eout:
- b = node_id[child]
+ b = gv_nodes[id(child)]
edge_str += '\t{} -> {}'.format(a, b)
if edge_attr:
edge_str += ' [' + edge_attr(node, child) + ']'