Prim's algorithm

Prim's algorithm step-by-step

  • Choose a random point on the graph (1st visited node)
  • Choose the connection with the smallest value connected with this node
  • Add this node to the set of visited nodes
  • Choose the connection with the smallest value connected with your set of visited nodes and add it to your tree
  • Add the new visited node to your set of visited nodes
  • Continue until you visited all nodes
  • You have now found the minimal spanning tree

The algorithm step by step

Click on the arrows of the navigation bar and follow how the algorithm is set up.