Attribution Non-Commercial (BY-NC)

45 views

Attribution Non-Commercial (BY-NC)

- Finite Element Method Intro
- Precalculus Performance Task 1.1 (1)
- Solucionarios Calculo Fisica Mecanica Algebra Vectoria Logistica Dinamica Estatica Etc
- expressions and equations math 7th grade
- quiz-eecs2602.pdf
- IS_Tp03-3
- Step 1: Look for a GCF.
- Chapter 3
- D-bredd-eng-vt99
- Lecture 1 Functions, Limits
- 38159924 MATH Portfolio I Stellar Numbers
- Babuska81
- Closed profile spline filter library
- Aptitude Shortcuts and Mind Tricks for Partnership Problems Type-II
- Main
- Pre Algebra Lesson 2 3
- MAT 116 AID Education Expert-mat116aid.com
- Maths
- dp
- Honors Advanced Calculus and Linear Algebra p4

You are on page 1of 13

1

Recall the All-Pairs Shortest Paths Problem

function , where is the set of real num-

bers, determine the length of the shortest path (i.e.,

distance) between all pairs of vertices in . Here we

assume that there are no cycle with zero or negative

cost.

a 20 b a −20 b

6 e 3 e

12 8 4 4 5

5 3 4

4

17 10

d c d c

2

Solutions Covered in the Previous Lecture

time .

a natural decomposition of the problem. Running

time .

gorithm, the Floyd-Warshall algorithm, with time com-

plexity .

It also illustrate that there could be more than one way

of developing a dynamic programming algorithm.

3

Solution 3: the Input and Output Format

assume that the graph is represented by an

matrix with the weights of the edges:

$%

if #

& $'

$ )$'

*

! " # if # ( and # ,

+ $ ) $'

,*

if # ( and # .

./

Output Format: an distance - 10 where

/ $

is the distance from vertex # to .

4

Step 1: The Floyd-Warshall Decomposition

6575858

Definition: The vertices 243 2 2 9<;>= are called the

:

@ 585857

6

intermediate vertices of the path ? 2 = 2:3 2A9CB .

/ED)FHG

Let be the length of the shortest path from

$

# to such that any intermediate vertices on the

KLM565M56N%O

path (if any) are chosen from the set I'J .

/ DQP:G

is defined to be , i.e., no intermediate ver-

tex.

DQFHG .R/%D)FHG

Let - be the matrix 0 .

/EDTSG $

is the distance from # to . So our aim is to

DUSG

compute - .

DQFHG N 6VMV6VMWX5

Subproblems: compute - for J

"

5

Step 2: Structure of shortest paths

Observation 1:

A shortest path does not contain the same vertex twice.

Proof: A path that contains the same vertex twice,

contains a cycle. Removing the cycle gives a shorter

path.

$

Observation 2: For a shortest path from # to such

that any intermediate vertices on the path are chosen

WKLM56565MN%O

from the set I'J , there are two possibilities:

N

1. is not a vertex on the path,

/YDQF ;>= G

The shortest such path has length .

N

2. is a vertex on the path.

/YDQF ;>= G /ED)F ;>= G

The shortest such path has length F Z F .

6

Step 2: Structure of shortest paths

$

Consider a shortest path from # to containing the

N N

vertex . It consists of a subpath from # to and a

N $

subpath from to .

Each of them only contains intermediate vertices in

M585858 N [ O

IJ J , and must be as short as possible,

/ D)F ;>= G / D)F ;>= G

namely F and F .

/ QD F ;>= G / QD F ;>= G

Hence the path has length F Z F .

/ QD FHG \ ]8^ / QD F ;>= G / DQF ;>= G / )D F ;_= G O`5

I F Z F

7

Step 3: the Bottom-up Computation

DQP:G .

Bottom: - aM0 , the weight matrix.

Compute - from - using

/EDQFHG \ 8] ^ bc/EDQF ;>= G d/ED)F ;_= G /EDQF ;>= G

F Z F e

N 585858f

M

for J .

8

The Floyd-Warshall Algorithm

f

Floyd-Warshall( )

g

for # J to do

$

for J to do

g /h. ) $ . &$

# 0 # 0;

/h. &$

?EiAj # 0 )# k ;

l

N

for J to do

for # J to do

$

for J to do

d/h. mN /h.nNop$ /h. ) $

if # 0 Z 0q # 0

g /h. & $ h / . N /h.nNop$

# 0 # 0 Z 0;

/h. p$ N

?EiAj # 0 ;

l

/h. 575rX 585s

return J J 0;

l

9

Comments on the Floyd-Warshall Algorithm

NE

This does not affect the correctness

of the algorithm.

Why???

.{z|d}

The predecessor pointer tvuxwAy 0 can be used

to extract the final path (see next page).

10

Extracting the Shortest Paths

.z`d}

The predecessor pointers tvu~wAy 0 can be used to

extract the final path. The idea is as follows.

$ N

to passes through an intermediate vertex , we set

/h. p$ N

?EiAj # 0 .

/h. &$

mediate vertex, then ?%iAj # 0 )# k .

$ /h. )$

To find the shortest path from # to , we consult ?%iAj # 0 .

)$'

Otherwise, we recursively compute the shortest path

/h. p$ /h. &$

from # to ?EiAj # 0 and the shortest path from ?EiAj # 0

$

to .

11

The Algorithm for Extracting the Shortest Paths

Q$

