[Haskell-beginners] Implementation question about directed acyclic graph

Benjamin Edwards edwards.benj at gmail.com
Fri May 8 14:02:30 UTC 2015


Having a look at how graphs are implemented in fgl might be helpful to you.

Ben

On Fri, 8 May 2015 at 14:31 Christian Sperandio <
christian.sperandio at gmail.com> wrote:

> Hi,
>
> I’m learning the Bayesian networks and I want to write my own
> implementation.
> So, I started implementing t a DAG in Haskell but I’ve got some questions
> about the best way to do it in a functional mind.
>
> I’m thinking about a DAG implementation avoids duplicate information. So,
> I imagined this implementation:
>
> data Node a = Node { event :: a, proved :: Bool, nodeID :: Int }
>
> type Connections = M.Map Int [Int]
>
> data Graph a = Empty
>              | Gragh { nodes :: M.Map Int (Node a), nextID :: Int,
> connections :: Connections }
>
>
>
> My idea is to yield an ID for each node and use this ID for connections.
> Thus, I can have the same events connected many times without duplicate the
> event data.
> And when I have to change a node state, I don’t need to search all
> occurrences in the graph.
>
> Am I on the right  way ?
>
> Chris
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150508/8bb9971c/attachment.html>


More information about the Beginners mailing list