This preview shows pages 1–5. Sign up to view the full content.

Discussion #33 Chapter 7, Section 5.1-4 1/13 Discussion #33 Adjacency Lists; Breadth-First Search & Depth-First Search

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Discussion #33 Chapter 7, Section 5.1-4 2/13 Topics Adjacency list representation Dense & sparse graphs Breadth-First Search (BFS) Depth-First Search (DFS)
Discussion #33 Chapter 7, Section 5.1-4 3/13 Adjacency Lists For directed graphs: b a c 1 a 1 2 3 2 b 3 3 c 2 b c c b c b a a Simple Notation { (a,a), (a,b), (a,c), (b,c), (c,b) } 0 1 0 c 1 0 0 b 1 1 1 a c b a

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Discussion #33 Chapter 7, Section 5.1-4 4/13 Space: Adjacency Lists vs. Matricies Space ( n vertices and m edges) matrix: n 2 + n × (vertex-name size) = matrix size + header size matrix can be bits, but bits are not directly addressable list: n × (header-node size) + m × (list-node size) Sparse: few edges 0 in the extreme case Matrix fixed size: so no size benefit List variable size: as little as n × (vertex-node size) Dense: many edges n 2 in the extreme case Matrix fixed size: so no size loss List variable size: as much as n × (header-node size) + n 2 × (list-node size)
This is the end of the preview. Sign up to access the rest of the document.