<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I’m learning the Bayesian networks and I want to write my own implementation.</div><div class="">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 class=""><br class=""></div><div class="">I’m thinking about a DAG implementation avoids duplicate information. So, I imagined this implementation:</div><div class=""><br class=""></div><div class=""><div class=""><div class=""><font face="Menlo" class="">data Node a = Node { event :: a, proved :: Bool, nodeID :: Int }</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">type Connections = M.Map Int [Int]</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">data Graph a = Empty</font></div><div class=""><font face="Menlo" class="">             | Gragh { nodes :: M.Map Int (Node a), nextID :: Int, connections :: Connections }</font></div><div class=""><br class=""></div></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">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 class="">And when I have to change a node state, I don’t need to search all occurrences in the graph.</div><div class=""><br class=""></div><div class="">Am I on the right  way ?</div><div class=""><br class=""></div><div class="">Chris</div><div class=""><br class=""></div></body></html>