SlideShare a Scribd company logo
1 of 11
Single source
shortest path…
By,
Janani.J
I.M.sc IT
V.V.Vannaiperumal
college for women,
Virudhunagar.
Dynamic program
2
﹡ Dynamic programming approach is similar to divide and conquer in
breaking down the problem into smaller and yet smaller possible
sub-problems.
﹡ Dynamic programming is used where we have problems, which can
be divided into similar sub-problems, so that their results can be re-
used.
﹡ There are two approaches to dynamic programming:
﹡ Top-down approach
﹡ Bottom-up approach
﹡ The main use of dynamic programming is to solve optimization
problems.
﹡ There are two ways of applying dynamic programming:
﹡ Top-Down
﹡ Bottom-Up
Example
﹡ The following computer problems can be solved using dynamic
programming approach −
﹡ Fibonacci number series
﹡ Knapsack problem
﹡ All pair shortest path by Floyd-Warshall
﹡ Shortest path by Dijkstra 3
Single source shortest path
﹡ The single source shortest path algorithm is also known Bellman-
Ford algorithm is used to find minimum distance from source
vertex to any other vertex.
﹡ In a shortest- paths problem, we are given a weighted, directed
graphs G = (V, E), with weight function w: E → R mapping edges
to real-valued weights. The weight of path p = (v0,v1,….. Vk) is
the total of the weights of its constituent edges:
﹡ We define the shortest – path weight from u to v by δ(u,v) = min
(w (p): u→v), if there is a path from u to v, and δ(u,v)= ∞,
4
Bellman-ford algorithm
﹡ The Bellman-Ford algorithm is a single-source shortest path
algorithm.
﹡ This means that, given a weighted graph, this algorithm will
output the shortest distance from a selected node to all other
nodes.
﹡ Given a source vertex s from a set of vertices V in a weighted
graph where its edge weights w(u, v) can be negative, find the
shortest path weights d(s, v) from source s for all
vertices v present in the graph. If the graph contains a negative-
weight cycle, report it.
﹡ For example, consider the following graph:
5
6
• The distance of vertex 0 from the
source is 0. Its path is [0]
• The distance of vertex 1 from the
source is -1. Its path is [0 —> 1]
• The distance of vertex 2 from the
source is 2. Its path is [0 —> 1 —
> 2]
• The distance of vertex 3 from the
source is -2. Its path is [0 —> 1 —
> 4 —> 3]
• The distance of vertex 4 from the
source is 1. Its path is [0 —> 1 —
> 4]
7
• Total number of vertices
in the graph is 5, so all
edges must be processed
4 times.
• Let all edges are
processed in the following
order: (B, E), (D, B), (B,
D), (A, B), (A, C), (D, C),
(B, C), (E, D).
The first iteration
guarantees to give all
shortest paths which are at
most 1 edge long.
8
﹡ The second iteration
guarantees to give all
shortest paths which are at
most 2 edges long.
9
10
1.
Transition headline
Let’s start with the first set of slides

More Related Content

What's hot

segment tree algorithm.pptx
segment tree algorithm.pptxsegment tree algorithm.pptx
segment tree algorithm.pptxMuzamil Amin
 
Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...Waqas Afzal
 
linear equation and gaussian elimination
linear equation and gaussian eliminationlinear equation and gaussian elimination
linear equation and gaussian eliminationAju Thadikulangara
 
Adaptive filtersfinal
Adaptive filtersfinalAdaptive filtersfinal
Adaptive filtersfinalWiw Miu
 
Clustering of graphs and search of assemblages
Clustering of graphs and search of assemblagesClustering of graphs and search of assemblages
Clustering of graphs and search of assemblagesData-Centric_Alliance
 
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm Aparna Joshi
 
APLICACIONES DE ESPACIO VECTORIALES
APLICACIONES DE ESPACIO VECTORIALESAPLICACIONES DE ESPACIO VECTORIALES
APLICACIONES DE ESPACIO VECTORIALESJoseLuisCastroGualot
 
UP-STAT 2015 Abstract Presentation - Statistical and Machine Learning Methods...
UP-STAT 2015 Abstract Presentation - Statistical and Machine Learning Methods...UP-STAT 2015 Abstract Presentation - Statistical and Machine Learning Methods...
UP-STAT 2015 Abstract Presentation - Statistical and Machine Learning Methods...MATTHEW CORSETTI
 
Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Charlton Inao
 
Improvement of shortest path algorithms using subgraphs heuristics
Improvement of shortest path algorithms using subgraphs heuristicsImprovement of shortest path algorithms using subgraphs heuristics
Improvement of shortest path algorithms using subgraphs heuristicsMahdi Atawneh
 
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical MethodsGauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical MethodsJanki Shah
 
