don't check for _
[minfp.git] / scc.icl
diff --git a/scc.icl b/scc.icl
index b25ebfb..8c879cf 100644 (file)
--- a/scc.icl
+++ b/scc.icl
@@ -7,7 +7,7 @@ import Data.Map => qualified updateAt
 :: Annot = {index :: Int, lowlink :: Int, onstack :: Bool}
 
 scc :: [(a, [a])] -> [[a]] | Eq, Ord a
-scc nodes = (foldr strongconnect {nextindex=0,stack=[],map=newMap,sccs=[]} nodes).sccs
+scc nodes = reverse (foldr strongconnect {nextindex=0,stack=[],map=newMap,sccs=[]} nodes).sccs
 where
 //     strongconnect :: (a, [a]) (St a) -> St a | Eq, Ord a
        strongconnect (v, suc) s
@@ -30,7 +30,9 @@ where
 //             processSucc :: a (St a) -> St a | Eq, Ord a
                processSucc w s = case get w s.map of
                        Nothing
-                               # s = strongconnect (hd [l\\l=:(n, _)<-nodes | n == w]) s
+                               # n = [l\\l=:(n, _)<-nodes | n == w]
+                               | n =: [] = s
+                               # s = strongconnect (hd n) s
                                # (Just aw) = get w s.map
                                # (Just av) = get v s.map
                                = {s & map=put v {av & lowlink=min av.lowlink aw.lowlink} s.map}