SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Zain Zahid (bscs)
Air university, islamabad
zainzahid99@gmail.com
*
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
Vertices Distance Parent
A 0 0
B ∞ 0
C ∞ 0
D ∞ 0
E ∞ 0
F ∞ 0
G ∞ 0
H ∞ 0 ∞
0
∞
∞
∞
∞
∞∞
2
For demonstration purpose, we would consider the following graph:
• Considering A as the source, assign it the distance zero.
• For all vertices except A assign a distance infinity.
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
∞
∞
∞
∞
∞∞
Vertices Distance Parent
A 0 0
B 8 A
C
D
E
F
G
H
2
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
∞
6
∞
∞
∞∞
Vertices Distance Parent
A 0 0
B 8 A
C
D
E 6 A
F
G
H
2
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
∞
6
∞
∞
∞14
Vertices Distance Parent
A 0 0
B 8 A
C 14 B
D
E 6 A
F
G
H
2
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
∞
6
9
∞
∞14
Vertices Distance Parent
A 0 0
B 8 A
C 14 B
D
E 6 A
F 9 E
G
H
2
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
∞
6
9
8
∞14
Vertices Distance Parent
A 0 0
B 8 A
C 14 B
D
E 6 A
F 9 E
G 8 E
H
2
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
9
6
9
8
∞14
Vertices Distance Parent
A 0 0
B 8 A
C 14 B
D 9 G
E 6 A
F 9 E
G 8 E
H
2
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
9
6
9
8
1814
Vertices Distance Parent
A 0 0
B 8 A
C 14 B
D 9 G
E 6 A
F 9 E
G 8 E
H 18 C
2
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
9
6
9
8
1814
Vertices Distance Parent
A 0 0
B 8 A
C 14 B
D 9 G
E 6 A
F 9 E
G 8 E
H 18 C
2
STEP-2 START CHECKING EACH VERTEX AGAIN
B D E F G H remains same
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
9
6
9
8
187
Vertices Distance Parent
A 0 0
B 8 A
C 7 G
D 9 G
E 6 A
F 9 E
G 8 E
H 18 C
2
Change will be only in C
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
9
6
9
8
117
Vertices Distance Parent
A 0 0
B 8 A
C 7 G
D 9 G
E 6 A
F 9 E
G 8 E
H 11 C
2
STEP-3 START CHECKING EACH VERTEX AGAIN
Change will be only in H
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
9
6
9
8
117
Vertices Distance Parent
A 0 0
B 8 A
C 7 G
D 9 G
E 6 A
F 9 E
G 8 E
H 11 C
2
And B C D E F G remains same
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
9
6
9
8
117
Vertices Distance Parent
A 0 0
B 8 A
C 7 G
D 9 G
E 6 A
F 9 E
G 8 E
H 11 C
2
STEP-4 START CHECKING EACH VERTEX AGAIN
This time there is no change and all vertices remain same
So we can stop here
A
E
F
G
C
D
B
H
6
-1
4
6
2
3
1
-2
6
8
8
0
9
6
9
8
117
Vertices Distance Parent
A 0 0
B 8 A
C 7 G
D 9 G
E 6 A
F 9 E
G 8 E
H 11 C
2
Shortest Paths are:
B=AB=8
C=AEGC=7
D=AEGD=9
E=AE=6
F=AEF=9
G=AEG=8
H=AEGCH=11
*There are two cases in iterations
*We might not notice any change in distance for any vertex in
later iterations. It would be good to stop at that point for
making the algorithm efficient.
*We might endlessly notice changes in distances of one or the
other vertex in later iterations. This will be the case of negative
weight cycles. Hence, we need to stop at some point and that
would be the after |V| – 1

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Camera Assbly 3-11
Camera Assbly 3-11Camera Assbly 3-11
Camera Assbly 3-11
 
custom_woven_carpet_surface_revival_trend
custom_woven_carpet_surface_revival_trendcustom_woven_carpet_surface_revival_trend
custom_woven_carpet_surface_revival_trend
 
Planos estructurales graderia
Planos estructurales graderiaPlanos estructurales graderia
Planos estructurales graderia
 
Entrega grifo final Juan Ospina
Entrega grifo final Juan Ospina Entrega grifo final Juan Ospina
Entrega grifo final Juan Ospina
 
Planos tecnicos
Planos tecnicosPlanos tecnicos
Planos tecnicos
 
