Cover of Introduction To Algorithms by Thomas H Cormen, Charles E Leiserson, Ronald L Rivest, Clifford Stein - Business and Economics Book

From "Introduction To Algorithms"

Author: Thomas H Cormen, Charles E Leiserson, Ronald L Rivest, Clifford Stein
Publisher: MIT Press
Year: 2001
Category: Computers

๐ŸŽง Free Preview Complete

You've listened to your free 10-minute preview.
Sign up free to continue listening to the full summary.

๐ŸŽง Listen to Summary

Free 10-min Preview
0:00
Speed:
10:00 free remaining
Chapter 6: VI Graph Algorithms
Key Insight 1 from this chapter

Representations of Graphs

Key Insight

Graphs can be represented using adjacency lists or adjacency matrices. Adjacency lists consist of an array `Adj` of `|V|` lists, one for each vertex, where `Adj[u]` contains all vertices `v` such that an edge `(u,v)` exists. This representation is compact and generally preferred for sparse graphs (where `|E|` is much less than `|V|ยฒ`), requiring `O(V+E)` memory. For a directed graph, the sum of adjacency list lengths is `|E|`; for an undirected graph, it is `2|E|`.

The adjacency-matrix representation uses a `|V| x |V|` matrix `A` where `a_ij = 1` if an edge `(i,j)` exists and `0` otherwise. This method is preferred for dense graphs (where `|E|` is close to `|V|ยฒ`) or when rapid determination of edge existence between two specific vertices is critical. It requires `O(Vยฒ) ` memory, regardless of the number of edges. For undirected graphs, the adjacency matrix `A` is symmetric, meaning `A = Aแต€`.

Both adjacency lists and adjacency matrices can represent weighted graphs by storing edge weights (e.g., `w(u,v)`) within the list entry or matrix cell. Algorithms often maintain attributes for vertices (e.g., `u:color`, `u:d`) and edges (e.g., `(u,v):f`), which can be implemented using parallel arrays or object-oriented structures. While adjacency lists are asymptotically more space-efficient for sparse graphs, matrices can be simpler for small graphs and require only one bit per entry for unweighted graphs.

๐Ÿ“š Continue Your Learning Journey โ€” No Payment Required

Access the complete Introduction To Algorithms summary with audio narration, key takeaways, and actionable insights from Thomas H Cormen, Charles E Leiserson, Ronald L Rivest, Clifford Stein.