1
1
mirror of https://github.com/github/semantic.git synced 2024-12-26 00:12:29 +03:00

Test a diamond graph.

Co-Authored-By: Rick Winfrey <rick.winfrey@gmail.com>
This commit is contained in:
Rob Rix 2018-06-25 16:09:55 -04:00
parent d346a36559
commit 4943a58d43

View File

@ -44,6 +44,9 @@ simplify (Graph graph) = Graph (G.simplify graph)
-- --
-- >>> topologicalSort ((vertex 'a' `connect` vertex 'b') <> (vertex 'a' `connect` vertex 'c')) -- >>> topologicalSort ((vertex 'a' `connect` vertex 'b') <> (vertex 'a' `connect` vertex 'c'))
-- "cba" -- "cba"
--
-- >>> topologicalSort (Class.path "abd" <> Class.path "acd")
-- "dcba"
topologicalSort :: forall v . Ord v => Graph v -> [v] topologicalSort :: forall v . Ord v => Graph v -> [v]
topologicalSort = go . toAdjacencyMap . G.transpose . unGraph topologicalSort = go . toAdjacencyMap . G.transpose . unGraph
where go :: A.AdjacencyMap v -> [v] where go :: A.AdjacencyMap v -> [v]