#include <stddef.h>
#include "c_types/pgr_edge_t.h"
#include "c_types/pgr_mst_rt.h"
Go to the source code of this file.
|
void | do_pgr_kruskal (pgr_edge_t *data_edges, size_t total_edges, int64_t *root, size_t total_roots, char *fn_suffix, int64_t max_depth, double distance, pgr_mst_rt **return_tuples, size_t *return_count, char **log_msg, char **notice_msg, char **err_msg) |
|
◆ do_pgr_kruskal()
void do_pgr_kruskal |
( |
pgr_edge_t * |
data_edges, |
|
|
size_t |
total_edges, |
|
|
int64_t * |
root, |
|
|
size_t |
total_roots, |
|
|
char * |
fn_suffix, |
|
|
int64_t |
max_depth, |
|
|
double |
distance, |
|
|
pgr_mst_rt ** |
return_tuples, |
|
|
size_t * |
return_count, |
|
|
char ** |
log_msg, |
|
|
char ** |
notice_msg, |
|
|
char ** |
err_msg |
|
) |
| |
Definition at line 44 of file kruskal_driver.cpp.
62 std::ostringstream log;
63 std::ostringstream err;
64 std::ostringstream notice;
72 std::vector<int64_t> roots(rootsArr, rootsArr + size_rootsArr);
73 std::string suffix(fn_suffix);
75 std::vector<pgr_mst_rt> results;
77 if (total_edges == 0) {
81 undigraph.insert_edges(data_edges, total_edges);
87 results = kruskal.kruskal(undigraph);
88 }
else if (suffix ==
"BFS") {
89 results = kruskal.kruskalBFS(undigraph, roots, max_depth);
90 }
else if (suffix ==
"DFS") {
91 results = kruskal.kruskalDFS(undigraph, roots, max_depth);
92 }
else if (suffix ==
"DD") {
93 results = kruskal.kruskalDD(undigraph, roots, distance);
95 err <<
"Unknown Kruskal function";
96 *err_msg =
pgr_msg(err.str().c_str());
101 auto count = results.size();
104 (*return_tuples) = NULL;
106 notice <<
"No spanning tree found";
110 (*return_tuples) =
pgr_alloc(count, (*return_tuples));
111 for (
size_t i = 0; i < count; i++) {
112 *((*return_tuples) + i) = results[i];
114 (*return_count) = count;
117 *log_msg = log.str().empty()?
120 *notice_msg = notice.str().empty()?
124 (*return_tuples) =
pgr_free(*return_tuples);
126 err << except.
what();
127 *err_msg =
pgr_msg(err.str().c_str());
128 *log_msg =
pgr_msg(log.str().c_str());
129 }
catch (std::exception &except) {
130 (*return_tuples) =
pgr_free(*return_tuples);
132 err << except.what();
133 *err_msg =
pgr_msg(err.str().c_str());
134 *log_msg =
pgr_msg(log.str().c_str());
136 (*return_tuples) =
pgr_free(*return_tuples);
138 err <<
"Caught unknown exception!";
139 *err_msg =
pgr_msg(err.str().c_str());
140 *log_msg =
pgr_msg(log.str().c_str());
References pgrouting::details::get_no_edge_graph_result(), 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().