Data.Graph patch
John Meacham
john at repetae.net
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
--
John Meacham - ⑆repetae.net⑆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
31c31
< graphFromEdges, buildG, transposeG,
---
> graphFromEdges, graphFromEdges', buildG, transposeG,
190,191c190,198
< 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