Mercurial > hg > WSGraph
comparison wsgraph/model.py @ 10:81d68388ec97
some nonsense about how this model is full of holes and how it should be better
| author | Jeff Hammel <jhammel@mozilla.com> |
|---|---|
| date | Mon, 10 Dec 2012 17:14:49 -0800 |
| parents | 0affca1f4dc0 |
| children | 7b8e40eda563 |
comparison
equal
deleted
inserted
replaced
| 9:0affca1f4dc0 | 10:81d68388ec97 |
|---|---|
| 4 | 4 |
| 5 class GraphModel(object): | 5 class GraphModel(object): |
| 6 | 6 |
| 7 @abstractmethod | 7 @abstractmethod |
| 8 def node(self, name, **values): | 8 def node(self, name, **values): |
| 9 """get or set a node""" | 9 """ |
| 10 get or set a node | |
| 11 | |
| 12 When setting a node, a value of `None` will pop the value from | |
| 13 the nodal values | |
| 14 """ | |
| 10 | 15 |
| 11 @abstractmethod | 16 @abstractmethod |
| 12 def nodes(self): | 17 def nodes(self): |
| 13 """returns a list of all nodes""" | 18 """returns a list of all nodes""" |
| 14 | 19 |
| 15 @abstractmethod | 20 @abstractmethod |
| 21 def edge(self, node1, node2, **values): | |
| 22 """ | |
| 23 get or set edge from node1 to node2 | |
| 24 """ | |
| 25 | |
| 26 @abstractmethod | |
| 16 def edges(self): | 27 def edges(self): |
| 17 """returns a list of all edges""" | 28 """returns a list of all edges""" |
| 18 | |
| 19 @abstractmethod | |
| 20 def edge(self, node1, node2, **values): | |
| 21 """returns edge from node1 to node2""" | |
| 22 | 29 |
| 23 def __getitem__(self, key): | 30 def __getitem__(self, key): |
| 24 """ | 31 """ |
| 25 if key is a basestring, return the node of that name; | 32 if key is a basestring, return the node of that name; |
| 26 if key is a 2-tuple/list, return the edge of that name | 33 if key is a 2-tuple/list, return the edge of that name |
