b.t.TopoSorter(object) : class documentation

Part of bzrlib.tsort View In Hierarchy

No class docstring
Method __init__ Topological sorting of a graph.
Method sorted Sort the graph and return as a list.
Method iter_topo_order Yield the nodes of the graph in a topological order.
def __init__(self, graph):
Topological sorting of a graph.

node identifiers can be any hashable object, and are typically strings.

If you have a graph like [('a', ['b']), ('a', ['c'])] this will only use one of the two values for 'a'.

The graph is sorted lazily: until you iterate or sort the input is not processed other than to create an internal representation.

iteration or sorting may raise GraphCycleError if a cycle is present in the graph.

Parametersgraphsequence of pairs of node_name->parent_names_list. i.e. [('C', ['B']), ('B', ['A']), ('A', [])] For this input the output from the sort or iter_topo_order routines will be: 'A', 'B', 'C'
def sorted(self):
Sort the graph and return as a list.

After calling this the sorter is empty and you must create a new one.

def iter_topo_order(self):
Yield the nodes of the graph in a topological order.

After finishing iteration the sorter is empty and you cannot continue iteration.

API Documentation for Bazaar, generated by pydoctor at 2019-08-25 00:28:39.