Wrap up: Weighted, directed graph shortest path Minimum Spanning Tree. Feb 25, 2019 CSCI211 - Sprenkle

Similar documents
Max Flow, Min Cut COS 521. Kevin Wayne Fall Soviet Rail Network, Cuts. Minimum Cut Problem. Flow network.

Admin MAX FLOW APPLICATIONS. Flow graph/networks. Flow constraints 4/30/13. CS lunch today Grading. in-flow = out-flow for every vertex (except s, t)

The Residual Graph. 12 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

Basic Tools CMSC 641. Running Time. Problem. Problem. Algorithmic Design Paradigms. lg (n!) (lg n)! (lg n) lgn n.2

Warm Up. Correct order: s,u,v,y,x,w,t

The Residual Graph. 11 Augmenting Path Algorithms. Augmenting Path Algorithm. Augmenting Path Algorithm

Introduction to Congestion Games

Network Flows UPCOPENCOURSEWARE number 34414

! Abstraction for material flowing through the edges. ! G = (V, E) = directed graph, no parallel edges.

Today: Max Flow Proofs

Maximum Flow and Minimum Cut

Problem Set If all directed edges in a network have distinct capacities, then there is a unique maximum flow.

Maximum Flow in Planar Graphs

Soviet Rail Network, 1955

MAXIMUM FLOW. introduction Ford-Fulkerson algorithm maxflow-mincut theorem

Algorithmic Discrete Mathematics 6. Exercise Sheet

Network Flows: Introduction & Maximum Flow

Soviet Rail Network, 1955

Notes for Lecture 17-18

CSE 521: Design & Analysis of Algorithms I

Flow networks. Flow Networks. A flow on a network. Flow networks. The maximum-flow problem. Introduction to Algorithms, Lecture 22 December 5, 2001

Main Reference: Sections in CLRS.

CS4445/9544 Analysis of Algorithms II Solution for Assignment 1

18 Extensions of Maximum Flow

Randomized Perfect Bipartite Matching

Please Complete Course Survey. CMPSCI 311: Introduction to Algorithms. Approximation Algorithms. Coping With NP-Completeness. Greedy Vertex Cover

Ground Rules. PC1221 Fundamentals of Physics I. Kinematics. Position. Lectures 3 and 4 Motion in One Dimension. A/Prof Tay Seng Chuan

Graphs III - Network Flow

CS 473G Lecture 15: Max-Flow Algorithms and Applications Fall 2005

Discussion Session 2 Constant Acceleration/Relative Motion Week 03

Matching. Slides designed by Kevin Wayne.

