Set edge value. If tail does not exist, it is created and added to graph if necessary. >>> g = Graph(VertexType=WVertex) >>> g[1][2] = 1 >>> g[1][3] += 1 #new tail (3): starts as value False (0), now add 1. >>> print g {1: {2: 1, 3: 1}, 2: {}, 3:
(self, tail, value)
| 116 | return dict.get(self, tail, False) |
| 117 | |
| 118 | def __setitem__(self, tail, value): |
| 119 | """Set edge value. If tail does not exist, it is created and added to graph |
| 120 | if necessary. |
| 121 | |
| 122 | >>> g = Graph(VertexType=WVertex) |
| 123 | >>> g[1][2] = 1 |
| 124 | >>> g[1][3] += 1 #new tail (3): starts as value False (0), now add 1. |
| 125 | >>> print g |
| 126 | {1: {2: 1, 3: 1}, 2: {}, 3: {}} |
| 127 | """ |
| 128 | super(VertexCommon, self).__setitem__(tail, value) |
| 129 | if tail not in self._graph and tail!=self._id: #XXX ?do this first to preserve invariants in case vertex addition fails |
| 130 | self._graph.add(tail) |
| 131 | |
| 132 | def copy(self): raise NotImplementedError |
| 133 |
nothing calls this directly
no test coverage detected