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

Method __setitem__

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

Set edge value. If tail does not exist, it is created and added to graph if necessary. >>> g = Graph() >>> g[1][2] = 3 #edge values ignored on plain Vertex >>> g[1][2] True

(self, tail, value)

Source from the content-addressed store, hash-verified

326 EDGEVALUE = True #XXX doesn't get used -- Graph[v1][v2] returns 1 instead of True
327
328 def __setitem__(self, tail, value):
329 """Set edge value. If tail does not exist, it is created and added to graph
330 if necessary.
331
332 >>> g = Graph()
333 >>> g[1][2] = 3 #edge values ignored on plain Vertex
334 >>> g[1][2]
335 True
336 """
337 super(Vertex, self).__setitem__(tail, True)
338
339 def __str__(self):
340 """Return string of tail vertices in set notation.

Callers

nothing calls this directly

Calls 1

__setitem__Method · 0.45

Tested by

no test coverage detected