Network flows. The problem. c : V V! R + 0 [ f+1g. flow network G = (V, E, c), a source s and a sink t uv not in E implies c(u, v) = 0

1 Motivation and Basic Definitions

EECE 301 Signals & Systems Prof. Mark Fowler

24 Single-Source Shortest Paths

Welcome Back to Physics 215!

16 Max-Flow Algorithms and Applications

Linear Motion, Speed & Velocity

Dynamic Programming 11/8/2009. Weighted Interval Scheduling. Weighted Interval Scheduling. Unweighted Interval Scheduling: Review

CMU-Q Lecture 3: Search algorithms: Informed. Teacher: Gianni A. Di Caro

2.1: What is physics? Ch02: Motion along a straight line. 2.2: Motion. 2.3: Position, Displacement, Distance

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

6/3/2009. CS 244 Algorithm Design Instructor: t Artur Czumaj. Lecture 8 Network flows. Maximum Flow and Minimum Cut. Minimum Cut Problem.

Math 2214 Solution Test 1 B Spring 2016

KINEMATICS IN ONE DIMENSION

Algorithms and Data Structures 2011/12 Week 9 Solutions (Tues 15th - Fri 18th Nov)

Algorithm Design and Analysis

Math 2214 Solution Test 1A Spring 2016

Constant Acceleration

Greedy. I Divide and Conquer. I Dynamic Programming. I Network Flows. Network Flow. I Previous topics: design techniques

Introduction to SLE Lecture Notes

Lecture 2-1 Kinematics in One Dimension Displacement, Velocity and Acceleration Everything in the world is moving. Nothing stays still.

PHYSICS Solving Equations

Math 221: Mathematical Notation

Geometric Path Problems with Violations

Chapter 3 Kinematics in Two Dimensions

Maximum Flow. Contents. Max Flow Network. Maximum Flow and Minimum Cut

Physics 218 Exam 1 with Solutions Spring 2011, Sections ,526,528

Phys 221 Fall Chapter 2. Motion in One Dimension. 2014, 2005 A. Dzyubenko Brooks/Cole

How to Solve System Dynamic s Problems

= ( ) ) or a system of differential equations with continuous parametrization (T = R

CS 4495 Computer Vision Tracking 1- Kalman,Gaussian

Selfish Routing and the Price of Anarchy. Tim Roughgarden Cornell University

Reminder: Flow Networks

Graph Theory: Network Flow

Physics 240: Worksheet 16 Name

Average Case Lower Bounds for Monotone Switching Networks

( ) a system of differential equations with continuous parametrization ( T = R + These look like, respectively:

4/12/12. Applications of the Maxflow Problem 7.5 Bipartite Matching. Bipartite Matching. Bipartite Matching. Bipartite matching: the flow network

Physics 218 Exam 1. with Solutions Fall 2010, Sections Part 1 (15) Part 2 (20) Part 3 (20) Part 4 (20) Bonus (5)

CS Lunch This Week. Special Talk This Week. Soviet Rail Network, Flow Networks. Slides20 - Network Flow Intro.key - December 5, 2016

23 Maximum Flows and Minimum Cuts

On the Submodularity of Influence in Social Networks

6. DYNAMIC PROGRAMMING II

3.6 Derivatives as Rates of Change

Q2.1 This is the x t graph of the motion of a particle. Of the four points P, Q, R, and S, the velocity v x is greatest (most positive) at

, the. L and the L. x x. max. i n. It is easy to show that these two norms satisfy the following relation: x x n x = (17.3) max

T L. t=1. Proof of Lemma 1. Using the marginal cost accounting in Equation(4) and standard arguments. t )+Π RB. t )+K 1(Q RB

Flow networks, flow, maximum flow. Some definitions. Edmonton. Saskatoon Winnipeg. Vancouver Regina. Calgary. 12/12 a.

2. VECTORS. R Vectors are denoted by bold-face characters such as R, V, etc. The magnitude of a vector, such as R, is denoted as R, R, V

IB Physics Kinematics Worksheet

Chapter 10 INDUCTANCE Recommended Problems:

Algorithm Design and Analysis

CS781 Lecture 3 January 27, 2011

Algorithms. Algorithms 6.4 MAXIMUM FLOW

5.1 - Logarithms and Their Properties

arxiv: v1 [cs.cg] 21 Mar 2013

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

Designing Information Devices and Systems I Spring 2019 Lecture Notes Note 17

Flow Networks. Ma/CS 6a. Class 14: Flow Exercises

MEI Mechanics 1 General motion. Section 1: Using calculus

Notes on cointegration of real interest rates and real exchange rates. ρ (2)

! ln 2xdx = (x ln 2x - x) 3 1 = (3 ln 6-3) - (ln 2-1)

CSC 364S Notes University of Toronto, Spring, The networks we will consider are directed graphs, where each edge has associated with it

Algorithm Design and Analysis

Selfish Routing. Tim Roughgarden Cornell University. Includes joint work with Éva Tardos

16 Max-Flow Algorithms

Christos Papadimitriou & Luca Trevisan November 22, 2016

Math 23 Spring Differential Equations. Final Exam Due Date: Tuesday, June 6, 5pm

Transcription:

Objecive Wrap up: Weighed, direced graph hore pah Minimum Spanning Tree eb, 1 SI - Sprenkle 1 Review Wha are greedy algorihm? Wha i our emplae for olving hem? Review he la problem we were working on: Single-ource, weighed-graph hore pah Ø Wha wa our approach o olving he problem? eb, 1 SI - Sprenkle 1

Review: Shore Pah Problem Given Ø ireced graph G = (V, ) Ø Source, deinaion Ø Lengh! e = lengh of edge e (non-negaive) Shore pah problem: find hore direced pah from o www.wlu.edu 3 o of pah ---- = + 3 + + = 48 www.cnn.com eb, 1 SI - Sprenkle 3 Wha wa our raegy? 1 co of pah = um of edge co in pah Review: ijkra lgorihm 1. Mainain a e of explored node S Ø Keep he hore pah diance d(u) from o u. Iniialize S={}, d()=, u, d(u)= 3. Repeaedly chooe unexplored node v which imize π ( v) = d( u) + e, Ø dd v o S and e d(v) = p(v) S d(u) u! e e = ( u, v) : u S v hore pah o (ome u in explored par followed by a ingle edge (u, v)) Implemenaion Idea Wha o repreen? How o repreen? eb, 1 SI - Sprenkle 4

ijkra Shore Pah lgorihm ind hore pah from o 4 1 eb, 1 SI - Sprenkle ijkra Shore Pah lgorihm S = { } PQ = {,,,,,,, } Iniialize diance o all node o infiniy 4 1 diance label eb, 1 SI - Sprenkle 3

ijkra Shore Pah lgorihm S = { } PQ = {,,,,,,, } elee 4 1 diance label eb, 1 SI - Sprenkle 7 ijkra Shore Pah lgorihm S = { } PQ = {,,,,,, } ecreae key xplored Se dd node o explored e X Updae diance o node i poin o 4 X 1 diance label X eb, 1 SI - Sprenkle 8 4

ijkra Shore Pah lgorihm S = { } PQ = {,,,,,, } ecreae key Updae PQ baed on he diance xplored Se X 4 1 diance label X eb, 1 SI - Sprenkle ijkra Shore Pah lgorihm S = { } PQ = {,,,,,, } elee xplored Se Selec node wih imum lengh from explored e (from PQ) 4 X 1 diance label X eb, 1 SI - Sprenkle 1

ijkra Shore Pah lgorihm S = {, } PQ = {,,,,, } elee xplored Se dd node o explored e 4 X 1 diance label X eb, 1 SI - Sprenkle ijkra Shore Pah lgorihm xplored Se S = {, } PQ = {,,,,, } Updae diance o node ha poin o, if maller 4 ecreae key X 33 1 eb, 1 SI - Sprenkle 1

ijkra Shore Pah lgorihm xplored Se S = {, } PQ = {,,,,, } elee he imum node from PQ, dd i o S elee 4 X 33 1 eb, 1 SI - Sprenkle 13 ijkra Shore Pah lgorihm S = {,, } PQ = {,,,, } dd o S 33 elee X 4 1 eb, 1 SI - Sprenkle 7

ijkra Shore Pah lgorihm S = {,, } PQ = {,,,, } Updae diance o node poin o, if maller X 4 3 33 X 1 eb, 1 SI - Sprenkle ijkra Shore Pah lgorihm S = {,, } PQ = {,,,, } Remove from PQ 3 4 1 elee eb, 1 SI - Sprenkle 8

ijkra Shore Pah lgorihm S = {,,, } PQ = {,,, } dd o S, Updae diance o node X 3 4 3 1 elee X eb, 1 SI - Sprenkle 17 ijkra Shore Pah lgorihm S = {,,, } PQ = {,,, } elee from PQ 4 X 3 elee 3 1 X eb, 1 SI - Sprenkle

ijkra Shore Pah lgorihm S = {,,,, } PQ = {,, } dd o S, Updae diance o node 3 X 34 4 elee 3 1 1 X eb, 1 SI - Sprenkle 1 ijkra Shore Pah lgorihm S = {,,,, } PQ = {,, } elee 4 34 1 elee 1 eb, 1 SI - Sprenkle 3 1

ijkra Shore Pah lgorihm S = {,,,,, } PQ = {, } dd o S, Updae diance o node 4 4 X 34 1 elee 1 X eb, 1 SI - Sprenkle 1 3 ijkra Shore Pah lgorihm S = {,,,,, } PQ = {, } elee 3 34 4 elee 4 1 1 X eb, 1 SI - Sprenkle

ijkra Shore Pah lgorihm S = {,,,,,, } PQ = { } dd o S, Updae diance o node 34 4 4 3 1 1 X eb, 1 SI - Sprenkle 3 ijkra Shore Pah lgorihm S = {,,,,,, } PQ = { } 3 34 4 4 1 elee eb, 1 SI - Sprenkle 4 1

ijkra Shore Pah lgorihm S = {,,,,,,, } PQ = { } dd o S, Updae diance o node 34 4 4 3 1 elee eb, 1 SI - Sprenkle ijkra Shore Pah lgorihm S = {,,,,,,, } PQ = { } 3 34 4 4 1 eb, 1 SI - Sprenkle 13

ijkra' lgorihm: Proof of orrecne Invarian. or each node u Î S, d(u) i he lengh of he hore -u pah Pf. (by inducion on S ) ae cae: S =1 Inducive hypohei? Nex ep? eb, 1 SI - Sprenkle 7 ijkra' lgorihm: Proof of orrecne Prove: or each node u Î S, d(u) i he lengh of he hore -u pah Pf. (by inducion on S ) ae cae: or S = 1, S={}; d() = Inducive hypohei: ume rue for S = k, k ³ 1 Proof: Ø Grow S o k+1 Ø Greedy: dd node v by u v Ø Wha do we know abou u? Ø Why didn Greedy pick y a he nex node? Ø Wha can we ay abou all oher v pah? S P' u x Greedy P v y eb, 1 SI - Sprenkle 8

ijkra' lgorihm: Proof of orrecne Prove: or each node u Î S, d(u) i he lengh of he hore -u pah Pf. (by inducion on S ) Inducive hypohei: ume rue for S = k, k ³ 1 Proof: Ø Le v be he nex node added o S by Greedy, and le uàv be he choen edge Ø The hore àu pah plu uàv i an àv pah of lengh p(v) Ø onider any àv pah P. I' no horer han p(v). Ø Le xày be he fir edge in P ha leave S, and le P' be he ubpah o x. Ø P i already oo long a oon a i leave S. In erm of inequaliie:! (P) ³! (P') +! (x,y) = d(x) +! (x, y) ³ p(y) ³ p(v) nonnegaive weigh inducive hypohei defn of p(y) ijkra choe v inead of y eb, 1 SI - Sprenkle S P' u x Greedy P v y icuion: ijra lgorihm Why doe he algorihm break down if we allow negaive weigh/co on edge? 4 3 1 7 eb, 1 SI - Sprenkle

