Prim's algorithm is a method for finding the mininum spanning tree for a network. This implementation of the algorithm uses a matrix representation of the network. A first node is chosen, and then the arc with the smallest weight from that node is identified, creating a partial tree of two nodes so far. Further arcs are then added to this tree, each time choosing the one with the least weight, following the rules that the tree must always be connected, and that a cycle must not be formed. This calculator consists of around 90 lines of javascript, and should run on most browsers, without needing any extra files or scripts.

Prim's algorithm takes a square matrix (representing a network with weighted arcs) and finds arcs which form a minimum spanning tree. The network must be connected for a spanning tree to exist.

You can re-enter values (you may need to change symmetric values manually) and re-calculate the solution. The program doesn't work if the minimum spanning tree has weight over one billion. This implementation always chooses to start with column 1. Arcs used are highlighted in red. If the graph is not connected no spanning tree will be found (but some arcs may be highlighted during the process). If the graph is connected the arcs used will be highlighted, and the total weight will be calculated.