TTK.#5
TTK.#5TTK.#5
TTK.#5
 
Tanque
TanqueTanque
Tanque
 
PAINTBALLGUN.PDF
PAINTBALLGUN.PDFPAINTBALLGUN.PDF
PAINTBALLGUN.PDF
 
GHRCEM_Amravati_Slider Crank Chain Mechanism
GHRCEM_Amravati_Slider Crank Chain MechanismGHRCEM_Amravati_Slider Crank Chain Mechanism
GHRCEM_Amravati_Slider Crank Chain Mechanism
 
ViseEXPLODED
ViseEXPLODEDViseEXPLODED
ViseEXPLODED
 
Vise base4
Vise base4Vise base4
Vise base4
 
EX7-72
EX7-72EX7-72
EX7-72
 
SAMPLE REVIT DRAWINGS-SUNIT K DHINGRA-COMPLETE - WATERMANS
SAMPLE REVIT DRAWINGS-SUNIT K DHINGRA-COMPLETE - WATERMANSSAMPLE REVIT DRAWINGS-SUNIT K DHINGRA-COMPLETE - WATERMANS
SAMPLE REVIT DRAWINGS-SUNIT K DHINGRA-COMPLETE - WATERMANS
 
gate 2014 sol
gate 2014 solgate 2014 sol
gate 2014 sol
 
COURTYARD-STAIR
COURTYARD-STAIRCOURTYARD-STAIR
COURTYARD-STAIR
 
Vise base2
Vise base2Vise base2
Vise base2
 
Vise base
Vise baseVise base
Vise base
 
1786235_2016-10-28_151016
1786235_2016-10-28_1510161786235_2016-10-28_151016
1786235_2016-10-28_151016
 
Zonal progress of work
Zonal progress of workZonal progress of work
Zonal progress of work
 
Vise base3
Vise base3Vise base3
Vise base3
 

Andere mochten auch

Bellman ford (part-i)
Bellman ford (part-i)Bellman ford (part-i)
Bellman ford (part-i)Zain Zahid
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithmtaimurkhan803
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's AlgorithmTanmay Baranwal
 
Bellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraqBellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraqmontaser185
 
Lecture 15 data structures and algorithms
Lecture 15 data structures and algorithmsLecture 15 data structures and algorithms
Lecture 15 data structures and algorithmsAakash deep Singhal
 
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
 
Bellman ford algorithm -Shortest Path
Bellman ford algorithm -Shortest PathBellman ford algorithm -Shortest Path
Bellman ford algorithm -Shortest PathSharmilaChidaravalli
 
Computer graphics mini project on bellman-ford algorithm
Computer graphics mini project on bellman-ford algorithmComputer graphics mini project on bellman-ford algorithm
Computer graphics mini project on bellman-ford algorithmRAJEEV KUMAR SINGH
 
A study on performance comparison of dymo with aodv and dsr
A study on performance comparison of dymo with aodv and dsrA study on performance comparison of dymo with aodv and dsr
A study on performance comparison of dymo with aodv and dsrIAEME Publication
 
Network Lifetime Analysis of Routing Protocols of Short Network in Qualnet
Network Lifetime Analysis of Routing Protocols of Short Network in QualnetNetwork Lifetime Analysis of Routing Protocols of Short Network in Qualnet
Network Lifetime Analysis of Routing Protocols of Short Network in QualnetIOSR Journals
 
Simulation & comparison of aodv & dsr protocol
Simulation & comparison of aodv & dsr protocolSimulation & comparison of aodv & dsr protocol
Simulation & comparison of aodv & dsr protocolPrafull Johri
 
Eigrp
EigrpEigrp
Eigrpfirey
 

Andere mochten auch (20)

Bellman ford (part-i)
Bellman ford (part-i)Bellman ford (part-i)
Bellman ford (part-i)
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Bellman Ford's Algorithm
Bellman Ford's AlgorithmBellman Ford's Algorithm
Bellman Ford's Algorithm
 
Bellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraqBellmanford . montaser hamza.iraq
Bellmanford . montaser hamza.iraq
 
Lecture 15 data structures and algorithms
Lecture 15 data structures and algorithmsLecture 15 data structures and algorithms
Lecture 15 data structures and 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
 
