[graph] improve Visitor class docstring

This commit is contained in:
Yann Lanthony 2018-01-05 19:19:38 +01:00
parent 614ef3a5d1
commit 2d30a65252

View file

@ -1015,34 +1015,48 @@ GRAY = 1
BLACK = 2 BLACK = 2
class Visitor: class Visitor(object):
"""
Base class for Graph Visitors that does nothing.
Sub-classes can override any method to implement specific algorithms.
"""
# def initializeVertex(self, s, g): # def initializeVertex(self, s, g):
# '''is invoked on every vertex of the graph before the start of the graph search.''' # '''is invoked on every vertex of the graph before the start of the graph search.'''
# pass # pass
# def startVertex(self, s, g): # def startVertex(self, s, g):
# '''is invoked on the source vertex once before the start of the search.''' # '''is invoked on the source vertex once before the start of the search.'''
# pass # pass
def discoverVertex(self, u, g): def discoverVertex(self, u, g):
""" is invoked when a vertex is encountered for the first time. """ """ Is invoked when a vertex is encountered for the first time. """
pass pass
def examineEdge(self, e, g): def examineEdge(self, e, g):
'''is invoked on every out-edge of each vertex after it is discovered.''' """ Is invoked on every out-edge of each vertex after it is discovered."""
pass pass
def treeEdge(self, e, g): def treeEdge(self, e, g):
'''is invoked on each edge as it becomes a member of the edges that form the search tree. If you wish to record predecessors, do so at this event point.''' """ Is invoked on each edge as it becomes a member of the edges that form the search tree.
If you wish to record predecessors, do so at this event point. """
pass pass
def backEdge(self, e, g): def backEdge(self, e, g):
'''is invoked on the back edges in the graph.''' """ Is invoked on the back edges in the graph. """
pass pass
def forwardOrCrossEdge(self, e, g): def forwardOrCrossEdge(self, e, g):
'''is invoked on forward or cross edges in the graph. In an undirected graph this method is never called.''' """ Is invoked on forward or cross edges in the graph.
In an undirected graph this method is never called."""
pass pass
def finishEdge(self, e, g): def finishEdge(self, e, g):
'''is invoked on the non-tree edges in the graph as well as on each tree edge after its target vertex is finished.''' """ Is invoked on the non-tree edges in the graph
as well as on each tree edge after its target vertex is finished. """
pass pass
def finishVertex(self, u, g): def finishVertex(self, u, g):
""" is invoked on a vertex after all of its out edges have been added to the search tree and all of the """ Is invoked on a vertex after all of its out edges have been added to the search tree and all of the
adjacent vertices have been discovered (but before their out-edges have been examined). """ adjacent vertices have been discovered (but before their out-edges have been examined). """
pass pass