Graph Algorithms Ananth Grama, Anshul Gupta, George Karypis, and Vipin Kumar To accompany the text “Introduction to Parallel Computing”, Addison Wesley, 2003.
Topic Overview • Definitions and Representation • Minimum Spanning Tree: Prim’s Algorithm • Single-Source Shortest Paths: Dijkstra’s Algorithm • All-Pairs Shortest Paths • Transitive Closure • Connected Components • Algorithms for Sparse Graphs
Definitions and Representation • An undirected graph G is a pair (V, E), where V is a finite set of points called vertices and E is a finite set of edges. • An edge e ∈ E is an unordered pair (u, v), where u, v ∈ V . • In a directed graph, the edge e is an ordered pair (u, v). An edge (u, v) is incident from vertex u and is incident to vertex v. • A path from a vertex v to a vertex u is a sequence hv0, v1, v2, . . . , vk i of vertices where v0 = v, vk = u, and (vi, vi+1) ∈ E for i = 0, 1, . . . , k − 1. • The length of a path is defined as the number of edges in the path.
Definitions and Representation 5 2 e 3 4 6 6 5 4 3 f 2 1 (a) 1 (b) (a) An undirected graph and (b) a directed graph.