diff options
author | Jed Barber <jjbarber@y7mail.com> | 2012-07-05 10:25:16 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2012-07-05 10:25:16 +1000 |
commit | 75854b6f0e73c55fa2dafc0d6b50fb23a96edfaf (patch) | |
tree | 0b79705929a00a341ab82b888c007809f0cf3a13 | |
parent | 60ba2362fd3c2c7a8d58c51f9010c0aefbfab3ad (diff) |
Fixed bug in not detecting duplicate nodes in the graph
-rw-r--r-- | ProofGraph.hs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/ProofGraph.hs b/ProofGraph.hs index f3caa6f..1a6f3fe 100644 --- a/ProofGraph.hs +++ b/ProofGraph.hs @@ -67,14 +67,12 @@ process str io graph stack = insertNode :: LNode String -> [LEdge (Int,Int)] -> PGraph -> (LNode String, PGraph) insertNode node edgeList graph = let checkList = filter (\x -> (snd x) == (snd node)) (Graph.labNodes graph) - edgeCheck = filter (\x -> (snd x) == edgeList) (zip [0..] (map ((Graph.out graph) . fst) checkList)) - actualNode = if (edgeCheck == []) - then node - else checkList !! (fst . head $ edgeCheck) - actualEdges = map (\x -> case x of - (a,b,c) -> (fst actualNode,b,c)) edgeList + edgeCheck = filter (\x -> (length (snd x) == length edgeList) && + all (\((a,b,c),(d,e,f)) -> b==e && c==f) + (zip (snd x) edgeList)) (zip [0..] (map ((Graph.out graph) . fst) checkList)) + actualNode = if (edgeCheck == []) then node else checkList !! (fst . head $ edgeCheck) graph' = if (node == actualNode) - then Graph.insEdges actualEdges (Graph.insNode actualNode graph) + then Graph.insEdges edgeList (Graph.insNode actualNode graph) else graph in (actualNode,graph') |