EdgeSetIF * MSTSolverIF::getMST(EdgeSetIF* visibleSet) throw (GraphExceptions::DisconnectedGraphException) { ConnectivityList connectivityList = GraphUtils::shrinkConnectivityToSet( graph, visibleSet); EdgeSetIF* minimumSpanningTree = getMST(); graph->restoreConnectivityAllEdges(connectivityList); return minimumSpanningTree; }
EdgeSetIF * MSTSolverIF::getMST(VertexIF * const initialVertex, EdgeSetIF* visibleSet) throw (GraphExceptions::DisconnectedGraphException) { VisibilityList visibilityList = GraphUtils::shrinkVisibilityToSet(graph, visibleSet); EdgeSetIF* minimumSpanningTree = getMST(initialVertex); graph->restoreVisibilityAllEdges(visibilityList); return minimumSpanningTree; }
EdgeSetIF * MSTSolverIF::getMST() throw (GraphExceptions::DisconnectedGraphException) { if (!graph->hasAnyVertex(Visibility::VISIBLE)) { WARN(logger, LogBundleKey::MSTS_IF_EMPTY_INPUT_GRAPH); return new EdgeSetImpl { }; } else { return getMST(graph->nextVertex(Visibility::VISIBLE)); } }
std::vector<std::string> Graph::getPairs(int root) { std::vector<Edge> temp = getMST(root); std::vector<std::string> result; for (std::vector<Edge>::iterator it = temp.begin(); it != temp.end(); it++) { std::ostringstream s1; s1 << it->getDestination(); std::ostringstream s2; s2 << it->getSource(); result.push_back(s1.str() + " " + s2.str()); } return result; }
EdgeSetIF * MSTSolverIF::getMST(VertexIF * const initialVertex) throw (GraphExceptions::DisconnectedGraphException) { if (initialVertex == nullptr) { return getMST(); } if (GraphUtils::isGraphConnected(graph) == false) { ERROR(logger, LogBundleKey::MSTS_IF_GRAPH_NOT_CONNECTED); throw GraphExceptions::DisconnectedGraphException(); } else { INFO(logger, LogBundleKey::MSTS_IF_CONSTRUCT_FROM_SOURCE, graph->getNumberOfVertices(Visibility::VISIBLE), graph->getNumberOfEdges(Visibility::VISIBLE), initialVertex->getVertexIdx()); return resolve(initialVertex); } }