The Shortest Path Problem Graph Algorithms - 3

Similar documents
Mid-Term Examination - Spring 2014 Mathematical Programming with Applications to Economics Total Score: 45; Time: 3 hours

MATH4455 Module 10 Evens, Odds and Ends

Global alignment. Genome Rearrangements Finding preserved genes. Lecture 18

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

SIMPLE NONLINEAR GRAPHS

] dx (3) = [15x] 2 0

Artificial Intelligence Markov Decision Problems

a) Read over steps (1)- (4) below and sketch the path of the cycle on a P V plot on the graph below. Label all appropriate points.

PHYSICS 211 MIDTERM I 22 October 2003

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs

CSCI565 - Compiler Design

CS 347 Parallel and Distributed Data Processing

Exercise sheet 6: Solutions

The Double Integral. The Riemann sum of a function f (x; y) over this partition of [a; b] [c; d] is. f (r j ; t k ) x j y k

CISC 320 Introduction to Algorithms Spring 2014

Section The Precise Definition Of A Limit

18.06 Problem Set 4 Due Wednesday, Oct. 11, 2006 at 4:00 p.m. in 2-106

Prefix-Free Regular-Expression Matching

AQA Further Pure 2. Hyperbolic Functions. Section 2: The inverse hyperbolic functions

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite!

Connectivity in Graphs. CS311H: Discrete Mathematics. Graph Theory II. Example. Paths. Connectedness. Example

AVL Trees. D Oisín Kidney. August 2, 2018

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

CS 491G Combinatorial Optimization Lecture Notes

Tutorial Worksheet. 1. Find all solutions to the linear system by following the given steps. x + 2y + 3z = 2 2x + 3y + z = 4.

Algebra Readiness PLACEMENT 1 Fraction Basics 2 Percent Basics 3. Algebra Basics 9. CRS Algebra 1

22: Union Find. CS 473u - Algorithms - Spring April 14, We want to maintain a collection of sets, under the operations of:

Precalculus Due Tuesday/Wednesday, Sept. 12/13th Mr. Zawolo with questions.

SECTION A STUDENT MATERIAL. Part 1. What and Why.?

Arrow s Impossibility Theorem

CIT 596 Theory of Computation 1. Graphs and Digraphs

Common intervals of genomes. Mathieu Raffinot CNRS LIAFA

Unit 2 Exponents Study Guide

Data Structures LECTURE 10. Huffman coding. Example. Coding: problem definition

CS 188: Artificial Intelligence Spring 2007

CSE 332. Sorting. Data Abstractions. CSE 332: Data Abstractions. QuickSort Cutoff 1. Where We Are 2. Bounding The MAXIMUM Problem 4

Physics 111. Lecture 11 (Walker: 6.1-2) Friction Forces. Frictional Forces. Microscopic Friction. Friction vs. Area

Green s Theorem. (2x e y ) da. (2x e y ) dx dy. x 2 xe y. (1 e y ) dy. y=1. = y e y. y=0. = 2 e

Applications of Definite Integral

April 8, 2017 Math 9. Geometry. Solving vector problems. Problem. Prove that if vectors and satisfy, then.

GM1 Consolidation Worksheet

Languages & Automata

4. UNBALANCED 3 FAULTS

Solutions to assignment 3

Tutorial 2 Euler Lagrange ( ) ( ) In one sentence: d dx

Running an NFA & the subset algorithm (NFA->DFA) CS 350 Fall 2018 gilray.org/classes/fall2018/cs350/

CS 573 Automata Theory and Formal Languages

Nondeterministic Finite Automata

1. Extend QR downwards to meet the x-axis at U(6, 0). y

NON-DETERMINISTIC FSA

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points:

20.2. The Transform and its Inverse. Introduction. Prerequisites. Learning Outcomes

Project 3: Using Identities to Rewrite Expressions

H (2a, a) (u 2a) 2 (E) Show that u v 4a. Explain why this implies that u v 4a, with equality if and only u a if u v 2a.

Transfer Functions. Chapter 5. Transfer Functions. Derivation of a Transfer Function. Transfer Functions

The Ellipse. is larger than the other.

8.3 THE HYPERBOLA OBJECTIVES

Lecture 6: Coding theory

A recursive construction of efficiently decodable list-disjunct matrices

12.4 Similarity in Right Triangles

Applications of Definite Integral

These slides are from 2014 and contain a semi-serious error at one point in the

Calculus Module C21. Areas by Integration. Copyright This publication The Northern Alberta Institute of Technology All Rights Reserved.

Chapter 4 State-Space Planning

1. Twelve less than five times a number is thirty three. What is the number

CSC 373: Algorithm Design and Analysis Lecture 9

Arrow s Impossibility Theorem

Nondeterminism and Nodeterministic Automata

