FUNDAMENTAL PROBLEMS AND ALGORITHMS Graph Theory and Combinational © Giovanni De Micheli Stanford University.

Slides:



Advertisements
Similar presentations
Graphs and Finding your way in the wilderness
Advertisements

22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
Greedy Algorithms Greed is good. (Some of the time)
Techniques for Dealing with Hard Problems Backtrack: –Systematically enumerates all potential solutions by continually trying to extend a partial solution.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
The Theory of NP-Completeness
5-1 Chapter 5 Tree Searching Strategies. 5-2 Satisfiability problem Tree representation of 8 assignments. If there are n variables x 1, x 2, …,x n, then.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Fundamentals of Python: From First Programs Through Data Structures
Chapter 3 The Greedy Method 3.
Graph Algorithms: Minimum Spanning Tree We are given a weighted, undirected graph G = (V, E), with weight function w:
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Approximation Algorithms Lecture for CS 302. What is a NP problem? Given an instance of the problem, V, and a ‘certificate’, C, we can verify V is in.
Implicit Hitting Set Problems Richard M. Karp Harvard University August 29, 2011.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
FUNDAMENTAL PROBLEMS AND ALGORITHMS  Giovanni De Micheli Stanford University Branch and Bound.
Ch 13 – Backtracking + Branch-and-Bound
Tirgul 13. Unweighted Graphs Wishful Thinking – you decide to go to work on your sun-tan in ‘ Hatzuk ’ beach in Tel-Aviv. Therefore, you take your swimming.
COE 561 Digital System Design & Synthesis Resource Sharing and Binding Dr. Aiman H. El-Maleh Computer Engineering Department King Fahd University of Petroleum.
SCHEDULING SOURCES- Mark Manwaring Kia Bazargan Giovanni De Micheli Gupta Youn-Long Lin M. Balakrishnan Camposano, J. Hofstede, Knapp, MacMillen Lin.
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
CISC220 Fall 2009 James Atlas Nov 13: Graphs, Line Intersections.
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
Backtracking.
CSE 589 Applied Algorithms Spring Colorability Branch and Bound.
Spring 2010, Feb 10...ELEC 7770: Advanced VLSI Design (Agrawal)1 ELEC 7770 Advanced VLSI Design Spring 2010 Constraint Graph and Retiming Solution Vishwani.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
IS 2610: Data Structures Graph April 5, 2004.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
NP-Completeness: 3D Matching
Approximation Algorithms for NP-hard Combinatorial Problems Magnús M. Halldórsson Reykjavik University
Chapter 2 Graph Algorithms.
Chapter 14 Graphs. © 2004 Pearson Addison-Wesley. All rights reserved Terminology G = {V, E} A graph G consists of two sets –A set V of vertices,
1 ELEC692 Fall 2004 Lecture 1b ELEC692 Lecture 1a Introduction to graph theory and algorithm.
A Clustering Algorithm based on Graph Connectivity Balakrishna Thiagarajan Computer Science and Engineering State University of New York at Buffalo.
CSE332: Data Abstractions Lecture 24.5: Interlude on Intractability Dan Grossman Spring 2012.
Chap 10. Integer Prog. Formulations
Data Structures & Algorithms Graphs
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Unit 9: Coping with NP-Completeness
Single-Source Shortest Path
Implicit Hitting Set Problems Richard M. Karp Erick Moreno Centeno DIMACS 20 th Anniversary.
CS 61B Data Structures and Programming Methodology Aug 5, 2008 David Sun.
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
© 2006 Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs.
Introduction to Graph Theory By: Arun Kumar (Asst. Professor) (Asst. Professor)
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Data Structures and Algorithm Analysis Graph Algorithms Lecturer: Jing Liu Homepage:
CS 721 Project Implementation of Hypergraph Edge Covering Algorithms By David Leung ( )
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
The Theory of NP-Completeness
Vishwani D. Agrawal James J. Danaher Professor
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
The Taxi Scheduling Problem
Graphs Chapter 13.
Graphs Part 2 Adjacency Matrix
CSCI2100 Data Structures Tutorial
Graphs and Vertex Coloring
Autumn 2016 Lecture 10 Minimum Spanning Trees
The Theory of NP-Completeness
Winter 2019 Lecture 11 Minimum Spanning Trees (Part II)
Chapter 14 Graphs © 2011 Pearson Addison-Wesley. All rights reserved.
Winter 2019 Lecture 10 Minimum Spanning Trees
Richard Anderson Winter 2019 Lecture 5
Autumn 2019 Lecture 11 Minimum Spanning Trees (Part II)
Presentation transcript:

