PGROUTING  3.2
makeConnected_driver.h File Reference
#include <stddef.h>
#include "c_types/pgr_edge_t.h"
#include "c_types/pgr_makeConnected_t.h"
#include "c_types/pgr_mst_rt.h"
Include dependency graph for makeConnected_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_makeConnected (pgr_edge_t *data_edges, size_t total_tuples, pgr_makeConnected_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

◆ do_pgr_makeConnected()

void do_pgr_makeConnected ( pgr_edge_t data_edges,
size_t  total_tuples,
pgr_makeConnected_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 43 of file makeConnected_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  std::vector<pgr_makeConnected_t> results;
64  std::string logstr;
65 
66 
67  graphType gType = UNDIRECTED;
68  log << "Working with Undirected Graph\n";
69  pgrouting::UndirectedGraph undigraph(gType);
70  undigraph.insert_edges(data_edges, total_edges);
72  results = fn_makeConnected.makeConnected(undigraph);
73  logstr += fn_makeConnected.get_log();
74  log << logstr;
75 
76  auto count = results.size();
77 
78  if (count == 0) {
79  (*return_tuples) = NULL;
80  (*return_count) = 0;
81  notice <<
82  "No Vertices";
83  *log_msg = pgr_msg(notice.str().c_str());
84  return;
85  }
86 
87  (*return_tuples) = pgr_alloc(count, (*return_tuples));
88  log << "\nConverting a set of traversals into the tuples";
89  for (size_t i = 0; i < count; i++) {
90  *((*return_tuples) + i) = results[i];
91  }
92  (*return_count) = count;
93 
94  pgassert(*err_msg == NULL);
95  *log_msg = log.str().empty()?
96  *log_msg :
97  pgr_msg(log.str().c_str());
98  *notice_msg = notice.str().empty()?
99  *notice_msg :
100  pgr_msg(notice.str().c_str());
101  } catch (AssertFailedException &except) {
102  (*return_tuples) = pgr_free(*return_tuples);
103  (*return_count) = 0;
104  err << except.what();
105  *err_msg = pgr_msg(err.str().c_str());
106  *log_msg = pgr_msg(log.str().c_str());
107  } catch (std::exception &except) {
108  (*return_tuples) = pgr_free(*return_tuples);
109  (*return_count) = 0;
110  err << except.what();
111  *err_msg = pgr_msg(err.str().c_str());
112  *log_msg = pgr_msg(log.str().c_str());
113  } catch(...) {
114  (*return_tuples) = pgr_free(*return_tuples);
115  (*return_count) = 0;
116  err << "Caught unknown exception!";
117  *err_msg = pgr_msg(err.str().c_str());
118  *log_msg = pgr_msg(log.str().c_str());
119  }
120 }

References pgrouting::Pgr_messages::get_log(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), pgrouting::functions::Pgr_makeConnected< G >::makeConnected(), 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
pgrouting::functions::Pgr_makeConnected
Definition: pgr_makeConnected.hpp:49
pgassert
#define pgassert(expr)
Uses the standard assert syntax.
Definition: pgr_assert.h:94
UNDIRECTED
@ UNDIRECTED
Definition: graph_enum.h:30
pgrouting::Pgr_messages::get_log
std::string get_log() const
get_log
Definition: pgr_messages.cpp:36
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
pgrouting::functions::Pgr_makeConnected::makeConnected
std::vector< pgr_makeConnected_t > makeConnected(G &graph)
Definition: pgr_makeConnected.hpp:54
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:139