Exemplo n.º 1
0
VertSet intersection(const VertSet &set1, const VertSet &set2) {
    VertSet result = VertSet();
    for (VertSet_const_IT it = set1.begin(); it != set1.end(); it++) {
        if (set2.find(*it) != set2.end()) {
            result.insert(*it);
        }
    }
    return result;
}
Exemplo n.º 2
0
VertSet Vert::one_ring() {
    VertSet result = VertSet();

    Edge *e = edge;
    do {
        result.insert(e->pair->vert);
        e = e->pair->prev;
    } while(e != edge);

    return result;
}
Exemplo n.º 3
0
 /**
 * Return first path found from start vertex to end vertex
 * as a vector of edges, or NULL of no such path is found.
 */
 bool findDfsVertexPathMarking(vector<Vertex*> &path, Vertex *start, const Vertex *end)
 {
     mMarks.clear();
     path.clear();
     if (mEdges.find(start) != mEdges.end()) {
         mMarks.insert(start);
         path.push_back(start);
         return findDfsVertexPathMarkingRec(path, end);
     }
     return false;
 }
Exemplo n.º 4
0
 /**
 *  Add an edge if both vertices are non-NULL and distinct
 */
 bool addEdge(Vertex *vertA, Vertex *vertB) 
 {
     if (vertA == NULL || vertB == NULL || vertA == vertB)
         return false;                   // no side effects on failure
     addVertex(vertA);
     addVertex(vertB);
     if (mEdges.find(vertA) == mEdges.end()) {
         mEdges.insert(EdgeMap::value_type(vertA, new VertSet()));
     }
     VertSet *nexts = mEdges.at(vertA);
     return   nexts->insert(vertB).second;
 }
Exemplo n.º 5
0
VertSet Vert::two_ring() {
    VertSet result = VertSet();

    VertSet first_ring = edge->vert->one_ring();

    for (VertSet_IT it = first_ring.begin(); it != first_ring.end(); it++) {
        VertSet temp_ring = (*it)->edge->vert->one_ring();
        for (VertSet_IT it = temp_ring.begin(); it != temp_ring.end(); it++) {
            result.insert(*it);
        }
    }

    return result;
}
Exemplo n.º 6
0
    bool findDfsVertexPathMarkingRec(vector<Vertex*> &path, const Vertex *end)
    {
        Vertex *lastVert = path.back();
        if (lastVert == end)
            return  true;

        if (mEdges.find(lastVert) != mEdges.end()) {
            VertSet *nexts = mEdges.at(lastVert);
            for (VertSet::iterator it = nexts->begin(); it != nexts->end(); ++it) {
                Vertex *vert = *it;
                if (mMarks.find(vert) == mMarks.end()) {
                    mMarks.insert(vert);
                    path.push_back(vert);
                    bool found = findDfsVertexPathMarkingRec(path, end);
                    if ( found )
                        return found;
                    else
                        path.pop_back();
                }
            }
        }
        return false;
    }
Exemplo n.º 7
0
 bool addVertex(Vertex *vert) 
 {
     return mVerts.insert(vert).second;
 }