`mkGraph` requires the user to know about its underlying implementation
The Graph
type has two type parameters, v
for node labels and one for edge labels. Internally, though, it represents nodes using Int
s.*
The function mkGraph
takes as input a [v]
(for nodes) and a [((Int, Int), e)]
* (for edges): the user needs to specify the edges in the form of (labelled) pairs of Int
s, even though they specified nodes in the form of elements of the label type v
. This requires them to know in advance which Int
each v
will be mapped to.
In other words, the user is supposed to know how the graph's underlying representation will be constructed (before it even exists), which 1. is more work than should be required of them, and 2. can lead to breakages should the underlying implementation change.
Note : The documentation for the function's first argument does specify that "each [node] will be assigned a ID from 0 to N", but it is not clear whether that assignment is in the order of the input list, in increasing order (v
is required to be Ord
), or in some other arbitrary order.
* Node
is just a type alias for Int
, and LEdge a
is a type alias for ((Int, Int), a)
.