Mercurial > hg > WSGraph
diff wsgraph/model.py @ 15:ee45f44394a0
i need a name, Bastian
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 10 Dec 2012 17:33:44 -0800 |
parents | 7b8e40eda563 |
children | 24d57daaca21 |
line wrap: on
line diff
--- a/wsgraph/model.py Mon Dec 10 17:32:33 2012 -0800 +++ b/wsgraph/model.py Mon Dec 10 17:33:44 2012 -0800 @@ -1,6 +1,6 @@ from abc import abstractmethod from copy import deepcopy -from utils import iterable +from utils import isiterable class GraphModel(object): @@ -36,7 +36,7 @@ if key is a 2-tuple/list, return the edge of that name """ - if isinstance(key, basestring) or (not iterable(key)): + if isinstance(key, basestring) or (not isiterable(key)): return self.node(key) else: return self.edge(*key) @@ -47,12 +47,14 @@ if key is a 2-tuple/list, returns if the edge is in the graph """ # XXX not necessarily the best implementation! - if isinstance(key, basestring) or (not iterable(key)): + if isinstance(key, basestring) or (not isiterable(key)): return key in self.nodes() else: return tuple(key) in self.edges() + class MemoryCache(GraphModel): + """volatile in-memory representation of a graph""" def __init__(self): self._edges = {}