[Haskell-cafe] functional graphs

Thomas Hartman tphyahoo at gmail.com
Sat Jan 19 12:05:06 EST 2008

I don't get where the graph edges (Node,Node) are specified.

Do you just assume that every two nodes have an edge between them and
calculate the edge label from the function?

Also, is there a real world / motivating use for a graph defined this way?


2008/1/18, Christian Maeder <Christian.Maeder at dfki.de>:
> Hi,
> Given a complete graph as a list of nodes whose edge labels are given by
> a function over two nodes:
> data CGraph a b = CGraph [a] (a -> a -> b)
> Can I define an instance for the fgl Graph class?
> import Data.Graph.Inductive.Graph
> instance Graph CGraph where
>   empty = CGraph []  -- and now?
> I had no idea how to define empty (except using undefined).
> I thought of requiring a context for the node labels of type a, but this
> type is not mentioned in the class header. So it looked to me like the
> impossibility to define sets (requiring an Ord) as monads. (i.e.
> instance Monad Data.Set.Set)
> Any working proposals for my graph problem?
> Cheers Christian
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list