bool HyperedgeTreeNode::removeOtherJunctionsFrom(HyperedgeTreeEdge *ignored, 
            JunctionSet& treeRoots)
{
    bool containsCycle = false;
    if (visited)
    {
        // We've encountered this node before, so there must be cycles in
        // the hyperedge.  Don't recurse any further.
        containsCycle = true;
        return containsCycle;
    }
    
    if (junction && (ignored != NULL))
    {
        // Remove junctions other than the first (when ignored == NULL).
        treeRoots.erase(junction);
    }
    visited = true;
    for (std::list<HyperedgeTreeEdge *>::iterator curr = edges.begin();
            curr != edges.end(); ++curr)
    {
        if (*curr != ignored)
        {
            containsCycle |= (*curr)->removeOtherJunctionsFrom(this, treeRoots);
        }
    }
    return containsCycle;
}
Esempio n. 2
0
// This method traverses the hyperedge tree and removes from treeRoots any
// junction nodes.
//
void HyperEdgeTreeEdge::removeOtherJunctionsFrom(HyperEdgeTreeNode *ignored,
                    JunctionSet& treeRoots)
{
    if (ends.first && (ends.first != ignored))
    {
        ends.first->removeOtherJunctionsFrom(this, treeRoots);
        if (ends.first->junction)
        {
            treeRoots.erase(ends.first->junction);
        }
    }

    if (ends.second && (ends.second != ignored))
    {
        ends.second->removeOtherJunctionsFrom(this, treeRoots);
        if (ends.second->junction)
        {
            treeRoots.erase(ends.second->junction);
        }
    }
}