Download presentation

Presentation is loading. Please wait.

1
**Reachability as Transitive Closure**

Algorithm : Design & Analysis [17]

2
**In the last class… Undirected and Symmetric Digraph**

UDF Search Skeleton Biconnected Components Articulation Points and Biconnectedness Biconnected Component Algorithm Analysis of the Algorithm

3
**Reachability as Transitive Closure**

Transitive Closure by DFS Transitive Closure by Shortcuts Washall’s Algorithm for Transitive Closure All-Pair Shortest Paths

4
**Fundamental Questions**

For all pair of vertices in a graph, say, u, v: Is there a path from u to v? What is the shortest path from u to v? Reachability as a (reflexive) transitive closure of the adjacency relation, which can be represented as a bit matrix.

5
**Computing the Reachability by DFS**

With each vertex vi, constructing a DFS tree rooted at vi. For each vertex vj encountered, R[i][j] is set to true. At most, m edges are processed. It is possible to set one in more than one row during each DFS. (In fact, if vk is on the path from vi to vj, when vj is encountered, not only R[i][j], but also R[k][j] can be set)

6
**Computing Reachability by Condensation Graph**

Note: the elements of the sub-matrix of R for a strong component are all true. The steps: Find the strong components of G, and get G, the condensation graph of G. ((n+m)) Computing reachability for G. Expand the reachability for G to that for G. (O(n2))

7
**Transitive Closure by Shortcuts**

The idea: if there are edges sisk, sksj, then an edge sisj, the “shortcut” is inserted. 1 2 5 3 4 1 2 5 3 4 1 2 5 3 4 Pass two Pass one Note: the triple (1,5,3) is considered more than once

8
**Transitive Closure by Shortcuts: the algorithm**

Input: A, an nn boolean matrix that represents a binary relation Output: R, the boolean matrix for the transitive closure of A Procedure void simpleTransitiveClosure(boolean[][] A, int n, boolean[][] R) int i,j,k; Copy A to R; Set all main diagonal entries, rii, to true; while (any entry of R changed during one complete pass) for (i=1; in; i++) for (j=1; jn; j++) for (k=1; kn; k++) rij=rij(rikrkj) The order of (i,j,k) matters

9
**Change the order: Washall’s Algorithm**

void simpleTransitiveClosure(boolean[][] A, int n, boolean[][] R) int i,j,k; Copy A to R; Set all main diagonal entries, rii, to true; while (any entry of R changed during one complete pass) for (k=1; kn; k++) for (i=1; in; i++) for (j=1; jn; j++) rij=rij(rikrkj) k varys in the outmost loop Note: “false to true” can not be reversed

10
**Highest-numbered intermediate vertex**

The highest intermediate vertex in the intervals (sisk), (sksj) are both less than sk sj sk si A specific order is assumed for all vertices Vertical position of vertices reflect their vertex numbers

11
**Correctness of Washall’s Algorithm**

Notation: The value of rij changes during the execution of the body of the “for k…” loop After initializations: rij(0) After the kth time of execution: rij(k)

12
**Correctness of Washall’s Algorithm**

If there is a simple path from si to sj(ij) for which the highest-numbered intermediate vertex is sk, then rij(k)=true. Proof by induction: Base case: rij(0)=true if and only if sisjE Hypothesis: the conclusion holds for h<k(h0) Induction: the simple sisj-path can be looked as sisk-path+sksj-path, with the indices h1, h2 of the highest-numbered intermediate vertices of both segment strictly(simple path) less than k. So, rij(h1)=true, rij(h2)=true, then rij(k-1)=true, rij(k-1)=true(Remember, false to true can not be reversed). So, rij(k)=true

13
**Correctness of Washall’s Algorithm**

If there is no path from si to sj, then rij=false. Proof If rij=true, then only two cases: rij is set by initialization, then sisjE Otherwise, rij is set during the kth execution of (for k…) when rij(k-1)=true, rij(k-1)=true, which, recursively, leads to the conclusion of the existence of a sisj-path. (Note: If a sisj-path exists, there exists a simple sisj-path)

14
**All-pairs Shortest Path**

Non-negative weighted graph Shortest path property: If a shortest path from x to z consisting of path P from x to y followed by path Q from y to z. Then P is a shortest xz-path, and Q, a shortest zy-path.

15
**Computing the Distance Matrix**

Basic formula: D(0)[i][j]=wij D(k)[i][j]=min(D(k-1)[i][j], D(k-1)[i][k]+ D(k-1)[i][j]) Basic property: D(k)[i][j]dij(k) where dij(k) is the weight of a shortest path from vi to vj with highest numbered vertex vk.

16
**All-Pairs Shortest Paths**

Floyd algorithm Only slight changes on Washall’s algorithm. Routing table

Similar presentations

OK

Advanced Algorithm Design and Analysis (Lecture 7) SW5 fall 2004 Simonas Šaltenis E1-215b

Advanced Algorithm Design and Analysis (Lecture 7) SW5 fall 2004 Simonas Šaltenis E1-215b

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on pricing policy objectives Ppt on autonomous car project Free ppt on brain machine interface application Ppt on edge detection tutorial Notebook backgrounds for ppt on social media Ppt on steel structures in india Ppt on sea level rise projections Ppt on video conferencing basics Ppt on power system transient stability Free ppt on telephone etiquette