Continue to refactor zoning to be more stream-based
This commit is contained in:
+4
-3
@@ -14,13 +14,14 @@ import Data.Graph
|
||||
import Data.Maybe
|
||||
import qualified Data.Graph.Inductive.Graph as F
|
||||
import qualified Data.Graph.Inductive.PatriciaTree as F
|
||||
import qualified Data.Set as S
|
||||
import Data.Bifunctor
|
||||
|
||||
pairsToIncidence :: Ord a => [(a,a)] -> [(a,[a])]
|
||||
pairsToIncidence :: Ord a => S.Set (a,a) -> [(a,[a])]
|
||||
pairsToIncidence
|
||||
= map (first head . unzip)
|
||||
. groupOn fst
|
||||
. sort
|
||||
. S.toAscList -- TODO check that the lexicographic sorting is correct for groupOn fst
|
||||
|
||||
incidenceToFunction :: Eq a => [(a,[a])] -> a -> [a]
|
||||
incidenceToFunction xs a = fromMaybe [] $ lookup a xs
|
||||
@@ -28,7 +29,7 @@ incidenceToFunction xs a = fromMaybe [] $ lookup a xs
|
||||
mkNode :: (a,[a]) -> (a,a,[a])
|
||||
mkNode (x,xs) = (x,x,xs)
|
||||
|
||||
pairsToSCC :: Ord a => [(a,a)] -> [SCC a]
|
||||
pairsToSCC :: Ord a => S.Set (a,a) -> [SCC a]
|
||||
pairsToSCC = stronglyConnComp . map mkNode . pairsToIncidence
|
||||
|
||||
graphToEdges :: forall a b . F.Gr a b -> [(a,a)]
|
||||
|
||||
Reference in New Issue
Block a user