PGROUTING  3.2
bipartite_driver.cpp File Reference
#include <string>
#include <sstream>
#include <deque>
#include <vector>
#include <algorithm>
#include "cpp_common/identifiers.hpp"
#include "cpp_common/pgr_alloc.hpp"
#include "cpp_common/basePath_SSEC.hpp"
#include "cpp_common/pgr_base_graph.hpp"
#include "drivers/coloring/bipartite_driver.h"
#include "coloring/pgr_bipartite_driver.hpp"
#include "c_types/pgr_bipartite_rt.h"
Include dependency graph for bipartite_driver.cpp:

Go to the source code of this file.

Functions

void do_pgr_bipartite (pgr_edge_t *data_edges, size_t total_edges, pgr_bipartite_rt **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

◆ do_pgr_bipartite()

void do_pgr_bipartite ( pgr_edge_t data_edges,
size_t  total_edges,
pgr_bipartite_rt **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 53 of file bipartite_driver.cpp.

60  {
61  std::ostringstream log;
62  std::ostringstream notice;
63  std::ostringstream err;
64 
65 
66  try {
67  pgassert(total_edges != 0);
68  pgassert(!(*log_msg));
69  pgassert(!(*notice_msg));
70  pgassert(!(*err_msg));
71  pgassert(!(*return_tuples));
72  pgassert(*return_count == 0);
73 
74  std::string logstr;
75  graphType gType = UNDIRECTED;
76  pgrouting::UndirectedGraph undigraph(gType);
77  undigraph.insert_edges(data_edges, total_edges);
78  std::vector<pgr_bipartite_rt> results;
80  results = fn_Bipartite.pgr_bipartite(undigraph);
81  logstr += fn_Bipartite.get_log();
82  log << logstr;
83  auto count = results.size();
84  if (count == 0) {
85  (*return_tuples) = NULL;
86  (*return_count) = 0;
87  *log_msg = log.str().empty()?
88  *log_msg :
89  pgr_msg(log.str().c_str());
90  *notice_msg = notice.str().empty()?
91  *notice_msg :
92  pgr_msg(notice.str().c_str());
93  return;
94  }
95  (*return_tuples) = pgr_alloc(count, (*return_tuples));
96  for (size_t i = 0; i < count; i++) {
97  *((*return_tuples) + i) = results[i];
98  }
99  (*return_count) = count;
100 
101  pgassert(*err_msg == NULL);
102  *log_msg = log.str().empty()?
103  *log_msg :
104  pgr_msg(log.str().c_str());
105  *notice_msg = notice.str().empty()?
106  *notice_msg :
107  pgr_msg(notice.str().c_str());
108  } catch (AssertFailedException &except) {
109  (*return_tuples) = pgr_free(*return_tuples);
110  (*return_count) = 0;
111  err << except.what();
112  *err_msg = pgr_msg(err.str().c_str());
113  *log_msg = pgr_msg(log.str().c_str());
114  } catch (std::exception &except) {
115  (*return_tuples) = pgr_free(*return_tuples);
116  (*return_count) = 0;
117  err << except.what();
118  *err_msg = pgr_msg(err.str().c_str());
119  *log_msg = pgr_msg(log.str().c_str());
120  } catch(...) {
121  (*return_tuples) = pgr_free(*return_tuples);
122  (*return_count) = 0;
123  err << "Caught unknown exception!";
124  *err_msg = pgr_msg(err.str().c_str());
125  *log_msg = pgr_msg(log.str().c_str());
126  }
127 }

References pgrouting::Pgr_messages::get_log(), pgrouting::graph::Pgr_base_graph< G, T_V, T_E >::insert_edges(), pgassert, pgr_alloc(), pgrouting::functions::Pgr_Bipartite< G >::pgr_bipartite(), pgr_free(), pgr_msg(), UNDIRECTED, and AssertFailedException::what().

Referenced by process().

pgrouting::functions::Pgr_Bipartite
Definition: pgr_bipartite_driver.hpp:53
pgr_alloc
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
pgrouting::functions::Pgr_Bipartite::pgr_bipartite
std::vector< pgr_bipartite_rt > pgr_bipartite(G &graph)
Definition: pgr_bipartite_driver.hpp:85
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
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
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:139