コード例 #1
0
ファイル: LeftistOrdering.cpp プロジェクト: marvin2k/ogdf
// computes the leftist canonical order. Requires that G is simple, triconnected and embedded.
// adj_v1n is the adjEntry at v_1 looking towards v_n, the outerface is choosen such that v_2 is the cyclic pred
// of v_n. the result is saved in result, a list of list of nodes, first set is v_1, v_2, last one is v_n.
bool LeftistOrdering::call(const Graph& G, adjEntry adj_v1n, List<List<node> >& result)
{
    // init the is marked array for all adj entries
    m_marked.init(G, false);

    // v1 -> v_n edge
    adjEntry adj_v12 = adj_v1n->cyclicPred();

    // the node v_n
    node v_n = adj_v1n->twinNode();

    // init all the node related arrays
    m_cutFaces.init(G, 0);
    m_cutEdges.init(G, 0);
    m_cutFaces[v_n] = 1;

    // mark v_1 -> v_n
    m_marked[adj_v12] = true;
    m_marked[adj_v12->twin()] = true;

    // initial candidate for the belt
    Candidate v12_candidate;
    v12_candidate.chain.pushBack(adj_v12->twin()); // edge 2->1
    v12_candidate.chain.pushBack(adj_v12);         // edge 1->2
    v12_candidate.chain.pushBack(adj_v12->twin()); // edge 2->1
    v12_candidate.stopper = nullptr;

    // init the belt
    m_belt.pushBack(v12_candidate);

    // init the candidate variable
    // we us an iterator here to keep things simple
    m_currCandidateIt = m_belt.begin();

    // while the belt contains some candidates
    while (!m_belt.empty())
    {
        // the next partition
        List<node> P_k;

        // get the next leftmost feasible candidate
        if (!leftmostFeasibleCandidate(P_k))
            return false;

        // update the belt
        updateBelt();

        // save the result.
        result.pushBack(P_k);
    }
    // thats it we are done
    return true;
}
コード例 #2
0
node CombinatorialEmbedding::splitNode(adjEntry adjStartLeft, adjEntry adjStartRight)
{
	face fL = leftFace(adjStartLeft);
	face fR = leftFace(adjStartRight);

	node u = m_pGraph->splitNode(adjStartLeft,adjStartRight);

	adjEntry adj = adjStartLeft->cyclicPred();

	m_rightFace[adj] = fL;
	++fL->m_size;
	m_rightFace[adj->twin()] = fR;
	++fR->m_size;

	OGDF_ASSERT_IF(dlConsistencyChecks, consistencyCheck());

	return u;
}