libgraph 1.8 → 1.9
raw patch · 2 files changed
+23/−1 lines, 2 files
Files
- Data/Graph/Libgraph/AlgoDebug.hs +22/−0
- libgraph.cabal +1/−1
Data/Graph/Libgraph/AlgoDebug.hs view
@@ -2,6 +2,8 @@ import Data.Graph.Libgraph.Core import Data.Graph.Libgraph.Dagify(collapse,remove) import Prelude hiding (Right)+import Data.List(find)+import Data.Maybe(isJust) data Judgement = Right | Wrong | Unassessed | Assisted String deriving (Eq,Show,Ord) @@ -14,7 +16,26 @@ => (v -> Judgement) -> ([v]->v) -> Graph v a -> [v] findFaulty isWrong merge = (findFaulty_dag isWrong) . (collapse merge) . remove +next_step :: Eq v => Graph v a -> (v -> Judgement) -> v+next_step tree j = case go r of + Just v -> v+ Nothing -> r -- no defect?+ where+ r = root tree+ go v | v == r = findJust (map go (succs tree v))+ | j v == Right = Nothing -- v is right; don't examine (grand)children+ | j v == Wrong = case findJust (map go (succs tree v)) of+ Nothing -> (Just v) -- v is a faulty node+ (Just w) -> (Just w) -- found next node w in (grand)children of v+ | otherwise = Just v -- v is an unassed node+ findJust mvs = case (find (isJust) mvs) of Just justv -> justv; Nothing -> Nothing +{- A more efficient next_step implementation; that starts from the+ current computation statement. The problem with this implementation+ is that it can get "stuck" in trees with nodes that already have some+ judged nodes (e.g. due to free exploration or using property-assisted+ algorithmic debugging.)+ next_step :: Eq v => Graph v a -> (v -> Judgement) -> v -> v next_step tree j v | j v == Wrong || v == root tree =@@ -28,3 +49,4 @@ (w:_) -> next_step tree j w | otherwise = v -- j v is Unassessed or Assisted+-}
libgraph.cabal view
@@ -1,5 +1,5 @@ Name: libgraph -Version: 1.8 +Version: 1.9 Homepage: http://maartenfaddegon.nl Synopsis: Store and manipulate data in a graph. Description: A graph type, analysis of graphs and manipulation of graphs.