Ejemplo n.º 1
0
void WeightedDigraph::addEdge(const DirectedEdge &e)
{
    if(e.from() >= V() || e.to() >= V())
        return;
    
    ++edgeCount;
    array[e.from()].push(e);
}
Ejemplo n.º 2
0
std::deque<DirectedEdge> *Djikstra::pathTo(int v){
    if(!hasPathTo(v))
         return 0;
    std::deque<DirectedEdge> *path =  new std::deque<DirectedEdge>();
    for(DirectedEdge e = edgeTo[v]; e.from() || e.to() || e.Getweight(); e =edgeTo[e.from()])
        path->push_front(e);
    return path;
}
Ejemplo n.º 3
0
std::deque<DirectedEdge> *BellmanFord::pathTo(int v){
    if(!hasPathTo(v))
        return 0;
    std::deque<DirectedEdge> *path = new std::deque<DirectedEdge>();
    for(DirectedEdge e = edgeTo[v];e.from() || e.to() || e.Getweight(); e=edgeTo[e.from()] ){
        int w = e.from();
        w++;w--;
        path->push_front(e);
    }
    return path;
}