From 5b4f1e25980ee18a323eba1415ed453b3a910ca3 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 24 Aug 2015 15:32:06 +0200 Subject: Remove in-edges from monkey.graph.Node class --- monkey/graph.py | 12 ++---------- monkey/test.py | 8 +------- 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'monkey') diff --git a/monkey/graph.py b/monkey/graph.py index a8ad4b0..c69d55c 100644 --- a/monkey/graph.py +++ b/monkey/graph.py @@ -3,21 +3,13 @@ class Node(object): def __init__(self, data, eout=None): self.data = data - self.ein = [] self.eout = eout if eout else [] - # (Re-)insert a child node [target] to [self] at index [idx] (or as the - # rightmost child if index is not given). Also append [self] to the list of - # parents of [target]. + # (Re-)insert [target] as the right-most child of [self]. def add_out(self, target, idx=None): if target in self.eout: self.eout.remove(target) - if idx is None: - self.eout.append(target) - else: - self.eout.insert(idx, target) - if self not in target.ein: - target.ein.append(self) + self.eout.append(target) return target # Return a list of nodes in [self]. diff --git a/monkey/test.py b/monkey/test.py index bb28e9b..dfe20bc 100755 --- a/monkey/test.py +++ b/monkey/test.py @@ -167,16 +167,10 @@ elif sys.argv[2] == 'graph' and len(sys.argv) == 4: def label(node): return stringify(node.data[2]) - def node_attr(node): - if node.ein and node.data[2] == node.ein[0].data[2]: - return 'shape="point"' - return '' - def edge_attr(a, b): if a.data[2] == b.data[2]: return 'arrowhead="none"' return '' - graphviz_str = graphviz(nodes, pos=position, label=label, - node_attr=node_attr, edge_attr=edge_attr) + graphviz_str = graphviz(nodes, pos=position, label=label, edge_attr=edge_attr) print(graphviz_str) -- cgit v1.2.1