PGROUTING  3.2
floydWarshall_driver.cpp File Reference
#include "drivers/allpairs/floydWarshall_driver.h"
#include <sstream>
#include <deque>
#include <vector>
#include "allpairs/pgr_allpairs.hpp"
#include "cpp_common/pgr_assert.h"
Include dependency graph for floydWarshall_driver.cpp:

Go to the source code of this file.

Functions

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)
 

Function Documentation

◆ do_pgr_floydWarshall()

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 
)

Definition at line 42 of file floydWarshall_driver.cpp.

50  {
51  std::ostringstream log;
52  std::ostringstream err;
53 
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  pgr_floydWarshall(digraph, *return_count, return_tuples);
68  } else {
69  log << "Processing Undirected graph\n";
70  pgrouting::UndirectedGraph undigraph(gType);
71  undigraph.insert_edges(data_edges, total_tuples);
72  pgr_floydWarshall(undigraph, *return_count, return_tuples);
73  }
74 
75 
76  if (*return_count == 0) {
77  err << "No result generated, report this error\n";
78  *err_msg = pgr_msg(err.str().c_str());
79  *return_tuples = NULL;
80  *return_count = 0;
81  return;
82  }
83 
84  *log_msg = log.str().empty()?
85  *log_msg :
86  pgr_msg(log.str().c_str());
87  } catch (AssertFailedException &except) {
88  (*return_tuples) = pgr_free(*return_tuples);
89  (*return_count) = 0;
90  err << except.what();
91  *err_msg = pgr_msg(err.str().c_str());
92  *log_msg = pgr_msg(log.str().c_str());
93  } catch (std::exception &except) {
94  (*return_tuples) = pgr_free(*return_tuples);
95  (*return_count) = 0;
96  err << except.what();
97  *err_msg = pgr_msg(err.str().c_str());
98  *log_msg = pgr_msg(log.str().c_str());
99  } catch(...) {
100  (*return_tuples) = pgr_free(*return_tuples);
101  (*return_count) = 0;
102  err << "Caught unknown exception!";
103  *err_msg = pgr_msg(err.str().c_str());
104  *log_msg = pgr_msg(log.str().c_str());
105  }
106 }

References DIRECTED, pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), pgassert, pgr_floydWarshall(), pgr_free(), pgr_msg(), UNDIRECTED, and AssertFailedException::what().

Referenced by process().

pgr_msg
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:30
AssertFailedException::what
virtual const char * what() const
Definition: pgr_assert.cpp:67
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
UNDIRECTED
@ UNDIRECTED
Definition: graph_enum.h:30
pgr_floydWarshall
void pgr_floydWarshall(G &graph, std::vector< Matrix_cell_t > &rows)
Definition: pgr_allpairs.hpp:64
graphType
graphType
Definition: graph_enum.h:30
DIRECTED
@ DIRECTED
Definition: graph_enum.h:30
pgr_free
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:77
pgrouting::graph::Pgr_base_graph
Definition: pgr_base_graph.hpp:168
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:139