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

Method __str__

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

Return string of tail vertices in set notation. >>> g = Graph() >>> g.add(1, [1, 3, 4]) >>> print g[1] {1, 3, 4}

(self)

Source from the content-addressed store, hash-verified

337 super(Vertex, self).__setitem__(tail, True)
338
339 def __str__(self):
340 """Return string of tail vertices in set notation.
341
342 >>> g = Graph()
343 >>> g.add(1, [1, 3, 4])
344 >>> print g[1]
345 {1, 3, 4}
346 """
347 if _DEBUG: self._validate()
348 if not self: return '{}' #nothing to sort
349 keys = self.keys()
350 keys.sort()
351 return '{%s}' % ', '.join(map(repr, keys))
352
353
354def MERGE_VERTEX(g, h, vert): g[h].update(vert)

Callers

nothing calls this directly

Calls 5

mapFunction · 0.85
_validateMethod · 0.45
keysMethod · 0.45
sortMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected