X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FGraph.hs;h=42059640f4671e79cb5db43399b3ec4a44d30389;hb=3e0d5857cc3fd3316b7bfa41b3afe697a11a794d;hp=130c7dd3eaa8b0c2757ac2b2fe2fdb3b501999ea;hpb=e6492fce6f70270acda18b5747f408d3add29724;p=ghc-base.git diff --git a/Data/Graph.hs b/Data/Graph.hs index 130c7dd..4205964 100644 --- a/Data/Graph.hs +++ b/Data/Graph.hs @@ -43,7 +43,7 @@ module Data.Graph( components, scc, bcc, - -- back, cross, forward, + -- tree, back, cross, forward, reachable, path, module Data.Tree @@ -60,6 +60,10 @@ import Data.Maybe import Data.Array import Data.List +#ifdef __HADDOCK__ +import Prelude +#endif + ------------------------------------------------------------------------- -- - -- External interface @@ -101,7 +105,7 @@ stronglyConnComp edges0 -- | The strongly connected components of a directed graph, topologically -- sorted. The function is the same as 'stronglyConnComp', except that -- all the information about each node retained. --- The "R" interface is used when you expect to apply 'SCC' to +-- This interface is used when you expect to apply 'SCC' to -- (some of) the result of 'SCC', so you don't want to lose the -- dependency information. stronglyConnCompR @@ -321,6 +325,10 @@ scc g = dfs g (reverse (postOrd (transposeG g))) -- Algorithm 5: Classifying edges ------------------------------------------------------------ +tree :: Bounds -> Forest Vertex -> Graph +tree bnds ts = buildG bnds (concat (map flat ts)) + where flat (Node v ts) = [ (v, w) | Node w _us <- ts ] ++ concat (map flat ts) + back :: Graph -> Table Int -> Graph back g post = mapT select g where select v ws = [ w | w <- ws, post!v < post!w ]