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