CurryInfo: icurry-3.2.0 / TermGraph.SVG.getNodeDepth

definition:
getNodeDepth :: [(NodeID, [NodeID])] -> M.Map NodeID Int -> [NodeID]
                    -> NodeID -> NodeID ->  M.Map NodeID Int
getNodeDepth predMap depthMap visited root currNode =
    case (M.lookup currNode depthMap) of
      Just _  -> depthMap
      Nothing
        | currNode `elem` visited -> depthMap
        | currNode == root -> M.insert currNode 0 depthMap
        | otherwise -> case maxPath of
                        Nothing -> newMap
                        Just mp -> M.insert
                                    currNode
                                    (if length preds > 1 then mp + 2
                                                         else mp + 1)
                                    newMap
            where
              preds   = filter (/= currNode)
                               (fromMaybe
                                  (error "Error in getNodeDepth, could not find node")
                                  (lookup currNode predMap))
              maxPath = maximum (map ((flip M.lookup) newMap) preds)
              newMap  = foldr (\pr m -> getNodeDepth predMap m (currNode : visited) root pr) depthMap preds
demand:
argument 2
deterministic:
deterministic operation
documentation:
-- calculate the depth a node needs to be drawn at:
-- Normally it's the length of the longest (non-cyclic) path it can be reached by,
-- if a node has multple direct predecessors, add one for better visuals
failfree:
<FAILING>
indeterministic:
referentially transparent operation
infix:
no fixity defined
iotype:
{(_,_,_,_,_) |-> _}
name:
getNodeDepth
precedence:
no precedence defined
result-values:
_
signature:
[(Prelude.Int, [Prelude.Int])] -> Data.Map.Map Prelude.Int Prelude.Int
-> [Prelude.Int] -> Prelude.Int -> Prelude.Int
-> Data.Map.Map Prelude.Int Prelude.Int
solution-complete:
operation might suspend on free variables
terminating:
possibly non-terminating
totally-defined:
possibly non-reducible on same data term