pgRouting  2.2
pgRouting extends the PostGIS / PostgreSQL geospatial database to provide geospatial routing functionality.
 All Classes Functions Variables Pages
warshall.hpp
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 #include "./../../warshall/src/pgr_warshall.hpp"
22 
23 template <typename G>
24 void process_warshall(G &graph, const std::vector<std::string> &tokens) {
25  std::string::size_type sz;
26 
27 
28  if (tokens.size() == 1) {
29  std::cout << "Performing warshall\n";
30  std::vector< Matrix_cell_t> matrix_rows;
31 
32  pgr_warshall(graph, matrix_rows);
33 
34  std::cout << "\t\t\tTHE OPUTPUT\n";
35  std::cout << "seq\tfrom\tto\tcost\n";
36  size_t seq = 0;
37  for (size_t i = 0; i < matrix_rows.size(); i++) {
38  std::cout << seq++ << "\t" << matrix_rows[i].from_vid << "\t" << matrix_rows[i].to_vid << "\t" << matrix_rows[i].cost << "\n";
39  }
40 #ifdef TEST_POSTGRES
41  size_t result_tuple_count;
42  Matrix_cell_t *postgres_rows = NULL;
43  pgr_warshall(graph, result_tuple_count, &postgres_rows);
44  std::cout << "\t\t\tTHE POSTGRESQL OPUTPUT\n";
45  std::cout << "seq\tfrom\tto\tcost\n";
46  seq = 0;
47  for (size_t i = 0; i < result_tuple_count; i++) {
48  std::cout << seq++ << "\t" << postgres_rows[i].from_vid << "\t" << postgres_rows[i].to_vid << "\t" << postgres_rows[i].cost << "\n";
49  }
50 #endif // TEST_POSTGRES
51 
52  } else {
53  std::cout << "unknown number of parameters\n";
54  }
55 }
56