SlideShare a Scribd company logo
1 of 37
SUBITTED BY:-AKHILESH SINGH
ROLL NUMBER:-51910079
GRAPH
 A data structure that consists of a set of
nodes(vertices) a set of edges that
relate the nodes to each other.
 The of edged describes relationships
among the vertices.
 A graph G is defined as follows.
G=(V,E)
V(G): a finite ,nonempty set of vertices
E(G): a set of edges (pairs of vertices)
Examples of Graphs
 V={0,1,2,3,4}
 E={(0,1),(1,2),(0,3),(3,0),(2,2),(4,3)}
0
4
1
3
2
Directed graph and undirected
graph
 Directed graph
 directed edge
 Undirected graph
 undirected edge
1 2
1
2
Weighted graph
1 2
3
4
5
6
8
3
4
7
53
7
9
2
2
4
Graph terminology
 Adjacent nodes: two nodes are said to adjacent if they are
connected by an edge
 Path: a sequence of vertices that connect two
 Complete graph : a graph in which every vertex is directly
connected to every other vertex.
4 5 is adjacent to 45
 Cycle : a cycle is a simple path with the same
start and end vertex.
 Degree : the degree of vertex is the no. of
edges incident on vertex.
e.g ., d(a)=3, d(d)=2.
a
s
r
d
v t h
 loops: edges connect a vertex to itself
 Simple graph a simple graph has no loop ,no
multiedge.
 Complete graph : a graph in which every vertex is
directly connected to every other vertex.
5
Connections
 An undirected graph are connected if there is a
path between any two vertices
 Directed graph are strongly connected if there is a
path from any one vertex to any other
 Directed graph are weakly connected if there is a
path between any two vertices
ignoring direction .
A complete graph has an edge between every pair of
vertices.
Graph searching
 Problem: find a path between two nodes
of the graph .
 Method:
1: depth-first-search (DFS)
2: breadth-first-search (BFS)
Depth-first-search (DFS)
 What is the idea behind DFS?
travel as far as you can down a path.
back up as little as possible when you reach a “dead
end”(i.e., next vertex has been “marked” or there is no next vertex)
 DFS can be implemented efficiently using a
stack
DFS…..
set found to false
stack.Push(stackVertex)
DO
stack.Pop(vertex)
IF vertex == endVertex
set found to true
ELSE
push all adjacent vertices onto stack
WHILE !stack.IsEmpty()AND !found
IF(!found)
Write “path does not exist”.
Breadth-first-searching
(BFS)
 what is idea behind BFS ?
 Look at all possible paths at the same the same depth
You go at a level
 Back up as far as possible when you reach a “dead end”
(i.e., next vertex has been “marked” or there is no next vertex)
Implementation of graph
Thank you
mam

More Related Content

What's hot

Breadth First Search (BFS) pada Graph
Breadth First Search (BFS) pada GraphBreadth First Search (BFS) pada Graph
Breadth First Search (BFS) pada GraphAchmad Solichin
 
Depth First Search (DFS) pada Graph
Depth First Search (DFS) pada GraphDepth First Search (DFS) pada Graph
Depth First Search (DFS) pada GraphAchmad Solichin
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapterSavit Chandra
 
Graph Theory: Planarity & Dual Graph
Graph Theory: Planarity & Dual GraphGraph Theory: Planarity & Dual Graph
Graph Theory: Planarity & Dual GraphAshikur Rahman
 
14 figure grid references explained.
14 figure grid references explained.14 figure grid references explained.
14 figure grid references explained.lavenderbongo
 
14 Figure Grid References
14  Figure Grid References14  Figure Grid References
14 Figure Grid Referencesmrmacfarquhar
 
Königsberg, Euler and the origins of graph theory
Königsberg, Euler and the origins of graph theoryKönigsberg, Euler and the origins of graph theory
Königsberg, Euler and the origins of graph theorypupbroeders
 
Graph Theory: Paths & Cycles
Graph Theory: Paths & CyclesGraph Theory: Paths & Cycles
Graph Theory: Paths & CyclesAshikur Rahman
 
Area and Grid References
Area and Grid ReferencesArea and Grid References
Area and Grid ReferencesMr Shipp
 
BFS, Breadth first search | Search Traversal Algorithm
BFS, Breadth first search | Search Traversal AlgorithmBFS, Breadth first search | Search Traversal Algorithm
BFS, Breadth first search | Search Traversal AlgorithmMSA Technosoft
 
