algoritmauzmanı
Sign in
TREN
Subtopic 8.2

Graph with Adjacency Lists

6lessons39 min0done

With adjacency lists each vertex keeps only the neighbours it really has, in a linked list. In sparse graphs with few edges, the room a matrix spends on empty cells disappears; memory grows with the number of vertices and edges.

The operations from the matrix lessons are repeated in the same order with the same names; since neighbours are kept sorted from small to large, BFS and DFS give the same output. The last lesson compares the two layouts.

Lesson 8.2.1 A graph of lists: creating it6 min