Shortest Paths in Graphs. Paths in graphs. Shortest paths CS 445. Alon Efrat Slides courtesy of Erik Demaine and Carola Wenk

Similar documents
Minimum Spanning Trees

Examples and applications on SSSP and MST

Preview. Graph. Graph. Graph. Graph Representation. Graph Representation 12/3/2018. Graph Graph Representation Graph Search Algorithms

Cycles and Simple Cycles. Paths and Simple Paths. Trees. Problem: There is No Completely Standard Terminology!

Lecture 20: Minimum Spanning Trees (CLRS 23)

Lucas Test is based on Euler s theorem which states that if n is any integer and a is coprime to n, then a φ(n) 1modn.

Strongly Connected Components

Ερωτήσεις και ασκησεις Κεφ. 10 (για μόρια) ΠΑΡΑΔΟΣΗ 29/11/2016. (d)

Week 3: Connected Subgraphs

Analysis of Algorithms - Elementary graphs algorithms -

Minimum Spanning Trees

Final Exam Solutions

Weighted Graphs. Weighted graphs may be either directed or undirected.

Paths. Connectivity. Euler and Hamilton Paths. Planar graphs.

Introduction to Algorithms

External Equivalent. EE 521 Analysis of Power Systems. Chen-Ching Liu, Boeing Distinguished Professor Washington State University

Analysis of Algorithms - Elementary graphs algorithms -

Spanning Trees. BFS, DFS spanning tree Minimum spanning tree. March 28, 2018 Cinda Heeren / Geoffrey Tien 1

The Matrix Exponential

CSE 373: More on graphs; DFS and BFS. Michael Lee Wednesday, Feb 14, 2018

Outline. 1 Introduction. 2 Min-Cost Spanning Trees. 4 Example

The Matrix Exponential

4.1 Interval Scheduling. Chapter 4. Greedy Algorithms. Interval Scheduling: Greedy Algorithms. Interval Scheduling. Interval scheduling.

Chapter 10. The singular integral Introducing S(n) and J(n)

Introduction to Algorithms

4D SIMPLICIAL QUANTUM GRAVITY

The University of Sydney MATH 2009

Review - Probabilistic Classification

CMPS 2200 Fall Graphs. Carola Wenk. Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk

Correlation in tree The (ferromagnetic) Ising model

12/3/12. Outline. Part 10. Graphs. Circuits. Euler paths/circuits. Euler s bridge problem (Bridges of Konigsberg Problem)

5/9/13. Part 10. Graphs. Outline. Circuits. Introduction Terminology Implementing Graphs

Outline. Computer Science 331. Computation of Min-Cost Spanning Trees. Costs of Spanning Trees in Weighted Graphs

Searching Linked Lists. Perfect Skip List. Building a Skip List. Skip List Analysis (1) Assume the list is sorted, but is stored in a linked list.

Introduction to Algorithms

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

Heisenberg Model. Sayed Mohammad Mahdi Sadrnezhaad. Supervisor: Prof. Abdollah Langari

CS 491 G Combinatorial Optimization

Jones vector & matrices

Total Prime Graph. Abstract: We introduce a new type of labeling known as Total Prime Labeling. Graphs which admit a Total Prime labeling are

Minimum Spanning Trees

ON THE COMPLEXITY OF K-STEP AND K-HOP DOMINATING SETS IN GRAPHS

9.5 Complex variables

Basic Polyhedral theory

V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

LECTURE 6 TRANSFORMATION OF RANDOM VARIABLES

ECE COMBINATIONAL BUILDING BLOCKS - INVEST 13 DECODERS AND ENCODERS

10/7/14. Mixture Models. Comp 135 Introduction to Machine Learning and Data Mining. Maximum likelihood estimation. Mixture of Normals in 1D

Soft k-means Clustering. Comp 135 Machine Learning Computer Science Tufts University. Mixture Models. Mixture of Normals in 1D

Outlier-tolerant parameter estimation

5/1/2018. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees

Weighted graphs -- reminder. Data Structures LECTURE 15. Shortest paths algorithms. Example: weighted graph. Two basic properties of shortest paths

Folding of Regular CW-Complexes

Section 6.1. Question: 2. Let H be a subgroup of a group G. Then H operates on G by left multiplication. Describe the orbits for this operation.

