






















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An overview of graph searching algorithms, specifically Breadth-First Search (BFS) and Depth-First Search (DFS). It covers the concepts, procedures, and properties of both algorithms, including their differences. BFS explores vertices and edges starting from a specified vertex, looking at vertices closest first, while DFS explores vertices and edges based on the depth of the graph. Both algorithms are essential in understanding graph theory and its applications.
What you will learn
Typology: Lecture notes
1 / 62
This page cannot be seen from the preview
Don't miss anything!
Graph seacrhing is the systematic traversal of the vertices and edges of a graph in order to learn useful structural properties of a graph.
Graph seacrhing is the systematic traversal of the vertices and edges of a graph in order to learn useful structural properties of a graph. Graph searching techniques are central to several important graph algorithms. Many advanced algorithms begin by a graph searching routine before proceeding with other computations. The two most common graph searching algorithms are Breadth-First Search (BFS) and Depth-First Search (DFS).
BFS explores the edges and vertices of a graph starting from a specified vertex by looking at vertices closest first and then moving to remote vertices. It performs explorations at all vertices at a distance k from the source before looking at any vertex before doing so for any vertex at distance k + 1.
BFS explores the edges and vertices of a graph starting from a specified vertex by looking at vertices closest first and then moving to remote vertices. It performs explorations at all vertices at a distance k from the source before looking at any vertex before doing so for any vertex at distance k + 1.
DFS explores further and deeper along a path until no further progress is possible and then retraces and branches from an earlier point.
During their course both these algorithms get useful information about the graph. They are used either directly or as prototypes to develop subroutines for many graph algorithms.
(^1) for each vertex u โ V [G ] \ {s}
(^1) for each vertex u โ V [G ] \ {s} (^2) do colour [u] โ white (^3) d[u] โ โ
(^1) for each vertex u โ V [G ] \ {s} (^2) do colour [u] โ white (^3) d[u] โ โ (^4) ฯ[u] โ nil
(^1) for each vertex u โ V [G ] \ {s} (^2) do colour [u] โ white (^3) d[u] โ โ (^4) ฯ[u] โ nil (^5) colour [s] โ grey (^6) d[s] โ s
(^1) for each vertex u โ V [G ] \ {s} (^2) do colour [u] โ white (^3) d[u] โ โ (^4) ฯ[u] โ nil (^5) colour [s] โ grey (^6) d[s] โ s (^7) ฯ[s] โ nil
(^1) for each vertex u โ V [G ] \ {s} (^2) do colour [u] โ white (^3) d[u] โ โ (^4) ฯ[u] โ nil (^5) colour [s] โ grey (^6) d[s] โ s (^7) ฯ[s] โ nil (^8) Q โ โ (^9) ENQUEUE (Q, s)
(^10) while (Q 6 = โ )
(^10) while (Q 6 = โ )
(^11) do u โ DEQUEUE (Q)
(^12) for each v โ Adj[u]
(^10) while (Q 6 = โ )
(^11) do u โ DEQUEUE (Q)
(^12) for each v โ Adj[u]
(^13) do if colour [v ] = white