# Graphs

Cities and roads, friends and followers: what a graph is, two ways to store one, and searching it level by level like ripples or deep first like a maze.

Updated: November 17, 2026

## [Graphs](https://www.ask-codey.com/courses/data-structures/topics/ds-graphs)

1. [Who Knows Whom? When Anything Can Connect: Graphs](https://www.ask-codey.com/lessons/ds-graphs) (Journeyman): Find a person's friends in one step, in a network where anyone can know anyone and friendships loop back around: why a list of pairs and a tree both fall short, and the structure that fits, the graph, with one-way and two-way connections and weights.
2. [Are These Two Friends? Adjacency Lists and Grids](https://www.ask-codey.com/lessons/ds-graph-representations) (Journeyman): Answer "are these two already friends?" in one step without running out of memory, before every Add friend button: why reading a friend list and a box for every pair both fall short at a million people, and how to choose between an adjacency list, a set per person and an adjacency matrix.

## [Searching a Graph](https://www.ask-codey.com/courses/data-structures/topics/ds-searching-a-graph)

1. [How Many Steps Apart? Breadth-First Search](https://www.ask-codey.com/lessons/ds-bfs) (Journeyman): Find how many friendships apart two people are, the fewest, without listing every route or walking in circles: why both of those fail, and the search that fixes them, breadth-first search, with a queue and a visited set.
2. [Who Can I Reach? Depth-First Search](https://www.ask-codey.com/lessons/ds-dfs) (Journeyman): Find everyone a person can reach through friends, and split a network into the groups that don't touch, with a short recursive walk that never goes round in circles: why the folder walk from Module 3 loops forever here, and the search that fixes it, depth-first search, and when to choose it over breadth-first search.

## [Exercise: Friends of Friends](https://www.ask-codey.com/courses/data-structures/topics/exercise-ds-friends-of-friends)

1. [Exercise: Friends of Friends](https://www.ask-codey.com/lessons/exercise-ds-friends-of-friends) (Journeyman): A small social app needs a "people you may know" box and a "how many steps apart?" line that stay fast in a town of 90,000 people: turn the app's list of friendships into something quick to search, write both features, and let the tests check them, the big town included.

Source: https://www.ask-codey.com/courses/data-structures/chapters/ds-graphs
