def visit(klass, graph): ''' Given a graph, run a topological sort on the supplied graph and return the results. :param graph: The graph to perform a topological sort on :returns: The results of the topological sort ''' visitor = klass() graph_dfs_visit(graph, visitor) return visitor.result
def visit(klass, graph, source, sink): ''' Given a graph, run the path search on the supplied graph and return the results. :param graph: The graph to perform a path search on :param source: The starting point of the search :param sink: The ending point of the search :returns: The results of the topological sort ''' visitor = klass(sink) graph_dfs_visit(graph, visitor, source) return visitor.path_exists