The Hyperelastic material is examined in this section.

(Minimum) Spanning Trees

EEO 401 Digital Signal Processing Prof. Mark Fowler

10. EXTENDING TRACTABILITY

September 27, Introduction to Ordinary Differential Equations. ME 501A Seminar in Engineering Analysis Page 1. Outline

CSE303 - Introduction to the Theory of Computing Sample Solutions for Exercises on Finite Automata

Introduction to Algorithms

BINOMIAL COEFFICIENTS INVOLVING INFINITE POWERS OF PRIMES. 1. Statement of results

minimize c'x subject to subject to subject to

Independent Domination in Line Graphs

COMP108 Algorithmic Foundations

Solutions to Homework 5

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

Graph Search Algorithms CSE

Combinatorial Networks Week 1, March 11-12

Integration Continued. Integration by Parts Solving Definite Integrals: Area Under a Curve Improper Integrals

Introduction to logistic regression

An undirected graph G = (V, E) V a set of vertices E a set of unordered edges (v,w) where v, w in V

Filter Design Techniques

Function Spaces. a x 3. (Letting x = 1 =)) a(0) + b + c (1) = 0. Row reducing the matrix. b 1. e 4 3. e 9. >: (x = 1 =)) a(0) + b + c (1) = 0

2. Laser physics - basics

Classical Magnetic Dipole

CSE 373: AVL trees. Warmup: Warmup. Interlude: Exploring the balance invariant. AVL Trees: Invariants. AVL tree invariants review

priority queue ADT heaps 1

Graphs. CSC 1300 Discrete Structures Villanova University. Villanova CSC Dr Papalaskari

Economics 600: August, 2007 Dynamic Part: Problem Set 5. Problems on Differential Equations and Continuous Time Optimization

The Equitable Dominating Graph

Improving Union. Implementation. Union-by-size Code. Union-by-Size Find Analysis. Path Compression! Improving Find find(e)

Graphs. Graphs. Graphs: Basic Terminology. Directed Graphs. Dr Papalaskari 1

(A) the function is an eigenfunction with eigenvalue Physical Chemistry (I) First Quiz

Strongly connected components. Finding strongly-connected components

u x v x dx u x v x v x u x dx d u x v x u x v x dx u x v x dx Integration by Parts Formula

UNTYPED LAMBDA CALCULUS (II)

Propositional Logic. Combinatorial Problem Solving (CPS) Albert Oliveras Enric Rodríguez-Carbonell. May 17, 2018

The second condition says that a node α of the tree has exactly n children if the arity of its label is n.

CSC Design and Analysis of Algorithms. Example: Change-Making Problem

Algorithmic and NP-Completeness Aspects of a Total Lict Domination Number of a Graph

y = 2xe x + x 2 e x at (0, 3). solution: Since y is implicitly related to x we have to use implicit differentiation: 3 6y = 0 y = 1 2 x ln(b) ln(b)

Multiple Short Term Infusion Homework # 5 PHA 5127

ANALYSIS IN THE FREQUENCY DOMAIN

CHAPTER 33: PARTICLE PHYSICS

, each of which is a tree, and whose roots r 1. , respectively, are children of r. Data Structures & File Management

Design and Analysis of Algorithms

Spanning Tree. Preview. Minimum Spanning Tree. Minimum Spanning Tree. Minimum Spanning Tree. Minimum Spanning Tree 10/17/2017.

A general N-dimensional vector consists of N values. They can be arranged as a column or a row and can be real or complex.

Construction of asymmetric orthogonal arrays of strength three via a replacement method

Transcription:

S 445 Shortst Paths n Graphs lon frat Sls courtsy of rk man an arola Wnk Paths n raphs onsr a raph G = (V, ) wth -wht functon w : R. Th wht of path p = v v v k s fn to xampl: k = w ( p) = w( v, v + ). v 4 v 5 v v 4 v 5 w(p) = Shortst paths shortst path from u to v s a path of mnmum wht from u to v. Th shortstpath wht from u to v s fn as δ(u, v) = mn{w(p) : p s a path from u to v}. lso call stanc of u from v Not: δ(u, v) = f no path from u to v xsts.

