Graph Algorithms

Prim's Algorithm

Find the Minimum Spanning Tree (MST) by greedily adding the minimum-weight edge connecting visited nodes to unvisited nodes.

Input Graph

Enter edges as: from to weight (one per line)

Each line represents an edge: source destination weight. Nodes are identified by letters or numbers.

Trace

Step-by-step execution showing edges added to the MST.

  1. Run the algorithm to populate steps.