Created
December 5, 2012 22:06
Revisions
-
5outh created this gist
Dec 5, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ module Graph( Graph(Graph), removeEdge, outbound, inbound )where data Graph a = Graph{ vertices :: [a], edges :: [(a, a)] } deriving Show removeEdge :: (Eq a) => (a, a) -> Graph a -> Graph a removeEdge x (Graph v e) = Graph v (filter (/=x) e) connections :: (Eq a) => ((a, a) -> a) -> a -> Graph a -> [(a, a)] connections f x (Graph _ e) = filter ((==x) . f) e --outbound connections outbound a = connections fst a --inbound connections inbound a = connections snd a