Minimum spanning tree (Prim algorithm) online calculator
Prim algorithm takes a square matrix representing a graph with weighted edges
and finds the edges that form the minimum spanning tree.
You can enter values again and recalculate the solution. Symmetric values
are filled automatically, but you can change them manually if needed. The calculation always
starts from the first row. Used edges are highlighted in red.
If the graph is disconnected, a minimum spanning tree will not be found.
Description
Enter the matrix size.
Fill in the weight matrix for your graph.
Click "Run Prim".
Check the highlighted edges of the minimum spanning tree and the total weight.
Example calculation and graph-to-matrix conversion:
Prim algorithm is a greedy algorithm for finding a minimum spanning tree in a weighted undirected graph. It builds the tree step by step: starting from one vertex and adding the cheapest edge that connects the current tree to a new vertex.
Comments