1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
module Grasp.Edge (
GEdge,
GEdgeType,
singleton,
fromStringList,
src,
dest,
lab
) where
import Data.Graph.Inductive.Graph( LEdge )
import Data.Map( Map )
import qualified Data.Map as Map
type GEdge = LEdge String
type GEdgeType = String
singleton :: Int -> Int -> String -> GEdge
singleton f t s = (f,t,s)
fromStringList :: Map String Int -> [(String,String,String)] -> [GEdge]
fromStringList m es =
let change x = case (Map.lookup x m) of
Just a -> a
Nothing -> error "Grasp.Edge.fromStringList: no value for key " ++ x
in map (\(x,y,z) -> (change x, change y, z)) es
src :: GEdge -> Int
src (x,_,_) = x
dest :: GEdge -> Int
dest (_,x,_) = x
lab :: GEdge -> String
lab (_,_,x) = x
|