CurryInfo: icurry-3.2.0 / ICurry.Graph.replaceNode

definition:
replaceNode :: Graph -> NodeID -> NodeID -> Graph
replaceNode (Graph nodes mx root) oldnid newid =
  Graph (filter ((/= oldnid) . fst) . map redirect $ nodes) mx newroot
 where
  redirect (ni, n) = (ni, redirectTargets n)
  newroot = if root == oldnid then newid else root

  redirectTargets (FuncNode f ns)      = FuncNode f (map redirectTarget ns)
  redirectTargets (ConsNode f ns)      = ConsNode f (map redirectTarget ns)
  redirectTargets (PartNode f n ns)    = PartNode f n (map redirectTarget ns)
  redirectTargets (ChoiceNode c n1 n2) =
    ChoiceNode c (redirectTarget n1) (redirectTarget n2)
  redirectTargets FreeNode             = FreeNode

  redirectTarget ni = if ni == oldnid then newid else ni
demand:
argument 1
deterministic:
deterministic operation
documentation:
-- Replaces a node `n1` in a graph by another node `n2` already contained
-- in the graph.
-- Thus, all edges with target `n1` are redirected to target `n2`.
-- Furthermore, node `n1` is deleted from the graph since it is garbage.
failfree:
(_, _, _)
indeterministic:
referentially transparent operation
infix:
no fixity defined
iotype:
{({Graph},_,_) |-> {Graph}}
name:
replaceNode
precedence:
no precedence defined
result-values:
{Graph}
signature:
Graph -> Prelude.Int -> Prelude.Int -> Graph
solution-complete:
operation might suspend on free variables
terminating:
possibly non-terminating
totally-defined:
reducible on all ground data terms