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 dam1784
Recipients dam1784, eric.smith, python-dev, rhettinger, tim.peters
Date 2022-01-21.02:31:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642732276.1.0.587683949106.issue46071@roundup.psfhosted.org>
In-reply-to
Content
> The argument passed is the predecessor form of the graph B -> A

where graph = {'A' : ['B']}

This is part that I'm objecting to. The form of the graph should be A -> B, not B -> A.

The issue with the current form is that you can not traverse the graph, at least not forwards. When I say traverse forwards I mean that you follow the edges in the direction of the arrows. If you look up 'A' in the current graph you get  all of the nodes that point  *to* A, but that doesn't help you get *from* A to anywhere else.

There are two conventions:
1) Graphs should be traverse-able, by following the arrows.
2) Topological sorting makes the arrows point to the right.

Convention #1 was broken to satisfy convention #2.

What is important about the topo-sort is that it makes all of the edges point in the *same* direction. It doesn't actually matter which direction that is. And credit where due, the library picked the more-useful direction. It was a pragmatic choice, driven by the real use case of dependency resolution.

But having the graph with arrows pointing in the wrong direction is going to cause endless confusion.

For an example of the confusion this causes, look at the API itself. The "add" method explicitly calls out the fact that you can add nodes with no predecessors. This is obviously also possible with the graph argument as it currently is.

> It is possible to add a node with no dependencies (predecessors is not provided)
   https://docs.python.org/3/library/graphlib.html#graphlib.TopologicalSorter.add
History
Date User Action Args
2022-01-21 02:31:16dam1784setrecipients: + dam1784, tim.peters, rhettinger, eric.smith, python-dev
2022-01-21 02:31:16dam1784setmessageid: <1642732276.1.0.587683949106.issue46071@roundup.psfhosted.org>
2022-01-21 02:31:16dam1784linkissue46071 messages
2022-01-21 02:31:15dam1784create