-- | Compute the /topological sort/ of a graph. Note that this function returns
-- a result even if the graph is cyclic.
--
-- In the following examples we will use the helper function:
--
-- @
-- (%) :: (GraphKL Int -> a) -> 'AM.AdjacencyMap' Int -> a
-- a % g = a $ 'fromAdjacencyMap' g
-- @
--
-- for greater clarity.
--
-- @
-- topSort % (1 * 2 + 3 * 1) == [3,1,2]
-- topSort % (1 * 2 + 2 * 1) == [1,2]
-- @
topSort :: GraphKL a -> [a]
topSort (GraphKL g r _) = map r (KL.topSort g)
topSort :: GraphKL a -> [a]
topSort (GraphKL g r _) = map r (KL.topSort g)
topSort (GraphKL g r _) = map r (KL.topSort g)