SlideShare a Scribd company logo
DIRECTED ACYCLIC GRAPHS
Shortest Paths
(DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 92 / 101
Shortest paths in DAGs
General Problem. Given a digraph G = (V, E), edge lengths le ≥ 0, source
s ∈ V, and destination t ∈ V, find the shortest directed path from s to t.
Single-source shortest paths problem in DAG
Input Given a DAG, G = (V, E) and a source vertex s in V.
Output Find the shortest path from s to every other vertex in G, i.e, both
the sequence of nodes on the shortest path and its length.
Figure: Example Problem
(DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 93 / 101
How to proceed ?
■ STEP-1 OF 2 : linearize DAG, i.e, arrange nodes of G on a line so
that all edges go from left to right.
■ Find the topological sort of the following graphs:
(DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 94 / 101
Match your solution
(DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 95 / 101
Shortest paths in DAGs : data structures
• Formally, for the vth element of arrays:
• dist[v] stores the weight of a shortest path from s to v.
• pred[v] stores the predecessor of v on the so-far identified
shortest path.
Figure: Finding single source shortest path
(DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 96 / 101
Shortest paths in DAGs: Step-2
• STEP-2 OF 2
• RELAX sub-procedure.
(DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 97 / 101
Algorithm for shortest paths in DAG
(DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 98 / 101
Example
(DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 99 / 101
Running time for shortest paths in DAG
Time complexity
(DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 100 / 101
(DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 101 / 101

More Related Content

PDF
301_DP_Elements_and_Shortest_Paths_in_DAG.pdf
PDF
Single source shortes path in dag
PDF
All pairs shortest path algorithm
PPT
Shortest path
PPT
Design and Analysis of Algorithm -Shortest paths problem
PPTX
unit-4-dynamic programming
PDF
My presentation all shortestpath
PPTX
Introduction to graphs
301_DP_Elements_and_Shortest_Paths_in_DAG.pdf
Single source shortes path in dag
All pairs shortest path algorithm
Shortest path
Design and Analysis of Algorithm -Shortest paths problem
unit-4-dynamic programming
My presentation all shortestpath
Introduction to graphs

Similar to 306_Shortest_Paths_in_DAGs_design_andanalysisofalgorithms.pdf (20)

PDF
Daa chpater14
PPT
chapter24.ppt
PPTX
Directed Graph in Graph Theory and Combinatorics.pptx
PPT
Single Source Shortest Path Algorithm.ppt
PPTX
Lecture 10 - Graph part 2.pptx,discrete mathemactics
PPT
10--Dijkstra-s-Shortest-Path-and-Graph-Representations-24042025-113241am.ppt
PPT
lecture 21
PPT
Bellman ford algorithm
PPTX
12_Graph.pptx
PPTX
(floyd's algm)
PPTX
PPT
SINGLE-SOURCE SHORTEST PATHS
PDF
04 greedyalgorithmsii 2x2
PDF
Shortest path, Bellman-Ford's algorithm, Dijkastra's algorithm, their Java co...
PPTX
DIJKSTRA_123.pptx
PPT
Dijkstra's algorithm for computer science
PDF
02_AJMS_165_18_RA.pdf
PDF
02_AJMS_165_18_RA.pdf
PPTX
Dijkstra algorithm a dynammic programming approach
PPT
Chapter 26 aoa
Daa chpater14
chapter24.ppt
Directed Graph in Graph Theory and Combinatorics.pptx
Single Source Shortest Path Algorithm.ppt
Lecture 10 - Graph part 2.pptx,discrete mathemactics
10--Dijkstra-s-Shortest-Path-and-Graph-Representations-24042025-113241am.ppt
lecture 21
Bellman ford algorithm
12_Graph.pptx
(floyd's algm)
SINGLE-SOURCE SHORTEST PATHS
04 greedyalgorithmsii 2x2
Shortest path, Bellman-Ford's algorithm, Dijkastra's algorithm, their Java co...
DIJKSTRA_123.pptx
Dijkstra's algorithm for computer science
02_AJMS_165_18_RA.pdf
02_AJMS_165_18_RA.pdf
Dijkstra algorithm a dynammic programming approach
Chapter 26 aoa
Ad

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
cuic standard and advanced reporting.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPT
Teaching material agriculture food technology
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Approach and Philosophy of On baking technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Big Data Technologies - Introduction.pptx
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
A Presentation on Artificial Intelligence
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
MIND Revenue Release Quarter 2 2025 Press Release
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Electronic commerce courselecture one. Pdf
Encapsulation_ Review paper, used for researhc scholars
cuic standard and advanced reporting.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Teaching material agriculture food technology
sap open course for s4hana steps from ECC to s4
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Approach and Philosophy of On baking technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
Spectral efficient network and resource selection model in 5G networks
Big Data Technologies - Introduction.pptx
20250228 LYD VKU AI Blended-Learning.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
A comparative analysis of optical character recognition models for extracting...
A Presentation on Artificial Intelligence
Review of recent advances in non-invasive hemoglobin estimation
Chapter 3 Spatial Domain Image Processing.pdf
Assigned Numbers - 2025 - Bluetooth® Document
MIND Revenue Release Quarter 2 2025 Press Release
Ad

306_Shortest_Paths_in_DAGs_design_andanalysisofalgorithms.pdf

  • 1. DIRECTED ACYCLIC GRAPHS Shortest Paths (DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 92 / 101
  • 2. Shortest paths in DAGs General Problem. Given a digraph G = (V, E), edge lengths le ≥ 0, source s ∈ V, and destination t ∈ V, find the shortest directed path from s to t. Single-source shortest paths problem in DAG Input Given a DAG, G = (V, E) and a source vertex s in V. Output Find the shortest path from s to every other vertex in G, i.e, both the sequence of nodes on the shortest path and its length. Figure: Example Problem (DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 93 / 101
  • 3. How to proceed ? ■ STEP-1 OF 2 : linearize DAG, i.e, arrange nodes of G on a line so that all edges go from left to right. ■ Find the topological sort of the following graphs: (DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 94 / 101
  • 4. Match your solution (DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 95 / 101
  • 5. Shortest paths in DAGs : data structures • Formally, for the vth element of arrays: • dist[v] stores the weight of a shortest path from s to v. • pred[v] stores the predecessor of v on the so-far identified shortest path. Figure: Finding single source shortest path (DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 96 / 101
  • 6. Shortest paths in DAGs: Step-2 • STEP-2 OF 2 • RELAX sub-procedure. (DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 97 / 101
  • 7. Algorithm for shortest paths in DAG (DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 98 / 101
  • 8. Example (DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 99 / 101
  • 9. Running time for shortest paths in DAG Time complexity (DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 100 / 101
  • 10. (DAA, Dr. Ashish Gupta) ULC403 : Unit-I/II 101 / 101