PGROUTING  3.2
bridges_driver.cpp File Reference
#include "drivers/components/bridges_driver.h"
#include <sstream>
#include <deque>
#include <vector>
#include "components/pgr_components.hpp"
#include "cpp_common/pgr_alloc.hpp"
#include "cpp_common/pgr_assert.h"
#include "cpp_common/pgr_base_graph.hpp"
Include dependency graph for bridges_driver.cpp:

Go to the source code of this file.

Functions

void do_pgr_bridges (pgr_edge_t *data_edges, size_t total_edges, int64_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

◆ do_pgr_bridges()

void do_pgr_bridges ( pgr_edge_t data_edges,
size_t  total_edges,
int64_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 44 of file bridges_driver.cpp.

51  {
52  std::ostringstream log;
53  std::ostringstream err;
54  std::ostringstream notice;
55  try {
56  pgassert(!(*log_msg));
57  pgassert(!(*notice_msg));
58  pgassert(!(*err_msg));
59  pgassert(!(*return_tuples));
60  pgassert(*return_count == 0);
61  pgassert(total_edges != 0);
62 
63  graphType gType = UNDIRECTED;
64 
65 
66  log << "Working with Undirected Graph\n";
67  pgrouting::UndirectedGraph undigraph(gType);
68  undigraph.insert_edges(data_edges, total_edges);
69  auto results = pgrouting::algorithms::bridges(undigraph);
70 
71  auto count = results.size();
72 
73  if (count == 0) {
74  (*return_tuples) = NULL;
75  (*return_count) = 0;
76  notice <<
77  "No paths found between start_vid and end_vid vertices";
78  return;
79  }
80 
81  (*return_tuples) = pgr_alloc(count, (*return_tuples));
82  size_t i = 0;
83  for (const auto edge : results) {
84  *((*return_tuples) + i) = edge;
85  ++i;
86  }
87  (*return_count) = count;
88 
89  pgassert(*err_msg == NULL);
90  *log_msg = log.str().empty()?
91  *log_msg :
92  pgr_msg(log.str().c_str());
93  *notice_msg = notice.str().empty()?
94  *notice_msg :
95  pgr_msg(notice.str().c_str());
96  } catch (AssertFailedException &except) {
97  (*return_tuples) = pgr_free(*return_tuples);
98  (*return_count) = 0;
99  err << except.what();
100  *err_msg = pgr_msg(err.str().c_str());
101  *log_msg = pgr_msg(log.str().c_str());
102  } catch (std::exception &except) {
103  (*return_tuples) = pgr_free(*return_tuples);
104  (*return_count) = 0;
105  err << except.what();
106  *err_msg = pgr_msg(err.str().c_str());
107  *log_msg = pgr_msg(log.str().c_str());
108  } catch(...) {
109  (*return_tuples) = pgr_free(*return_tuples);
110  (*return_count) = 0;
111  err << "Caught unknown exception!";
112  *err_msg = pgr_msg(err.str().c_str());
113  *log_msg = pgr_msg(log.str().c_str());
114  }
115 }

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

Referenced by process().

pgr_alloc
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
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
edge
Definition: trsp.h:41
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
UNDIRECTED
@ UNDIRECTED
Definition: graph_enum.h:30
pgrouting::algorithms::bridges
Identifiers< int64_t > bridges(pgrouting::UndirectedGraph &graph)
Bridges Bridges are closely related to the concept of articulation vertices, vertices that belong to ...
Definition: pgr_components.cpp:162
graphType
graphType
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