FUNDAMENTAL PROBLEMS AND ALGORITHMS Graph Theory and Combinational © Giovanni De Micheli Stanford University

Shortest/Longest path problem Single-source shortest path problemSingle-source shortest path problem. Model: G (V, E) N –Directed graph G (V, E) with N vertices. –Weights on each edge. –A source vertex. Single-source shortest path problem. –Find shortest path from the source to any vertex. –Inconsistent problem: Negative-weighted cycles.

Shortest path problem Acyclic graphs: O(N 2 ). –Topological sort O(N 2 ). –- All positive weights: – Dijkstra’s algorithm. Bellman’s equations: G (V, E) N G (V, E) with N vertices

Dijkstra’s algorithm DIJKSTRA(G(V, E, W)) { s 0 =0; for (i =1 to N) s i = w 0,i, repeat { select unmarked v q such that s q is minimal; mark v q ; foreach (unmarked vertex v i ) s i = min {s i, ( s q +w q, i )}, } until (all vertices are marked) } Apply to Korea’s map, robot tour, etc G (V, E) N G (V, E) with N vertices

Bellman-Ford’s algorithm BELLMAN_FORD(G(V, E, W)) { s 1 0 = 0; for (i = 1 to N) s 1 i =w 0, i ; for (j =1 to N){ for (i =1 to N){ s j+1 i = min { s j i, (s j k +w q, i )}, } if (s j+1 i == s j i  i ) return (TRUE) ; } return (FALSE) } kiki

Longest path problem Use shortest path algorithms: – by reversing signs on weights. Modify algorithms: – by changing min with max. Remarks: – Dijkstra’s algorithm is not relevant. – Inconsistent problem: Positive-weighted cycles.

Example – Bellman-Ford Iteration 1: l 0 =0, l 1 =3, l 2 = 1, l 3 = . Iteration 2: l 0 =0, l 1 =3, l 2 =2, l 3 =5. Iteration 3: l 0 =0, l 1 =3, l 2 =2, l 3 =6. Use shortest path algorithms: by reversing signs on weights. source

Liao-Wong’s algorithm LIAO WONG(G( V, E  F, W)) { for ( i = 1 to N) l 1 i = 0; { for ( j = 1 to |F|+ 1) { foreach vertex v i l j+ 1 i = longest path in G( V, E,W E ) ; flag = TRUE; foreach edge ( v p, v q )  F { if ( l j+ 1 q < l j+ 1 p + w p,q ){ flag = FALSE; E = E  ( v 0, v q ) with weight ( l j+ 1 p + w p,q ) } if ( flag ) return (TRUE) ; } } return (FALSE) } adjust

Example – Liao-Wong Iteration 1:Iteration 1: l 0 = 0, l 1 = 3, l 2 = 1, l 3 = 5. Adjust: add edge (v 0, v 1 ) with weight 2. Iteration 2:Iteration 2: l 0 = 0, l 1 = 3, l 2 = 2, l 3 = 6. Only positive edges from (a) (b) adjusted by adding longest path from node 0 to node 2 Looking for longest path from node 0 to node 3

Vertex cover Given a graph G(V, E) –Find a subset of the vertices covering all the edges. Intractable problem. Goals: –Minimum cover. –Irredundant cover: No vertex can be removed.

Example

Heuristic algorithm vertex based VERTEX_COVERV(G(V; E)) { C =  ;  while ( E   ) do { select a vertex v  V; delete v from G(V, E) ; C= C  { f v } ; }

Heuristic algorithm edge based E VERTEX_COVERE(G(V, E)) { C =  ;  while ( E   ) do { select an edge {u, v}  E; C= C  {u, v }; delete from G(V, E) any edge incident to either u or v ; }

Graph coloring Vertex labeling (coloring): –No edge has end-point with the same label. Intractable on general graphs. Polynomial-time algorithms for chordal (and interval) graphs: –Left-edge algorithm.

Graph coloring heuristic algorithm VERTEX_COLOR(G(V, E)) { for (i =1 to |V| ) { c =1 v i while (  a vertex adjacent to v i with color c) do { c = c +1; color v i with color c ; }

Graph coloring exact algorithm EXACT_COLOR( G( V, E), k) { repeat { NEXT VALUE( k) ; if ( c k == 0) return ; if ( k == n) c is a proper coloring; else EXACT COLOR( G( V, E), k+ 1) }

Graph coloring exact algorithm NEXT VALUE( k) { repeat { c k = c k + 1; if ( there is no adjacent vertex to v k with the same color c k ) return ; } until ( c k =  maximum number of colors ) ; c k = 0; }

Interval graphs Edges represent interval intersections. Example: –Restricted channel routing problem with no vertical constraints. Possible to sort the intervals by left edge.

Example

Left-edge algorithm LEFT EDGE( I) { Sort elements of I in a list L with ascending order of l i ; c = 0; { while (Some interval has not been colored ) do { S =  ; repeat { s = first element in the list L whose left edge l s is higher than the rightmost edge in S. S= S  { s} ; } until ( an element s is found ); c = c + 1; color elements of S with color c; delete elements of S from L; } } }

Clique partitioning and covering A clique partition is a cover. A clique partition can be derived from a cover by making the vertex subsets disjoint. Intractable problem on general graphs. Heuristics: –Search for maximal cliques. Polynomial-time algorithms for chordal graphs.

Heuristic algorithm CLIQUEPARTITION( G( V, E) ) { =  ; while ( G( V, E) not empty ) do { compute largest clique C V in G( V, E) ; =  C; delete C from G( V, E) ; } CLIQUE( G( V, E) ) { C = seed vertex; repeat { select vertex v  V, v  C and adjacent to all vertices of C; if (no such vertex is found) return C = C  {v} ; } }

Covering and Satisfiability Covering problems can be cast as satisfiability. Vertex cover. –Ex1: ( x 1 + x 2 ) (x 2 + x 3 ) (x 3 + x 4 ) (x 4 + x 5 ) –Ex2: (x 3 + x 4 ) (x 1 + x 3 ) (x 1 + x 2 ) (x 2 + x 4 ) (x 4 + x 5 ) Objective function: Result: –Ex1: x 2 = 1, x 4 = 1 –Ex2: x 1 = 1, x 4 = 1

Covering problem Set covering problem: –A set S. –A collection C of subsets. –Select fewest elements of C to cover S. Intractable. Exact method: – Branch and bound algorithm. Heuristic methods.

Example vertex-cover of a graph

Example edge-cover of a hypergraph

Matrix representation A.Boolean matrix: A. x. Selection Boolean vector: x. x Determine x such that: –A x –A x  1. –Select enough columns to cover all rows. Minimize cardinality of x.

Branch and bound algorithm Tree search of the solution space: –Potentially exponential search. Use bounding function: –If the lower bound on the solution cost that can be derived from a set of future choices exceeds the cost of the best solution seen so far: –Kill the search. Good pruning may reduce run-time.

Branch and bound algorithm BRANCH_AND_BOUND{ Current best = anything; Current cost = 1; S= s 0 ; while (S6 = ; ) do { Select an element in s 2S; Remove s from S ; Make a branching decision based on s yielding sequences f s i ; i= 1; 2;...; mg ; for ( i = 1 to m) { Compute the lower bound b i of s i ; if ( b i Current cost) Kill s i ; else { if ( s i is a complete solution ) { Current best = s i, Current cost = cost of s i, } else Add s i to set S; }

Example