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

Go to the source code of this file.

Functions

void do_pgr_johnson (pgr_edge_t *data_edges, size_t total_tuples, bool directed, Matrix_cell_t **return_tuples, size_t *return_count, char **log_msg, char **err_msg)
 

Function Documentation

◆ do_pgr_johnson()

void do_pgr_johnson ( pgr_edge_t data_edges,
size_t  total_tuples,
bool  directed,
Matrix_cell_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  err_msg 
)

Definition at line 42 of file johnson_driver.cpp.

49  {
50  std::ostringstream log;
51  std::ostringstream err;
52 
53  try {
54  pgassert(!(*log_msg));
55  pgassert(!(*err_msg));
56  pgassert(!(*return_tuples));
57  pgassert(*return_count == 0);
58 
59  graphType gType = directed? DIRECTED: UNDIRECTED;
60 
61  if (directed) {
62  log << "Processing Directed graph\n";
63  pgrouting::DirectedGraph digraph(gType);
64  digraph.insert_edges(data_edges, total_tuples);
65  pgr_johnson(digraph, *return_count, return_tuples);
66  } else {
67  log << "Processing Undirected graph\n";
68  pgrouting::UndirectedGraph undigraph(gType);
69  undigraph.insert_edges(data_edges, total_tuples);
70  pgr_johnson(undigraph, *return_count, return_tuples);
71  }
72 
73 
74  if (*return_count == 0) {
75  log << "No result generated, report this error\n";
76  *log_msg = pgr_msg(err.str().c_str());
77  *return_tuples = NULL;
78  *return_count = 0;
79  return;
80  }
81 
82 
83  *log_msg = log.str().empty()?
84  *log_msg :
85  pgr_msg(log.str().c_str());
86  } catch (AssertFailedException &except) {
87  (*return_tuples) = pgr_free(*return_tuples);
88  (*return_count) = 0;
89  err << except.what();
90  *err_msg = pgr_msg(err.str().c_str());
91  *log_msg = pgr_msg(log.str().c_str());
92  } catch (std::exception &except) {
93  (*return_tuples) = pgr_free(*return_tuples);
94  (*return_count) = 0;
95  err << except.what();
96  *err_msg = pgr_msg(err.str().c_str());
97  *log_msg = pgr_msg(log.str().c_str());
98  } catch(...) {
99  (*return_tuples) = pgr_free(*return_tuples);
100  (*return_count) = 0;
101  err << "Caught unknown exception!";
102  *err_msg = pgr_msg(err.str().c_str());
103  *log_msg = pgr_msg(log.str().c_str());
104  }
105 }

References DIRECTED, pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), pgassert, pgr_free(), pgr_johnson(), 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
graphType
graphType
Definition: graph_enum.h:30
pgr_johnson
void pgr_johnson(G &graph, std::vector< Matrix_cell_t > &rows)
Definition: pgr_allpairs.hpp:57
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