ijkra lgorihm: nalyi 1. Mainain a e of explored node S Ø Know he hore pah diance d(u) from o u. Iniialize S={}, d()=, u, d(u)= 3. Repeaedly chooe unexplored node v which imize π ( v) = d( u) + e, Ø dd v o S and e d(v) = p(v) S d(u) u! e e = ( u, v) : u S v hore pah o ome u in explored par, followed by a ingle edge (u, v) Running ime? Implemenaion? aa rucure? eb, 1 SI - Sprenkle 31 ijkra lgorihm: nalyi 1. Mainain a e of explored node S Ø Keep he hore pah diance d(u) from o u. Iniialize S={}, d()=, u, d(u)= 3. Repeaedly chooe unexplored node v which imize π ( v) = d( u) + e, Ø dd v o S and e d(v) = p(v) PQ Operaion RT of Op # in ijkra Iner xracmin hangekey Impy e = ( u, v) : u S hore pah o ome u in explored par, followed by a ingle edge (u, v) How long doe each operaion ake? How many of each operaion? Toal eb, 1 SI - Sprenkle 3

ijkra lgorihm: Implemenaion or each unexplored node, explicily mainain π(v) = d(u) + e. e = (u,v) : u S Ø Nex node o explore = node wih imum p(v). Ø When exploring v, for each inciden edge e = (v, w), updae π(w) = { π(w), π(v)+ e }. fficien implemenaion. Mainain a prioriy queue of unexplored node, prioriized by p(v) PQ Operaion RT of Op # Prioriy in ijkra Queue Iner log n n xracmin log n n hangekey log n m Impy 1 n Toal eb, 1 SI - Sprenkle 33 ijkra lgorihm: Implemenaion or each unexplored node, explicily mainain π(v) = d(u) + e. e = (u,v) : u S Ø Nex node o explore = node wih imum p(v). Ø When exploring v, for each inciden edge e = (v, w), updae π(w) = { π(w), π(v)+ e }. fficien implemenaion. Mainain a prioriy queue of unexplored node, prioriized by p(v) PQ Operaion RT of Op # Prioriy in ijkra Queue Iner log n n xracmin log n n hangekey log n m Impy 1 n O(m log n) Toal m log n eb, 1 SI - Sprenkle 34 17

Laying able omca wan o lay cable in a neighborhood Ø Reach all houe Ø Lea co Neighborhood Layou o of laying cable bw houe depend on amoun of cable, landcaping, obacle, ec. 3 1 1 7 8 13 8 4 Wha ype of graph? eb, 1 SI - Sprenkle 3 Minimum Spanning Tree (MST) Spanning ree: pan all node in graph Given a conneced graph G = (V, ) wih poiive edge weigh c e, an MST i a ube of he edge T Í uch ha T i a panning ree whoe um of edge weigh i imized 4 4 3 8 1 1 4 8 7 7 T, S G = (V, ) eît c e = eb, 1 SI - Sprenkle 3

Looking ahead Wiki oday: haper 4 (fron maer), 4.1, 4., 4.4 PS due riday eb, 1 SI - Sprenkle 37 1