
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