Myriad of applications

Reference : Croft & Davison, Chapter 12, Blocks 1,2. A matrix ti is a rectangular array or block of numbers usually enclosed in brackets.

We will see what is meant by standard form very shortly

Preview 11/1/2017. Greedy Algorithms. Coin Change. Coin Change. Coin Change. Coin Change. Greedy algorithms. Greedy Algorithms

Section 1.3 Triangles

Computational Biology Lecture 18: Genome rearrangements, finding maximal matches Saad Mneimneh

Adding and Subtracting Rational Expressions

50 AMC Lectures Problem Book 2 (36) Substitution Method

A-Level Mathematics Transition Task (compulsory for all maths students and all further maths student)

Data Compression Techniques (Spring 2012) Model Solutions for Exercise 4

Core 2 Logarithms and exponentials. Section 1: Introduction to logarithms

GRAND PLAN. Visualizing Quaternions. I: Fundamentals of Quaternions. Andrew J. Hanson. II: Visualizing Quaternion Geometry. III: Quaternion Frames

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Logarithms. Logarithm is another word for an index or power. POWER. 2 is the power to which the base 10 must be raised to give 100.

( ) 1. 1) Let f( x ) = 10 5x. Find and simplify f( 2) and then state the domain of f(x).

Introduction to Algebra - Part 2

p-adic Egyptian Fractions

6. Suppose lim = constant> 0. Which of the following does not hold?

CARLETON UNIVERSITY. 1.0 Problems and Most Solutions, Sect B, 2005

Hamiltonian Connectedness of Toeplitz Graphs

Lesson 1: Quadratic Equations

5. Every rational number have either terminating or repeating (recurring) decimal representation.

