






















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
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