---
title: "Kruskal's Algorithm | Combinatorics"
description: "Kruskal's Algorithm finds a minimum spanning tree by adding the lightest edges without forming cycles, a core graph method in Combinatorics."
canonical: "https://fiveable.me/combinatorics/key-terms/kruskals-algorithm"
type: "key-term"
subject: "Combinatorics"
unit: "Unit 10"
---

# Kruskal's Algorithm | Combinatorics

## Definition

Kruskal's Algorithm is a method for finding a minimum spanning tree in a weighted graph by choosing edges from smallest to largest while skipping any edge that creates a cycle. In Combinatorics, it shows how greedy choices can build an optimal network.

## What It Is

Kruskal's Algorithm is a greedy method in Combinatorics for building a minimum spanning tree from a weighted, undirected graph. You sort all edges from lightest to heaviest, then add an edge only if it connects two different parts of the graph and does not create a cycle.

The big idea is that the algorithm makes local choices that stay safe globally. A light edge is not automatically chosen just because it is small, though. It has to connect separate components, because if it closes a loop, it would make the tree less efficient without helping you reach a new vertex.

A minimum spanning tree is a spanning tree with the smallest possible total weight. That means it still touches every vertex, but it uses exactly n - 1 edges for n vertices and avoids extra connections. Kruskal's Algorithm works especially well when the graph is sparse, because there are fewer edges to sort and check.

To keep track of which vertices are already connected, the algorithm usually uses union-find, also called disjoint sets. That data structure tells you quickly whether two endpoints are already in the same component. If they are, adding the edge would form a cycle, so you skip it.

A small example makes the process easier to see. Suppose you have four vertices and weighted edges 1, 2, 3, 4, and 5. Kruskal's Algorithm takes edge 1, then edge 2 if it does not create a cycle, then keeps moving upward in weight until all vertices are connected. If the graph is disconnected, you do not get one spanning tree, you get a minimum spanning forest, one tree per connected part.

## Why It Matters

Kruskal's Algorithm shows up when Combinatorics moves from counting objects to optimizing networks. It is one of the cleanest examples of a greedy algorithm, so it helps you see how a rule like "take the smallest safe edge" can produce a globally best answer instead of just a decent one.

It also ties together several graph topics at once. You need to recognize graph representations, know what a tree and spanning tree are, and understand why cycles matter. That makes it a useful bridge between abstract graph theory and algorithmic thinking.

The algorithm is also a good place to think about complexity. Since the edges must be sorted first, the running time is usually described as O(E log E), which makes the sorting step the bottleneck. That matters when you compare Kruskal's Algorithm with other MST methods or when you explain why it works better on sparse graphs.

In problem sets, this is the kind of method where accuracy matters more than memorizing a slogan. If you can trace the edge choices and justify each skip with cycle logic, you are already doing the core work the course asks for.

## Connections

### Minimum Spanning Tree

Kruskal's Algorithm is one way to find a minimum spanning tree, so you need the MST definition first. The tree must connect every vertex, use no cycles, and have the smallest total edge weight possible. If you do not know what counts as a spanning tree, Kruskal's steps will feel random instead of rule-based.

### Union-Find

Union-find is the data structure that makes Kruskal's Algorithm efficient. It tracks which vertices already belong to the same component, so you can check whether a new edge would create a cycle. Without it, you would have to do much slower cycle checks by hand or with repeated graph searches.

### [Borůvka's Algorithm](/combinatorics/key-terms/boruvkas-algorithm)

Borůvka's Algorithm is another minimum spanning tree method, but it grows the tree differently. Instead of sorting every edge once and moving upward like Kruskal's Algorithm, Borůvka's approach repeatedly adds the cheapest edge leaving each component. Comparing the two helps you see different greedy strategies for the same MST goal.

### [Minimum-weight edge lemma](/combinatorics/key-terms/minimum-weight-edge-lemma)

This lemma explains why picking a light edge can be safe in an MST argument. Kruskal's Algorithm depends on that same intuition, because it only accepts the smallest edge that does not create a cycle. When you justify a step in a proof, this is the kind of idea behind it.

## On the AP Exam

A problem set or quiz may give you a weighted graph and ask for the minimum spanning tree. You would sort the edges by weight, add the smallest edge that does not form a cycle, and continue until the graph is connected or you have a spanning forest. The real skill is not just listing the edges, it is explaining why each rejected edge was skipped.

If the graph is drawn as a table, adjacency matrix, or edge list, you still use the same logic. Students often lose points by picking a low-weight edge that closes a cycle too early, so checking component membership matters. If the graph is disconnected, be ready to say that Kruskal's Algorithm returns a minimum spanning forest instead of forcing one tree.

## Kruskal's Algorithm vs Prim's Algorithm

Both Kruskal's and Prim's Algorithm find minimum spanning trees, but they grow the solution differently. Kruskal's Algorithm sorts all edges and adds the next safe edge anywhere in the graph, while Prim's Algorithm grows outward from one starting vertex. If a question asks about edge sorting and cycle checks, it is usually Kruskal's.

## Key Takeaways

- Kruskal's Algorithm is a greedy method for finding a minimum spanning tree in a weighted, undirected graph.
- It works by sorting edges from smallest to largest and adding only the ones that do not create a cycle.
- Union-find is the usual tool for checking whether two vertices are already in the same component.
- The algorithm is especially efficient for sparse graphs, and its runtime is usually driven by edge sorting.
- If the graph is disconnected, the result is a minimum spanning forest, not one spanning tree.

## FAQs

### What is Kruskal's Algorithm in Combinatorics?

