<div dir="ltr">Having a look at how graphs are implemented in fgl might be helpful to you.<br><br>Ben</div><br><div class="gmail_quote">On Fri, 8 May 2015 at 14:31 Christian Sperandio <<a href="mailto:christian.sperandio@gmail.com">christian.sperandio@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi,<div><br></div><div>I’m learning the Bayesian networks and I want to write my own implementation.</div><div>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.</div><div><br></div><div>I’m thinking about a DAG implementation avoids duplicate information. So, I imagined this implementation:</div><div><br></div><div><div><div><font face="Menlo">data Node a = Node { event :: a, proved :: Bool, nodeID :: Int }</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">type Connections = M.Map Int [Int]</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">data Graph a = Empty</font></div><div><font face="Menlo">             | Gragh { nodes :: M.Map Int (Node a), nextID :: Int, connections :: Connections }</font></div><div><br></div></div></div><div><br></div><div><br></div><div>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.</div><div>And when I have to change a node state, I don’t need to search all occurrences in the graph.</div><div><br></div><div>Am I on the right  way ?</div><div><br></div><div>Chris</div><div><br></div></div>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote></div>