SlideShare a Scribd company logo
1 of 15
CVR COLLEGE OF ENGINEERING
Vastunagar , Mangalpalli(V) , Ibrahimpatnam(M) , R.R.Dist.
Pin-501510
Department of COMPUTER SCIENCE AND ENGINEERING
AKULA RAJU
19B81A0599
1. Given a graph G=(V,E) and a distinguished source vertex ‘s’ , breadth-first
search systematically explores the edges of G to discover every reachable
vertex from ‘s’. It produces "Breadth First Search Tree" with root ‘s’ that
contains all reachable from vertices.
2. The algorithm works on both directed and undirected graphs.
Assumptions made in the algorithm are:
1. Input graph G=(V,E) is represented using adjacency list representation.
2. We use 3 different colors to distinguish between vertices.
3. White color specifies that the vertex is not yet discovered, Gray color
specifies that the vertex is discovered for the first time, & Black color
specifies that the vertex is fully discovered.
4. We store color of each vertex in u.coIor and predecessor of u in u.pi if no
predecessor u.pi=null and shortest distance of u from 's' in u.d . This
algorithm uses FIFO QUEUE for Gray vertices.
Working of procedure BFS(G,s) is as follows:
Example: Progress of BFS on a sample graph is shown in the figure below :
Fig. l. Given Undirected graph Fig. 4. Search visits vertices ‘t’ and ‘x’
Fig. 2. Source vertex ‘s’ is ENQUEUED
Fig. 3. Search visits vertices ‘r’ and ‘w’
Fig. 5. Search visits vertices ‘v’
Fig. 6. Search visits vertices ‘u’
Fig. 7. Search visits vertices ‘y’
Fig. 8. Vertex ‘v’ is completely traversed
hence Dequeued
Fig. 9. Vertex ‘u’ is completely traversed
hence Dequeued’
Example 1 :Consider the given
directed graph given below
The output Tree:
Example 2 :Consider the given
directed graph given below
Output forest with multiple trees
when the root vertex is ‘m’ :
Output tree when root vertex is ‘p’ :
Output tree when root vertex is ‘r’ :
• We can observe that In Example 1 as graph was a Forest so it is
obvious that according to BFS algorithm the search would be
incomplete.
• But in example 2 input graph is directed Acyclic graph (Dag) and
still the BFS algorithm was unable to search the graph completely.
• These can be overcomed by the modified BFS Algorithm.
For a Given graph G=(V,E) and a distinguished source vertex 's’, with
modified BFS algorithm we can traverse the graphs, which we may not
traverse with existing BFS completely but the output may contain
multiple trees FORMING A SPANNING FOREST.
Assumptions made in the algorithm are:
1. Input graph G=(V,E) is represented using adjacency list
representation.
2. We use 3 different colors to distinguish between vertices.
3. White color specifies that the vertex is not yet discovered, Gray color
specifies that the vertex is discovered for the first time, a Black color
specifies that the vertex is fully discovered.
4. We store color of each vertex in u.color & predecessor of u in u.pi if
no predecessor
The Algorithm:
BFS (G, root) :
1. for each vertex u in G.V
2. u. color = WHITE
//Initializing all the vertices in the given
graph.
3. u.d = ∞
4. u. π = NIL
5. u = root
6. B_FS(G, u)
// calling B_FS algorithm with specified root
vertex.
7. for each vertex u ∈ G. v - {root}
8. if u. color = = white
//calling B_FS algorithm with unreached
vertices.
9. B_FS(G , u)
B_FS (G , u) :
1. u. color = GRAY /*Traditional BFS
algorithm that forms a BFS tree from */
2. u. d = 0 // tree from the specified root
vertex
3. u. π = NIL
4. Q ≠ Φ
5. ENQUEUE(Q, u)
6. While Q ≠ Φ
7. u = DEQUEUE (Q)
8. for each v ∈ G. Adj [u]
9. if v. color = = WHITE
10. v. color = GRAY
11. v. d = u.d + 1
12. v. π = u
13. ENQUEUE (Q, v)
14. u.color = BLACK
Given directed Acyclic Graph :
Output forest with multiple trees :
Given directed Acyclic Graph :
Output forest with multiple trees when root vertex is ‘m’
 https://www.researchgate.net/publication/286668754_Traversing_dir
ected_cyclic_and_acyclic_graphs_using_modified_BFS_algorithm
Technical_Seminar .pptx

More Related Content

Similar to Technical_Seminar .pptx

graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxgraphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
whittemorelucilla
 
Skiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first searchSkiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first search
zukun
 
Discrete mathematic answers of questions
Discrete mathematic answers of questionsDiscrete mathematic answers of questions
Discrete mathematic answers of questions
Samet öztoprak
 

Similar to Technical_Seminar .pptx (20)

Unit-6 Graph.ppsx ppt
Unit-6 Graph.ppsx                                       pptUnit-6 Graph.ppsx                                       ppt
Unit-6 Graph.ppsx ppt
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first search
 
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docxgraphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
 
Breadth First Search (BFS)
Breadth First Search (BFS)Breadth First Search (BFS)
Breadth First Search (BFS)
 
logic.pptx
logic.pptxlogic.pptx
logic.pptx
 
DATA STRUCTURES.pptx
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapter
 
Cs6702 graph theory and applications Anna University question paper apr may 2...
Cs6702 graph theory and applications Anna University question paper apr may 2...Cs6702 graph theory and applications Anna University question paper apr may 2...
Cs6702 graph theory and applications Anna University question paper apr may 2...
 
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
 
