Graphs show up everywhere in computer science — often in places that don't look like graphs at first glance. Social networks, road maps, recommendation systems, dependency graphs, distributed systems. Once you learn to see graphs, you start seeing them everywhere. This post breaks down what graphs are, how we represent them in code, and the core traversal algorithms you need for interviews and real-world systems.
What is a graph?
A graph is a data structure made up of vertices (nodes) and edges that connect those vertices. Graphs are ideal for modeling relationships: