diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2015-08-24 12:35:47 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@araneo.org> | 2015-08-24 12:35:47 +0200 |
commit | d9c8ca8f64839128d2fd3ae04a19ba73c1125b7b (patch) | |
tree | 7f00bdde6817ad89fc3c0ccd4e5d79b989b12402 | |
parent | 5ee22607bd5df9c35f2c19a7fe9d69d567c74518 (diff) |
monkey.graph.graphviz: use id() to reference nodes
-rw-r--r-- | monkey/graph.py | 10 |
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) + ']' |