Elementary graph algorithms Chapter 22

Slides:



Advertisements
Similar presentations
Graph Algorithms Algorithm Design and Analysis Victor AdamchikCS Spring 2014 Lecture 11Feb 07, 2014Carnegie Mellon University.
Advertisements

What is a graph ? G=(V,E) V = a set of vertices E = a set of edges edge = unordered pair of vertices
Graphs - II Algorithms G. Miller V. Adamchik CS Spring 2014 Carnegie Mellon University.
Elementary Graph Algorithms Depth-first search.Topological Sort. Strongly connected components. Chapter 22 CLRS.
Theory of Computing Lecture 6 MAS 714 Hartmut Klauck.
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture eight Dr. Hamdy M. Mousa.
More Graphs COL 106 Slides from Naveen. Some Terminology for Graph Search A vertex is white if it is undiscovered A vertex is gray if it has been discovered.
CSE 2331/5331 Topic 11: Basic Graph Alg. Representations Undirected graph Directed graph Topological sort.
Graph Traversals Visit vertices of a graph G to determine some property: Is G connected? Is there a path from vertex a to vertex b? Does G have a cycle?
Graph Searching (Graph Traversal) Algorithm Design and Analysis Week 8 Bibliography: [CLRS] – chap 22.2 –
MCA 202: Discrete Structures Instructor Neelima Gupta
Applications of graph traversals
Applications of DFS: Articulation Points and Biconnected Components
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
CPSC 311, Fall CPSC 311 Analysis of Algorithms Graph Algorithms Prof. Jennifer Welch Fall 2009.
Graphs Intro G.Kamberova, Algorithms Graphs Introduction Gerda Kamberova Department of Computer Science Hofstra University.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Chapter 23: Graph Algorithms Chapter 24: Minimum Spanning Trees.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2001 Makeup Lecture Chapter 23: Graph Algorithms Depth-First SearchBreadth-First.
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lectures 3 Tuesday, 9/25/01 Graph Algorithms: Part 1 Shortest.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2008 Lecture 4 Tuesday, 9/30/08 Graph Algorithms: Part 1 Shortest.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Connected Components, Directed Graphs, Topological Sort COMP171.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 9 Instructor: Paul Beame.
Graph Algorithms: Part 1
Tirgul 11 BFS,DFS review Properties Use. Breadth-First-Search(BFS) The BFS algorithm executes a breadth search over the graph. The search starts at a.
Connected Components, Directed Graphs, Topological Sort Lecture 25 COMP171 Fall 2006.
CS344: Lecture 16 S. Muthu Muthukrishnan. Graph Navigation BFS: DFS: DFS numbering by start time or finish time. –tree, back, forward and cross edges.
Lecture 15: Depth First Search Shang-Hua Teng. Graphs G= (V,E) B E C F D A B E C F D A Directed Graph (digraph) –Degree: in/out Undirected Graph –Adjacency.
Connected Components, Directed graphs, Topological sort COMP171 Fall 2005.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
Tirgul 7 Review of graphs Graph algorithms: – BFS (next tirgul) – DFS – Properties of DFS – Topological sort.
Review of Graphs A graph is composed of edges E and vertices V that link the nodes together. A graph G is often denoted G=(V,E) where V is the set of vertices.
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
Jim Anderson Comp 122, Fall 2003 Single-source SPs - 1 Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
Spring 2015 Lecture 10: Elementary Graph Algorithms
Chapter 2 Graph Algorithms.
Elementary Graph Algorithms CLRS Chapter 22. Graph A graph is a structure that consists of a set of vertices and a set of edges between pairs of vertices.
Graphs.
Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph. Want to compute a shortest path for each possible.
Lecture 11 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
Jan Topological Order and SCC Edge classification Topological order Recognition of strongly connected components.
1 Chapter 22 Elementary Graph Algorithms. 2 Introduction G=(V, E) –V = vertex set –E = edge set Graph representation –Adjacency list –Adjacency matrix.
 2004 SDU Lectrue4-Properties of DFS Properties of DFS Classification of edges Topological sort.
Chapter 22: Elementary Graph Algorithms
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 20.
Topological Sort: Definition
CS 2133: Algorithms Intro to Graph Algorithms (Slides created by David Luebke)
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 5.
Graphs 2015, Fall Pusan National University Ki-Joune Li.
1 Chapter 22: Elementary Graph Algorithms III. 2 About this lecture Topological Sort.
CSE 421 Algorithms Richard Anderson Autumn 2015 Lecture 5.
CS 361 – Chapter 13 Graph Review Purpose Representation Traversal Comparison with tree.
CSC317 1 At the same time: Breadth-first search tree: If node v is discovered after u then edge uv is added to the tree. We say that u is a predecessor.
Chapter 22: Elementary Graph Algorithms Overview: Definition of a graph Representation of graphs adjacency list matrix Elementary search algorithms breadth-first.
Trees.
Introduction to Algorithms
Chapter 22 Elementary Graph Algorithms
Graph Algorithms Using Depth First Search
Graph Algorithm.
Lecture 10 Algorithm Analysis
Elementary graph algorithms Chapter 22
Data Structures and Algorithms (AT70. 02) Comp. Sc. and Inf. Mgmt
Richard Anderson Autumn 2016 Lecture 5
Chapter 24: Single-Source Shortest Paths
Chapter 24: Single-Source Shortest Paths
Elementary graph algorithms Chapter 22
Richard Anderson Lecture 5 Graph Theory
Richard Anderson Winter 2019 Lecture 5
Presentation transcript:

