30 std::string::size_type sz;
31 if (tokens[1].compare(
"from") != 0) {
32 std::cout <<
"missing 'from' kewyword\n";
36 std::vector< int64_t > sources;
37 unsigned int i_ptr = 2;
39 for ( ; i_ptr < tokens.size(); ++i_ptr) {
40 if (tokens[i_ptr].compare(
"to") == 0)
break;
42 uint64_t start_vertex(stol(tokens[i_ptr], &sz));
43 sources.push_back(start_vertex);
49 if (i_ptr == tokens.size() || tokens[i_ptr].compare(
"to") != 0) {
50 std::cout <<
"dijkstra: 'dist' kewyword not found\n";
54 if (sources.size() == 0) {
55 std::cout <<
"dijkstra: No start value found\n";
60 if (i_ptr == tokens.size()) {
61 std::cout <<
"dijkstra: No 'to' values found\n";
65 std::vector< int64_t > targets;
66 for ( ; i_ptr < tokens.size(); ++i_ptr) {
67 auto end_vertex(stol(tokens[i_ptr], &sz));
68 targets.push_back(end_vertex);
72 if (sources.size() == 1 && targets.size() == 1) {
76 std::cout <<
"THE OPUTPUT ----> total cost: " << path.cost <<
"\n";
81 }
else if (sources.size() == 1 && targets.size() > 1) {
85 std::cout <<
"THE OPUTPUTS ----> total outputs: " << paths.size() <<
"\n";
86 for (
unsigned int i = 0; i < paths.size(); ++i) {
87 if (
sizeof(paths[i]) == 0)
continue;
88 std::cout <<
"Path #" << i <<
" cost: " << paths[i].cost <<
"\n";
89 paths[i].print_path();
91 }
else if (sources.size() > 1 && targets.size() == 1) {
93 std::deque<Path> paths;
97 std::cout <<
"THE OPUTPUTS ----> total outputs: " << paths.size() <<
"\n";
98 for (
unsigned int i = 0; i < paths.size(); ++i) {
99 if (
sizeof(paths[i]) == 0)
continue;
100 std::cout <<
"Path #" << i <<
" cost: " << paths[i].cost <<
"\n";
101 paths[i].print_path();
105 std::deque<Path> paths;
108 std::cout <<
"THE OPUTPUTS ----> total outputs: " << paths.size() <<
"\n";
109 for (
unsigned int i = 0; i < paths.size(); ++i) {
110 if (
sizeof(paths[i]) == 0)
continue;
111 std::cout <<
"Path #" << i <<
" cost: " << paths[i].cost <<
"\n";
112 paths[i].print_path();
void process_dijkstra(G &graph, const std::vector< std::string > &tokens)
void pgr_dijkstra(G &graph, Path &path, int64_t source, int64_t target, bool only_cost=false)