Data.Graph patch

John Meacham john at
Mon Jan 31 17:20:28 EST 2005

Here is a patch for Data.Graph which fixes an oversight in
graphFromEdges. graphFromEdges returns a function which turns vertexes
into nodes, but provides no way to go the other direction and figure out 
which vertex goes with a node. I simply return the already created
function of type key -> Maybe Vertex in the tuple.

I provided it as a new function 
graphFromEdges' and left the old functionality under the old name. if we
don't care about backwards compatability, I'd recommend just replacing
the one that is already there since it is a more complete interface and
an easy transition for anyone currently using the library.


John Meacham - ⑆⑆john⑈ 
-------------- next part --------------
Index: Graph.hs
RCS file: /cvs/fptools/libraries/base/Data/Graph.hs,v
retrieving revision 1.3
diff -r1.3 Graph.hs
< 	graphFromEdges, buildG, transposeG,
> 	graphFromEdges, graphFromEdges', buildG, transposeG,
< graphFromEdges edges0
<   = (graph, \v -> vertex_map ! v)
> graphFromEdges x = (a,b) where
>     (a,b,_) = graphFromEdges' x
> graphFromEdges'
> 	:: Ord key
> 	=> [(node, key, [key])]
> 	-> (Graph, Vertex -> (node, key, [key]), key -> Maybe Vertex)
> graphFromEdges' edges0
>   = (graph, \v -> vertex_map ! v, key_vertex)

More information about the Libraries mailing list