CS223 Advanced Data Structures and Algorithms Graph Neil Tang 02/25/2010 CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms Class Overview Basic concepts Applications Adjacency matrix Adjacency list CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms Basic Concepts Graph (V, E) CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms Basic Concepts Directed graph (digraph) Undirected graph Path: a sequence of vertices and edges (w1,w2, …,wn) Simple path: all vertices are distinct except the first and the last that could be the same. Cycle: a path (w1,w2, …,wn) with w1 = wn Directed Acyclic Graph (DAG) CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms Basic Concepts Connected undirected graph Strongly/weakly connected digraph Complete graph CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms Applications Airport system Transportation system Computer network Digital maps CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms Adjacency Matrix VID 1 2 3 4 5 6 7 1 0 1 1 1 0 0 0 2 0 0 0 1 1 0 0 3 0 0 0 0 0 1 0 4 0 0 1 0 0 1 1 5 0 0 0 1 0 0 1 6 0 0 0 0 0 0 0 0 0 0 0 0 1 0 Weighted graph? Space: (|V|2) CS223 Advanced Data Structures and Algorithms
CS223 Advanced Data Structures and Algorithms Adjacency List Space: O(|V|+|E|) CS223 Advanced Data Structures and Algorithms