PGROUTING  2.5
floydWarshall_driver.cpp
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 File: floydWarshall_driver.cpp
3 
4 Generated with Template by:
5 Copyright (c) 2015 pgRouting developers
6 Mail: project@pgrouting.org
7 
8 Function's developer:
9 Copyright (c) 2015 Celia Virginia Vergara Castillo
10 Mail: vicky_vergara@hotmail.com
11 
12 ------
13 
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
18 
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23 
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 
28 ********************************************************************PGR-GNU*/
29 
31 
32 #include <sstream>
33 #include <deque>
34 #include <vector>
35 
37 
38 #include "cpp_common/pgr_assert.h"
39 
40 
41 void
43  pgr_edge_t *data_edges,
44  size_t total_tuples,
45  bool directedFlag,
46 
47  // return values
48  Matrix_cell_t **return_tuples,
49  size_t *return_count,
50  char ** log_msg,
51  char ** err_msg) {
52  // function starts
53  std::ostringstream log;
54  try {
55  pgassert(!(*log_msg));
56  pgassert(!(*err_msg));
57  pgassert(!(*return_tuples));
58  pgassert(*return_count == 0);
59 
60  graphType gType = directedFlag? DIRECTED: UNDIRECTED;
61 
62 
63  if (directedFlag) {
64  log << "Processing Directed graph\n";
65  pgrouting::DirectedGraph digraph(gType);
66  digraph.insert_edges(data_edges, total_tuples);
67  log << digraph;
68  pgr_floydWarshall(digraph, *return_count, return_tuples);
69  } else {
70  log << "Processing Undirected graph\n";
71  pgrouting::UndirectedGraph undigraph(gType);
72  undigraph.insert_edges(data_edges, total_tuples);
73  log << undigraph;
74  pgr_floydWarshall(undigraph, *return_count, return_tuples);
75  }
76 
77 
78  if (*return_count == 0) {
79  log << "NOTICE: No Vertices found??? wiered error\n";
80  *err_msg = strdup(log.str().c_str());
81  *return_tuples = NULL;
82  *return_count = 0;
83  return;
84  }
85 
86  *log_msg = strdup(log.str().c_str());
87  return;
88  } catch (AssertFailedException &except) {
89  if (*return_tuples) free(*return_tuples);
90  (*return_count) = 0;
91  log << except.what() << "\n";
92  *err_msg = strdup(log.str().c_str());
93  } catch (std::exception& except) {
94  if (*return_tuples) free(*return_tuples);
95  (*return_count) = 0;
96  log << except.what() << "\n";
97  *err_msg = strdup(log.str().c_str());
98  } catch(...) {
99  if (*return_tuples) free(*return_tuples);
100  (*return_count) = 0;
101  log << "Caught unknown exception!\n";
102  *err_msg = strdup(log.str().c_str());
103  }
104 }
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
void insert_edges(const T *edges, int64_t count)
Inserts count edges of type T into the graph.
void do_pgr_floydWarshall(pgr_edge_t *data_edges, size_t total_tuples, bool directedFlag, Matrix_cell_t **return_tuples, size_t *return_count, char **log_msg, char **err_msg)
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
Assertions Handling.
virtual const char * what() const
Definition: pgr_assert.cpp:53
void pgr_floydWarshall(G &graph, std::vector< Matrix_cell_t > &rows)
graphType
Definition: graph_enum.h:30