Reputation: 149
Given a graph described by the list of its edges, such as
[("c","cac"),("cac","cb"),("cac","bcc"),("c","ba")]
where cac
comes after c
, cb
comes after cac
, bcc
comes after cac
…
How do I convert it to a graph in the sense of the fgl library, so that I can make use of the graph algorithms therein?
Upvotes: 1
Views: 200
Reputation: 25763
In fgl
, nodes are identified by Int
s. But the module Data.Graph.Inductive.NodeMap
can help you manage the mapping from your node names (String
) to fgl’s nodes.
In particular, you can use insMapNodes
on the list of strings in your list to create a NodeMap
, and then pass that NodeMap
and your list to insMapEdges
.
Upvotes: 3