About the Book
Graph Theory Through Problems teaches graph theory the way it sticks: by solving problems. It collects 300 exercises across 13 chapters, graded from routine checks of a definition to challenging proofs, and it gives a complete solution to every exercise.
Most textbooks end each chapter with a list of exercises and leave you alone with them. This book is built the other way around. The exercises are the main text, the harder ones come with hints so you can get unstuck without reading the whole answer, and the solutions show the full reasoning, not just the final result.
- 300 exercises, from quick checks to proofs that take real thought.
- Hints for every harder exercise, so you can try again before you look at the solution.
- Complete solutions to all 300 exercises.
- Algorithms run by hand, such as Dijkstra, Prim and Ford–Fulkerson, with every step shown in a table.
- Topics from trees and matchings to planar graphs and Ramsey theory.
It is meant to be used next to a textbook or a course, not instead of one. Read the theory in your course notes or in a book such as West's Introduction to Graph Theory, then come here to practise it until you can do it on your own.
Who It Is For
- Students in a first graph theory or discrete mathematics course who want more practice than the course gives, with answers they can check.
- Students preparing for an exam, who need to rehearse proofs and run algorithms by hand under time pressure.
- Self-learners who have read the definitions and want to find out whether they really understand them.
- Computer science students who know the algorithms as code and want the mathematical side: why they are correct, not only how to run them.
What the Problems Look Like
Here are two exercises in the style of the book, written for this page: a short proof with a hint, and an algorithm run by hand in a step table.
Every tree with at least two vertices has at least two leaves.
A leaf is a vertex of degree 1. Prove the statement for every tree with n ≥ 2 vertices.
Hint. Look at a longest path in the tree. What can you say about its two ends?
Show the solution
Let P = v0 v1 … vk be a longest path in the tree T. Since T is connected and has at least two vertices, it has an edge, so k ≥ 1 and the two ends v0 and vk are different.
Suppose v0 had a neighbour w other than v1. If w is not on P, then w v0 v1 … vk is a longer path, which contradicts the choice of P. If w = vi for some i ≥ 2, then v0 v1 … vi v0 is a cycle, which a tree cannot contain. So v0 has degree 1. The same argument applies to vk.
So v0 and vk are two different leaves. ∎
Run Dijkstra's algorithm from A on the graph below.
Hint. At each step, settle the unsettled vertex with the smallest tentative distance, then try to improve its neighbours.
Show the solution
Each row settles one vertex (marked *) and updates the tentative distances of its neighbours.
| Step | Settle | A | B | C | D | E |
|---|---|---|---|---|---|---|
| 0 | – | 0 | ∞ | ∞ | ∞ | ∞ |
| 1 | A | 0* | 4 | 2 | ∞ | ∞ |
| 2 | C | 3 | 2* | 10 | 12 | |
| 3 | B | 3* | 8 | 12 | ||
| 4 | D | 8* | 10 | |||
| 5 | E | 10* |
The shortest distances from A are B = 3, C = 2, D = 8 and E = 10. Following the updates backwards, the shortest route to E is A → C → B → D → E. Notice that the direct edge A–B (4) loses to the detour through C (2 + 1 = 3), and the direct edge C–E (10) loses to C → B → D → E (1 + 5 + 2 = 8). Spotting those two places is the point of the exercise.
Want to watch it run? Build this graph in the Dijkstra visualizer and step through it, or read the Dijkstra's algorithm guide.
Free Companions on This Site
The book works on paper. This site lets you see the same ideas move. While you work through an exercise, these free pages are a click away:
| Topic | Read | Watch it run |
|---|---|---|
| Trees | Trees in graph theory | DFS visualizer |
| Spanning trees | Minimum spanning trees | Prim visualizer |
| Shortest paths | Shortest path algorithms | Dijkstra visualizer |
| Matchings and bipartite graphs | Bipartite graphs | Bipartite check |
| Network flow | Max flow and min cut | Max flow visualizer |
| Planar graphs | Planar graphs | – |
| Colouring | Graph colouring | Colouring visualizer |
| Euler and Hamilton | Eulerian paths, Hamiltonian cycles | Euler path visualizer |
New to the subject? Start with the introduction to graph theory and the study roadmap.
Which of the Two Books Is for You?
Mohammed Islam Hadjoudj has written two graph books with different jobs. Pick by what you need to do next.
| Graph Theory Through Problems | Graph Algorithms for Coding Interviews | |
|---|---|---|
| Goal | Understand the theory and pass a graph theory course or exam | Solve graph questions in technical interviews |
| Contents | 300 exercises over 13 chapters | 100 solved interview problems |
| Support | Hints for the harder exercises and a complete solution to every one | A visual explanation and a Python solution for every problem |
| Style | Proofs, and algorithms run by hand in step tables | Code you can run and adapt |
| Formats | Kindle and paperback | Kindle and paperback |
About the Author
Frequently Asked Questions
Does every exercise have a solution?
Yes. All 300 exercises have a complete, worked solution, and the harder ones also have a hint, so you can try again before reading the answer.
Is Graph Theory Through Problems good for beginners?
It is written for a first course. The exercises start with routine checks of the definitions and build up to challenging proofs, so a beginner can start at the top of each chapter. It works best next to a textbook or course notes.
What topics does the book cover?
It runs across 13 chapters, from trees and matchings to planar graphs and Ramsey theory, and it includes algorithms such as Dijkstra, Prim and Ford-Fulkerson worked by hand in step tables.
Is it available on Kindle?
Yes. The book is available as a Kindle ebook and as a paperback on Amazon.
Who wrote Graph Theory Through Problems?
Mohammed Islam Hadjoudj, who holds a Master's degree in Operations Research and a Bachelor's degree in Mathematics and created the Learn Graph Theory website.
Disclosure: this page is written by the author of the book, who also runs this site. Example problems on this page were written for this page to show the style of the book.
