1 / 4

All-Pairs SPs on DG

All-Pairs SPs on DG. Run Dijkstra;s algorithm for each vertex or Use DP: Floyd-Warshall O(n 3 ) algorithm. The structure of SP: Intermediate vertices of P={v 1 ,v 2 ,…,v k }: {v 2 ,v 3 ,…,v k-1 } {1,2,…,k-1} notation for vertices.

sheila
Download Presentation

All-Pairs SPs on DG

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. All-Pairs SPs on DG • Run Dijkstra;s algorithm for each vertex or • Use DP: Floyd-Warshall O(n3) algorithm. • The structure of SP: • Intermediate vertices of P={v1,v2,…,vk}: • {v2,v3,…,vk-1} • {1,2,…,k-1} notation for vertices. • For any i,j of V consider all paths with intermediate vertices in {1,2,…,k}. • Let P be min-weight path found this way.

  2. All-Pairs SP (cont.) • Relation between P and SP(i,j) with intermediate vertices in {1,2,…,k-1} • K not in P: same • K in P: break P: • Recursive solution: dij(k) is weight of SP(i,j) with interm. vertices in {1,2,…,k}. • dij(k)=wij, if k=0; • dij(k)=min{dij(k-1), dik(k-1)+dkj(k-1)} if k >=1. • Matrix D(n)=dij(n) gives final solution.

  3. SP Bottom-Up Computation • W: wij= 0, if i=j; weight of edge (i,j) if exists; “infinity”, otherwise. D(0)=W; For k=1 to n do for i=1 to n do for j=1 to n do dij(k)=min{dij(k-1),dik(k-1)+dkj(k-1)}. Return D(n).

  4. Constructing a SP • Compute predecessor matrix P(n) together with D(n). • Pij(k): predecesor of j on SP(i,j) with intermediate vertices in {1,2,…,k}. • Pij(0)= nil, if i=j or no edge (i,j). i, if edge (i,j). • K >=1: ikj same predecessor as kj with intermediate vertices in {1,2,…,k-1}. • Pij(k)=Pij(k-1), if dij(k-1) <= dik(k-1)+dkj(k-1) • Pij(k)=Pkj(k-1), if dij(k-1) > dik(k-1)+dkj(k-1)

More Related