Begin Algo
Data structures · 2 lessons

Graph RepresentationStoring a graph, and answering "connected?"

A graph is nodes and edges, and it can describe any problem about things being related. This topic is only about storage: when to use an adjacency list versus a matrix, and union-find, a structure built specifically for connectivity. The algorithms live under Graph Algorithms.

Why learn Graph Representation

Where it shows up
Friendships in a social network

A billion users with a few hundred friends each. An adjacency matrix would need 10¹⁸ cells; an adjacency list stores only the edges that exist.

→ Lesson: Adjacency List / Matrix
Is the network still connected?

Links between data centres come and go, and you need "can A still reach B?" at any moment. Union-find makes that almost constant time.

→ Lesson: Union-Find
Grouping faces in a photo library

Draw an edge between two similar faces, and each connected component ends up being one person. Union-find is the simplest clustering tool there is.

→ Lesson: Union-Find

Lessons

2 lessons