Learning multifractal structure in large networks (Purdue ML Seminar)
Learning multifractal structure in large networks (Purdue ML Seminar)Learning multifractal structure in large networks (Purdue ML Seminar)
Learning multifractal structure in large networks (Purdue ML Seminar)Austin Benson
 
Coordinate Descent method
Coordinate Descent methodCoordinate Descent method
Coordinate Descent methodSanghyuk Chun
 
Expressions for shape functions of linear element
Expressions for shape functions of linear element Expressions for shape functions of linear element
Expressions for shape functions of linear element Sharath Kumar
 

What's hot (20)

segment tree algorithm.pptx
segment tree algorithm.pptxsegment tree algorithm.pptx
segment tree algorithm.pptx
 
H023078082
H023078082H023078082
H023078082
 
Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
Signal Flow Graph, SFG and Mason Gain Formula, Example solved with Masson Gai...
 
linear equation and gaussian elimination
linear equation and gaussian eliminationlinear equation and gaussian elimination
linear equation and gaussian elimination
 
Adaptive filtersfinal
Adaptive filtersfinalAdaptive filtersfinal
Adaptive filtersfinal
 
Merge sort
Merge sortMerge sort
Merge sort
 
Clustering of graphs and search of assemblages
Clustering of graphs and search of assemblagesClustering of graphs and search of assemblages
Clustering of graphs and search of assemblages
 
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm
Raster Scan Graphics, Line Drawing Algorithm and Circle Drawing Algorithm
 
Gauss elimination
Gauss eliminationGauss elimination
Gauss elimination
 
APLICACIONES DE ESPACIO VECTORIALES
APLICACIONES DE ESPACIO VECTORIALESAPLICACIONES DE ESPACIO VECTORIALES
APLICACIONES DE ESPACIO VECTORIALES
 
UP-STAT 2015 Abstract Presentation - Statistical and Machine Learning Methods...
UP-STAT 2015 Abstract Presentation - Statistical and Machine Learning Methods...UP-STAT 2015 Abstract Presentation - Statistical and Machine Learning Methods...
UP-STAT 2015 Abstract Presentation - Statistical and Machine Learning Methods...
 
Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05Wk 6 part 2 non linearites and non linearization april 05
Wk 6 part 2 non linearites and non linearization april 05
 
Improvement of shortest path algorithms using subgraphs heuristics
Improvement of shortest path algorithms using subgraphs heuristicsImprovement of shortest path algorithms using subgraphs heuristics
Improvement of shortest path algorithms using subgraphs heuristics
 
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical MethodsGauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
 
Parallel algorithm in linear algebra
Parallel algorithm in linear algebraParallel algorithm in linear algebra
Parallel algorithm in linear algebra
 
Electrical Engineering Assignment Help
Electrical Engineering Assignment HelpElectrical Engineering Assignment Help
Electrical Engineering Assignment Help
 
Learning multifractal structure in large networks (Purdue ML Seminar)
Learning multifractal structure in large networks (Purdue ML Seminar)Learning multifractal structure in large networks (Purdue ML Seminar)
Learning multifractal structure in large networks (Purdue ML Seminar)
 
Coordinate Descent method
Coordinate Descent methodCoordinate Descent method
Coordinate Descent method
 
Block diagrams
Block diagramsBlock diagrams
Block diagrams
 
Expressions for shape functions of linear element
Expressions for shape functions of linear element Expressions for shape functions of linear element
Expressions for shape functions of linear element
 

Similar to Single source shortestpath

Shortest Path Problem.docx
Shortest Path Problem.docxShortest Path Problem.docx
Shortest Path Problem.docxSeethaDinesh
 
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...Khoa Mac Tu
 
shortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdfshortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdfzefergaming
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithmsana younas
 
DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchMohammad Imam Hossain
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...KUSHDHIRRA2111026030
 
Single source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraSingle source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraRoshan Tailor
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slidesHJ DS
 
Single sourceshortestpath by emad
Single sourceshortestpath by emadSingle sourceshortestpath by emad
Single sourceshortestpath by emadKazi Emad
 
Bellman Ford Algorithm
Bellman Ford AlgorithmBellman Ford Algorithm
Bellman Ford Algorithmiqra593488
 
Unit 4- Dynamic Programming.pdf
Unit 4- Dynamic Programming.pdfUnit 4- Dynamic Programming.pdf
Unit 4- Dynamic Programming.pdfMaryJacob24
 

Similar to Single source shortestpath (20)

