PGROUTING  2.6
maximum_cardinality_matching_driver.cpp File Reference
Include dependency graph for maximum_cardinality_matching_driver.cpp:

Go to the source code of this file.

Functions

void do_pgr_maximum_cardinality_matching (pgr_basic_edge_t *data_edges, size_t total_tuples, bool directed, pgr_basic_edge_t **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg)
 

Function Documentation

void do_pgr_maximum_cardinality_matching ( pgr_basic_edge_t data_edges,
size_t  total_tuples,
bool  directed,
pgr_basic_edge_t **  return_tuples,
size_t *  return_count,
char **  log_msg,
char **  notice_msg,
char **  err_msg 
)

Definition at line 42 of file maximum_cardinality_matching_driver.cpp.

References pgrouting::flow::PgrCardinalityGraph< G >::create_max_cardinality_graph(), pgr_alloc(), pgr_free(), pgr_msg(), and AssertFailedException::what().

Referenced by process().

52  {
53  std::ostringstream log;
54  std::ostringstream notice;
55  std::ostringstream err;
56 
57  try {
58  std::vector<pgr_basic_edge_t> matched_vertices;
59 
60  if (directed) {
63  G.create_max_cardinality_graph(data_edges, total_tuples);
64  std::vector<int64_t> mate_map(boost::num_vertices(G.boost_graph));
65  G.maximum_cardinality_matching(mate_map);
66  G.get_matched_vertices(matched_vertices, mate_map);
67  } else {
70  G.create_max_cardinality_graph(data_edges, total_tuples);
71  std::vector<int64_t> mate_map(boost::num_vertices(G.boost_graph));
72  G.maximum_cardinality_matching(mate_map);
73  G.get_matched_vertices(matched_vertices, mate_map);
74  }
75 
76  (*return_tuples) = pgr_alloc(matched_vertices.size(), (*return_tuples));
77  for (size_t i = 0; i < matched_vertices.size(); ++i) {
78  (*return_tuples)[i] = matched_vertices[i];
79  }
80  *return_count = matched_vertices.size();
81 
82  *log_msg = log.str().empty()?
83  *log_msg :
84  pgr_msg(log.str().c_str());
85  *notice_msg = notice.str().empty()?
86  *notice_msg :
87  pgr_msg(notice.str().c_str());
88  } catch (AssertFailedException &except) {
89  (*return_tuples) = pgr_free(*return_tuples);
90  (*return_count) = 0;
91  err << except.what();
92  *err_msg = pgr_msg(err.str().c_str());
93  *log_msg = pgr_msg(log.str().c_str());
94  } catch (std::exception &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(...) {
101  (*return_tuples) = pgr_free(*return_tuples);
102  (*return_count) = 0;
103  err << "Caught unknown exception!";
104  *err_msg = pgr_msg(err.str().c_str());
105  *log_msg = pgr_msg(log.str().c_str());
106  }
107 }
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:126
boost::adjacency_list< boost::listS, boost::vecS, boost::directedS > BasicDirectedGraph
boost::adjacency_list< boost::listS, boost::vecS, boost::undirectedS > BasicUndirectedGraph
T * pgr_free(T *ptr)
Definition: pgr_alloc.hpp:77
void create_max_cardinality_graph(pgr_basic_edge_t *data_edges, size_t total_tuples)
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:30
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
virtual const char * what() const
Definition: pgr_assert.cpp:53

Here is the call graph for this function:

Here is the caller graph for this function: