PGROUTING  2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
warshall.hpp
Go to the documentation of this file.
1 /*PGR
2 
3 Copyright (c) 2015 Celia Virginia Vergara Castillo
4 vicky_vergara@hotmail.com
5 
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 
20 */
21 
22 #include <string>
23 #include <vector>
24 #include "./../../warshall/src/pgr_warshall.hpp"
25 
26 template <typename G>
27 void process_warshall(G &graph, const std::vector<std::string> &tokens) {
28  std::string::size_type sz;
29 
30 
31  if (tokens.size() == 1) {
32  std::cout << "Performing warshall\n";
33  std::vector< Matrix_cell_t> matrix_rows;
34 
35  pgr_warshall(graph, matrix_rows);
36 
37  std::cout << "\t\t\tTHE OPUTPUT\n";
38  std::cout << "seq\tfrom\tto\tcost\n";
39  size_t seq = 0;
40  for (size_t i = 0; i < matrix_rows.size(); i++) {
41  std::cout << seq++ << "\t" << matrix_rows[i].from_vid << "\t" << matrix_rows[i].to_vid << "\t" << matrix_rows[i].cost << "\n";
42  }
43 #ifdef TEST_POSTGRES
44  size_t result_tuple_count;
45  Matrix_cell_t *postgres_rows = NULL;
46  pgr_warshall(graph, result_tuple_count, &postgres_rows);
47  std::cout << "\t\t\tTHE POSTGRESQL OPUTPUT\n";
48  std::cout << "seq\tfrom\tto\tcost\n";
49  seq = 0;
50  for (size_t i = 0; i < result_tuple_count; i++) {
51  std::cout << seq++ << "\t" << postgres_rows[i].from_vid << "\t" << postgres_rows[i].to_vid << "\t" << postgres_rows[i].cost << "\n";
52  }
53 #endif // TEST_POSTGRES
54  } else {
55  std::cout << "unknown number of parameters\n";
56  }
57 }
58 
int64_t from_vid
Definition: pgr_types.h:165
void process_warshall(G &graph, const std::vector< std::string > &tokens)
Definition: warshall.hpp:27
double cost
Definition: pgr_types.h:167
int64_t to_vid
Definition: pgr_types.h:166