Path( # )

g /h. &$

if (?EiAj # 0 #)k ) single edge

&$'

output # ;

else compute the two parts of the path

g

/h. p$

Path( # ?EiAj # 0 );

/h. p$ ) $

Path(?%ij # 0 );

l

l

12

Example of Extracting the Shortest Paths

KL575 WKL

/h.K m

Path ?EiAj 0

KL575r 585 WKLd

/h.K

Path ?EiAj 0

KL575R 585s585 WKL

/h.K

Path ?EiAj 0 #)k T?EY (2,5)

K 585r 585 d

/h.n

Path ?EiAj 0 )# k T?EY (5,4)

Kh 585

/h.Rm

Path m

?EiAj 0

Kh 585R 585 /h.R

Path ?EiAj 0 #)k T?EY (4,6)

KhY 585

/h.m

Path ?EiAj 0 )# k T?EY (6,3)

KhYo

13

- Finite Element Method IntroUploaded byNadheera Senasinghe
- Precalculus Performance Task 1.1 (1)Uploaded byAria Carino
- Solucionarios Calculo Fisica Mecanica Algebra Vectoria Logistica Dinamica Estatica EtcUploaded byalxeslavas
- expressions and equations math 7th gradeUploaded byapi-240347221
- quiz-eecs2602.pdfUploaded bysiarwafa
- IS_Tp03-3Uploaded byRatnakar Swain
- Step 1: Look for a GCF.Uploaded byapi-26199179
- Chapter 3Uploaded byJazz Kaur
- D-bredd-eng-vt99Uploaded byEpic Win
- Lecture 1 Functions, LimitsUploaded bymubashk
- 38159924 MATH Portfolio I Stellar NumbersUploaded byStelios Drazinakis
- Babuska81Uploaded byDuong Pham
- Closed profile spline filter libraryUploaded byRohith M. Athreya
- Aptitude Shortcuts and Mind Tricks for Partnership Problems Type-IIUploaded byssd231
- MainUploaded byMajid Khorsand Vakilzadeh
- Pre Algebra Lesson 2 3Uploaded by412137
- MAT 116 AID Education Expert-mat116aid.comUploaded bynanna07
- MathsUploaded byarup giri
- dpUploaded byKisalay Kumar
- Honors Advanced Calculus and Linear Algebra p4Uploaded bymarchelo_chelo
- Note11Uploaded bynaefmubarak
- mathematical modelingUploaded bykabangi
- seniorproject2pdfUploaded byapi-277844027
- Assignment 1 Computing Applications for EngineersUploaded byAizatZack
- What Do I Mean by Combinatorial Thinking (2)Uploaded byAmmamiarihta Tarigan
- Advanced Functions Ex.1(B)Uploaded byRishi Garg
- Economic Dispatch Termal-2-Hand Out.pdfUploaded byArya Repatmaja
- Dsp Fpga Part1Uploaded byNguyễn Hoàng Dũng
- DOC-20170902-WA0001.pdfUploaded byRajasugumar
- Assembly line schedulingUploaded byJay Gala

- Adaptive Routing AlgorithmUploaded bymcgerald
- 3gpp LTE OverviewUploaded byAmit Chakradeo
- OMF000502 Network Planning Principle ISSUE1.3Uploaded bymcgerald
- Routing in 80216 Mesh Networks a Survey Paper IT610Uploaded bymcgerald
- Algoritmo Floyd WarshallUploaded bymcgerald
- Routing AlgorithmUploaded bymcgerald

- Employee Motivation and Work Performance: A Comparative Study of Mining Companies in GhanaUploaded byAdri Ana
- wdtdriverspecUploaded byJesus Marsa
- MongoDB Performance Best PracticesUploaded byDavid Romero
- Emergency Preparedness Drill FinalUploaded byJacques Owokel
- debate 2Uploaded byapi-256056875
- New Text DocumentUploaded byAnonymous yfhY7Ldpiz
- Oracle Sap Newsletter Vol26 en 3715874Uploaded bySilumula Murali
- What is Sound Art - N. B. AldrichUploaded bymykhos
- HASHIM_Optimal Speed Control for DC Motors Using LQRUploaded byAnonymous PsEz5kGVae
- [Elaine_Carey]_Women_Drug_Traffickers__Mules,_BossUploaded byER
- applicationUploaded byYohanes Dogomo
- Japanese AlphabetUploaded byAniruddho Das
- Bureaucracy. Encyclopedia BritannicaUploaded byjorge gonzalez
- slsu-tomas-oppus-tracer-form.docUploaded byNeWo YanTot
- literature49_Diamante-Neale_Mar-Apr_07Uploaded byBohra Nilesh
- Calendar 2018 DKFUploaded byShaykh Shameem Madni
- Water Treatment Lecture 4 EENVUploaded byEllina Teh
- ANSYS Tcl Tk Legacy Training 2013-02-01Uploaded bySharan Annapura
- Ctet Pp Child Development 02 Answer h8ddUploaded bySaravanan Vanan
- Theory of PowerUploaded bytomjonespage
- HUAWEI ManageOne Service OperationsUploaded byhmendezp
- Regional Municipal Planning StrategyUploaded bycrest
- Scissor Skill Develop.Uploaded byHARRIS
- P5 ForcesUploaded byMrs S Baker
- D7 FinalUploaded bydimitrios25
- gen+phil+mind-body+handoutUploaded byBob Krueger
- Minnesota; Green Roof Fact Sheet - Minnesota Green Roofs CouncilUploaded byFree Rain Garden Manuals
- IEC 61850 Testing Tools ENUUploaded byfaithnic
- Remote Desktop Support With VNCUploaded byAmine Elghazi
- IEC 611158 FieldbusUploaded byDenis Fyodorov