Topological sort
Topological sortTopological sort
Topological sort
 
Breadth first search
Breadth first searchBreadth first search
Breadth first search
 
Skiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first searchSkiena algorithm 2007 lecture11 breadth deapth first search
Skiena algorithm 2007 lecture11 breadth deapth first search
 
B.tech admission in india
B.tech admission in indiaB.tech admission in india
B.tech admission in india
 
Algorithms Design Assignment Help
Algorithms Design Assignment HelpAlgorithms Design Assignment Help
Algorithms Design Assignment Help
 
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 - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]Data Structures - Lecture 10 [Graphs]
Data Structures - Lecture 10 [Graphs]
 
Discrete mathematic answers of questions
Discrete mathematic answers of questionsDiscrete mathematic answers of questions
Discrete mathematic answers of questions
 
Discrete mathematic answers of questions
Discrete mathematic answers of questionsDiscrete mathematic answers of questions
Discrete mathematic answers of questions
 
Algorithms Design Exam Help
Algorithms Design Exam HelpAlgorithms Design Exam Help
Algorithms Design Exam Help
 
Diabolic Str8ts #1
Diabolic Str8ts #1Diabolic Str8ts #1
Diabolic Str8ts #1
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 

Technical_Seminar .pptx

  • 1.
  • 2. CVR COLLEGE OF ENGINEERING Vastunagar , Mangalpalli(V) , Ibrahimpatnam(M) , R.R.Dist. Pin-501510 Department of COMPUTER SCIENCE AND ENGINEERING AKULA RAJU 19B81A0599
  • 3.
  • 4.
  • 5.
  • 6. 1. Given a graph G=(V,E) and a distinguished source vertex ‘s’ , breadth-first search systematically explores the edges of G to discover every reachable vertex from ‘s’. It produces "Breadth First Search Tree" with root ‘s’ that contains all reachable from vertices. 2. The algorithm works on both directed and undirected graphs. Assumptions made in the algorithm are: 1. Input graph G=(V,E) is represented using adjacency list representation. 2. We use 3 different colors to distinguish between vertices. 3. White color specifies that the vertex is not yet discovered, Gray color specifies that the vertex is discovered for the first time, & Black color specifies that the vertex is fully discovered. 4. We store color of each vertex in u.coIor and predecessor of u in u.pi if no predecessor u.pi=null and shortest distance of u from 's' in u.d . This algorithm uses FIFO QUEUE for Gray vertices.
  • 7.
  • 8. Working of procedure BFS(G,s) is as follows: Example: Progress of BFS on a sample graph is shown in the figure below : Fig. l. Given Undirected graph Fig. 4. Search visits vertices ‘t’ and ‘x’ Fig. 2. Source vertex ‘s’ is ENQUEUED Fig. 3. Search visits vertices ‘r’ and ‘w’ Fig. 5. Search visits vertices ‘v’ Fig. 6. Search visits vertices ‘u’ Fig. 7. Search visits vertices ‘y’ Fig. 8. Vertex ‘v’ is completely traversed hence Dequeued Fig. 9. Vertex ‘u’ is completely traversed hence Dequeued’
  • 9. Example 1 :Consider the given directed graph given below The output Tree: Example 2 :Consider the given directed graph given below Output forest with multiple trees when the root vertex is ‘m’ : Output tree when root vertex is ‘p’ : Output tree when root vertex is ‘r’ :
  • 10. • We can observe that In Example 1 as graph was a Forest so it is obvious that according to BFS algorithm the search would be incomplete. • But in example 2 input graph is directed Acyclic graph (Dag) and still the BFS algorithm was unable to search the graph completely. • These can be overcomed by the modified BFS Algorithm.
  • 11. For a Given graph G=(V,E) and a distinguished source vertex 's’, with modified BFS algorithm we can traverse the graphs, which we may not traverse with existing BFS completely but the output may contain multiple trees FORMING A SPANNING FOREST. Assumptions made in the algorithm are: 1. Input graph G=(V,E) is represented using adjacency list representation. 2. We use 3 different colors to distinguish between vertices. 3. White color specifies that the vertex is not yet discovered, Gray color specifies that the vertex is discovered for the first time, a Black color specifies that the vertex is fully discovered. 4. We store color of each vertex in u.color & predecessor of u in u.pi if no predecessor
  • 12. The Algorithm: BFS (G, root) : 1. for each vertex u in G.V 2. u. color = WHITE //Initializing all the vertices in the given graph. 3. u.d = ∞ 4. u. π = NIL 5. u = root 6. B_FS(G, u) // calling B_FS algorithm with specified root vertex. 7. for each vertex u ∈ G. v - {root} 8. if u. color = = white //calling B_FS algorithm with unreached vertices. 9. B_FS(G , u) B_FS (G , u) : 1. u. color = GRAY /*Traditional BFS algorithm that forms a BFS tree from */ 2. u. d = 0 // tree from the specified root vertex 3. u. π = NIL 4. Q ≠ Φ 5. ENQUEUE(Q, u) 6. While Q ≠ Φ 7. u = DEQUEUE (Q) 8. for each v ∈ G. Adj [u] 9. if v. color = = WHITE 10. v. color = GRAY 11. v. d = u.d + 1 12. v. π = u 13. ENQUEUE (Q, v) 14. u.color = BLACK
  • 13. Given directed Acyclic Graph : Output forest with multiple trees : Given directed Acyclic Graph : Output forest with multiple trees when root vertex is ‘m’