Re: [Haskell-cafe] functional graphs

2008-01-21 Thread Benja Fallenstein
Hi Christian, On Jan 21, 2008 10:57 AM, Christian Maeder <[EMAIL PROTECTED]> wrote: > Thanks for pointing out this proposal. The actual problem is mkGraph > that needs all the many edges created beforehand (that's what I wanted > to avoid). Well, uh, at the risk of being obvious, if you can avoid

Re: [Haskell-cafe] functional graphs

2008-01-21 Thread Christian Maeder
Benja Fallenstein wrote: > However, if you'd be able to live with > > data CGraph a b = CGraph [LNode a] (Node -> Node -> b) > > then you should be able to write the instance like this-- > > instance Graph CGraph where > empty = CGraph [] (const $ error "Node not in graph") > isEmpty (CGraph

Re: [Haskell-cafe] functional graphs

2008-01-21 Thread Christian Maeder
Thomas Hartman wrote: > I don't think this will work. > > From > > http://www.haskell.org/ghc/docs/latest/html/libraries/fgl/src/Data-Graph-Inductive-Graph.html > > the minimal implementatin for Graph is > > -- | Minimum implementation: 'empty', 'isEmpty', 'match', 'mkGraph', > 'labNodes' > ..

Re: [Haskell-cafe] functional graphs

2008-01-19 Thread Benja Fallenstein
Hi, On Jan 19, 2008 6:05 PM, Thomas Hartman <[EMAIL PROTECTED]> wrote: > Do you just assume that every two nodes have an edge between them [...]? Since that's what "complete graph" means, I assume so =-) - Benja ___ Haskell-Cafe mailing list Haskell-Ca

Re: [Haskell-cafe] functional graphs

2008-01-19 Thread Benja Fallenstein
Hi Christian, On Jan 18, 2008 1:55 PM, Christian Maeder <[EMAIL PROTECTED]> wrote: > data CGraph a b = CGraph [a] (a -> a -> b) > > Can I define an instance for the fgl Graph class? > > I had no idea how to define empty (except using undefined). Well, presumably the function does not need to be d

[Haskell-cafe] functional graphs

2008-01-19 Thread Thomas Hartman
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? thomas. 2008/1/18, Christian Maeder <[EMAIL P

[Haskell-cafe] functional graphs

2008-01-18 Thread Christian Maeder
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