Agda-2.6.3.20230930: A dependently typed functional programming language and proof assistant
Safe HaskellSafe-Inferred
LanguageHaskell2010

Agda.Utils.Graph.TopSort

Synopsis
  • topSort :: Ord n => Set n -> [(n, n)] -> Maybe [n]

Documentation

topSort :: Ord n => Set n -> [(n, n)] -> Maybe [n] Source #

topoligical sort with smallest-numbered available vertex first | input: nodes, edges | output is Nothing if the graph is not a DAG Note: should be stable to preserve order of generalizable variables. Algorithm due to Richard Eisenberg, and works by walking over the list left-to-right and moving each node the minimum distance left to guarantee topological ordering.