Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees

Size: px
Start display at page:

Download "Discrete Wiskunde II. Lecture 5: Shortest Paths & Spanning Trees"

Transcription

1 , 2009 Lecture 5: Shortest Paths & Spanning Trees University of Twente wwwhome.math.utwente.nl/~uetzm/dw/

2 Shortest Path Problem "#$%&'%()*%"()$#+,&- Given directed "#$%&'()*+,%+('-*.#/' '.*,'7+"-%/8',&'5"4'84%#3 graph (digraph) G = (V, E), V = n and E = m, arc 9$%#$%& lengths c : E R, two vertices s, t V want: :/;*%+8%'#.%/'< shortest path 84% =*;>'8'%;'%? from s to t (from s to all nodes v V ) :/;*%+8%'#.%/8'< 84@."('()8%.",+8'(2@6'=*;>'8'%;'.77';%/+*'@ (&) $ " ) $ ) $ # # " # %&' (&) " $ # %&' Assumption: all vertices are reachable from s

3 Three main cases Arbitrary digraphs includes negative cycle detection Label correcting algorithms O( nm ) computation time Nonnegative edge lengths (c vw 0 for all (v, w) E) Dijkstra s Algorithm O( n 2 ) computation time Acyclic graphs ( directed cycle) Dynamic programming O( n + m ) computation time

