Skip to content

Commit b1f248e

Browse files
authored
reverse topological ordering (#638)
Add reverse topological ordering for `Data.Graph`.
1 parent e445cae commit b1f248e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

containers/src/Data/Graph.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ module Data.Graph (
6767
, dfs
6868
, dff
6969
, topSort
70+
, reverseTopSort
7071
, components
7172
, scc
7273
, bcc
@@ -617,6 +618,10 @@ postOrd g = postorderF (dff g) []
617618
topSort :: Graph -> [Vertex]
618619
topSort = reverse . postOrd
619620

621+
-- | Reverse ordering of `topSort`.
622+
reverseTopSort :: Graph -> [Vertex]
623+
reverseTopSort = postOrd
624+
620625
------------------------------------------------------------
621626
-- Algorithm 3: connected components
622627
------------------------------------------------------------

0 commit comments

Comments
 (0)