This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients dam1784, eric.smith, python-dev, rhettinger, tim.peters
Date 2022-01-21.01:37:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642729052.8.0.28733382241.issue46071@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2022-01-21 01:37:32tim.peterssetrecipients: + tim.peters, rhettinger, eric.smith, python-dev, dam1784
2022-01-21 01:37:32tim.peterssetmessageid: <1642729052.8.0.28733382241.issue46071@roundup.psfhosted.org>
2022-01-21 01:37:32tim.peterslinkissue46071 messages
2022-01-21 01:37:32tim.peterscreate