SlideShare a Scribd company logo
Design & Analysis of Algorithm 
Graph Traversal Algorithms 
Kamalesh Karmakar 
Assistant Professor 
Department of C.S.E. 
MeghnadSahaInstitute of Technology 
Kolkata.
Design & Analysis of Algorithm 
Graph Traversal Algorithms
Design & Analysis of Algorithm 
Graph Traversal Algorithms
Design & Analysis of Algorithm 
Graph Traversal Algorithms
Design & Analysis of Algorithm 
Graph Traversal Algorithms
Design & Analysis of Algorithm 
Beforeprovingthevariouspropertiesofbreadth-firstsearch,wetakeonthesomewhateasierjobofanalyzingitsrunningtimeonaninputgraphG=(V,E).Weuseaggregateanalysis,aswesawinSection17.1.Afterinitialization,novertexiseverwhitened,andthusthetestinline13ensuresthateachvertexisenqueuedatmostonce,andhencedequeuedatmostonce.TheoperationsofenqueuinganddequeuingtakeO(1)time,sothetotaltimedevotedtoqueueoperationsisO(V).Becausetheadjacencylistofeachvertexisscannedonlywhenthevertexisdequeued,eachadjacencylistisscannedatmostonce.Sincethesumofthelengthsofalltheadjacencylistsis(E),thetotaltimespentinscanningadjacencylistsisO(E).TheoverheadforinitializationisO(V),andthusthetotalrunningtimeofBFSisO(V+E).Thus,breadth-firstsearchrunsintimelinearinthesizeoftheadjacency-listrepresentationofG. 
Graph Traversal Algorithms
Design & Analysis of Algorithm 
Graph Traversal Algorithms
Design & Analysis of Algorithm 
Graph Traversal Algorithms
Design & Analysis of Algorithm 
Graph Traversal Algorithms
Design & Analysis of Algorithm 
Graph Traversal Algorithms
Design & Analysis of Algorithm 
G. 
Graph Traversal Algorithms
Design & Analysis of Algorithm 
Wecandefinefouredgetypesintermsofthedepth-firstforestGπproducedbyadepth-firstsearchonG. 
1.Treeedgesareedgesinthedepth-firstforestGπ.Edge(u,v)isatreeedgeifvwasfirstdiscoveredbyexploringedge(u,v). 
2.Backedgesarethoseedges(u,v)connectingavertexutoanancestorvinadepth-firsttree.Self-loops,whichmayoccurindirectedgraphs,areconsideredtobebackedges. 
3.Forwardedgesarethosenon-treeedges(u,v)connectingavertexutoadescendantvinadepth-firsttree. 
4.Crossedgesareallotheredges.Theycangobetweenverticesinthesamedepth-firsttree,aslongasonevertexisnotanancestoroftheother,ortheycangobetweenverticesindifferentdepth-firsttrees. 
Graph Traversal Algorithms

More Related Content

What's hot

Applied Design Patterns - A Compiler Case Study
Applied Design Patterns - A Compiler Case StudyApplied Design Patterns - A Compiler Case Study
Applied Design Patterns - A Compiler Case Study
CodeOps Technologies LLP
 
Graph processing - Graphlab
Graph processing - GraphlabGraph processing - Graphlab
Graph processing - Graphlab
Amir Payberah
 
Graph processing - Powergraph and GraphX
Graph processing - Powergraph and GraphXGraph processing - Powergraph and GraphX
Graph processing - Powergraph and GraphX
Amir Payberah
 
Model and Design
Model and Design Model and Design
Model and Design
Dr Shashikant Athawale
 
Lecture 1 objective and course plan
Lecture 1   objective and course planLecture 1   objective and course plan
Lecture 1 objective and course plan
jayavignesh86
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
Prabhakaran V M
 
An Efficient and Parallel Abstract Interpreter in Scala — Preparatory Work — ...
An Efficient and Parallel Abstract Interpreter in Scala — Preparatory Work — ...An Efficient and Parallel Abstract Interpreter in Scala — Preparatory Work — ...
An Efficient and Parallel Abstract Interpreter in Scala — Preparatory Work — ...
🌳 Olivier Pirson — OPi 🇧🇪🇫🇷🇬🇧 🐧 👨‍💻 👨‍🔬
 
