Mercurial > hg > WSGraph
diff wsgraph/model.py @ 38:df2a719a9b6e
stubbing deletion of nodes + edges
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 24 Dec 2012 22:57:02 -0800 |
parents | f17a6577cc0d |
children | d1e9602145fa |
line wrap: on
line diff
--- a/wsgraph/model.py Sat Dec 15 23:22:19 2012 -0800 +++ b/wsgraph/model.py Mon Dec 24 22:57:02 2012 -0800 @@ -38,6 +38,13 @@ def edges(self): """returns a list of all edges""" + @abstractmethod + def delete(self, node1, node2=None): + """ + delete a node or edge if node2 is given + If a node is deleted, all edges to it should be deleted + """ + def __call__(self): """ returns JSGN format of graph: @@ -73,6 +80,13 @@ key1, key2 = key self.edge(key1, key2, value) + def __delitem__(self, key): + if isinstance(key, basestring) or (not isiterable(key)): + self.delete(key) + else: + key1, key2 = key + self.delete(key1, key2) + def __contains__(self, key): """ if key is ..., returns if that node is in the graph