Kruskal's Algorithm is a greedy graph algorithm used to find a minimum spanning tree. It chooses edges in increasing order of weight and skips any edge that would create a cycle. In Combinatorics, it is a standard example of optimization with graphs.

### How does Kruskal's Algorithm avoid cycles?

It avoids cycles by checking whether the two endpoints of an edge are already connected through earlier choices. If they are in the same component, adding the edge would make a loop, so the edge is rejected. This is why union-find is so useful with the algorithm.

### What is the difference between Kruskal's Algorithm and Prim's Algorithm?

Both find minimum spanning trees, but Kruskal's Algorithm looks at all edges in increasing order and builds several components that merge over time. Prim's Algorithm starts from one vertex and expands a single tree outward. That difference is the easiest way to tell them apart on a graph problem.

### Does Kruskal's Algorithm work on disconnected graphs?

Yes, but the result is a minimum spanning forest instead of one spanning tree. Each connected component gets its own tree. That is a common detail to mention when a graph is not fully connected.

## Related Study Guides

- [10.2 Graph representations and isomorphisms](/combinatorics/unit-10/graph-representations-isomorphisms/study-guide/FJv3XHGcxSejl0yc)
- [16.3 Algorithmic complexity and analysis](/combinatorics/unit-16/algorithmic-complexity-analysis/study-guide/Y8YHqAUPzwpbhkKZ)
- [11.4 Trees and spanning trees](/combinatorics/unit-11/trees-spanning-trees/study-guide/cwgmh3HfhIBqK9KA)
- [14.2 Minimum spanning trees](/combinatorics/unit-14/minimum-spanning-trees/study-guide/te5wQ9BCYoD1fH5D)
- [16.4 Combinatorial aspects of data structures](/combinatorics/unit-16/combinatorial-aspects-data-structures/study-guide/w6GWahbuHeUwQxeC)

## About This Document

Canonical Fiveable pages are available as Markdown at the same path plus `.md`.

- [llms.txt](https://fiveable.me/llms.txt): index of Fiveable's sections and URL patterns
- [llms-full.txt](https://fiveable.me/llms-full.txt): complete subject and unit listing
- [MCP server](https://fiveable.me/mcp): call Fiveable as tools instead of fetching pages (`https://fiveable.me/api/mcp`)
- [MCP server for AP teachers](https://fiveable.me/mcp/teachers): a teacher's classes, assignments and AP-rubric grading (`https://fiveable.me/api/mcp/teacher`)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/combinatorics/key-terms/kruskals-algorithm#resource","name":"Kruskal's Algorithm | Combinatorics","url":"https://fiveable.me/combinatorics/key-terms/kruskals-algorithm","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/combinatorics/key-terms/kruskals-algorithm#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-07-03T02:21:06.613Z","isPartOf":{"@type":"Collection","name":"Combinatorics Key Terms","url":"https://fiveable.me/combinatorics/key-terms"},"author":{"@type":"Organization","@id":"https://fiveable.me/editorial#content-team","name":"Fiveable Content Team","url":"https://fiveable.me/editorial","parentOrganization":{"@id":"https://fiveable.me/#organization"},"member":[{"@type":"Person","name":"Amanda DoAmaral","sameAs":["https://www.linkedin.com/in/adoamaral"]},{"@type":"Person","name":"Becky Bahr","sameAs":["https://www.linkedin.com/in/becky-bahr-b52743132"]}]},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/combinatorics/key-terms/kruskals-algorithm#term","name":"Kruskal's Algorithm","description":"Kruskal's Algorithm is a method for finding a minimum spanning tree in a weighted graph by choosing edges from smallest to largest while skipping any edge that creates a cycle. In Combinatorics, it shows how greedy choices can build an optimal network.","url":"https://fiveable.me/combinatorics/key-terms/kruskals-algorithm","inDefinedTermSet":{"@type":"DefinedTermSet","name":"Combinatorics Key Terms","url":"https://fiveable.me/combinatorics/key-terms"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is Kruskal's Algorithm in Combinatorics?","acceptedAnswer":{"@type":"Answer","text":"Kruskal's Algorithm is a greedy graph algorithm used to find a minimum spanning tree. It chooses edges in increasing order of weight and skips any edge that would create a cycle. In Combinatorics, it is a standard example of optimization with graphs."}},{"@type":"Question","name":"How does Kruskal's Algorithm avoid cycles?","acceptedAnswer":{"@type":"Answer","text":"It avoids cycles by checking whether the two endpoints of an edge are already connected through earlier choices. If they are in the same component, adding the edge would make a loop, so the edge is rejected. This is why union-find is so useful with the algorithm."}},{"@type":"Question","name":"What is the difference between Kruskal's Algorithm and Prim's Algorithm?","acceptedAnswer":{"@type":"Answer","text":"Both find minimum spanning trees, but Kruskal's Algorithm looks at all edges in increasing order and builds several components that merge over time. Prim's Algorithm starts from one vertex and expands a single tree outward. That difference is the easiest way to tell them apart on a graph problem."}},{"@type":"Question","name":"Does Kruskal's Algorithm work on disconnected graphs?","acceptedAnswer":{"@type":"Answer","text":"Yes, but the result is a minimum spanning forest instead of one spanning tree. Each connected component gets its own tree. That is a common detail to mention when a graph is not fully connected."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Combinatorics","item":"https://fiveable.me/combinatorics"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/combinatorics/key-terms"},{"@type":"ListItem","position":3,"name":"Unit 10","item":"https://fiveable.me/combinatorics/unit-10"},{"@type":"ListItem","position":4,"name":"Kruskal's Algorithm"}]}]}
```
