PGROUTING  2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
30 #include "./floydWarshall_driver.h"
31 
32 #include <sstream>
33 #include <deque>
34 #include <vector>
35 
36 #include "./pgr_allpairs.hpp"
37 
38 #include "./../../common/src/pgr_assert.h"
39 #include "./../../common/src/pgr_types.h"
40 
41 
42 void
44  pgr_edge_t *data_edges,
45  size_t total_tuples,
46  bool directedFlag,
47 
48  // return values
49  Matrix_cell_t **return_tuples,
50  size_t *return_count,
51  char ** log_msg,
52  char ** err_msg) {
53  // function starts
54  std::ostringstream log;
55  try {
56  pgassert(!(*log_msg));
57  pgassert(!(*err_msg));
58  pgassert(!(*return_tuples));
59  pgassert(*return_count == 0);
60 
61  graphType gType = directedFlag? DIRECTED: UNDIRECTED;
62 
63 
64  if (directedFlag) {
65  log << "Processing Directed graph\n";
66  pgrouting::DirectedGraph digraph(gType);
67  digraph.insert_edges(data_edges, total_tuples);
68  log << digraph;
69  pgr_floydWarshall(digraph, *return_count, return_tuples);
70  } else {
71  log << "Processing Undirected graph\n";
72  pgrouting::UndirectedGraph undigraph(gType);
73  undigraph.insert_edges(data_edges, total_tuples);
74  log << undigraph;
75  pgr_floydWarshall(undigraph, *return_count, return_tuples);
76  }
77 
78 
79  if (*return_count == 0) {
80  log << "NOTICE: No Vertices found??? wiered error\n";
81  *err_msg = strdup(log.str().c_str());
82  *return_tuples = NULL;
83  *return_count = 0;
84  return;
85  }
86 
87  *log_msg = strdup(log.str().c_str());
88  return;
89  } catch (AssertFailedException &except) {
90  if (*return_tuples) free(*return_tuples);
91  (*return_count) = 0;
92  log << except.what() << "\n";
93  *err_msg = strdup(log.str().c_str());
94  } catch (std::exception& except) {
95  if (*return_tuples) free(*return_tuples);
96  (*return_count) = 0;
97  log << except.what() << "\n";
98  *err_msg = strdup(log.str().c_str());
99  } catch(...) {
100  if (*return_tuples) free(*return_tuples);
101  (*return_count) = 0;
102  log << "Caught unknown exception!\n";
103  *err_msg = strdup(log.str().c_str());
104  }
105 }
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
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)
void insert_edges(const T *edges, int64_t count)
Inserts count edges of type T into the graph.
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
graphType
Definition: pgr_types.h:222
virtual const char * what() const
Definition: pgr_assert.cpp:53
void pgr_floydWarshall(G &graph, std::vector< Matrix_cell_t > &rows)
char * err_msg
Definition: BDATester.cpp:50