Line data Source code
1 : #include "Alg/ShortestPath/ShortestPathOneMany.hpp" 2 : 3 : #include <list> 4 : 5 : using namespace std; 6 : using namespace Alg; 7 : using namespace Alg::ShortestPath; 8 : 9 93792 : ShortestPathOneMany::~ShortestPathOneMany() {} 10 : 11 208337 : void ShortestPathOneMany::solve(const Graph &G, Graph::Node s) { 12 208337 : list<Graph::Node> sList = {s}; 13 208337 : solveList(G, sList); 14 208337 : } 15 : 16 14 : Graph::Path ShortestPathOneMany::getPath(Graph::Node d) const { 17 14 : if(isStart(d)) return Graph::Path(); 18 : 19 26 : list<Graph::Edge> res; 20 : 21 12 : Graph::Edge e = getPrev(d); 22 : 23 12 : if(e.u == Graph::NODE_INVALID) return Graph::Path({Graph::EDGE_INVALID}); 24 : 25 28 : while(!isStart(e.u)) { 26 17 : res.push_front(e); 27 17 : e = getPrev(e.u); 28 : } 29 11 : res.push_front(e); 30 11 : return Graph::Path(res.begin(), res.end()); 31 : }