4 Shortest Path Optimality "#$%&'%()*%"'(+,%-.*/-%0(1#23-%-#2 Let d(v), v V be arbitrary node labels such that d(v) shortest path length from s to v, v V "#$%&'("#$%&'%(%$)(*+,#-'. )*(&"%(+#$ /+-(0123(12#43(5+(.67+(%$5"-$%$8(,60+(*%5+*..9)'(-'%-(0123(".(%,(9&&+$( 9&&+$( Theorem 569,0 :6$(-'+(.'6$-+.-(&%-'(:$67(.(-6(2(12#4;.3< Labels d(v) are shortest (s, v)-path lengths if and only if the ='+(,60+(*%5+*.(0123(%$+(.'6$-+.-(&%-'(*+,#-'.(":(%,0(6,*8(": -inequality holds 01>3( for all 01,3?) edges (v, w) E,%- :6$(%**(12@>3#A d(w) d(v) + c vw * (&) $ " " ) $ ) $ # # " " # + 2 %&' ) 2> >

5 Proof Necessity trivial, for otherwise there is a shortcut to w via v Sufficiency Let l(w) be the (true) shortest path length to w, l(w) d(w). pick shortest (s, w)-path P = (s,... u, v, w), length l(w) use -inequality along this path d(w) d(v) + c vw d(u) + c uv + c vw. d(s) + length(p) = length(p) = l(w)

6 Dijkstra s Algorithm (1959) all arc lengths c vw are nonnegative Idea Start with distance labels d(v) shortest path lengths, then correct violated -inequalities in a clever way Algorithm d(s) = 0, d(v) = and pred(v) = v V \ s, S = while (S V ) pick v S := V \ S with smallest label d(v) S = S v /*d(v) will remain unchanged*/ For all w with (v, w) E, if (d(w) > d(v) + c vw ) d(w) = d(v) + c vw pred(w) = v pred(v) = predecessor of v on a shortest (s, v)-path

7 Example: Dijkstra "#$%&'( s= t= s= t= note: set S already has the correct distance labels

8 Correctness Dijkstra I We prove by induction on # iterations Claim 1: d(u) d(w) for all u S, w S Iteration 1: S = s, d(s) = 0, other d(w) 0 Iteration where S = S v: First argue about v: d(v) d(w) w S, by our choice of v Next, argue about any other u S: If d(w), w S, was not updated, d(u) d(w) for all u S by induction hypothesis If d(w), w S, has been updated, d(w) = d(v) + c vw d(v), as c vw 0 and d(u) d(v) u S by induction hypothesis so d(u) d(w) u S also after this update

9 Correctness Dijkstra II We prove by induction on # iterations Claim 2: labels within S are the correct shortest path lengths Iteration 1: S = s, d(s) = 0 Iteration where S = S v: By induction hypothesis, only need to check that d(v) is correct. Theorem only need to verify -inequality for edges into v Case 1: consider any (u, v), u S: From iteration S = S u (which was before), d(v) d(u) + c uv Case 2: consider any (w, v), w S: In iteration S = S w (which is later), our claim 1 yields d(v) d(w) d(w) + c wu (d(v) remains unchanged) Upon termination, S = V, so Dijkstra works correctly

10 Computation Time Simple Initialization O( n ) n iterations of while-loop, in each need to find smallest label in V \ S, which is doable in O( n ) O( n 2 ) in total, at most m updates of d(v), O( 1 ) each O( m ) Which gives O( n ) + n O( n ) + O( m ) O( n 2 ) time Less Simple An O( m log n ) implementation, which uses priority queue (also called heap) to manage finding minimal d(v) in O( 1 ) time. (log n comes from overhead in organization of the heap)

11 BFS - breadth-first-search Let all arc lengths c vw = 1. What about Dijkstra s algorithm? distance labels d(v) = minimal # arcs to reach v from s (shortest path tree = BFS tree) d(v) = for non-reachable v ( reachability algorithm ) Computation time? once assigned a finite value, no node needs relabeling (otherwise contradiction to choice of v = argmin{d(v)}) hence organize such nodes as a FIFO list Q (queue): when d(w) is assigned a (finite) value, w end of Q then minimal d(v) is found in O( 1 ) time, at top of Q Total time O( n + m )

12 "#$%&'()*+& ",#$%-.&&&' % /0(12&)&()*++,+-'./00()*++,+-'./00 "/&,#$&-&"2&)&3($$ Minimum Spanning Trees (MST),"4$4.&50%%$53$6&)%6&)5758"5-9%*:3;& MST ()*+&'"',#$% - Given $6'$&50232 an edge-weighted, 1 0 $'0" % connected, undirected graph <:3*:3; G = (V, E, c), with V = n and E = m, find a MST. (cheapest & connected % 2:5+&3+)3&&,#$&'-&"2&) acyclic subgraph) 3($$& ="3+&1"%"1)8&303)8&5023& 1,&- "' $ " > 1,0-4 " $ #% $& & % $& # "& $% % " $& & % $ #% $& # "& $% %

13 Spanning Trees and Cuts "#$$%$&'()**+'#$,'-./+ "#$%%&'()'$'*+"" *,"+" -. $'/)-0/" 1$*, 2"*3"") $)4 *35 )56". $)6'" "#$%%&'()'$'*+"" #7'#$ %,$. *35'#5815)")*.'9"$#,'% & -.'$'2+-6:"; Definitions <"=-)-*-5).& For subset of nodes W V, δ(w ) denotes the cut induced >5+'$)4./2."* 5=')56". '" ()*9';" & -.'#$%%"6'*," +,- -)6/#"6 24 by ' W : all edges leaving W [δ(w ) = δ(v \ W )] Given 98"$)-): a spanning $%%'"6:". tree -)'?'*,$* T G, let BC7'-D"D7'#5))"#* C(e) be the cut' induced $)6'('; by deleting?-a") $'.1$))-): edge e from *+""'5='?7'3" T /." *,"')5*$*-5).9%; =5+ *," #/* -)'/ *,$* -. -)6/#"6 24 6"%"*-): "6:"'%*-) # " #$ "$ % # "% ' #' & "$ ( #) # ' " #$ "$ % # "% ' #' & "# ( #) # '

14 The Cut Condition "#$%&'$#()*+,#*-./0$#$./ Theorem "#$%#&'()*+#, Given a graph G -(.%-/" = (V, E) "0#$%1 with edge costs 2*3" c#4.#(5$636 e, e E, then& ' a $(' %$ 3"#, spanning -(6/-,,*,. tree T 3%## E is" an MST 7(*6(-,(89 if and only*: if-,4($,;< *: # #4.#6 c e c f # for all (-,4(# edges e #4.#6 T and: all=0#1'((((50#1( edges f C(e). 50:1 (i.e., T has the cheapest connection that crosses the cut) " #$ "$ % # "% ' #' ( "# # #) & '

15 *,# The *,(-(3%## Condition 0?,*D?#1(/-3" :%$&?(3$(+E In a tree T, denote by P T (v, w) the (unique) path from v to w $%#&'()*+#, -(.%-/" "0#$%1 2*3" #4.#(5$636 & Theorem ' $(' %$, -(6/-,,*,. 3%## " 7(*6(-(89 *: -,4($,;< *: Given a graph G = (V, E) with edge costs c e, e E, then a spanning tree T E is an MST if and only if.#6 :=>?@+A 7 -,4(# #4.#6 # B 0?@+1'((((50#1(" 50:1 edges f = {v, w} E \ T : c f c e edges e P T (v, w) " %# "# $ "$ ' % ) %' "% % %( & '

16 Kruskal s Greedy Algorithm (1957) "##$%&'()*"+,-. / 01"2345(6&/789: "#$%&$'#%&%()&)*+)$ $,-(&%(.% )/01 - )/21 3&3&3&3&3& - )/41 8'# /"60&%'&41&9 "8 / " "#$%&"$&.-:-;"-19 5# 5" )/"17 < < #)%,#= 57 >=?.#".=%@ 03 /AB51.-:-;"- 23 5&$.%"$8")$&%()&C.%(& -'=*"%"'= D'&"8 %().;+'#"%(4 #)%,#=$.&-'==)-%)* +#.C(B&"% "$ =)-)$$.#";:.=&ED53 Theorem "#$%&'%#(()%*'+,-&"&.'/%&.+(%'0%12-#3"45#%"46'2.&7+%.# 89/+:; Kruskals <'##.=4(%>.&7%=(&&(2%?"&"%#&2-@&-2(#)%89+%4'6%+:; algorithm solves MST problem in time O( m log m + n 2 ).

17 Kruskal s Algorithm: Correctness Proof 2nd Invariant (Path Condition) any edge f = {v, w} not added to T creates cycle, namely {v, w} P T (v, w), in particular, all edges e P T (v, w) are already in T by the sorting of the edges c f c e e P T (v, w) T connected for any cut δ(w ) of the graph (V, E), the cheapest (so at least one) edge e δ(w ) must be in T thus (V, T ) must be connected (connected : graph contains at least one edge from any cut δ(w ), W V )

18 Kruskal s Algorithm: Computation Time To start with O( m log m ) for sorting the c e values (MergeSort) need to do m times: Is T e acyclic?, and if so, add e to T We need a clever data structure Store & update to which component any node belongs: Initialize c(v) = v v V [n components] O( n ) m times we do for an edge {v, w}: Check (T {v, w} acyclic) c(v) c(w) O( 1 ) If so, add {v, w} to T [merge 2 components, n 1 times]: For all u V : If c(u) == c(w) let c(u) = c(v) O( n ) O( m log m ) + O( n ) + mo( 1 ) + (n 1)O( n ) O( m log m + n 2 )

19 More about MSTs With a little more care (data structure & analysis), Kruskal s algorithm can be implemented to run in O( m log m ) time Prim s algorithm (1959) Start with W = {v 0 }, any v 0 V, T = For (i = 1,..., n 1) Let edge e i = {v, w} be the cheapest edge in δ(w ) (where v W and w W ) Let T = T e i and W = W {w} Correctness follows directly from Cut Condition Computation time can be shown in O( n 2 )

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths

Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Matroids Shortest Paths Discrete Optimization 2010 Lecture 2 Matroids & Shortest Paths Marc Uetz University of Twente m.uetz@utwente.nl Lecture 2: sheet 1 / 25 Marc Uetz Discrete Optimization Matroids

More information

Discrete Optimization 2010 Lecture 3 Maximum Flows

Discrete Optimization 2010 Lecture 3 Maximum Flows Remainder: Shortest Paths Maximum Flows Discrete Optimization 2010 Lecture 3 Maximum Flows Marc Uetz University of Twente m.uetz@utwente.nl Lecture 3: sheet 1 / 29 Marc Uetz Discrete Optimization Outline

More information

CS 4407 Algorithms Lecture: Shortest Path Algorithms

CS 4407 Algorithms Lecture: Shortest Path Algorithms CS 440 Algorithms Lecture: Shortest Path Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Outline Shortest Path Problem General Lemmas and Theorems. Algorithms Bellman-Ford

More information

Single Source Shortest Paths

Single Source Shortest Paths CMPS 00 Fall 015 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk 1 Paths in graphs Consider a digraph G = (V, E) with an edge-weight

More information

CMPS 6610 Fall 2018 Shortest Paths Carola Wenk

CMPS 6610 Fall 2018 Shortest Paths Carola Wenk CMPS 6610 Fall 018 Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk Paths in graphs Consider a digraph G = (V, E) with an edge-weight function w

More information

Single Source Shortest Paths

Single Source Shortest Paths CMPS 00 Fall 017 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk Paths in graphs Consider a digraph G = (V, E) with an edge-weight

More information

CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk. 10/8/12 CMPS 2200 Intro.

CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk. 10/8/12 CMPS 2200 Intro. CMPS 00 Fall 01 Single Source Shortest Paths Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk 1 Paths in graphs Consider a digraph G = (V, E) with edge-weight function

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms 6.046J/18.401J LECTURE 14 Shortest Paths I Properties of shortest paths Dijkstra s algorithm Correctness Analysis Breadth-first search Prof. Charles E. Leiserson Paths in graphs

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms 6.046J/8.40J/SMA550 Lecture 7 Prof. Erik Demaine Paths in graphs Consider a digraph G = (V, E) with edge-weight function w : E R. The weight of path p = v v L v k is defined

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms Design and Analysis of Algorithms CSE 5311 Lecture 21 Single-Source Shortest Paths Junzhou Huang, Ph.D. Department of Computer Science and Engineering CSE5311 Design and Analysis of Algorithms 1 Single-Source

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms 6.046J/18.401J LECTURE 17 Shortest Paths I Properties of shortest paths Dijkstra s algorithm Correctness Analysis Breadth-first search Prof. Erik Demaine November 14, 005 Copyright

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 7 Greedy Graph Algorithms Shortest paths Minimum Spanning Tree Sofya Raskhodnikova 9/14/016 S. Raskhodnikova; based on slides by E. Demaine, C. Leiserson, A. Smith,

More information

Contents Lecture 4. Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression

Contents Lecture 4. Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression Contents Lecture 4 Greedy graph algorithms Dijkstra s algorithm Prim s algorithm Kruskal s algorithm Union-find data structure with path compression Jonas Skeppstedt (jonasskeppstedt.net) Lecture 4 2018

More information

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya

CS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya CS6000: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Paths in graphs Consider a digraph G = (V, E) with edge-weight function w : E R. The weight of path p = v 1 v L v k

More information

Shortest Path Algorithms

Shortest Path Algorithms Shortest Path Algorithms Andreas Klappenecker [based on slides by Prof. Welch] 1 Single Source Shortest Path 2 Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node

More information

Analysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes

Analysis of Algorithms. Outline. Single Source Shortest Path. Andres Mendez-Vazquez. November 9, Notes. Notes Analysis of Algorithms Single Source Shortest Path Andres Mendez-Vazquez November 9, 01 1 / 108 Outline 1 Introduction Introduction and Similar Problems General Results Optimal Substructure Properties

More information

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11

Undirected Graphs. V = { 1, 2, 3, 4, 5, 6, 7, 8 } E = { 1-2, 1-3, 2-3, 2-4, 2-5, 3-5, 3-7, 3-8, 4-5, 5-6 } n = 8 m = 11 Undirected Graphs Undirected graph. G = (V, E) V = nodes. E = edges between pairs of nodes. Captures pairwise relationship between objects. Graph size parameters: n = V, m = E. V = {, 2, 3,,,, 7, 8 } E

More information

Introduction to Algorithms

Introduction to Algorithms Introduction to Algorithms, Lecture 5 // Introduction to Algorithms 6.46J/.4J LECTURE Shortest Paths I Properties o shortest paths Dijkstra s Correctness Analysis Breadth-irst Pro. Manolis Kellis March,

More information

Breadth First Search, Dijkstra s Algorithm for Shortest Paths

Breadth First Search, Dijkstra s Algorithm for Shortest Paths CS 374: Algorithms & Models of Computation, Spring 2017 Breadth First Search, Dijkstra s Algorithm for Shortest Paths Lecture 17 March 1, 2017 Chandra Chekuri (UIUC) CS374 1 Spring 2017 1 / 42 Part I Breadth

More information

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD Greedy s Greedy s Shortest path Claim 2: Let S be a subset of vertices containing s such that we know the shortest path length l(s, u) from s to any vertex in u S. Let e = (u, v) be an edge such that 1

More information

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker Dijkstra s Single Source Shortest Path Algorithm Andreas Klappenecker Single Source Shortest Path Given: a directed or undirected graph G = (V,E) a source node s in V a weight function w: E -> R. Goal:

More information

Discrete Optimization 2010 Lecture 1 Introduction / Algorithms & Spanning Trees

Discrete Optimization 2010 Lecture 1 Introduction / Algorithms & Spanning Trees Discrete Optimization 2010 Lecture 1 Introduction / Algorithms & Spanning Trees Marc Uetz University of Twente m.uetz@utwente.nl Lecture 1: sheet 1 / 43 Marc Uetz Discrete Optimization Outline 1 Introduction

More information

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs Instructor: Shaddin Dughmi Outline 1 Introduction 2 Shortest Path 3 Algorithms for Single-Source Shortest

More information

1 Some loose ends from last time

1 Some loose ends from last time Cornell University, Fall 2010 CS 6820: Algorithms Lecture notes: Kruskal s and Borůvka s MST algorithms September 20, 2010 1 Some loose ends from last time 1.1 A lemma concerning greedy algorithms and

More information

CMPSCI611: The Matroid Theorem Lecture 5

CMPSCI611: The Matroid Theorem Lecture 5 CMPSCI611: The Matroid Theorem Lecture 5 We first review our definitions: A subset system is a set E together with a set of subsets of E, called I, such that I is closed under inclusion. This means that

More information

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)}

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)} Preliminaries Graphs G = (V, E), V : set of vertices E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) 1 2 3 5 4 V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)} 1 Directed Graph (Digraph)

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright Pearson-Addison Wesley. All rights reserved. 4 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and finishes

More information

CS 6301 PROGRAMMING AND DATA STRUCTURE II Dept of CSE/IT UNIT V GRAPHS

CS 6301 PROGRAMMING AND DATA STRUCTURE II Dept of CSE/IT UNIT V GRAPHS UNIT V GRAPHS Representation of Graphs Breadth-first search Depth-first search Topological sort Minimum Spanning Trees Kruskal and Prim algorithm Shortest path algorithm Dijkstra s algorithm Bellman-Ford

More information

Minimum spanning tree

Minimum spanning tree Minimum spanning tree Jean Cousty MorphoGraph and Imagery 2011 J. Cousty : MorphoGraph and Imagery 1/17 Outline of the lecture 1 Minimum spanning tree 2 Cut theorem for MST 3 Kruskal algorithm J. Cousty

More information

Algorithms: Lecture 12. Chalmers University of Technology

Algorithms: Lecture 12. Chalmers University of Technology Algorithms: Lecture 1 Chalmers University of Technology Today s Topics Shortest Paths Network Flow Algorithms Shortest Path in a Graph Shortest Path Problem Shortest path network. Directed graph G = (V,

More information

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs Instructor: Shaddin Dughmi Outline 1 Introduction 2 Shortest Path 3 Algorithms for Single-Source

More information

Breadth-First Search of Graphs

Breadth-First Search of Graphs Breadth-First Search of Graphs Analysis of Algorithms Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Applications of Breadth-First Search of Graphs a) Single Source

More information

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: 2017 2018 Time Allowed 2 Hours INSTRUCTIONS TO STUDENTS 1. This assessment consists of Eight (8) questions and comprises

More information

CS781 Lecture 3 January 27, 2011

CS781 Lecture 3 January 27, 2011 CS781 Lecture 3 January 7, 011 Greedy Algorithms Topics: Interval Scheduling and Partitioning Dijkstra s Shortest Path Algorithm Minimum Spanning Trees Single-Link k-clustering Interval Scheduling Interval

More information

CS 410/584, Algorithm Design & Analysis, Lecture Notes 4

CS 410/584, Algorithm Design & Analysis, Lecture Notes 4 CS 0/58,, Biconnectivity Let G = (N,E) be a connected A node a N is an articulation point if there are v and w different from a such that every path from 0 9 8 3 5 7 6 David Maier Biconnected Component

More information

25. Minimum Spanning Trees

25. Minimum Spanning Trees 695 25. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci Heaps [Ottman/Widmayer, Kap. 9.6, 6.2, 6.1, Cormen et al,

More information

25. Minimum Spanning Trees

25. Minimum Spanning Trees Problem Given: Undirected, weighted, connected graph G = (V, E, c). 5. Minimum Spanning Trees Motivation, Greedy, Algorithm Kruskal, General Rules, ADT Union-Find, Algorithm Jarnik, Prim, Dijkstra, Fibonacci

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 8 Greedy Algorithms V Huffman Codes Adam Smith Review Questions Let G be a connected undirected graph with distinct edge weights. Answer true or false: Let e be the

More information

Trees. A tree is a graph which is. (a) Connected and. (b) has no cycles (acyclic).

Trees. A tree is a graph which is. (a) Connected and. (b) has no cycles (acyclic). Trees A tree is a graph which is (a) Connected and (b) has no cycles (acyclic). 1 Lemma 1 Let the components of G be C 1, C 2,..., C r, Suppose e = (u, v) / E, u C i, v C j. (a) i = j ω(g + e) = ω(g).

More information

Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 10

Greedy Algorithms. CSE 101: Design and Analysis of Algorithms Lecture 10 Greedy Algorithms CSE 101: Design and Analysis of Algorithms Lecture 10 CSE 101: Design and analysis of algorithms Greedy algorithms Reading: Kleinberg and Tardos, sections 4.1, 4.2, and 4.3 Homework 4

More information

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016) FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016) The final exam will be on Thursday, May 12, from 8:00 10:00 am, at our regular class location (CSI 2117). It will be closed-book and closed-notes, except

More information

UNIVERSITY OF YORK. MSc Examinations 2004 MATHEMATICS Networks. Time Allowed: 3 hours.

UNIVERSITY OF YORK. MSc Examinations 2004 MATHEMATICS Networks. Time Allowed: 3 hours. UNIVERSITY OF YORK MSc Examinations 2004 MATHEMATICS Networks Time Allowed: 3 hours. Answer 4 questions. Standard calculators will be provided but should be unnecessary. 1 Turn over 2 continued on next

More information

IS 709/809: Computational Methods in IS Research Fall Exam Review

IS 709/809: Computational Methods in IS Research Fall Exam Review IS 709/809: Computational Methods in IS Research Fall 2017 Exam Review Nirmalya Roy Department of Information Systems University of Maryland Baltimore County www.umbc.edu Exam When: Tuesday (11/28) 7:10pm

More information

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Dynamic Programming: Shortest Paths and DFA to Reg Exps CS 374: Algorithms & Models of Computation, Fall 205 Dynamic Programming: Shortest Paths and DFA to Reg Exps Lecture 7 October 22, 205 Chandra & Manoj (UIUC) CS374 Fall 205 / 54 Part I Shortest Paths with

More information

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Dynamic Programming: Shortest Paths and DFA to Reg Exps CS 374: Algorithms & Models of Computation, Spring 207 Dynamic Programming: Shortest Paths and DFA to Reg Exps Lecture 8 March 28, 207 Chandra Chekuri (UIUC) CS374 Spring 207 / 56 Part I Shortest Paths

More information

CMPSCI 611: Advanced Algorithms

CMPSCI 611: Advanced Algorithms CMPSCI 611: Advanced Algorithms Lecture 12: Network Flow Part II Andrew McGregor Last Compiled: December 14, 2017 1/26 Definitions Input: Directed Graph G = (V, E) Capacities C(u, v) > 0 for (u, v) E and

More information

6. DYNAMIC PROGRAMMING II. sequence alignment Hirschberg's algorithm Bellman-Ford distance vector protocols negative cycles in a digraph

6. DYNAMIC PROGRAMMING II. sequence alignment Hirschberg's algorithm Bellman-Ford distance vector protocols negative cycles in a digraph 6. DYNAMIC PROGRAMMING II sequence alignment Hirschberg's algorithm Bellman-Ford distance vector protocols negative cycles in a digraph Shortest paths Shortest path problem. Given a digraph G = (V, E),

More information

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. Chapter 4 Greedy Algorithms Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 4.1 Interval Scheduling Interval Scheduling Interval scheduling. Job j starts at s j and

More information

2 GRAPH AND NETWORK OPTIMIZATION. E. Amaldi Introduction to Operations Research Politecnico Milano 1

2 GRAPH AND NETWORK OPTIMIZATION. E. Amaldi Introduction to Operations Research Politecnico Milano 1 2 GRAPH AND NETWORK OPTIMIZATION E. Amaldi Introduction to Operations Research Politecnico Milano 1 A variety of decision-making problems can be formulated in terms of graphs and networks Examples: - transportation

More information

ICS 252 Introduction to Computer Design

ICS 252 Introduction to Computer Design ICS 252 fall 2006 Eli Bozorgzadeh Computer Science Department-UCI References and Copyright Textbooks referred [Mic94] G. De Micheli Synthesis and Optimization of Digital Circuits McGraw-Hill, 1994. [CLR90]

More information

Slides credited from Hsueh-I Lu & Hsu-Chun Hsiao

Slides credited from Hsueh-I Lu & Hsu-Chun Hsiao Slides credited from Hsueh-I Lu & Hsu-Chun Hsiao Homework 3 released Due on 12/13 (Thur) 14:20 (one week only) Mini-HW 9 released Due on 12/13 (Thur) 14:20 Homework 4 released Due on 1/3 (Thur) 14:20 (four

More information

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Matroids and Greedy Algorithms Date: 10/31/16

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Matroids and Greedy Algorithms Date: 10/31/16 60.433/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Matroids and Greedy Algorithms Date: 0/3/6 6. Introduction We talked a lot the last lecture about greedy algorithms. While both Prim

More information

Lecture 11. Single-Source Shortest Paths All-Pairs Shortest Paths

Lecture 11. Single-Source Shortest Paths All-Pairs Shortest Paths Lecture. Single-Source Shortest Paths All-Pairs Shortest Paths T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to, rd Edition, MIT Press, 009 Sungkyunkwan University Hyunseung Choo choo@skku.edu

More information

Algorithms and Data Structures (COMP 251) Midterm Solutions

Algorithms and Data Structures (COMP 251) Midterm Solutions Algorithms and Data Structures COMP 251) Midterm Solutions March 11, 2012 1. Stable Matching Problem a) Describe the input for the stable matching problem. Input: n men and n women. For each man, there

More information

6. DYNAMIC PROGRAMMING II

6. DYNAMIC PROGRAMMING II 6. DYNAMIC PROGRAMMING II sequence alignment Hirschberg's algorithm Bellman-Ford algorithm distance vector protocols negative cycles in a digraph Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison

More information

Data Structures and and Algorithm Xiaoqing Zheng

Data Structures and and Algorithm Xiaoqing Zheng Data Structures and Algorithm Xiaoqing Zheng zhengxq@fudan.edu.cn Representations of undirected graph 1 2 1 2 5 / 5 4 3 2 3 4 5 1 3 4 / 2 4 / 2 5 3 / 4 1 / Adjacency-list representation of graph G = (V,

More information

Scribes: Po-Hsuan Wei, William Kuzmaul Editor: Kevin Wu Date: October 18, 2016

Scribes: Po-Hsuan Wei, William Kuzmaul Editor: Kevin Wu Date: October 18, 2016 CS 267 Lecture 7 Graph Spanners Scribes: Po-Hsuan Wei, William Kuzmaul Editor: Kevin Wu Date: October 18, 2016 1 Graph Spanners Our goal is to compress information about distances in a graph by looking

More information

The min cost flow problem Course notes for Optimization Spring 2007

The min cost flow problem Course notes for Optimization Spring 2007 The min cost flow problem Course notes for Optimization Spring 2007 Peter Bro Miltersen February 7, 2007 Version 3.0 1 Definition of the min cost flow problem We shall consider a generalization of the

More information

Discrete Optimization 2010 Lecture 8 Lagrangian Relaxation / P, N P and co-n P

Discrete Optimization 2010 Lecture 8 Lagrangian Relaxation / P, N P and co-n P Discrete Optimization 2010 Lecture 8 Lagrangian Relaxation / P, N P and co-n P Marc Uetz University of Twente m.uetz@utwente.nl Lecture 8: sheet 1 / 32 Marc Uetz Discrete Optimization Outline 1 Lagrangian

More information

Matching Residents to Hospitals

Matching Residents to Hospitals Midterm Review Matching Residents to Hospitals Goal. Given a set of preferences among hospitals and medical school students, design a self-reinforcing admissions process. Unstable pair: applicant x and

More information

A faster algorithm for the single source shortest path problem with few distinct positive lengths

A faster algorithm for the single source shortest path problem with few distinct positive lengths A faster algorithm for the single source shortest path problem with few distinct positive lengths J. B. Orlin, K. Madduri, K. Subramani, and M. Williamson Journal of Discrete Algorithms 8 (2010) 189 198.

More information

ACO Comprehensive Exam 19 March Graph Theory

ACO Comprehensive Exam 19 March Graph Theory 1. Graph Theory Let G be a connected simple graph that is not a cycle and is not complete. Prove that there exist distinct non-adjacent vertices u, v V (G) such that the graph obtained from G by deleting

More information

CSE 4502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions

CSE 4502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions CSE 502/5717 Big Data Analytics Spring 2018; Homework 1 Solutions 1. Consider the following algorithm: for i := 1 to α n log e n do Pick a random j [1, n]; If a[j] = a[j + 1] or a[j] = a[j 1] then output:

More information

Homework Assignment 1 Solutions

Homework Assignment 1 Solutions MTAT.03.286: Advanced Methods in Algorithms Homework Assignment 1 Solutions University of Tartu 1 Big-O notation For each of the following, indicate whether f(n) = O(g(n)), f(n) = Ω(g(n)), or f(n) = Θ(g(n)).

More information

University of California Berkeley CS170: Efficient Algorithms and Intractable Problems November 19, 2001 Professor Luca Trevisan. Midterm 2 Solutions

University of California Berkeley CS170: Efficient Algorithms and Intractable Problems November 19, 2001 Professor Luca Trevisan. Midterm 2 Solutions University of California Berkeley Handout MS2 CS170: Efficient Algorithms and Intractable Problems November 19, 2001 Professor Luca Trevisan Midterm 2 Solutions Problem 1. Provide the following information:

More information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Reminder: Homework 1 due tonight at 11:59PM! Recap: Greedy Algorithms Interval Scheduling Goal: Maximize number of meeting

More information

Directed Graphs (Digraphs) and Graphs

Directed Graphs (Digraphs) and Graphs Directed Graphs (Digraphs) and Graphs Definitions Graph ADT Traversal algorithms DFS Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 74 1 Basic definitions 2 Digraph Representation

More information

MA015: Graph Algorithms

MA015: Graph Algorithms MA015 3. Minimum cuts 1 MA015: Graph Algorithms 3. Minimum cuts (in undirected graphs) Jan Obdržálek obdrzalek@fi.muni.cz Faculty of Informatics, Masaryk University, Brno All pairs flows/cuts MA015 3.

More information

COMP251: Bipartite graphs

COMP251: Bipartite graphs COMP251: Bipartite graphs Jérôme Waldispühl School of Computer Science McGill University Based on slides fom M. Langer (McGill) & P. Beame (UofW) Recap: Dijkstra s algorithm DIJKSTRA(V, E,w,s) INIT-SINGLE-SOURCE(V,s)

More information

Shortest paths: label setting

Shortest paths: label setting : label setting CE 377K February 19, 2015 REVIEW HW 2 posted, due in 2 weeks Review Basic search algorithm Prim s algorithm Review Algorithm (Assumes that the network is connected.) 1 Arbitrarily choose

More information

CS 580: Algorithm Design and Analysis

CS 580: Algorithm Design and Analysis CS 580: Algorithm Design and Analysis Jeremiah Blocki Purdue University Spring 2018 Announcement: Homework 1 due soon! Due: January 25 th at midnight (Blackboard) Recap: Graphs Bipartite Graphs Definition

More information

Graph Transformations T1 and T2

Graph Transformations T1 and T2 Graph Transformations T1 and T2 We now introduce two graph transformations T1 and T2. Reducibility by successive application of these two transformations is equivalent to reducibility by intervals. The

More information

Algorithms Booklet. 1 Graph Searching. 1.1 Breadth First Search

Algorithms Booklet. 1 Graph Searching. 1.1 Breadth First Search Algorithms Booklet 2010 Note: in all algorithms, unless stated otherwise, the input graph G is represented by adjacency lists. 1 Graph Searching 1.1 Breadth First Search Algorithm 1: BFS(G, s) Input: G

More information

CS 161: Design and Analysis of Algorithms

CS 161: Design and Analysis of Algorithms CS 161: Design and Analysis of Algorithms Greedy Algorithms 3: Minimum Spanning Trees/Scheduling Disjoint Sets, continued Analysis of Kruskal s Algorithm Interval Scheduling Disjoint Sets, Continued Each

More information

Branch-and-Bound for the Travelling Salesman Problem

Branch-and-Bound for the Travelling Salesman Problem Branch-and-Bound for the Travelling Salesman Problem Leo Liberti LIX, École Polytechnique, F-91128 Palaiseau, France Email:liberti@lix.polytechnique.fr March 15, 2011 Contents 1 The setting 1 1.1 Graphs...............................................

More information

HW Graph Theory SOLUTIONS (hbovik) - Q

HW Graph Theory SOLUTIONS (hbovik) - Q 1, Diestel 3.5: Deduce the k = 2 case of Menger s theorem (3.3.1) from Proposition 3.1.1. Let G be 2-connected, and let A and B be 2-sets. We handle some special cases (thus later in the induction if these

More information

CSE 417. Chapter 4: Greedy Algorithms. Many Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

CSE 417. Chapter 4: Greedy Algorithms. Many Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. CSE 417 Chapter 4: Greedy Algorithms Many Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved. 1 Greed is good. Greed is right. Greed works. Greed clarifies, cuts through,

More information

Maximum Flow Problem (Ford and Fulkerson, 1956)

Maximum Flow Problem (Ford and Fulkerson, 1956) Maximum Flow Problem (Ford and Fulkerson, 196) In this problem we find the maximum flow possible in a directed connected network with arc capacities. There is unlimited quantity available in the given

More information

Paths and cycles in extended and decomposable digraphs

Paths and cycles in extended and decomposable digraphs Paths and cycles in extended and decomposable digraphs Jørgen Bang-Jensen Gregory Gutin Department of Mathematics and Computer Science Odense University, Denmark Abstract We consider digraphs called extended

More information

Upper Bounds of Dynamic Chromatic Number

Upper Bounds of Dynamic Chromatic Number Upper Bounds of Dynamic Chromatic Number Hong-Jian Lai, Bruce Montgomery and Hoifung Poon Department of Mathematics West Virginia University, Morgantown, WV 26506-6310 June 22, 2000 Abstract A proper vertex

More information

Algorithm Design Strategies V

Algorithm Design Strategies V Algorithm Design Strategies V Joaquim Madeira Version 0.0 October 2016 U. Aveiro, October 2016 1 Overview The 0-1 Knapsack Problem Revisited The Fractional Knapsack Problem Greedy Algorithms Example Coin

More information

ne a priority queue for the nodes of G; ile (! PQ.is empty( )) select u PQ with d(u) minimal and remove it; I Informatik 1 Kurt Mehlhorn

ne a priority queue for the nodes of G; ile (! PQ.is empty( )) select u PQ with d(u) minimal and remove it; I Informatik 1 Kurt Mehlhorn n-negative Edge Costs: optimal choice: u U with d(u) minimal. e use a priority queue (de nition on next slide) PQ to maintain the set of pairs, d(u)) ; u U } and obtain Dijkstra s Algorithm: ne a priority

More information

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm

8 Priority Queues. 8 Priority Queues. Prim s Minimum Spanning Tree Algorithm. Dijkstra s Shortest Path Algorithm 8 Priority Queues 8 Priority Queues A Priority Queue S is a dynamic set data structure that supports the following operations: S. build(x 1,..., x n ): Creates a data-structure that contains just the elements

More information

Proof methods and greedy algorithms

Proof methods and greedy algorithms Proof methods and greedy algorithms Magnus Lie Hetland Lecture notes, May 5th 2008 1 Introduction This lecture in some ways covers two separate topics: (1) how to prove algorithms correct, in general,

More information

More on NP and Reductions

More on NP and Reductions Indian Institute of Information Technology Design and Manufacturing, Kancheepuram Chennai 600 127, India An Autonomous Institute under MHRD, Govt of India http://www.iiitdm.ac.in COM 501 Advanced Data

More information

Maximum flow problem (part I)

Maximum flow problem (part I) Maximum flow problem (part I) Combinatorial Optimization Giovanni Righini Università degli Studi di Milano Definitions A flow network is a digraph D = (N,A) with two particular nodes s and t acting as

More information

Running Time. Assumption. All capacities are integers between 1 and C.

Running Time. Assumption. All capacities are integers between 1 and C. Running Time Assumption. All capacities are integers between and. Invariant. Every flow value f(e) and every residual capacities c f (e) remains an integer throughout the algorithm. Theorem. The algorithm

More information

GRAPH ALGORITHMS Week 3 (16-21 October 2017)

GRAPH ALGORITHMS Week 3 (16-21 October 2017) GRAPH ALGORITHMS Week 3 (16-21 October 2017) C. Croitoru croitoru@info.uaic.ro FII October 15, 2017 1 / 63 OUTLINE Graph Theory Vocabulary 1 Definition of a Graph 2 Variations in the Definition of a Graph

More information

6.889 Lecture 4: Single-Source Shortest Paths

6.889 Lecture 4: Single-Source Shortest Paths 6.889 Lecture 4: Single-Source Shortest Paths Christian Sommer csom@mit.edu September 19 and 26, 2011 Single-Source Shortest Path SSSP) Problem: given a graph G = V, E) and a source vertex s V, compute

More information

2. A vertex in G is central if its greatest distance from any other vertex is as small as possible. This distance is the radius of G.

2. A vertex in G is central if its greatest distance from any other vertex is as small as possible. This distance is the radius of G. CME 305: Discrete Mathematics and Algorithms Instructor: Reza Zadeh (rezab@stanford.edu) HW#1 Due at the beginning of class Thursday 01/21/16 1. Prove that at least one of G and G is connected. Here, G

More information

Algorithm Design and Analysis

Algorithm Design and Analysis Algorithm Design and Analysis LECTURE 5 Greedy Algorithms Interval Scheduling Interval Partitioning Guest lecturer: Martin Furer Review In a DFS tree of an undirected graph, can there be an edge (u,v)

More information

Mathematics for Decision Making: An Introduction. Lecture 13

Mathematics for Decision Making: An Introduction. Lecture 13 Mathematics for Decision Making: An Introduction Lecture 13 Matthias Köppe UC Davis, Mathematics February 17, 2009 13 1 Reminder: Flows in networks General structure: Flows in networks In general, consider

More information

Introduction to Discrete Optimization

Introduction to Discrete Optimization Prof. Friedrich Eisenbrand Martin Niemeier Due Date: April 28, 2009 Discussions: April 2, 2009 Introduction to Discrete Optimization Spring 2009 s 8 Exercise What is the smallest number n such that an

More information

A combinatorial algorithm minimizing submodular functions in strongly polynomial time

A combinatorial algorithm minimizing submodular functions in strongly polynomial time A combinatorial algorithm minimizing submodular functions in strongly polynomial time Alexander Schrijver 1 Abstract We give a strongly polynomial-time algorithm minimizing a submodular function f given

More information

Shortest paths with negative lengths

Shortest paths with negative lengths Chapter 8 Shortest paths with negative lengths In this chapter we give a linear-space, nearly linear-time algorithm that, given a directed planar graph G with real positive and negative lengths, but no

More information

Ngày 20 tháng 7 năm Discrete Optimization Graphs

Ngày 20 tháng 7 năm Discrete Optimization Graphs Discrete Optimization Graphs Ngày 20 tháng 7 năm 2011 Lecture 6: Graphs In this class we shall prove some simple, useful theorems about graphs. We start with very simple obseravations. Lecture 6: Graphs

More information

Exact and Approximate Equilibria for Optimal Group Network Formation

Exact and Approximate Equilibria for Optimal Group Network Formation Exact and Approximate Equilibria for Optimal Group Network Formation Elliot Anshelevich and Bugra Caskurlu Computer Science Department, RPI, 110 8th Street, Troy, NY 12180 {eanshel,caskub}@cs.rpi.edu Abstract.

More information

Dynamic Programming. Data Structures and Algorithms Andrei Bulatov

Dynamic Programming. Data Structures and Algorithms Andrei Bulatov Dynamic Programming Data Structures and Algorithms Andrei Bulatov Algorithms Dynamic Programming 18-2 Weighted Interval Scheduling Weighted interval scheduling problem. Instance A set of n jobs. Job j

More information

Centrality measures in graphs or social networks

Centrality measures in graphs or social networks Centrality measures in graphs or social networks V.S. Subrahmanian University of Maryland vs@cs.umd.edu Copyright (C) 2012, V.S. Subrahmanian 1 PageRank Examples of vertices: Web pages Twitter ids nodes

More information

Problem set 1. (c) Is the Ford-Fulkerson algorithm guaranteed to produce an acyclic maximum flow?

Problem set 1. (c) Is the Ford-Fulkerson algorithm guaranteed to produce an acyclic maximum flow? CS261, Winter 2017. Instructor: Ashish Goel. Problem set 1 Electronic submission to Gradescope due 11:59pm Thursday 2/2. Form a group of 2-3 students that is, submit one homework with all of your names.

More information