Skip to content
This repository was archived by the owner on May 27, 2019. It is now read-only.

Commit 1cd2aef

Browse files
committed
Make prims's algorithm to return result
1 parent 3bfe9f0 commit 1cd2aef

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

UndirectedGraph.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void UndirectedGraph::loadRawDataToList(std::vector<int> rawData) {
147147

148148
// private
149149

150-
void UndirectedGraph::primsAlgorithmOnMatrix() {
150+
string UndirectedGraph::primsAlgorithmOnMatrix() {
151151
// prepare vector for output
152152
vector<vector<int>> minimumSpanningTree;
153153
int numberOfVertices = incidenceMatrix[0].size();
@@ -211,6 +211,11 @@ void UndirectedGraph::primsAlgorithmOnMatrix() {
211211
if (foundVertices.size() < numberOfVertices)
212212
throw "Graf niespojny!";
213213

214+
string output = "Minimalne drzewo rozpinajace\n";
215+
216+
output += printMatrix(minimumSpanningTree);
217+
218+
return output;
214219
}
215220

216221
void UndirectedGraph::primsAlgorithmOnList() {

UndirectedGraph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class UndirectedGraph : public Graph {
2525
void loadRawDataToList(std::vector<int> rawData) override ;
2626

2727
private:
28-
void primsAlgorithmOnMatrix();
28+
std::string primsAlgorithmOnMatrix();
2929
void primsAlgorithmOnList();
3030

3131
};

0 commit comments

Comments
 (0)