PGROUTING  2.5
strongComponents_driver.cpp File Reference
#include "drivers/components/strongComponents_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 dependency graph for strongComponents_driver.cpp:

Go to the source code of this file.

Functions

void do_pgr_strongComponents (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)
 
template<class G >
static std::vector< pgr_components_rtpgr_strongComponents (G &graph)
 

Function Documentation

void do_pgr_strongComponents ( 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 63 of file strongComponents_driver.cpp.

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

Referenced by process().

70  {
71  std::ostringstream log;
72  std::ostringstream err;
73  std::ostringstream notice;
74  try {
75  pgassert(!(*log_msg));
76  pgassert(!(*notice_msg));
77  pgassert(!(*err_msg));
78  pgassert(!(*return_tuples));
79  pgassert(*return_count == 0);
80  pgassert(total_edges != 0);
81 
82  graphType gType = DIRECTED;
83 
84  std::vector<pgr_components_rt> results;
85 
86  log << "Working with Directed Graph\n";
87  pgrouting::DirectedGraph digraph(gType);
88  digraph.insert_edges(data_edges, total_edges);
89  results = pgr_strongComponents(
90  digraph);
91 
92  auto count = results.size();
93 
94  if (count == 0) {
95  (*return_tuples) = NULL;
96  (*return_count) = 0;
97  notice <<
98  "No paths found between start_vid and end_vid vertices";
99  return;
100  }
101 
102  (*return_tuples) = pgr_alloc(count, (*return_tuples));
103  for (size_t i = 0; i < count; i++) {
104  *((*return_tuples) + i) = results[i];
105  }
106  (*return_count) = count;
107 
108  pgassert(*err_msg == NULL);
109  *log_msg = log.str().empty()?
110  *log_msg :
111  pgr_msg(log.str().c_str());
112  *notice_msg = notice.str().empty()?
113  *notice_msg :
114  pgr_msg(notice.str().c_str());
115  } catch (AssertFailedException &except) {
116  (*return_tuples) = pgr_free(*return_tuples);
117  (*return_count) = 0;
118  err << except.what();
119  *err_msg = pgr_msg(err.str().c_str());
120  *log_msg = pgr_msg(log.str().c_str());
121  } catch (std::exception &except) {
122  (*return_tuples) = pgr_free(*return_tuples);
123  (*return_count) = 0;
124  err << except.what();
125  *err_msg = pgr_msg(err.str().c_str());
126  *log_msg = pgr_msg(log.str().c_str());
127  } catch(...) {
128  (*return_tuples) = pgr_free(*return_tuples);
129  (*return_count) = 0;
130  err << "Caught unknown exception!";
131  *err_msg = pgr_msg(err.str().c_str());
132  *log_msg = pgr_msg(log.str().c_str());
133  }
134 }
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:79
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:81
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:29
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:68
virtual const char * what() const
Definition: pgr_assert.cpp:53
graphType
Definition: graph_enum.h:30
static std::vector< pgr_components_rt > pgr_strongComponents(G &graph)

Here is the call graph for this function:

Here is the caller graph for this function:

template<class G >
static std::vector<pgr_components_rt> pgr_strongComponents ( G &  graph)
static

Definition at line 54 of file strongComponents_driver.cpp.

References Pgr_components< G >::strongComponents().

Referenced by do_pgr_strongComponents().

55  {
56  std::vector<pgr_components_rt> results;
57  Pgr_components< G > fn_components;
58  return fn_components.strongComponents(graph);
59 }
std::vector< pgr_components_rt > strongComponents(G &graph)
Strongly Connected Components Vertex Version.

Here is the call graph for this function:

Here is the caller graph for this function: