Learn graph fundamentals, BFS, DFS, shortest paths and classic graph algorithms through simple practice challenges.
A graph is a collection of vertices connected by edges. It is useful for representing relationships between objects.
An individual node or object in a graph.
A connection between two vertices.
A value such as distance, cost or time stored on an edge.
Each vertex stores its connected neighbors. Great for sparse graphs.
0 → 1, 2 1 → 0, 3 2 → 0 3 → 1
A 2D matrix stores whether an edge exists between every pair.
0 1 2 0 0 1 1 1 1 0 0 2 1 0 0
Edges have a direction. A → B does not necessarily mean B → A.
Edges have no direction. A connected to B means B is connected to A.
Choosing the right traversal is one of the most important graph skills.
Uses a queue and explores level by level. Useful for shortest paths in unweighted graphs.
Uses recursion or a stack and explores one path deeply before backtracking.
Tracks visited vertices so nodes are not processed repeatedly.
Watch the concept lesson, then return to practice.