Reputation: 89
I have a little question concerning Haskell. If I have data type representing a graph like this one :
import Data.Map (Map,empty,member,insert)
import Graphviz
-- | A directed graph
data Graph v = Graph
{ arcsMap :: Map v [v] -- A map associating a vertex with its
successors
, labelMap :: Map v String -- The Graphviz label of each node
, styleMap :: Map v String -- The Graphviz style of each node
}
And i want to create a list by accessing every vertices of a given graph.
Like this:
-- | Returns the list of vertices of a graph in ascending order
--
-- >>> vertices emptyGraph
-- []
-- >>> vertices $ addVertices emptyGraph [1,4,5,2,1]
-- [1,2,4,5]
vertices :: Graph v -> [v]
My question is how can I tell Haskell to look into every vertices in arcsMap and create a list with it ? Thankyou !!!
Upvotes: 0
Views: 325