Owf 2013 rii alter go speaker 5
Owf 2013 rii alter go speaker 5 Owf 2013 rii alter go speaker 5
Owf 2013 rii alter go speaker 5 Patrick MOREAU
 
Ds03 algorithms jyoti lakhani
Ds03 algorithms jyoti lakhaniDs03 algorithms jyoti lakhani
Ds03 algorithms jyoti lakhani
jyoti_lakhani
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
Dr Geetha Mohan
 
Amortized analysis
Amortized analysisAmortized analysis
Amortized analysis
Dr Shashikant Athawale
 
Analysis algorithm introduction Lecture# 1
Analysis algorithm introduction Lecture# 1Analysis algorithm introduction Lecture# 1
Analysis algorithm introduction Lecture# 1
Tariq Khan
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 
Doctoral Consortium@RuleML2015: Genetic Programming for Design Grammar Rule I...
Doctoral Consortium@RuleML2015: Genetic Programming for Design Grammar Rule I...Doctoral Consortium@RuleML2015: Genetic Programming for Design Grammar Rule I...
Doctoral Consortium@RuleML2015: Genetic Programming for Design Grammar Rule I...
RuleML
 
Asymptotic analysis of parallel programs
Asymptotic analysis of parallel programsAsymptotic analysis of parallel programs
Asymptotic analysis of parallel programs
Sumita Das
 
Day 1 Chapter 1 Unit 1
Day 1 Chapter 1 Unit 1Day 1 Chapter 1 Unit 1
Evaluation of Expression in Query Processing
Evaluation of Expression in Query ProcessingEvaluation of Expression in Query Processing
Evaluation of Expression in Query Processing
Neel Shah
 
Instructuion set of 8085
Instructuion set of 8085Instructuion set of 8085
Instructuion set of 8085
harsh kothari
 
Lecture 2 role of algorithms in computing
Lecture 2   role of algorithms in computingLecture 2   role of algorithms in computing
Lecture 2 role of algorithms in computing
jayavignesh86
 

What's hot (20)

Applied Design Patterns - A Compiler Case Study
Applied Design Patterns - A Compiler Case StudyApplied Design Patterns - A Compiler Case Study
Applied Design Patterns - A Compiler Case Study
 
Graph processing - Graphlab
Graph processing - GraphlabGraph processing - Graphlab
Graph processing - Graphlab
 
Graph processing - Powergraph and GraphX
Graph processing - Powergraph and GraphXGraph processing - Powergraph and GraphX
Graph processing - Powergraph and GraphX
 
Model and Design
Model and Design Model and Design
Model and Design
 
Lecture 1 objective and course plan
Lecture 1   objective and course planLecture 1   objective and course plan
Lecture 1 objective and course plan
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
 
An Efficient and Parallel Abstract Interpreter in Scala — Preparatory Work — ...
An Efficient and Parallel Abstract Interpreter in Scala — Preparatory Work — ...An Efficient and Parallel Abstract Interpreter in Scala — Preparatory Work — ...
An Efficient and Parallel Abstract Interpreter in Scala — Preparatory Work — ...
 
Owf 2013 rii alter go speaker 5
Owf 2013 rii alter go speaker 5 Owf 2013 rii alter go speaker 5
Owf 2013 rii alter go speaker 5
 
Ds03 algorithms jyoti lakhani
Ds03 algorithms jyoti lakhaniDs03 algorithms jyoti lakhani
Ds03 algorithms jyoti lakhani
 
ziad_cv
ziad_cvziad_cv
ziad_cv
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Amortized analysis
Amortized analysisAmortized analysis
Amortized analysis
 
