1 / 12

Longest Path in a DAG

Longest Path in a DAG. Algorithm. Compute topological order of vertices: A B C D E F G H I . F. D. 3. 6. E. time. 5. C. H. I. A. B. G. 0. 6. 0. 4. 2. 4. Longest Path in a DAG. Algorithm. Compute topological order of vertices: A B C D E F G H I .

agrata
Download Presentation

Longest Path in a DAG

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. Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. F D 3 6 E time 5 C H I A B G 0 6 0 4 2 4

  2. Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. 0 earliest finish time 0 F D 3 0 6 E 5 0 0 0 0 0 0 C H I A B G 0 6 0 4 2 4

  3. 4 X Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. • Consider vertices v in topological order: • for each edge v-w, set fin[w] = max(fin[w], fin[v] + time[w]) 0 0 F D 3 0 6 E 5 0 0 0 0 0 0 C H I A B G 0 6 0 4 2 4

  4. 10 X 6 4 X X Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. • Consider vertices v in topological order: • for each edge v-w, set fin[w] = max(fin[w], fin[v] + time[w]) 0 0 F D 3 0 6 E 5 0 0 0 0 0 0 C H I A B G 0 6 0 4 2 4

  5. 12 10 10 X X X 6 4 X X Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. • Consider vertices v in topological order: • for each edge v-w, set fin[w] = max(fin[w], fin[v] + time[w]) 0 0 F D 3 0 6 E 5 0 0 0 0 0 0 C H I A B G 0 6 0 4 2 4

  6. 12 13 15 10 10 X X X X X 4 6 X X Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. • Consider vertices v in topological order: • for each edge v-w, set fin[w] = max(fin[w], fin[v] + time[w]) 0 0 F D 3 0 6 E 5 0 0 0 0 0 0 C H I A B G 0 6 0 4 2 4

  7. 10 13 15 12 10 X X X X X X X 6 4 19 21 X X Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. • Consider vertices v in topological order: • for each edge v-w, set fin[w] = max(fin[w], fin[v] + time[w]) 0 0 F D 3 0 6 E 5 0 0 0 0 0 0 C H I A B G 0 6 0 4 2 4

  8. 13 10 10 15 13 12 X X X X X X X X 6 4 19 21 X X Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. • Consider vertices v in topological order: • for each edge v-w, set fin[w] = max(fin[w], fin[v] + time[w]) 0 0 F D 3 0 6 E 5 0 0 0 0 0 0 C H I A B G 0 6 0 4 2 4

  9. 13 10 10 13 15 12 X X X X X X X X X 6 4 19 21 25 X X Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. • Consider vertices v in topological order: • for each edge v-w, set fin[w] = max(fin[w], fin[v] + time[w]) 0 0 F D 3 0 6 E 5 0 0 0 0 0 0 C H I A B G 0 6 0 4 2 4

  10. 15 10 13 10 12 13 X X X X X X X X X X 6 4 19 21 25 25 X X Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. • Consider vertices v in topological order: • for each edge v-w, set fin[w] = max(fin[w], fin[v] + time[w]) 0 0 F D 3 0 6 E 5 0 0 0 0 0 0 C H I A B G 0 6 0 4 2 4

  11. 15 10 13 10 12 13 X X X X X X X X X X 6 4 19 21 25 25 X X Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. • Consider vertices v in topological order: • for each edge v-w, set fin[w] = max(fin[w], fin[v] + time[w]) 0 0 F D 3 0 6 E 5 0 0 0 0 0 0 C H I A B G 0 6 0 4 2 4

  12. Longest Path in a DAG • Algorithm. • Compute topological order of vertices: A B C D E F G H I. • Initialize fin[v]= 0 for all vertices v. • Consider vertices v in topological order: • for each edge v-w, set fin[w] = max(fin[w], fin[v] + time[w]) 13 10 F D 3 15 6 E critical path 5 0 19 6 25 25 4 C H I A B G 0 6 0 4 2 4

More Related