Cluster abundances and clustering Can theory step up to precision cosmology?
Cluster abundances and clustering Can theory step up to precision cosmology?Cluster abundances and clustering Can theory step up to precision cosmology?
Cluster abundances and clustering Can theory step up to precision cosmology?CosmoAIMS Bassett
 
Koningsberg bridge problem
Koningsberg  bridge  problemKoningsberg  bridge  problem
Koningsberg bridge problemSudiksha Joshi
 
CPSC 125 Ch 5 Sec 1
CPSC 125 Ch 5 Sec 1CPSC 125 Ch 5 Sec 1
CPSC 125 Ch 5 Sec 1David Wood
 

What's hot (20)

Graph theory
Graph theory Graph theory
Graph theory
 
Breadth First Search (BFS) pada Graph
Breadth First Search (BFS) pada GraphBreadth First Search (BFS) pada Graph
Breadth First Search (BFS) pada Graph
 
Depth First Search (DFS) pada Graph
Depth First Search (DFS) pada GraphDepth First Search (DFS) pada Graph
Depth First Search (DFS) pada Graph
 
Graph theory
Graph theoryGraph theory
Graph theory
 
DFS algorithm
DFS algorithmDFS algorithm
DFS algorithm
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapter
 
Graph Theory: Planarity & Dual Graph
Graph Theory: Planarity & Dual GraphGraph Theory: Planarity & Dual Graph
Graph Theory: Planarity & Dual Graph
 
Bfs dfs
Bfs dfsBfs dfs
Bfs dfs
 
14 figure grid references explained.
14 figure grid references explained.14 figure grid references explained.
14 figure grid references explained.
 
Graph theory
Graph theoryGraph theory
Graph theory
 
14 Figure Grid References
14  Figure Grid References14  Figure Grid References
14 Figure Grid References
 
Königsberg, Euler and the origins of graph theory
Königsberg, Euler and the origins of graph theoryKönigsberg, Euler and the origins of graph theory
Königsberg, Euler and the origins of graph theory
 
Graph Theory: Paths & Cycles
Graph Theory: Paths & CyclesGraph Theory: Paths & Cycles
Graph Theory: Paths & Cycles
 
Area and Grid References
Area and Grid ReferencesArea and Grid References
Area and Grid References
 
BFS, Breadth first search | Search Traversal Algorithm
BFS, Breadth first search | Search Traversal AlgorithmBFS, Breadth first search | Search Traversal Algorithm
BFS, Breadth first search | Search Traversal Algorithm
 
Koinsburg bridge
Koinsburg bridgeKoinsburg bridge
Koinsburg bridge
 
Cluster abundances and clustering Can theory step up to precision cosmology?
Cluster abundances and clustering Can theory step up to precision cosmology?Cluster abundances and clustering Can theory step up to precision cosmology?
Cluster abundances and clustering Can theory step up to precision cosmology?
 
Koningsberg bridge problem
Koningsberg  bridge  problemKoningsberg  bridge  problem
Koningsberg bridge problem
 
CPSC 125 Ch 5 Sec 1
CPSC 125 Ch 5 Sec 1CPSC 125 Ch 5 Sec 1
CPSC 125 Ch 5 Sec 1
 
Graphs
GraphsGraphs
Graphs
 

Similar to Graphs

Graph Representation, DFS and BFS Presentation.pptx
Graph Representation, DFS and BFS Presentation.pptxGraph Representation, DFS and BFS Presentation.pptx
Graph Representation, DFS and BFS Presentation.pptxbashirabdullah789
 
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabatinabati
 
Unit-6 Graph.ppsx ppt
Unit-6 Graph.ppsx                                       pptUnit-6 Graph.ppsx                                       ppt
Unit-6 Graph.ppsx pptDhruvilSTATUS
 
graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________ssuser1989da
 
Lecture 5b graphs and hashing
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashingVictor Palmar
 
Graphs.ppt of mathemaics we have to clar all doubts
Graphs.ppt of mathemaics  we have to clar all doubtsGraphs.ppt of mathemaics  we have to clar all doubts
Graphs.ppt of mathemaics we have to clar all doubtsnc3186331
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structurePooja Bhojwani
 
