Kruskal's Algorithm
Sorts every edge by weight and greedily accepts the cheapest one that doesn't create a cycle, using a union-find structure to detect cycles in near-constant time.
- Data Structure: Union-Find (Disjoint Set)
- Visual Pattern: Edges lighting up out of order across the whole graph.
- Best For: Sparse graphs, edge lists.
Prim's Algorithm
Grows a single tree from a start node, at each step attaching the cheapest edge that connects the tree to a new node.
- Data Structure: Priority Queue / Min-Heap
- Visual Pattern: A single connected blob expanding outward.
- Best For: Dense graphs, adjacency lists.