Bellman ford algorithm -Shortest Path
Bellman ford algorithm -Shortest PathBellman ford algorithm -Shortest Path
Bellman ford algorithm -Shortest Path
 
Bellmanford
BellmanfordBellmanford
Bellmanford
 
Computer graphics mini project on bellman-ford algorithm
Computer graphics mini project on bellman-ford algorithmComputer graphics mini project on bellman-ford algorithm
Computer graphics mini project on bellman-ford algorithm
 
A study on performance comparison of dymo with aodv and dsr
A study on performance comparison of dymo with aodv and dsrA study on performance comparison of dymo with aodv and dsr
A study on performance comparison of dymo with aodv and dsr
 
Network Lifetime Analysis of Routing Protocols of Short Network in Qualnet
Network Lifetime Analysis of Routing Protocols of Short Network in QualnetNetwork Lifetime Analysis of Routing Protocols of Short Network in Qualnet
Network Lifetime Analysis of Routing Protocols of Short Network in Qualnet
 
11 routing
11 routing11 routing
11 routing
 
Simulation & comparison of aodv & dsr protocol
Simulation & comparison of aodv & dsr protocolSimulation & comparison of aodv & dsr protocol
Simulation & comparison of aodv & dsr protocol
 
Bellman ford 1
Bellman ford 1Bellman ford 1
Bellman ford 1
 
AODV routing protocol
AODV routing protocolAODV routing protocol
AODV routing protocol
 
Eigrp
EigrpEigrp
Eigrp
 
DYNAMIC SOURCE ROUTING (DSR)
DYNAMIC SOURCE ROUTING  (DSR)DYNAMIC SOURCE ROUTING  (DSR)
DYNAMIC SOURCE ROUTING (DSR)
 
Shortest Path in Graph
Shortest Path in GraphShortest Path in Graph
Shortest Path in Graph
 
Eigrp
EigrpEigrp
Eigrp
 
AODV Protocol
AODV ProtocolAODV Protocol
AODV Protocol
 

Ähnlich wie Bellman ford (part-ii)

Ähnlich wie Bellman ford (part-ii) (6)

Complete binary tree and heap
Complete binary tree and heapComplete binary tree and heap
Complete binary tree and heap
 
A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithm
 
MST
MSTMST
MST
 
MST
MSTMST
MST
 
Geometry & mensuration 1
Geometry & mensuration 1Geometry & mensuration 1
Geometry & mensuration 1
 
Geometry & mensuration 1
Geometry & mensuration 1Geometry & mensuration 1
Geometry & mensuration 1
 

Kürzlich hochgeladen

Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisDiwakar Mishra
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)PraveenaKalaiselvan1
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real timeSatoshi NAKAHIRA
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...jana861314
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfSumit Kumar yadav
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoSérgio Sacani
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |aasikanpl
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsSérgio Sacani
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhousejana861314
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 sciencefloriejanemacaya1
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksSérgio Sacani
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxSwapnil Therkar
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptMAESTRELLAMesa2
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxAArockiyaNisha
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 

Kürzlich hochgeladen (20)

Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Grafana in space: Monitoring Japan's SLIM moon lander in real time
Grafana in space: Monitoring Japan's SLIM moon lander  in real timeGrafana in space: Monitoring Japan's SLIM moon lander  in real time
Grafana in space: Monitoring Japan's SLIM moon lander in real time
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
Traditional Agroforestry System in India- Shifting Cultivation, Taungya, Home...
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
Call Us ≽ 9953322196 ≼ Call Girls In Mukherjee Nagar(Delhi) |
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
Orientation, design and principles of polyhouse
Orientation, design and principles of polyhouseOrientation, design and principles of polyhouse
Orientation, design and principles of polyhouse
 
Boyles law module in the grade 10 science
Boyles law module in the grade 10 scienceBoyles law module in the grade 10 science
Boyles law module in the grade 10 science
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptxAnalytical Profile of Coleus Forskohlii | Forskolin .pptx
Analytical Profile of Coleus Forskohlii | Forskolin .pptx
 
G9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.pptG9 Science Q4- Week 1-2 Projectile Motion.ppt
G9 Science Q4- Week 1-2 Projectile Motion.ppt
 
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptxPhysiochemical properties of nanomaterials and its nanotoxicity.pptx
Physiochemical properties of nanomaterials and its nanotoxicity.pptx
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 

Bellman ford (part-ii)