Graph 3
Graph 3Graph 3
Graph 3
 
Shortest Path Problem.docx
Shortest Path Problem.docxShortest Path Problem.docx
Shortest Path Problem.docx
 
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
 
DAA_Presentation - Copy.pptx
DAA_Presentation - Copy.pptxDAA_Presentation - Copy.pptx
DAA_Presentation - Copy.pptx
 
shortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdfshortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdf
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithm
 
DIJKSTRA_123.pptx
DIJKSTRA_123.pptxDIJKSTRA_123.pptx
DIJKSTRA_123.pptx
 
DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path Search
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
 
chapter24.ppt
chapter24.pptchapter24.ppt
chapter24.ppt
 
path
pathpath
path
 
1535 graph algorithms
1535 graph algorithms1535 graph algorithms
1535 graph algorithms
 
Single source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstraSingle source stortest path bellman ford and dijkstra
Single source stortest path bellman ford and dijkstra
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
 
Single sourceshortestpath by emad
Single sourceshortestpath by emadSingle sourceshortestpath by emad
Single sourceshortestpath by emad
 
Shortest Path Problem
Shortest Path ProblemShortest Path Problem
Shortest Path Problem
 
130210107039 2130702
130210107039 2130702130210107039 2130702
130210107039 2130702
 
Bellman Ford Algorithm
Bellman Ford AlgorithmBellman Ford Algorithm
Bellman Ford Algorithm
 
Unit 4- Dynamic Programming.pdf
Unit 4- Dynamic Programming.pdfUnit 4- Dynamic Programming.pdf
Unit 4- Dynamic Programming.pdf
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 

Recently uploaded (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 

Single source shortestpath

  • 1. Single source shortest path… By, Janani.J I.M.sc IT V.V.Vannaiperumal college for women, Virudhunagar.
  • 2. Dynamic program 2 ﹡ Dynamic programming approach is similar to divide and conquer in breaking down the problem into smaller and yet smaller possible sub-problems. ﹡ Dynamic programming is used where we have problems, which can be divided into similar sub-problems, so that their results can be re- used. ﹡ There are two approaches to dynamic programming: ﹡ Top-down approach ﹡ Bottom-up approach
  • 3. ﹡ The main use of dynamic programming is to solve optimization problems. ﹡ There are two ways of applying dynamic programming: ﹡ Top-Down ﹡ Bottom-Up Example ﹡ The following computer problems can be solved using dynamic programming approach − ﹡ Fibonacci number series ﹡ Knapsack problem ﹡ All pair shortest path by Floyd-Warshall ﹡ Shortest path by Dijkstra 3
  • 4. Single source shortest path ﹡ The single source shortest path algorithm is also known Bellman- Ford algorithm is used to find minimum distance from source vertex to any other vertex. ﹡ In a shortest- paths problem, we are given a weighted, directed graphs G = (V, E), with weight function w: E → R mapping edges to real-valued weights. The weight of path p = (v0,v1,….. Vk) is the total of the weights of its constituent edges: ﹡ We define the shortest – path weight from u to v by δ(u,v) = min (w (p): u→v), if there is a path from u to v, and δ(u,v)= ∞, 4
  • 5. Bellman-ford algorithm ﹡ The Bellman-Ford algorithm is a single-source shortest path algorithm. ﹡ This means that, given a weighted graph, this algorithm will output the shortest distance from a selected node to all other nodes. ﹡ Given a source vertex s from a set of vertices V in a weighted graph where its edge weights w(u, v) can be negative, find the shortest path weights d(s, v) from source s for all vertices v present in the graph. If the graph contains a negative- weight cycle, report it. ﹡ For example, consider the following graph: 5
  • 6. 6 • The distance of vertex 0 from the source is 0. Its path is [0] • The distance of vertex 1 from the source is -1. Its path is [0 —> 1] • The distance of vertex 2 from the source is 2. Its path is [0 —> 1 — > 2] • The distance of vertex 3 from the source is -2. Its path is [0 —> 1 — > 4 —> 3] • The distance of vertex 4 from the source is 1. Its path is [0 —> 1 — > 4]
  • 7. 7 • Total number of vertices in the graph is 5, so all edges must be processed 4 times. • Let all edges are processed in the following order: (B, E), (D, B), (B, D), (A, B), (A, C), (D, C), (B, C), (E, D).
  • 8. The first iteration guarantees to give all shortest paths which are at most 1 edge long. 8
  • 9. ﹡ The second iteration guarantees to give all shortest paths which are at most 2 edges long. 9
  • 10. 10
  • 11. 1. Transition headline Let’s start with the first set of slides