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

Method __str__

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

Return graph in adjacency format. >>> g = Graph() >>> g.add(range(3), range(3)) >>> str(g) '{0: {0, 1, 2}, 1: {0, 1, 2}, 2: {0, 1, 2}}' >>> g = Graph(VertexType=WVertex) >>> g.add(range(3), range(3)) >>> str(g) '{0: {0: 1, 1: 1, 2: 1},

(self)

Source from the content-addressed store, hash-verified

551 super(Graph, self).__delitem__(head)
552
553 def __str__(self):
554 """Return graph in adjacency format.
555
556 >>> g = Graph()
557 >>> g.add(range(3), range(3))
558 >>> str(g)
559 '{0: {0, 1, 2}, 1: {0, 1, 2}, 2: {0, 1, 2}}'
560 >>> g = Graph(VertexType=WVertex)
561 >>> g.add(range(3), range(3))
562 >>> str(g)
563 '{0: {0: 1, 1: 1, 2: 1}, 1: {0: 1, 1: 1, 2: 1}, 2: {0: 1, 1: 1, 2: 1}}'
564 """
565 if _DEBUG: self._validate()
566 return super(Graph, self).__str__()
567 #return '{%s}' % ', '.join(map(str, self.itervalues()))
568
569 def display(self):
570 """Display adjacency list.

Callers

nothing calls this directly

Calls 1

_validateMethod · 0.95

Tested by

no test coverage detected