Problem Solving

Kruskal’s Algorithm

Students join wooden towns using weighted links without closing a loop.

Kruskal’s Algorithm definition

Kruskal’s algorithm builds a minimum spanning tree by adding the lightest available edges that do not form a cycle.

In Spanish
algoritmo de Kruskal
Topic
Graph algorithms and networks

Kruskal’s Algorithm in a picture

Kruskal’s Algorithm diagramIn a triangle of edge weights 1, 2, and 4, accept the two lightest edges and skip the third.Sort the edges: 1, 2, 4Start with no edgesAccept weights 1 and 2They join all three verticesDo not add weight 4It would create a cycle
In a triangle of edge weights 1, 2, and 4, accept the two lightest edges and skip the third.

How it works

For a connected weighted undirected graph, sort edges by weight from smallest to largest. Add an edge if its endpoints currently lie in different connected components. Continue until there are n − 1 accepted edges for n vertices. A disconnected graph yields a minimum spanning forest.

Worked examples

What is the tree weight for a triangle with edge weights 2, 3, and 6?

5, from edges of weights 2 and 3.

How many edges are accepted for six vertices in a connected graph?

Five.

Must a minimum spanning tree be unique when edge weights tie?

No. Different valid choices can have the same total weight.

Common mistake

Skip an edge when its endpoints already connect through the accepted edges. A cheap edge can still form a cycle.

Quick check

What should happen if the next edge creates a cycle?

What weight order is used?

Show answer

Nondecreasing weight.

Does the algorithm choose a starting vertex?

Show answer

No. It begins with all vertices separate.

Sources

Flashcard

Kruskal’s Algorithm

Reveal the definition

Kruskal’s algorithm builds a minimum spanning tree by adding the lightest available edges that do not form a cycle.

Effortless Math. “Kruskal’s Algorithm.” Math Dictionary.