Th stanc s not always wll fn cycl wth natv wht s call (surprs) a natv cycl Th stanc twn nos mht not fn n th prsnc of natv cycls. xampl: v v 4 5 v v 4 v 5 δ(v, v 5 )=? Optmal sustructur Thorm. supath of a shortst path s a shortst path. Proof. ut an past: s u v t Tranl nqualty Thorm. For all u, v, x V, w hav Proof. u δ(u, v) δ(u, x) + δ(x, v). δ(u, v) v δ(u, x) δ(x, v) x Not: Ths os not mply that w(u,v) w(u,x)+w(x,v) u x v

Prorty Quu ky[v] ky[rht[v]] ky[v] ky[lft[v]] 5 Insrt(x), xtract_mn cras(x,δ) 5 5 5 45 ll on n O(lo n) FS Gvn a raph G(V,) whr th cost of ach s. FS fns th stanc δ(s, v) from th sourc s, to vry vrtx v s c f h ffrnt way to thnk aout FS al Thnk aout th rppls n th pool aftr a pul was ropp at th sourc. vry vrtx s scovr onc th frontr hts t. Sourc s c f h Frontr Th stanc δ(s, v) s th tm whn th vrtx s ht.

ffrnt way to thnk aout jkstra l Now th s hav whts. (assum ntrs) an thnk aout th rppls n th pool aftr a pul was ropp at th sourc. Mofy th Graph Rplac an (s,) of s wht y s of f h wht. Rplac an (u,v) wth wht w(u,v) y s of wht. Th stanc δ(s, v) s th tm whn th vrtx s ht. c Run FS jkstra al s an ffcnt way to smulat ths procss Snl-sourc shortst paths Prolm. From a vn sourc vrtx s V, fn th shortst-path whts δ(s, v) for all v V. If all whts w(u, v) ar nonnatv, all shortst-path whts must xst. W ll us jkstra s. I: Gry.. Mantan a st S of vrtcs whos shortst-path stancs from s ar known. lso mantan stanc stmats to th othr vrtcs.. t ach stp a to S th vrtx v V S whos stanc stmat from s s mnmal.. Upat th stanc stmats of vrtcs ajacnt to v. S s p V v Intrnal paths - fnton. Lt S a st of vrtcs (that contans s ). W say that path p s ntrnal to S f all ts vrtcs, xclun may th last on, ar n S.. stanc stmaton: Th mantans for vry vrtx v th valu [v], whch s th lnth of th shortst path from s to v, whch s ntrnal to S. 4. Wll show: If v s n S, thn [v]= δ(s, v) S V s p v

jkstra s [s] for ach v V {s} o [v] S Q V Q s a prorty quu mantann V S, sort as on [ ] whl Q o u XTRT-MIN(Q) S S {u} for ach v j[u] /* all nrs of u */ o f [v] > [u] + w(u, v) thn [v] [u] + w(u, v) Implct RS-KY rlaxaton stp xampl of jkstra s Graph wth nonnatv whts: Intalz: xampl of jkstra s S: {}

xampl of jkstra s XTRT-MIN(Q): S: { } xampl of jkstra s Rlax all s lavn : - - S: { } xampl of jkstra s XTRT-MIN(Q): - - S: {, }

xampl of jkstra s Rlax all s lavn : - - 5 5 S: {, } xampl of jkstra s XTRT-MIN(Q): - - 5 5 S: {,, } xampl of jkstra s Rlax all s lavn : 5 5 S: {,, }

xampl of jkstra s XTRT-MIN(Q): 5 5 S: {,,, } xampl of jkstra s Rlax all s lavn : 5 9 9 5 S: {,,, } xampl of jkstra s XTRT-MIN(Q): 5 9 9 5 S: {,,,, }