Elementary graph algorithms Chapter 22 Slide Sources: CLRS “Intro. To Algorithms” book website (copyright McGraw Hill) adapted and supplemented

Representation of graphs 2 representations of an undirected graph Space Query: is (i,j) in E? (b) Adjacency-list representation O(n+m) not O(1) time (c) Adjacency-matrix representation O(n^2) O(1) time

2 representations of a directed graph (b) Adjacency-list representation (c) Adjacency-matrix representation

BFS pseudo-code

Breadth-first-search BFS on an undirected graph. Compute into d(v) distance from source node s. Initially d(v)=‘infinity’. Shawn: queue Q in the beginning of an iteration, tree edges as produced by BFS (shaded), and d(v) correction

Analysis: shortest-path correctness delta(s,v) – the shortest distance from node s to node v in graph G(V,E) counting edges Theorem: At the end of BFS, d(v) = delta(s,v) [Lemma: If (u,v) is in E then delta(s,v) <= delta(s,u)+1] [Lemma: At the end of BFS, d(v) >= delta(s,v) Proof: By induction on the steps of BFS, if following any step of BFS d(v) < ‘inifinity’ then there exists a path from s to v with d(v) edges. ] Inductive claim on i: If d(v) <= i, then at the end of BFS, delta(s,v) = d(v) If delta(s,v) <= i, then at the end of BFS, delta(s,v) = d(v)

Analysis: complexity Method: Charging each operation to a vertex or an edge Upper bound the maximum number of charges per vertex and per edge Since constant, adjacency-list input  O(n+m) time. u s (u,v) v

Reconstructing path from s to v: The BFS tree

Dept-first search (DFS) Initialize and initiate DFS

The recursive call d(v) – discovery time f(v) – finish time

Properties of DFS Undirected graphs - 2 types of edges: - Tree edges - Back edges Directed graphs – 2 more: Forward edges Cross edges

Complexity Revisit: - Charging scheme - Resulting complexity

Topological sort Input: directed acyclic graph (DAG) representing ‘partial order’. Sort in a way which is compatible with partial order. Unconvincing example of DFS. More intuitive algorithm: Peel in-degree=0 nodes Repeat

Programming project Around the “peeling zero-indegree nodes” algorithm Motivation Attempted definition of computer engineering Old (obsolete) concept: HW versus CS, which is SW Proposal: Theory, algorithms, software, architecture, tools, applications and practice in computing that can be methodically validated and their validation, whether analytical, experimental, or a combination thereof. Underlined: ENEE641 Italics: programming project

DAG for topological sort

Undirected connected graph G(V,E): Articulation points, bridges and biconnected components. Ex 22-2 Root of DFS is an articulation point if and only if it has at least 2 children in the DFS tree Let v be a non-root of the DFS tree. v is an articulation point if it has a child s such that there is no back edge from s or any of its descendants to an ancestor of v. low(v) is the minimum of: d(v) and d(w), where (u,w) is a back edge from a descendant u of v. How to compute low(v) for all nodes v in linear time? The next slides explain why for this class bridges are also biconnected components 4. How to compute all articulation points in linear time? 5. How to compute all bridges in linear time? 6. Define biconnectivity* as a binary relation on edges: e1Re2 if they lie on a simple cycle, or e1=e2. Prove that R is an equivalence relation.

Clarification to definition of biconnected components * The prior slide defines biconnectivity as a binary relation on edges, which is an equivalence relation. This extends to biconnected components by including all the vertices that touch on the edges of an equivalence class. This definition implies that a single bridge is an equivalence class of one edge (or a biconnected component of 2 vertices). In contrast, Problem 22-2 in the textbook defines biconnected component as "a maximal set of edges such that any two edges in the set lie on a common simple cycle"; indeed item g seeks proof that the biconnected components of a graph partition only its non-bridge edges. In ENEE641 students should follow the definition in the slides, or in Wikipedia http://en.wikipedia.org/wiki/Biconnected_component, but not the one in the text.

Euler tour An Euler tour of a connected undirected graph G(V,E) is a cycle that traverses each edge of G exactly once. Show that G has an Euler tour if and only if the degree of every vertex is an even number. Describe an O(|E|) time algorithm to find the Euler tour of G if one exists. Comments 1. Important routine for “next generation sequencing. 2. Euler tour for directed graphs is defined in Problem 22-3.

Transition Parallelism of graph algorithms Also, why performance implementation is challenging and desirable http://www.yarcdata.com/files/product-brief/Urika%20Product%20Brief.pdf