module Digraph(
-- At present the only one with a "nice" external interface
- stronglyConnComp, stronglyConnCompR, SCC(..),
+ stronglyConnComp, stronglyConnCompR, SCC(..), flattenSCC, flattenSCCs,
Graph, Vertex,
graphFromEdges, buildG, transposeG, reverseE, outdegree, indegree,
import Maybe
import Array
import List
+import Outputable
\end{code}
data SCC vertex = AcyclicSCC vertex
| CyclicSCC [vertex]
+flattenSCCs :: [SCC a] -> [a]
+flattenSCCs = concatMap flattenSCC
+
+flattenSCC (AcyclicSCC v) = [v]
+flattenSCC (CyclicSCC vs) = vs
+
+instance Outputable a => Outputable (SCC a) where
+ ppr (AcyclicSCC v) = text "NONREC" $$ (nest 3 (ppr v))
+ ppr (CyclicSCC vs) = text "REC" $$ (nest 3 (vcat (map ppr vs)))
+\end{code}
+
+\begin{code}
stronglyConnComp
:: Ord key
=> [(node, key, [key])] -- The graph; its ok for the