#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_prim (pgr_edge_t *data_edges, size_t total_edges, int64_t *rootsArr, size_t size_rootsArr, 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_prim()
void do_pgr_prim |
( |
pgr_edge_t * |
data_edges, |
|
|
size_t |
total_edges, |
|
|
int64_t * |
rootsArr, |
|
|
size_t |
size_rootsArr, |
|
|
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 prim_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_min_edges_no_parallel(data_edges, total_edges);
84 results = prim.
prim(undigraph);
85 }
else if (suffix ==
"BFS") {
86 results = prim.
primBFS(undigraph, roots, max_depth);
87 }
else if (suffix ==
"DFS") {
88 results = prim.
primDFS(undigraph, roots, max_depth);
89 }
else if (suffix ==
"DD") {
90 results = prim.
primDD(undigraph, roots, distance);
92 err <<
"Unknown Prim function";
93 *err_msg =
pgr_msg(err.str().c_str());
98 auto count = results.size();
101 (*return_tuples) = NULL;
103 notice <<
"No spanning tree found";
107 (*return_tuples) =
pgr_alloc(count, (*return_tuples));
108 for (
size_t i = 0; i < count; i++) {
109 *((*return_tuples) + i) = results[i];
111 (*return_count) = count;
114 *log_msg = log.str().empty()?
117 *notice_msg = notice.str().empty()?
121 (*return_tuples) =
pgr_free(*return_tuples);
123 err << except.
what();
124 *err_msg =
pgr_msg(err.str().c_str());
125 *log_msg =
pgr_msg(log.str().c_str());
126 }
catch (std::exception &except) {
127 (*return_tuples) =
pgr_free(*return_tuples);
129 err << except.what();
130 *err_msg =
pgr_msg(err.str().c_str());
131 *log_msg =
pgr_msg(log.str().c_str());
133 (*return_tuples) =
pgr_free(*return_tuples);
135 err <<
"Caught unknown exception!";
136 *err_msg =
pgr_msg(err.str().c_str());
137 *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_min_edges_no_parallel(), pgassert, pgr_alloc(), pgr_free(), pgr_msg(), pgrouting::functions::Pgr_prim< G >::prim(), pgrouting::functions::Pgr_prim< G >::primBFS(), pgrouting::functions::Pgr_prim< G >::primDD(), pgrouting::functions::Pgr_prim< G >::primDFS(), UNDIRECTED, and AssertFailedException::what().
Referenced by process().