Modularise graph functions

This commit is contained in:
jgk
2021-04-03 12:14:53 +02:00
parent 29e7909db2
commit d65b099c0d
4 changed files with 25 additions and 10 deletions
+1 -9
View File
@@ -1,6 +1,7 @@
module Dodge.Path where
import Dodge.Data
import Dodge.Base
import Dodge.Graph
import Geometry
@@ -160,12 +161,3 @@ maybeToEither :: a -> Maybe b -> Either a b
maybeToEither _ (Just x) = Right x
maybeToEither y Nothing = Left y
pairsToIncidence :: (Eq a,Ord a) => [(a,a)] -> [(a,[a])]
pairsToIncidence = map ((\(xs,ys) -> (head xs,ys)) . unzip)
. groupBy ( (==) `on` fst)
. sort
incidenceToFunction :: Eq a => [(a,[a])] -> a -> [a]
incidenceToFunction xs a = case lookup a xs of Just ys -> ys
Nothing -> []