Vector Integration. Line integral: Let F ( x y,

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Vector Integration

CS241 Week 6 Tutorial Solutions

DATA Search I 魏忠钰. 复旦大学大数据学院 School of Data Science, Fudan University. March 7 th, 2018

Chapter 9 Definite Integrals

Surface maps into free groups

Math 1431 Section M TH 4:00 PM 6:00 PM Susan Wheeler Office Hours: Wed 6:00 7:00 PM Online ***NOTE LABS ARE MON AND WED

The Intouch Triangle and the OI-line

Chapter 3 Exponential and Logarithmic Functions Section 3.1

G8-11 Congruence Rules

Transcription:

Algorithm Deign nd Anli Vitor Admhik C - pring Leture Feb, Crnegie Mellon Univerit The hortet Pth Problem Grph Algorithm - The hortet Pth Problem Given poitivel weighted grph G with oure verte, find the hortet pth from to ll other vertie in the grph. 9 8 9 7 Greed pproh When lgorithm proeed ll vertie re divided into two group - vertie whoe hortet pth from the oure i known - vertie whoe hortet pth from the oure i NOT known Move vertie (hortet ditne) one t time from the unknown et to the known et. Mintin PQ of ditne from the oure to verte. The hortet Pth Problem 9 8 9 9 7 Compleit O (V Log V + E log V) Let D(v) denote length from the oure to verte v. We tore ditne D(v) in PQ. O(V) INIT: D() = ; D(v)= PQ h V vertie LOOP: O(log V) Delete node v from PQ uing deletemin() Updte D(w) for ll w in dj(v) uing dereeke() O(log V) We do O(E) updte D(w) = min[d(w), D(v) + (v, w)]

PQ i liner rr Aume tht unorted rr i ued inted of priorit queue. Wht would the lgorithm' running time in thi e? findmin tke O(V) - for one verte findmin tke O(V ) - for ll vertie Updting tke O() - for one edge totl edge djutment O(E) the lgorithm running time O(E + V ) Wh Dijktr lgorithm doe not work on grph with negtive weight? The ellmn-ford lgorithm (98) A repet V - time: for ll e in E: updte(e) -9 The ellmn-ford Algorithm for (k = ; k < V; k++) dit[k] = INFINITY; Queue q = new Queue(); dit[] = ; q.enqueue(); while (!q.iempt()) { v = q.dequeue(); for eh w in dj(v) do if (dit[w] > dit[v] + weight[v,w]) { dit[w] = dit[v] + weight[v,w]; if (!q.iinqueue(w)) q.enqueue(w); }} Wht i the wort-e ompleit of the ellmn-ford lgorithm? for (k = ; k < V; k++) dit[k] = INFINITY; Queue q = new Queue(); V dit[] = ; q.enqueue(); while (!q.iempt()) { v = q.dequeue(); E for eh w in dj(v) do if (dit[w] > dit[v] + weight[v,w]) { dit[w] = dit[v] + weight[v,w]; if (!q.iinqueue(w)) q.enqueue(w); }} O(V E)

Grph with negtive le? A How would ou ppl the ellmn-ford lgorithm to find out if grph h negtive le? -9 How would ou ppl the ellmn- Ford lgorithm to find out if grph h negtive le? Do not top fter V- itertion, perform one more round. If there i uh le, then ome ditne will be redued ellmn-ford Dnmi progrmming pproh We will be ounting the number of edge in the hortet pth Dnmi progrmming pproh For eh node, find the length of the hortet pth to t tht ue t mot edge, or write down if there i no uh pth. uppoe for ll v we hve olved for length of the hortet pth to t tht ue k or fewer edge. How n we ue thi to olve for the hortet pth tht ue k or fewer edge? We go to ome neighbor of v, nd then tke the hortet pth from to t tht ue k or fewer edge. All-Pir hortet Pth (APP) Given weighted grph, find hortet pth from n verte to n other verte. Note, no ditinguihed verte All-Pir hortet Pth One pproh: run Dijktr' lgorithm uing ever verte oure. Compleit: O(V E Log V) pre: O(V Log V) dene: O(V Log V) ut wht bout negtive weight

APP: ellmn-ford APP : Dnmi progrmming pproh Compleit : O(V E) Flod-Wrhll, O(V ) Note, for dene grph we hve O(V ). We won t diu it APP: Johnon lgorithm Compleit: O(V E + V E log V) for dene grph -- O(V log V). Johnon Algorithm It improve the runtime onl when grph h negtive weight. A bird view: - Reweight the grph, o ll weight re nonnegtive (b running ellmn-ford ) - Run Dijktr on ll vertie for pre grph -- O(V log V). Compleit: O(V E + V E log V) Johnon Algorithm: intuition Wrong reweighting (dding the fi mount) The w to improve the runtime i to run Dijktr from eh verte. A ut Dijktr doe not work on negtive edge. o wht bout if we hnge the edge weight to be nonnegtive? We hve to be reful on hnging the edge weight to preerve the hortet pth - C The tul hortet pth to i --C- Let u dd to ll edge

Wrong reweighting (dding the fi mount) A Adding the fi mount doe not work, ine ever hortet pth h different number of edge C hortet pth to i -A- Johnon Algorithm: reweighting Ever edge (v, u) with the ot w(v, u) i repled b where p(v) will be deided lter. w * (v, u) = + (-) = - v p(v)=- w(v, u) = u p(u)= Johnon Algorithm: reweighting Theorem. All pth between the me two vertie re reweighted b the me mount. Proof. Conider pth v = v v v n = u Then we hve w * (v,u) = w * (v, v ) + + w * (v n-, v n ) = w(v, v ) + p(v ) p(v ) + w(v, v ) + p(v ) p(v ) + Teleoping um Johnon reweighting hnge n pth between u nd v b the me mount nd therefore preerve the hortet pth unhnged Find verte lbeling P(v) Firt we need to rete new verte nd onnet it to ll other vertie with zero weight. Note thi hnge in the grph won t hnge the hortet ditne between vertie. - - b - z -

Running P Net we run ellmn-ford trting t verte. hortet Pth - i -b i - - i - nd o on - - - - b - z - Now we define p(v) the hortet ditne -v. - - Johnon Reweighting Here we redrw the emple b uing Edge (,b): -+-(-) = Edge (b,): -+(-)-(-) = Edge (z,): +-(-) = - - - - - b - z - - New grph After Johnon reweighting we get new grph with non-negtive weight. Remember, Johnon reweighting preerve the hortet pth. Now we n ue Dijktr z b Johnon Algorithm: reweighting Theorem. After reweighting ever edge h nonnegtive ot. Proof. Conider edge (v, u) p(v) i the hortet ditne from to v p(u) i the hortet ditne from to u p(u) p(v) + w(v, u) v u ine the hortet pth -u nnot be longer then p(v) + (v, u). QED Johnon Algorithm. Add new verte nd onnet it with ll other vertie.. Run ellmn-ford lgorithm from to ompute p(v). Note tht ellmn-ford lgorithm will orretl report if the originl grph h negtive ot le.. Reweight ll edge: w * (v,u) =w(v,u)+p(v) p(u). Run Dijktr lgorithm from ll vertie. Compute the tul ditne b ubtrting p(v) p(u) Compleit. Add new verte nd onnet it with ll other vertie.. Run ellmn-ford lgorithm from to ompute p(v). O(V) O(V E). Reweight ll edge: w * (v,u) =w(v,u)+p(v) p(u) O(E). Run Dijktr lgorithm from ll vertie O(V E log V). Compute the tul ditne b ubtrting p(v) p(u) O(E) Totl: O(V E log V)

Johnon Algorithm It hine for pre grph with negtive edge O(V log V) etter thn Flod-Wrhll, whih i O(V ) 7