Analysis algorithm introduction Lecture# 1
Analysis algorithm introduction Lecture# 1Analysis algorithm introduction Lecture# 1
Analysis algorithm introduction Lecture# 1
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 
Doctoral Consortium@RuleML2015: Genetic Programming for Design Grammar Rule I...
Doctoral Consortium@RuleML2015: Genetic Programming for Design Grammar Rule I...Doctoral Consortium@RuleML2015: Genetic Programming for Design Grammar Rule I...
Doctoral Consortium@RuleML2015: Genetic Programming for Design Grammar Rule I...
 
Asymptotic analysis of parallel programs
Asymptotic analysis of parallel programsAsymptotic analysis of parallel programs
Asymptotic analysis of parallel programs
 
Day 1 Chapter 1 Unit 1
Day 1 Chapter 1 Unit 1Day 1 Chapter 1 Unit 1
Day 1 Chapter 1 Unit 1
 
Evaluation of Expression in Query Processing
Evaluation of Expression in Query ProcessingEvaluation of Expression in Query Processing
Evaluation of Expression in Query Processing
 
Instructuion set of 8085
Instructuion set of 8085Instructuion set of 8085
Instructuion set of 8085
 
Lecture 2 role of algorithms in computing
Lecture 2   role of algorithms in computingLecture 2   role of algorithms in computing
Lecture 2 role of algorithms in computing
 

Similar to 08. graph traversal

DAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdf
DAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdfDAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdf
DAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdf
OnkarSalunkhe5
 
data structures.pptx
data structures.pptxdata structures.pptx
data structures.pptx
WasimAkram706836
 
chapter 1
chapter 1chapter 1
chapter 1
yatheesha
 
Analyzing algorithms
Analyzing algorithmsAnalyzing algorithms
Analyzing algorithms
Onkar Nath Sharma
 
APPROACHES IN USING EXPECTATIONMAXIMIZATION ALGORITHM FOR MAXIMUM LIKELIHOOD ...
APPROACHES IN USING EXPECTATIONMAXIMIZATION ALGORITHM FOR MAXIMUM LIKELIHOOD ...APPROACHES IN USING EXPECTATIONMAXIMIZATION ALGORITHM FOR MAXIMUM LIKELIHOOD ...
APPROACHES IN USING EXPECTATIONMAXIMIZATION ALGORITHM FOR MAXIMUM LIKELIHOOD ...
cscpconf
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and Notations
Abid Kohistani
 
Algorithm
AlgorithmAlgorithm
Algorithm
Syam Kumar
 

Similar to 08. graph traversal (9)

DAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdf
DAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdfDAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdf
DAAMOD12hjsfgi haFIUAFKJNASFQF MNDAF.pdf
 
data structures.pptx
data structures.pptxdata structures.pptx
data structures.pptx
 
chapter 1
chapter 1chapter 1
chapter 1
 
Analyzing algorithms
Analyzing algorithmsAnalyzing algorithms
Analyzing algorithms
 
APPROACHES IN USING EXPECTATIONMAXIMIZATION ALGORITHM FOR MAXIMUM LIKELIHOOD ...
APPROACHES IN USING EXPECTATIONMAXIMIZATION ALGORITHM FOR MAXIMUM LIKELIHOOD ...APPROACHES IN USING EXPECTATIONMAXIMIZATION ALGORITHM FOR MAXIMUM LIKELIHOOD ...
APPROACHES IN USING EXPECTATIONMAXIMIZATION ALGORITHM FOR MAXIMUM LIKELIHOOD ...
 
Algorithm in Computer, Sorting and Notations
Algorithm in Computer, Sorting  and NotationsAlgorithm in Computer, Sorting  and Notations
Algorithm in Computer, Sorting and Notations
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Algorithm
AlgorithmAlgorithm
Algorithm
 
Tiap
TiapTiap
Tiap
 

More from Onkar Nath Sharma

09. amortized analysis
09. amortized analysis09. amortized analysis
09. amortized analysis
Onkar Nath Sharma
 
07. disjoint set
07. disjoint set07. disjoint set
07. disjoint set
Onkar Nath Sharma
 
06. string matching
06. string matching06. string matching
06. string matching
Onkar Nath Sharma
 
05. greedy method
05. greedy method05. greedy method
05. greedy method
Onkar Nath Sharma
 