orrctnss Part I Lmma. t any sta of th, an for vry vrtx v V, t s always tru that [v] δ(s, v). Proof. It s tru aftr ntalzaton (trvally). Suppos not. Lt v th frst (chronolocally) vrtx for whch [v] < δ(s, v), an lt u th vrtx that caus [v] to chan: [v] = [u] + w(u, v). Thn, [v] < δ(s, v) supposton δ(s, u) + δ(u, v) tranl nqualty δ(s,u) + w(u, v) sh. path spcfc path [u] + w(u, v) v s frst volaton ontracton. Hanwav: [v] s th lnth of a path to v, whl δ(s,v) s th lnth of th shortst path to v. Mor accuratly. [v] s th lnth of shortst ntrnal path. orrctnss Part II Thorm. Whn th trmnats, [v] = δ(s, v), v V. Proof. It suffcs to show that [v] = δ(s, v), whn v s a to S. Suppos u s th frst vrtx a to S for whch [u] > δ(s, u). Rcall: [u] δ(s, u) always. Lt y th frst vrtx n V S alon a shortst path from s to u, an lt x ts prcssor: S, just for an u. s x y u orrctnss Part II (contnu) s S x y u ssumpton: [u] > δ(s, u). Snc u s th frst vrtx volatn th clam nvarant, [x] = δ(s, x). Snc supaths of shortst paths ar shortst paths, δ(s, y)= δ(s, x) + w(x, y) Whn x jon S, w prform a rlaxaton stp: [y]=mn{[y], [x]+w(x,y)} so [y]=δ(s, y) If u s y w ar on. So assum u s not y. W hav [y] = δ(s, y) δ(s, u) < [u]. ut, [u] [y] y our choc of u, a contracton.

nalyss of jkstra V tms r(u) tms whl Q o u XTRT-MIN(Q) S S {u} for ach v j[u] o f [v] > [u] + w(u, v) thn [v] [u] + w(u, v) Hanshakn Lmma Θ() mplct RS_KY s. Tm = Θ(V) T XTRT-MIN + Θ() T RS-KY nalyss of jkstra (contnu) Tm = Θ(V) T XTRT-MIN + Θ() T RS-KY Q T XTRT-MIN T RS-KY Total array O(V) O() O(V ) nary hap Fonacc hap O(l V) O(l V) O( l V) O(l V) amortz O() amortz O( + V l V) worst cas How to fn th actual shortst paths? Stor a prcssor tr: [s] ; for ach v V π[v] NULL for ach v V {s} o [v] S Q V Q s a prorty quu mantann V S whl Q o u XTRT-MIN(Q) S S {u} for ach v j[u] o f [v] > [u] + w(u, v) thn [v] [u] + w(u, v) π[v] u //Proucn s of // th shortst paths tr onvnc yourslf that n th s {(v, π [v ]) v n V } Form a tr. What s ts root? Why ar thr no cycls?

xampl of jkstra s Graph wth nonnatv whts: Intalz: xampl of jkstra s S: {} xampl of jkstra s XTRT-MIN(Q): S: { } π: - - - - -

xampl of jkstra s Rlax all s lavn : - - S: { } π: - Α Α - - xampl of jkstra s XTRT-MIN(Q): - - S: {, } π: - Α Α - - xampl of jkstra s Rlax all s lavn : - - 5 5 S: {, } π: - Α

xampl of jkstra s XTRT-MIN(Q): - - 5 5 S: {,, } π: - Α xampl of jkstra s Rlax all s lavn : 5 5 S: {,, } π: - Α xampl of jkstra s XTRT-MIN(Q): 5 5 S: {,,, } π: - Α

xampl of jkstra s Rlax all s lavn : 5 9 5 S: {,,, } 9 π: - Α xampl of jkstra s XTRT-MIN(Q): 5 9 9 5 S: {,,,, } π: - Α Unwht raphs Suppos w(u, v) = for all (u, v). Us a smpl FIFO quu nsta of a prorty quu. Hr [v] s an stmaton to th stanc rath-frst sarch [s] =. for all v V-s, [v]= NQUU(Q, s) whl Q o u QUU(Q) for ach v j[u] //scan th nrs of u" o f [v] = //f not sn for thn [v] [u] + NQUU(Q, v) nalyss: Tm = O(V + ).

xampl of rath-frst sarch a f h c xampl of rath-frst sarch a f h c a xampl of rath-frst sarch a f h c a

xampl of rath-frst sarch a c a c f h xampl of rath-frst sarch a c a c f h xampl of rath-frst sarch a c a c f h

xampl of rath-frst sarch a f c a c h xampl of rath-frst sarch a 4 f h c 4 a c f xampl of rath-frst sarch 4 4 a f h c 4 4 a c f h

xampl of rath-frst sarch 4 4 a f h c 4 a c f h xampl of rath-frst sarch 4 4 a f h c a c f h xampl of rath-frst sarch 4 4 a f h c a c f h