PGROUTING  3.2
biconnectedComponents_driver.h File Reference
#include <stddef.h>
#include "c_types/pgr_edge_t.h"
#include "c_types/pgr_components_rt.h"
Include dependency graph for biconnectedComponents_driver.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void do_pgr_biconnectedComponents (pgr_edge_t *data_edges, size_t total_edges, pgr_components_rt **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

◆ do_pgr_biconnectedComponents()

void do_pgr_biconnectedComponents ( pgr_edge_t data_edges,
size_t  total_edges,
pgr_components_rt **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 45 of file biconnectedComponents_driver.cpp.

52  {
53  std::ostringstream log;
54  std::ostringstream err;
55  std::ostringstream notice;
56  try {
57  pgassert(!(*log_msg));
58  pgassert(!(*notice_msg));
59  pgassert(!(*err_msg));
60  pgassert(!(*return_tuples));
61  pgassert(*return_count == 0);
62  pgassert(total_edges != 0);
63 
64  graphType gType = UNDIRECTED;
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::biconnectedComponents(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  for (size_t i = 0; i < count; i++) {
83  *((*return_tuples) + i) = results[i];
84  }
85  (*return_count) = count;
86 
87  pgassert(*err_msg == NULL);
88  *log_msg = log.str().empty()?
89  *log_msg :
90  pgr_msg(log.str().c_str());
91  *notice_msg = notice.str().empty()?
92  *notice_msg :
93  pgr_msg(notice.str().c_str());
94  } catch (AssertFailedException &except) {
95  (*return_tuples) = pgr_free(*return_tuples);
96  (*return_count) = 0;
97  err << except.what();
98  *err_msg = pgr_msg(err.str().c_str());
99  *log_msg = pgr_msg(log.str().c_str());
100  } catch (std::exception &except) {
101  (*return_tuples) = pgr_free(*return_tuples);
102  (*return_count) = 0;
103  err << except.what();
104  *err_msg = pgr_msg(err.str().c_str());
105  *log_msg = pgr_msg(log.str().c_str());
106  } catch(...) {
107  (*return_tuples) = pgr_free(*return_tuples);
108  (*return_count) = 0;
109  err << "Caught unknown exception!";
110  *err_msg = pgr_msg(err.str().c_str());
111  *log_msg = pgr_msg(log.str().c_str());
112  }
113 }

References pgrouting::algorithms::biconnectedComponents(), 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().

pgrouting::algorithms::biconnectedComponents
std::vector< pgr_components_rt > biconnectedComponents(pgrouting::UndirectedGraph &graph)
Biconnected Components.
Definition: pgr_components.cpp:101
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
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_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