04. backtracking
04. backtracking04. backtracking
04. backtracking
Onkar Nath Sharma
 
03. dynamic programming
03. dynamic programming03. dynamic programming
03. dynamic programming
Onkar Nath Sharma
 
02. divide and conquer
02. divide and conquer02. divide and conquer
02. divide and conquer
Onkar Nath Sharma
 
01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis
Onkar Nath Sharma
 

More from Onkar Nath Sharma (8)

09. amortized analysis
09. amortized analysis09. amortized analysis
09. amortized analysis
 
07. disjoint set
07. disjoint set07. disjoint set
07. disjoint set
 
06. string matching
06. string matching06. string matching
06. string matching
 
05. greedy method
05. greedy method05. greedy method
05. greedy method
 
04. backtracking
04. backtracking04. backtracking
04. backtracking
 
03. dynamic programming
03. dynamic programming03. dynamic programming
03. dynamic programming
 
02. divide and conquer
02. divide and conquer02. divide and conquer
02. divide and conquer
 
01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis01. design & analysis of agorithm intro & complexity analysis
01. design & analysis of agorithm intro & complexity analysis
 

Recently uploaded

Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 

Recently uploaded (20)

Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 

08. graph traversal

  • 1. Design & Analysis of Algorithm Graph Traversal Algorithms Kamalesh Karmakar Assistant Professor Department of C.S.E. MeghnadSahaInstitute of Technology Kolkata.
  • 2. Design & Analysis of Algorithm Graph Traversal Algorithms
  • 3. Design & Analysis of Algorithm Graph Traversal Algorithms
  • 4. Design & Analysis of Algorithm Graph Traversal Algorithms
  • 5. Design & Analysis of Algorithm Graph Traversal Algorithms
  • 6. Design & Analysis of Algorithm Beforeprovingthevariouspropertiesofbreadth-firstsearch,wetakeonthesomewhateasierjobofanalyzingitsrunningtimeonaninputgraphG=(V,E).Weuseaggregateanalysis,aswesawinSection17.1.Afterinitialization,novertexiseverwhitened,andthusthetestinline13ensuresthateachvertexisenqueuedatmostonce,andhencedequeuedatmostonce.TheoperationsofenqueuinganddequeuingtakeO(1)time,sothetotaltimedevotedtoqueueoperationsisO(V).Becausetheadjacencylistofeachvertexisscannedonlywhenthevertexisdequeued,eachadjacencylistisscannedatmostonce.Sincethesumofthelengthsofalltheadjacencylistsis(E),thetotaltimespentinscanningadjacencylistsisO(E).TheoverheadforinitializationisO(V),andthusthetotalrunningtimeofBFSisO(V+E).Thus,breadth-firstsearchrunsintimelinearinthesizeoftheadjacency-listrepresentationofG. Graph Traversal Algorithms
  • 7. Design & Analysis of Algorithm Graph Traversal Algorithms
  • 8. Design & Analysis of Algorithm Graph Traversal Algorithms
  • 9. Design & Analysis of Algorithm Graph Traversal Algorithms
  • 10. Design & Analysis of Algorithm Graph Traversal Algorithms
  • 11. Design & Analysis of Algorithm G. Graph Traversal Algorithms
  • 12. Design & Analysis of Algorithm Wecandefinefouredgetypesintermsofthedepth-firstforestGπproducedbyadepth-firstsearchonG. 1.Treeedgesareedgesinthedepth-firstforestGπ.Edge(u,v)isatreeedgeifvwasfirstdiscoveredbyexploringedge(u,v). 2.Backedgesarethoseedges(u,v)connectingavertexutoanancestorvinadepth-firsttree.Self-loops,whichmayoccurindirectedgraphs,areconsideredtobebackedges. 3.Forwardedgesarethosenon-treeedges(u,v)connectingavertexutoadescendantvinadepth-firsttree. 4.Crossedgesareallotheredges.Theycangobetweenverticesinthesamedepth-firsttree,aslongasonevertexisnotanancestoroftheother,ortheycangobetweenverticesindifferentdepth-firsttrees. Graph Traversal Algorithms