Graphs and eularian circuit & path with c++ program
Graphs and eularian circuit & path with c++ programGraphs and eularian circuit & path with c++ program
Graphs and eularian circuit & path with c++ programMuhammad Danish Badar
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structuresSavit Chandra
 

Similar to Graphs (20)

Graphs
GraphsGraphs
Graphs
 
Graph Representation, DFS and BFS Presentation.pptx
Graph Representation, DFS and BFS Presentation.pptxGraph Representation, DFS and BFS Presentation.pptx
Graph Representation, DFS and BFS Presentation.pptx
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
 
LEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdfLEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdf
 
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabati
 
Unit-6 Graph.ppsx ppt
Unit-6 Graph.ppsx                                       pptUnit-6 Graph.ppsx                                       ppt
Unit-6 Graph.ppsx ppt
 
graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________
 
Graph
GraphGraph
Graph
 
Unit 2: All
Unit 2: AllUnit 2: All
Unit 2: All
 
Lecture 5b graphs and hashing
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashing
 
Graphs.ppt
Graphs.pptGraphs.ppt
Graphs.ppt
 
Graphs.ppt of mathemaics we have to clar all doubts
Graphs.ppt of mathemaics  we have to clar all doubtsGraphs.ppt of mathemaics  we have to clar all doubts
Graphs.ppt of mathemaics we have to clar all doubts
 
logic.pptx
logic.pptxlogic.pptx
logic.pptx
 
Graphs (1)
Graphs (1)Graphs (1)
Graphs (1)
 
Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Graphs and eularian circuit & path with c++ program
Graphs and eularian circuit & path with c++ programGraphs and eularian circuit & path with c++ program
Graphs and eularian circuit & path with c++ program
 
DATA STRUCTURES.pptx
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
 
Spanningtreesppt
SpanningtreespptSpanningtreesppt
Spanningtreesppt
 
Graphs in data structures
Graphs in data structuresGraphs in data structures
Graphs in data structures
 
Graphs
GraphsGraphs
Graphs
 

Recently uploaded

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

Graphs

  • 2. GRAPH  A data structure that consists of a set of nodes(vertices) a set of edges that relate the nodes to each other.  The of edged describes relationships among the vertices.  A graph G is defined as follows. G=(V,E) V(G): a finite ,nonempty set of vertices E(G): a set of edges (pairs of vertices)
  • 3. Examples of Graphs  V={0,1,2,3,4}  E={(0,1),(1,2),(0,3),(3,0),(2,2),(4,3)} 0 4 1 3 2
  • 4. Directed graph and undirected graph  Directed graph  directed edge  Undirected graph  undirected edge 1 2 1 2
  • 6. Graph terminology  Adjacent nodes: two nodes are said to adjacent if they are connected by an edge  Path: a sequence of vertices that connect two  Complete graph : a graph in which every vertex is directly connected to every other vertex. 4 5 is adjacent to 45
  • 7.  Cycle : a cycle is a simple path with the same start and end vertex.  Degree : the degree of vertex is the no. of edges incident on vertex. e.g ., d(a)=3, d(d)=2. a s r d v t h
  • 8.  loops: edges connect a vertex to itself  Simple graph a simple graph has no loop ,no multiedge.  Complete graph : a graph in which every vertex is directly connected to every other vertex. 5
  • 9. Connections  An undirected graph are connected if there is a path between any two vertices  Directed graph are strongly connected if there is a path from any one vertex to any other  Directed graph are weakly connected if there is a path between any two vertices ignoring direction . A complete graph has an edge between every pair of vertices.
  • 10. Graph searching  Problem: find a path between two nodes of the graph .  Method: 1: depth-first-search (DFS) 2: breadth-first-search (BFS)
  • 11. Depth-first-search (DFS)  What is the idea behind DFS? travel as far as you can down a path. back up as little as possible when you reach a “dead end”(i.e., next vertex has been “marked” or there is no next vertex)  DFS can be implemented efficiently using a stack
  • 12. DFS….. set found to false stack.Push(stackVertex) DO stack.Pop(vertex) IF vertex == endVertex set found to true ELSE push all adjacent vertices onto stack WHILE !stack.IsEmpty()AND !found IF(!found) Write “path does not exist”.
  • 13. Breadth-first-searching (BFS)  what is idea behind BFS ?  Look at all possible paths at the same the same depth You go at a level  Back up as far as possible when you reach a “dead end” (i.e., next vertex has been “marked” or there is no next vertex)
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.