1. Array
Start your learning journey by understanding the most fundamental data structure.
2. Singly Linked List
Learn in-depth the most fundamental data structure in a programmer's life
6. Queue
Learn about the data structure that powers CPU and disk scheduling algorithms
7. Binary Tree
Learn all about the most critical data structure in computer science
What you will learn
How a graph models many-to-many relationships that arrays, lists, and trees cannot
Adjacency-list and adjacency-matrix representations, and when to pick one over the other
Cycle detection on directed and undirected graphs, plus DFS-based topological sort for DAGs
Dijkstra, Bellman-Ford, and Floyd-Warshall for weighted shortest paths
The max-flow / min-cut theorem via Ford-Fulkerson, and how it solves bipartite matching
The five graph patterns: DFS path enumeration, connected components, two-colouring, BFS shortest path, Dijkstra
Why this course
A 2D grid where each cell links to its four neighbours is a graph. A chain of words where two differ by one character is a graph. A list of build dependencies with one cycle in it is a graph. Recognising that, before reaching for a BFS template, is the actual skill an interviewer is testing. The pseudo-code for BFS and DFS is the easy half.
This course builds graphs from what they model up. You start with the only data structure that captures many-to-many relationships, walk through adjacency-list and adjacency-matrix representations, work through the classical algorithms (cycle detection, topological sort, Dijkstra, Bellman-Ford, Floyd-Warshall, Ford-Fulkerson, bipartite matching), and finish with the five problem-solving patterns that cover almost every graph question an interviewer will ask.
Requirements
The course assumes you can read code in any mainstream language and have seen recursion before. No prior graph experience is needed.
- Comfort with recursion and a rough mental model of the call stack.
- Familiarity with queues and stacks, plus basic Big-O notation (O(N), O(log N)).
- Either prior tree experience or willingness to learn traversal from scratch (the course teaches both).
Overview
A graph is the data structure for relationships. Every other data structure in this curriculum (arrays, linked lists, trees, hash tables) models one thing connected to one or two specific other things. A graph models one thing connected to anything else, in any direction, with any weight. Flight networks between cities, npm package dependencies, friendships in a social network, even a 2D grid where every cell points to its four neighbours, these are all graphs once you see the structure underneath.
Representation of a graph
The course covers both halves of the problem: how graphs are represented and traversed in memory, and how to recognise which of the five standard patterns a given interview problem fits into.
Fundamentals
The course opens with what a graph actually models. You see why arrays, linked lists, and trees cannot represent many-to-many relationships, then walk through the core terminology of vertex, edge, degree, indegree, outdegree, and path. From there you classify the seven flavours of graph you will encounter in interviews: directed, undirected, weighted, connected, cyclic, directed acyclic, and bipartite. Once that vocabulary is in place, you build the two representations from scratch. An adjacency matrix is an NxN grid where cell (i, j) marks an edge; an adjacency list stores a per-node neighbour list in a dynamic array. The weighted variants of each follow naturally, and the course shows when one representation beats the other on memory and locality of reference.
Traversal comes next. Depth-first and breadth-first search are taught on both abstract node-edge graphs and on grids, where each cell becomes a node identified by its row, col coordinates. Cycle detection follows directly from how DFS visits: a parent pointer is enough for undirected graphs, while directed graphs need both a visited set and a path set to flag back edges. Topological sort wraps the traversal block by showing how a DFS post-order reversal produces a valid dependency ordering on a DAG, the algorithm behind every build system and package manager.
The shortest-path block is the heaviest part of the course. You see why BFS only works on unweighted graphs, learn Dijkstra with a minimum priority queue for non-negative weights in O(E log N), hit the negative-edge case that breaks Dijkstra, then derive Bellman-Ford by relaxing every edge N - 1 times in O(N · E). Floyd-Warshall extends the same idea to all-pairs shortest path in O(N³) using a single intermediate-node loop. The fundamentals close with maximum flow via Ford-Fulkerson (including why reverse edges in the residual graph are necessary), the max-flow / min-cut theorem, and a reduction of maximum bipartite matching to a unit-capacity flow network.
Problem solving
After the algorithms come the patterns. Most graph problems you will see in an interview reduce to one of five templates. Once you recognise the template, you already know which traversal to reach for and what state to track on each visited node.
Each pattern is taught in three layers. First an Understanding lesson explains the technique on a problem where the pattern is obvious. Then an Identifying lesson teaches you the signals that tell you a new problem fits the template, the input format, the question being asked, and the constraints that point to a graph hiding behind a grid or a string puzzle. Then four problems give you progressively harder applications. The course finishes on Dijkstra-flavoured shortest-path problems, where the patterngrid lessons compound with the weighted-shortest-path block from the fundamentals.
How this course is different
Most graph material on the internet either races through BFS and DFS as one-line topics or stops before the algorithms that matter for systems work. This course does neither.
Who this course is for
The course suits anyone who needs to actually see the graph hiding in a problem, not just memorise BFS and DFS templates.
- New programmers who have written code but never modelled a real-world network as nodes and edges.
- Self-taught and bootcamp graduates who can write BFS on a textbook example but cannot spot a graph inside a grid or a word-ladder puzzle.
- Working developers who use graph databases or routing libraries day to day but cannot explain why Dijkstra fails on negative-weight edges.
- Engineers preparing for FAANG and Big Tech interviews, where graph questions (often disguised as grid or string problems) appear in nearly every onsite loop.
- Returning engineers who learned graph algorithms in university and want a refresher grounded in concrete patterns and identification signals.
- Anyone who has solved island-counting and word-ladder on autopilot without seeing the shared structure underneath.
Continue your DSA journey
Graphs sit at the intersection of nearly every other topic in this curriculum. After this course, several natural next steps deepen the foundation.
- Queue: BFS is a loop over a queue. The queue course covers the data structure and its implementations, which makes the BFS pattern's complexity claims concrete rather than abstract. It also explains why a deque is the right choice when you need O(1) pops from the front.
- Binary tree: A binary tree is a graph in disguise, an acyclic directed graph where every node has at most two children. Working through the binary tree course first makes graph traversal click faster, because BFS and DFS on a tree are the same algorithms without the cycle-detection bookkeeping. The DFS pattern in this course is the natural generalisation of recursive tree traversal.
- Heap: Dijkstra's algorithm depends entirely on a minimum priority queue, and the heap course shows you how that priority queue is built. Without it, the O(E log N) complexity claim stays a black box. Heaps also power top-K problems that frequently appear alongside graph questions.
- Recursion: DFS on a graph is recursion plus a visited set. If the call stack and base case still feel hazy, graph traversal will read like magic. The recursion course makes the mechanics explicit, which is the prerequisite for understanding why DFS-based topological sort works.
- Backtracking: Every DFS path-enumeration problem in this course (Hamiltonian Paths, Simple Cycles, Source to Target Paths) is a backtracking problem in graph clothing. The backtracking course teaches the unmark-on-exit mechanic that makes those problems work, with a much clearer treatment of when to undo state.
- Dynamic programming: Several graph problems cross over into DP territory. Floyd-Warshall is a DP recurrence on a 2D distance matrix, longest path in a DAG is solved by DP over a topological order, and edit distance is a graph traversal in disguise. Knowing both courses unlocks problems neither covers alone.
Frequently asked questions
list[list[int]], Java List>
, and C++ vector> so you can carry the algorithms into any language you write at work.