Tim Peters <t...@python.org> added the comment:
I'm going to leave this to Pablo - adding the `graph` argument was his idea ;-) It would, I think, have been better if this argument had been named, say, "preds" instead of "graph". The docs, to my eyes, are entirely clear about that `graph` is a representation based on mapping a node to its predecessors: """ If the optional graph argument is provided it must be a dictionary representing a directed acyclic graph where the keys are nodes and the values are iterables of all predecessors of that node in the graph (the nodes that have edges that point to the value in the key). """ but it could perhaps be usefully emphasized that "the usual" graph representation in Python maps a node to its successors instead. The stuff about "direction" continues to make no sense to me, though. The class computes the (forward!) topsort of the graph passed to it, given that the graph is presented as mapping nodes to predecessors. It's only "reversed" if you refuse to believe the docs, and insist that `graph` is mapping a node to its successors. But it's not. >>> import graphlib >>> ts = graphlib.TopologicalSorter({'A' : ['B']}) >>> list(ts.static_order()) ['B', 'A'] Nothing is "reversed". The argument passed is the predecessor form of the graph B -> A, and [B, A] is the forward topsort of that graph. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46071> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com