### Change topological_sort() to conventional ordering

`This fixes #192`
parent f87c1e11
 ... @@ -654,7 +654,7 @@ def topological_sort(g): ... @@ -654,7 +654,7 @@ def topological_sort(g): Notes Notes ----- ----- The topological sort algorithm creates a linear ordering of the vertices The topological sort algorithm creates a linear ordering of the vertices such that if edge (u,v) appears in the graph, then v comes before u in the such that if edge (u,v) appears in the graph, then u comes before v in the ordering. The graph must be a directed acyclic graph (DAG). ordering. The graph must be a directed acyclic graph (DAG). The time complexity is :math:`O(V + E)`. The time complexity is :math:`O(V + E)`. ... @@ -673,8 +673,8 @@ def topological_sort(g): ... @@ -673,8 +673,8 @@ def topological_sort(g): >>> g.set_edge_filter(tree) >>> g.set_edge_filter(tree) >>> sort = gt.topological_sort(g) >>> sort = gt.topological_sort(g) >>> print(sort) >>> print(sort) [ 8 7 0 1 25 2 3 13 12 19 4 5 6 9 10 11 14 15 16 17 18 20 21 22 24 [29, 28, 27, 26, 23, 24, 22, 21, 20, 18, 17, 16, 15, 14, 11, 10, 9, 23 26 27 28 29] 6, 5, 4, 19, 12, 13, 3, 2, 25, 1, 0, 7, 8] References References ---------- ---------- ... @@ -688,7 +688,7 @@ def topological_sort(g): ... @@ -688,7 +688,7 @@ def topological_sort(g): topological_sort(g._Graph__graph, topological_order) topological_sort(g._Graph__graph, topological_order) if not is_DAG: if not is_DAG: raise ValueError("Graph is not a directed acylic graph (DAG)."); raise ValueError("Graph is not a directed acylic graph (DAG)."); return topological_order.a.copy() return topological_order.a[::-1].copy() def transitive_closure(g): def transitive_closure(g): ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!