Message334014
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. |
|
Date |
User |
Action |
Args |
2019-01-18 21:39:46 | eric.smith | set | recipients:
+ eric.smith, rhettinger, terry.reedy, belopolsky, christian.heimes, tshepang, gdr@garethrees.org, martin.panter, pablogsal, remi.lapeyre |
2019-01-18 21:39:45 | eric.smith | set | messageid: <1547847585.16.0.0232246263653.issue17005@roundup.psfhosted.org> |
2019-01-18 21:39:45 | eric.smith | link | issue17005 messages |
2019-01-18 21:39:45 | eric.smith | create | |
|