MCPcopy Create free account
hub / github.com/ActiveState/code / __delitem__

Method __delitem__

recipes/Python/578615_graph/recipe-578615.py:246–261  ·  view source on GitHub ↗

Removes tail from self and self._id from tail.reverse. >>> class myvertex(ReverseEdgeMixin, WVertex): ... pass >>> g = Graph(VertexType=myvertex) >>> g[1][2] = 3 >>> g[2].reverse {1: 3} >>> del g[1][2] >>> g[2].reverse {}

(self, tail)

Source from the content-addressed store, hash-verified

244 self.reverse[self._id] = value
245
246 def __delitem__(self, tail):
247 """Removes tail from self and self._id from tail.reverse.
248
249 >>> class myvertex(ReverseEdgeMixin, WVertex):
250 ... pass
251 >>> g = Graph(VertexType=myvertex)
252 >>> g[1][2] = 3
253 >>> g[2].reverse
254 {1: 3}
255 >>> del g[1][2]
256 >>> g[2].reverse
257 {}
258 """
259 if tail in self._graph:
260 del self._graph[tail].reverse[self._id] #creates tail vertex so check if tail in graph first
261 super(ReverseEdgeMixin, self).__delitem__(tail)
262
263 def clear(self): #XXX should this clear self.reverse also?
264 """Removes all tails from self and all references to self._id in tail.reverse

Callers

nothing calls this directly

Calls 1

__delitem__Method · 0.45

Tested by

no test coverage detected