Esc
  • Loading…
↑ ↓ to moveEnter to openEsc to close

Graph

Learn what a graph is, how to store and walk one, then master the 12 graph patterns — from flood fill to Dijkstra and Tarjan — through the interview questions asked most.

  • 4 Lessons
  • 23 Problems
  • 55 Illustrations

What you will learn

  • What a graph is — vertices, edges, directed, weighted — and why maps, networks and dependencies are all graphs
  • How to store a graph as an adjacency list or matrix, and how a grid is a graph in disguise
  • BFS and DFS, the two ways to walk any graph, in JavaScript, Python, Java and C++
  • How to spot a graph problem and pick the right pattern from its wording
  • 12 patterns from easiest to hardest: flood fill, multi-source BFS, cycles, topological sort, union-find, Dijkstra, Bellman-Ford, MST, Floyd-Warshall and bridges
  • The graph questions interviews ask most, each with a dry-run simulator

Why this course

Graphs are everywhere: roads between cities, friends in a network, courses that unlock other courses, pages that link to pages. Learn to see a problem as dots joined by lines and a whole family of interview questions becomes the same few moves.

The introduction is short on purpose: what a graph is, how to store it, how BFS and DFS walk it, and how to recognise a graph problem. Every later lesson builds on those four.

Then come 12 patterns, from easiest to hardest — each taught through the interview questions that use it, with code in four languages, the complexity of every approach and a simulator you can step through.

Requirements

  • Comfort writing loops, conditionals, functions and recursion in at least one language
  • The Queue and Stack courses help: BFS walks a graph with a queue, DFS with a stack
  • For the weighted patterns (Dijkstra, Prim), the Heap course explains the priority queue they use

Course Contents