Richard Anderson Lecture 5 Graph Theory

Slides:



Advertisements
Similar presentations
Introduction to Algorithms Graph Algorithms
Advertisements

Chapter 8 Topics in Graph Theory
Lecture 16: DFS, DAG, and Strongly Connected Components Shang-Hua Teng.
Algorithms and Data Structures
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
1 Data Structures DFS, Topological Sort Dana Shapira.
Lecture 10 Topics Application of DFS Topological Sort
Is the following graph Hamiltonian- connected from vertex v? a). Yes b). No c). I have absolutely no idea v.
CSE 421 Algorithms Richard Anderson Lecture 4. What does it mean for an algorithm to be efficient?
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.
CSE 421 Algorithms Richard Anderson Lecture 10 Minimum Spanning Trees.
CSE 321 Discrete Structures Winter 2008 Lecture 25 Graph Theory.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 14 Strongly connected components Definition and motivation Algorithm Chapter 22.5.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 11 Instructor: Paul Beame.
Lecture 11 CSE 331 Sep 25, Homeworks Please hand in your HW 2 now HW 3 and graded HW 1 at the end of class.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Introduction to Graphs. Introduction Graphs are a generalization of trees –Nodes or verticies –Edges or arcs Two kinds of graphs –Directed –Undirected.
© 2004 Goodrich, Tamasia Recall: Digraphs A digraph is a graph whose edges are all directed Short for “directed graph” Applications one-way streets flights.
Lecture 11 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
CSEP 521 Applied Algorithms Richard Anderson Winter 2013 Lecture 2.
Lecture 5 CSE 331. Graphs Problem Statement Algorithm Problem Definition “Implementation” Analysis A generic tool to abstract out problems.
CSE 421 Algorithms Richard Anderson Winter 2009 Lecture 5.
Introduction to Graph Theory
CSE 421 Algorithms Richard Anderson Autumn 2015 Lecture 5.
Graph Terms By Susan Ott. Vertices Here are 7 vertices without any edges Each Vertex is labeled a different color and number.
Leda Demos By: Kelley Louie Credits: definitions from Algorithms Lectures and Discrete Mathematics with Algorithms by Albertson and Hutchinson graphics.
Certifying Algorithms [MNS11]R.M. McConnell, K. Mehlhorn, S. Näher, P. Schweitzer. Certifying algorithms. Computer Science Review, 5(2), , 2011.
Graph Search Applications, Minimum Spanning Tree
Introduction to Algorithms
Breadth-First Search (BFS)
Directed Graphs Directed Graphs Shortest Path 12/7/2017 7:10 AM BOS
Directed Graphs 12/7/2017 7:15 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Chapter 22 Elementary Graph Algorithms
Graphs Representation, BFS, DFS
Main algorithm with recursion: We’ll have a function DFS that initializes, and then calls DFS-Visit, which is a recursive function and does the depth first.
School of Computing Clemson University Fall, 2012
Richard Anderson Lecture 29 NP-Completeness and course wrap-up
GRAPHS Lecture 16 CS2110 Fall 2017.
CSE 2331/5331 Topic 9: Basic Graph Alg.
Lecture 12 Graph Algorithms
Directed Graphs 9/20/2018 1:45 AM Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia,
Directed Graphs 5/1/15 12:25:22 PM
Directed Graphs Directed Graphs 1 Shortest Path Shortest Path
Graph Search Applications
Planarity Testing.
CSE 421: Introduction to Algorithms
Lecture 10 Algorithm Analysis
Advanced Algorithms Analysis and Design
Richard Anderson Lecture 4
Elementary graph algorithms Chapter 22
"Learning how to learn is life's most important skill. " - Tony Buzan
CSE 373 Data Structures and Algorithms
Topological Sort CSE 373 Data Structures Lecture 19.
Richard Anderson Lecture 30 NP-Completeness
Richard Anderson Autumn 2016 Lecture 5
Directed Graphs Directed Graphs Directed Graphs 2/23/ :12 AM BOS
Richard Anderson Autumn 2016 Lecture 7
Richard Anderson Winter 2009 Lecture 6
Autumn 2016 Lecture 10 Minimum Spanning Trees
CSE 417: Algorithms and Computational Complexity
GRAPHS Lecture 17 CS2110 Spring 2018.
Elementary graph algorithms Chapter 22
Richard Anderson Winter 2019 Lecture 6
Winter 2019 Lecture 10 Minimum Spanning Trees
Lecture 11 Graph Algorithms
Richard Anderson Winter 2019 Lecture 5
Richard Anderson Autumn 2015 Lecture 6
Presentation transcript:

Richard Anderson Lecture 5 Graph Theory CSE 421 Algorithms Richard Anderson Lecture 5 Graph Theory

Bipartite A graph is bipartite if its vertices can be partitioned into two sets V1 and V2 such that all edges go between V1 and V2 A graph is bipartite if it can be two colored

Theorem: A graph is bipartite if and only if it has no odd cycles If a graph has an odd cycle it is not bipartite If a graph does not have an odd cycle, it is bipartite

Lemma 1 If a graph contains an odd cycle, it is not bipartite

Lemma 2 If a BFS tree has an intra-level edge, then the graph has an odd length cycle Intra-level edge: both end points are in the same level

Lemma 3 If a graph has no odd length cycles, then it is bipartite No odd length cycles implies no intra-level edges No intra-level edges implies two colorability

Connected Components Undirected Graphs

Computing Connected Components in O(n+m) time A search algorithm from a vertex v can find all vertices in v’s component While there is an unvisited vertex v, search from v to find a new component

Directed Graphs A Strongly Connected Component is a subset of the vertices with paths between every pair of vertices.

Identify the Strongly Connected Components There is an O(n+m) algorithm that we will not be covering

Strongly connected components can be found in O(n+m) time But it’s tricky! Simpler problem: given a vertex v, compute the vertices in v’s scc in O(n+m) time

Topological Sort Given a set of tasks with precedence constraints, find a linear order of the tasks 321 322 401 142 143 341 326 421 370 431 378

Find a topological order for the following graph J C F K B L

If a graph has a cycle, there is no topological sort Consider the first vertex on the cycle in the topological sort It must have an incoming edge A F B E C D

Lemma: If a graph is acyclic, it has a vertex with in degree 0 Proof: Pick a vertex v1, if it has in-degree 0 then done If not, let (v2, v1) be an edge, if v2 has in-degree 0 then done If not, let (v3, v2) be an edge . . . If this process continues for more than n steps, we have a repeated vertex, so we have a cycle

Topological Sort Algorithm While there exists a vertex v with in-degree 0 Output vertex v Delete the vertex v and all out going edges H E I A D G J C F K B L

Details for O(n+m) implementation Maintain a list of vertices of in-degree 0 Each vertex keeps track of its in-degree Update in-degrees and list when edges are removed m edge removals at O(1) cost each