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) {
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());