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 eric.smith
Recipients belopolsky, christian.heimes, eric.smith, gdr@garethrees.org, martin.panter, pablogsal, remi.lapeyre, rhettinger, terry.reedy, tshepang
Date 2019-01-18.21:39:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547847585.16.0.0232246263653.issue17005@roundup.psfhosted.org>
In-reply-to
Content
This is why I prefer the API exposed by https://pypi.org/project/toposort/

list(toposort({2: {11},
               9: {11, 8, 10},
               10: {11, 3},
               11: {7, 5},
               8: {7, 3},
              }))

returns [{3, 5, 7}, {8, 11}, {2, 10}, {9}]

For an node with no edges, use an empty set:

list(toposort({100: set(),
               2: {11},
               9: {11, 8, 10},
               10: {11, 3},
               11: {7, 5},
               8: {7, 3},
              }))
[{3, 100, 5, 7}, {8, 11}, {2, 10}, {9}]

I also don't think we should provide multiple APIs. Let's just provide one, and recipes for any helpers, if needed. For example, to flatten the result into a list. Or to take a list of edges as the input.
History
Date User Action Args
2019-01-18 21:39:46eric.smithsetrecipients: + eric.smith, rhettinger, terry.reedy, belopolsky, christian.heimes, tshepang, gdr@garethrees.org, martin.panter, pablogsal, remi.lapeyre
2019-01-18 21:39:45eric.smithsetmessageid: <1547847585.16.0.0232246263653.issue17005@roundup.psfhosted.org>
2019-01-18 21:39:45eric.smithlinkissue17005 messages
2019-01-18 21:39:45eric.smithcreate