Website Summary Files Commits Branches @commit @diff @stats
path: root / Seminar13 / src / mst-prim.cpp
diff options
context:
space:
mode:
Commit2042cb9741838ead8a0741c8b2274ebf2a6ec5fd (patch)
Author
 Stoycho Kyosev <skyosev@192.168.100.17>
2025-01-18 15:11:02 -0500
Committer
 Stoycho Kyosev <skyosev@192.168.100.17>
2025-01-18 15:11:02 -0500
Files9c4e3b356a668c40519bdded63e6d5cb26ae66b6 /Seminar13/src/mst-prim.cpp
Data-structures-and-algorithms-2042cb9741838ead8a0741c8b2274ebf2a6ec5fd.tar
Data-structures-and-algorithms-2042cb9741838ead8a0741c8b2274ebf2a6ec5fd.tar.gz
Data-structures-and-algorithms-2042cb9741838ead8a0741c8b2274ebf2a6ec5fd.zip
Parent1b1a8c4758334d8e67408429a8ad23f374c1af20 (diff)
Refactor
1 files changed, 0 insertions, 10 deletions
-rw-r--r--Seminar13/src/mst-prim.cpp10
diff --git a/Seminar13/src/mst-prim.cpp b/Seminar13/src/mst-prim.cpp
index c342ce8..a89bc26 100644
--- a/Seminar13/src/mst-prim.cpp
+++ b/Seminar13/src/mst-prim.cpp
@@ -76,10 +76,8 @@ mst_info prim(const weighted_graph& g, vertex_index_t start = 0)
int main()
{
- // Create a weighted graph with 7 vertices, undirected
weighted_graph g(7, false);
- // Add edges with weights
g.add_edge(0, 1, 4);
g.add_edge(0, 2, 3);
g.add_edge(1, 2, 1);
@@ -90,19 +88,11 @@ int main()
g.add_edge(4, 6, 8);
g.add_edge(5, 6, 4);
- // g.add_edge(0, 1, 10);
- // g.add_edge(0, 2, 5);
- // g.add_edge(1, 2, 1);
- // g.add_edge(1, 3, 2);
- // g.add_edge(2, 3, 3);
- // Run Prim's algorithm
auto result = prim(g);
- // Print the total cost of the MST
std::cout << "Total cost of MST: " << result.cost << '\n';
- // Print the tree structure
std::cout << "Tree structure (parent array): ";
for (const auto x : result.tree)
{