0% found this document useful (0 votes)
2 views4 pages

Data Structures Tutorials - BFS Graph Traversal _ DFS

The document explains graph traversal techniques, specifically focusing on Breadth First Search (BFS). BFS uses a queue to explore vertices in a graph, ensuring all vertices are visited without loops, ultimately producing a spanning tree. The document outlines the steps to implement BFS traversal effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Data Structures Tutorials - BFS Graph Traversal _ DFS

The document explains graph traversal techniques, specifically focusing on Breadth First Search (BFS). BFS uses a queue to explore vertices in a graph, ensuring all vertices are visited without loops, ultimately producing a spanning tree. The document outlines the steps to implement BFS traversal effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

3/9/22, 11:43 AM Data Structures Tutorials - BFS graph traversal | DFS

(../index.html)

Data
Structures
Place your ad here

 Previous (graph-traversal-dfs.html) Next  (linear-search.html)

Graph Traversal - BFS


Graph traversal is a technique used for searching a vertex in a graph. The graph traversal is also used to

decide the order of vertices is visited in the search process. A graph traversal finds the edges to be used in

the search process without creating loops. That means using graph traversal we visit all the vertices of the

graph without getting into looping path.

There are two graph traversal techniques and they are as follows...

1. DFS (Depth First Search)

2. BFS (Breadth First Search)

BFS (Breadth First Search)


BFS traversal of a graph produces a spanning tree as final result. Spanning Tree is a graph without loops. We

use Queue data structure with maximum size of total number of vertices in the graph to implement BFS
traversal.

We use the following steps to implement BFS traversal...

Step 1 - Define a Queue of size total number of vertices in the graph.

Step 2 - Select any vertex as starting point for traversal. Visit that vertex and insert it into the Queue.
Step 3 - Visit all the non-visited adjacent vertices of the vertex which is at front of the Queue and insert

them into the Queue.


Step 4 - When there is no new vertex to be visited from the vertex which is at front of the Queue then

delete that vertex.

www.btechsmartclass.com/data_structures/graph-traversal-bfs.html 1/4
3/9/22, 11:43 AM Data Structures Tutorials - BFS graph traversal | DFS

Step 5 - Repeat steps 3 and 4 until queue becomes empty.

Step 6 - When queue becomes empty, then produce final spanning tree by removing unused edges
from the graph

Example

www.btechsmartclass.com/data_structures/graph-traversal-bfs.html 2/4
3/9/22, 11:43 AM Data Structures Tutorials - BFS graph traversal | DFS

 (../index.html)  (../courses.html) ✏ (../authors.html)

 (../downloads.html)  (../contact-us.html) 

www.btechsmartclass.com/data_structures/graph-traversal-bfs.html 3/4
3/9/22, 11:43 AM Data Structures Tutorials - BFS graph traversal | DFS

 Previous (graph-traversal-dfs.html) Next  (linear-search.html)

Place your ad here

Place your ad here

Courses (../courses.html) | Downloads (../downloads.html) | About Us (../authors.html) | Contcat Us (../contact-


us.html)

Website designed by Rajinikanth B



   (https://www.youtube.com/channel/UC9YHZpCPtRqbYpu
(https://www.facebook.com/btechsmartclass/)
(https://plus.google.com/116706303219518006305)
(https://twitter.com/BtechClass)
NVP8Ecg)

www.btechsmartclass.com/data_structures/graph-traversal-bfs.html 4/4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy