Compute for
(2) For
(3)  Replace the node in that contains nodes with the Path .
    If , then remove and introduce new nodes with links
    for .
(4)  Connect path to . For any tree or cycle link in , let
    be the set of nodes in , or if is an empty node, the nodes in any nonempty
    node reachable from by some path of links disjoint from a cycle containing
    . Find the subset such that and connect to .
(5)  Label the nodes of . Let be the set of nodes mapped to in .
    Update by for all . All other mappings remain
(6)  Remove all empty nodes of degree and all empty 2-way cut nodes by contracting
    an adjacent tree link (a node is an -way cut node if its removal separates the graph into
    connected parts). Replace all empty 3-way cut nodes with 3 cycles.
Algorithm 7: Build-Cactus .