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; }
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; }