--- id: mst title: "Minimum Spanning Trees" author: Benjamin Qi prerequisites: - - Gold - Shortest Paths - - Gold - Disjoint Set Union description: A subset of the edges of a connected, undirected, edge-weighted graph that connects all the vertices to each other of minimum total weight, where no cycles are allowed. --- ## Standard - [Kattis Minimum Spanning Tree](https://open.kattis.com/problems/minspantree) - same as [CSES Road Reparation](https://cses.fi/problemset/task/1675) ## Tutorial - CPH 15 (Spanning Trees) - Prim's Algorithm - [cp-algo](https://cp-algorithms.com/graph/mst_prim.html) - Similar to Dijkstra - Kruskal's Algorithm - [cp-algo 1](https://cp-algorithms.com/graph/mst_kruskal.html) - [cp-algo 2](https://cp-algorithms.com/graph/mst_kruskal_with_dsu.html) ## USACO Gold Problems - [Old Silver - SuperBull](http://www.usaco.org/index.php?page=viewproblem2&cpid=531) - [Walk](http://usaco.org/index.php?page=viewproblem2&cpid=946) - Prim's is applicable, but the edge weights are special so you don't actually need to use an MST algo ... - [Fencedin](http://www.usaco.org/index.php?page=viewproblem2&cpid=623) - also special ... ## Other Problems - [Birthday Gifts](https://www.hackerearth.com/practice/math/combinatorics/inclusion-exclusion/practice-problems/algorithm/mancunian-and-birthday-gifts-d44faa15/) [](73) - [Spanning Tree Fraction](https://www.hackerrank.com/contests/w31/challenges/spanning-tree-fraction) [](78)