Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
2009aa5d
Commit
2009aa5d
authored
Jan 01, 2015
by
Tiago Peixoto
Browse files
Change topological_sort() to conventional ordering
This fixes
#192
parent
f87c1e11
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/topology/__init__.py
View file @
2009aa5d
...
...
@@ -654,7 +654,7 @@ def topological_sort(g):
Notes
-----
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).
The time complexity is :math:`O(V + E)`.
...
...
@@ -673,8 +673,8 @@ def topological_sort(g):
>>> g.set_edge_filter(tree)
>>> sort = gt.topological_sort(g)
>>> print(sort)
[
8 7 0 1 25 2 3 13 12 19 4 5 6 9 10 11 14
15 1
6 17 18 20 21 22 24
23
2
6
2
7 28 29
]
[
29, 28, 27, 26, 23, 24, 22, 21, 20, 18, 17, 16,
15
,
1
4, 11, 10, 9,
6, 5, 4, 19, 12, 13, 3,
2
,
2
5, 1, 0, 7, 8
]
References
----------
...
...
@@ -688,7 +688,7 @@ def topological_sort(g):
topological_sort
(
g
.
_Graph__graph
,
topological_order
)
if
not
is_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
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment