SlideShare a Scribd company logo
7
Most read
10
Most read
12
Most read
Graphs
Breadth First Search
&
Depth First Search
Submitted By:
Jailalita Gautam
Contents







10/27/13

Overview of Graph terminology.
Graph representation.
Breadth first search.
Depth first search.
Applications of BFS and DFS.
References.

NITTTR CHD

2
Graph terminology - overview


A graph consists of











set of vertices V = {v1, v2, ….. vn}
set of edges that connect the vertices E ={e1, e2, …. em}

Two vertices in a graph are adjacent if there is an
edge connecting the vertices.
Two vertices are on a path if there is a sequences
of vertices beginning with the first one and ending
with the second one
Graphs with ordered edges are directed. For
directed graphs, vertices have in and out degrees.
Weighted Graphs have values associated with
edges.

10/27/13

NITTTR CHD

3
Graph representation






There are two standard ways to represent a graph
G=(V,E) : as collection of adjacency list or as an
adjacency matrix.
Adjacency list preferred for sparse graphs- those for
which |E| much less than |V|^2.
Adjacency matrix preferred for dense graphs- |E| is
close to |V|^2.

10/27/13

NITTTR CHD

4
Graph representation – undirected

graph

10/27/13

Adjacency list

NITTTR CHD

Adjacency matrix

5
Graph representation – directed

graph

10/27/13

Adjacency list

NITTTR CHD

Adjacency matrix

6
Breadth first search


Given










a graph G=(V,E) – set of vertices and edges
a distinguished source vertex s

Breadth first search systematically explores the
edges of G to discover every vertex that is
reachable from s.
It also produces a ‘breadth first tree’ with root s that
contains all the vertices reachable from s.
For any vertex v reachable from s, the path in the
breadth first tree corresponds to the shortest path in
graph G from s to v.
It works on both directed and undirected graphs.
However, we will explore only directed graphs.

10/27/13

NITTTR CHD

7
Breadth first search - concepts







To keep track of progress, it colors each
vertex - white, gray or black.
All vertices start white.
A vertex discovered first time during the
search becomes nonwhite.
All vertices adjacent to black ones are
discovered. Whereas, gray ones may have
some white adjacent vertices.

10/27/13

NITTTR CHD

8
BFS – How it produces a Breadth first tree



The tree initially contains only root. – s
Whenever a vertex v is discovered in
scanning adjacency list of vertex u


10/27/13

Vertex v and edge (u,v) are added to the tree.

NITTTR CHD

9
BFS - algorithm
BFS(G, s)
// G is the graph and s is the starting node
1 for each vertex u ∈ V [G] - {s}
2
do color[u] ← WHITE
// color of vertex u
3
d[u] ← ∞
// distance from source s to vertex u
4
π[u] ← NIL
// predecessor of u
5 color[s] ← GRAY
6 d[s] ← 0
7 π[s] ← NIL
8 Q←Ø
// Q is a FIFO - queue
9 ENQUEUE(Q, s)
10 while Q ≠ Ø
// iterates as long as there are gray vertices. Lines 10-18
11
do u ← DEQUEUE(Q)
12
for each v ∈ Adj [u]
13
do if color[v] = WHITE
// discover the undiscovered adjacent vertices
14
then color[v] ← GRAY
// enqueued whenever painted gray
15
d[v] ← d[u] + 1
16
π[v] ← u
17
ENQUEUE(Q, v)
18
color[u] ← BLACK
// painted black whenever dequeued

10/27/13

NITTTR CHD

10
Breadth First Search - example

10/27/13

NITTTR CHD

11
Breadth first search - analysis






Enqueue and Dequeue happen only once for
each node. - O(V).
Total time spent in scanning adjacency lists
is O(E) .
Initialization overhead O(V)
Total runtime O(V+E)

10/27/13

NITTTR CHD

12
Depth first search





It searches ‘deeper’ the graph when possible.
Starts at the selected node and explores as far as
possible along each branch before backtracking.
Vertices go through white, gray and black stages of
color.






White – initially
Gray – when discovered first
Black – when finished i.e. the adjacency list of the vertex is
completely examined.

Also records timestamps for each vertex



10/27/13

d[v]
f[v]

when the vertex is first discovered
when the vertex is finished
NITTTR CHD

13
Depth first search - algorithm
DFS(G)
1 for each vertex u ∈ V [G]
2
do color[u] ← WHITE
3
π[u] ← NIL
4 time ← 0
5 for each vertex u ∈ V [G]
6
do if color[u] = WHITE
7
then DFS-VISIT(u)

// color all vertices white, set their parents NIL
// zero out time
// call only for unexplored vertices
// this may result in multiple sources

DFS-VISIT(u)
1 color[u] ← GRAY ▹White vertex u has just been discovered.
2 time ← time +1
3 d[u] time
// record the discovery time
4 for each v ∈ Adj[u]
▹Explore edge(u, v).
5
do if color[v] = WHITE
6
then π[v] ← u
// set the parent value
7
DFS-VISIT(v)
// recursive call
8 color[u] BLACK
▹ Blacken u; it is finished.
9 f [u] ▹ time ← time +1
10/27/13

NITTTR CHD

14
Depth first search – example

10/27/13

NITTTR CHD

15
Depth first search - analysis
Lines 1-3, initialization take time Θ(V).
 Lines 5-7 take time Θ(V), excluding the time to call
the DFS-VISIT.
 DFS-VISIT is called only once for each node (since
it’s called only for white nodes and the first step in it
is to paint the node gray).
 Loop on line 4-7 is executed |Adj(v)| times. Since
∑vєV |Adj(v)| = Ө (E),
the total cost of executing lines 4-7 of DFS-VISIT is
θ(E).


The total cost of DFS is θ(V+E)
10/27/13

NITTTR CHD

16
BFS and DFS - comparison






Space complexity of DFS is lower than that of BFS.
Time complexity of both is same – O(|V|+|E|).
The behavior differs for graphs where not all the
vertices can be reached from the given vertex s.
Predecessor subgraphs produced by DFS may be
different than those produced by BFS. The BFS
product is just one tree whereas the DFS product
may be multiple trees.

10/27/13

NITTTR CHD

17
BFS and DFS – possible applications




Possible to use in routing / exploration. E.g.,
 I want to explore all the nearest pizza places and want to go to
the nearest one with only two intersections.
 Find distance from my factory to every delivery center.
 Most of the mapping software (GOOGLE maps, YAHOO(?)
maps) should be using these algorithms.
Applications of DFS
 Topologically sorting a directed acyclic graph.




Finding the strongly connected components of a directed graph.


10/27/13

List the graph elements in such an order that all the nodes are listed
before nodes to which they have outgoing edges.
List all the sub graphs of a strongly connected graph which
themselves are strongly connected.

NITTTR CHD

18
References







Data structures with C++ using STL by Ford,
William; Topp, William; Prentice Hall.
Introduction to Algorithms by Cormen,
Thomas et. al., The MIT press.
http://en.wikipedia.org/wiki/Graph_theory
http://en.wikipedia.org/wiki/Depth_first_search

10/27/13

NITTTR CHD

19

More Related Content

What's hot (20)

PPTX
Dfs presentation
Alizay Khan
 
PPT
Max flow min cut
Mayank Garg
 
PPTX
DAA-Floyd Warshall Algorithm.pptx
ArbabMaalik
 
PPT
Bfs and dfs in data structure
Ankit Kumar Singh
 
PPTX
Depth First Search and Breadth First Search
Nisha Soms
 
PPT
Prim's Algorithm on minimum spanning tree
oneous
 
PPTX
Depth first search and breadth first searching
Kawsar Hamid Sumon
 
PPT
Graphs In Data Structure
Anuj Modi
 
PPTX
Searching Techniques and Analysis
AkashBorse2
 
PPTX
Disjoint sets union, find
subhashchandra197
 
PPTX
Presentation on Breadth First Search (BFS)
Shuvongkor Barman
 
PPT
Breadth first search
Sazzad Hossain
 
PPTX
Sum of subset problem.pptx
V.V.Vanniaperumal College for Women
 
PPT
Depth First Search ( DFS )
Sazzad Hossain
 
PPTX
Binary Tree in Data Structure
Meghaj Mallick
 
PPTX
DFS & BFS Graph
Mahfuzul Yamin
 
PPTX
Data Structures - Lecture 10 [Graphs]
Muhammad Hammad Waseem
 
PPT
Tree and Binary Search tree
Muhazzab Chouhadry
 
Dfs presentation
Alizay Khan
 
Max flow min cut
Mayank Garg
 
DAA-Floyd Warshall Algorithm.pptx
ArbabMaalik
 
Bfs and dfs in data structure
Ankit Kumar Singh
 
Depth First Search and Breadth First Search
Nisha Soms
 
Prim's Algorithm on minimum spanning tree
oneous
 
Depth first search and breadth first searching
Kawsar Hamid Sumon
 
Graphs In Data Structure
Anuj Modi
 
Searching Techniques and Analysis
AkashBorse2
 
Disjoint sets union, find
subhashchandra197
 
Presentation on Breadth First Search (BFS)
Shuvongkor Barman
 
Breadth first search
Sazzad Hossain
 
Sum of subset problem.pptx
V.V.Vanniaperumal College for Women
 
Depth First Search ( DFS )
Sazzad Hossain
 
Binary Tree in Data Structure
Meghaj Mallick
 
DFS & BFS Graph
Mahfuzul Yamin
 
Data Structures - Lecture 10 [Graphs]
Muhammad Hammad Waseem
 
Tree and Binary Search tree
Muhazzab Chouhadry
 

Viewers also liked (20)

PPT
Breadth first search
Vignesh Prasanna
 
PPTX
BFS
jyothimonc
 
PPT
2.5 bfs & dfs 02
Krish_ver2
 
PPTX
DFS BFS and UCS in R
Vichhaiy Serey
 
PPTX
Graph Traversal Algorithms - Depth First Search Traversal
Amrinder Arora
 
PPT
Heuristic Search
butest
 
PPT
chapter22.ppt
Tareq Hasan
 
PPT
Heuristic Search Techniques {Artificial Intelligence}
FellowBuddy.com
 
PPT
Ch2 3-informed (heuristic) search
chandsek666
 
PPT
artificial intelligence
vallibhargavi
 
PPT
5.5 back tracking
Krish_ver2
 
PPT
Normalization
murdhani heena
 
PPT
2.5 graph dfs
Krish_ver2
 
PPTX
Data structures and algorithms lab7
Bianca Teşilă
 
PPT
2.5 dfs & bfs
Krish_ver2
 
PPT
Algorithum Analysis
Ain-ul-Moiz Khawaja
 
PPT
Depth First Search, Breadth First Search and Best First Search
Adri Jovin
 
PPTX
Mca iii dfs u-4 tree and graph
Rai University
 
PDF
Distributed Graph Algorithms
Saurav Kumar
 
PPTX
Minimum spanning tree algorithms by ibrahim_alfayoumi
Ibrahim Alfayoumi
 
Breadth first search
Vignesh Prasanna
 
2.5 bfs & dfs 02
Krish_ver2
 
DFS BFS and UCS in R
Vichhaiy Serey
 
Graph Traversal Algorithms - Depth First Search Traversal
Amrinder Arora
 
Heuristic Search
butest
 
chapter22.ppt
Tareq Hasan
 
Heuristic Search Techniques {Artificial Intelligence}
FellowBuddy.com
 
Ch2 3-informed (heuristic) search
chandsek666
 
artificial intelligence
vallibhargavi
 
5.5 back tracking
Krish_ver2
 
Normalization
murdhani heena
 
2.5 graph dfs
Krish_ver2
 
Data structures and algorithms lab7
Bianca Teşilă
 
2.5 dfs & bfs
Krish_ver2
 
Algorithum Analysis
Ain-ul-Moiz Khawaja
 
Depth First Search, Breadth First Search and Best First Search
Adri Jovin
 
Mca iii dfs u-4 tree and graph
Rai University
 
Distributed Graph Algorithms
Saurav Kumar
 
Minimum spanning tree algorithms by ibrahim_alfayoumi
Ibrahim Alfayoumi
 
Ad

Similar to Graphs bfs dfs (20)

PDF
Analysis and design of algorithms part 3
Deepak John
 
PPT
Chapter 23 aoa
Hanif Durad
 
PDF
Bfs dfs
Praveen Yadav
 
PPTX
Breadth first search (Bfs)
Ishucs
 
PPT
B.tech admission in india
Edhole.com
 
PPT
19-graph1 (1).ppt
Himajanaidu2
 
PPT
Graphs Presentation of University by Coordinator
haseebanjum2611
 
PPTX
Graph Traversal Algorithm
jyothimonc
 
PPTX
Graph Representation, DFS and BFS Presentation.pptx
bashirabdullah789
 
PPTX
Graps 2
Saurabh Mishra
 
PPTX
Graphs
KomalPaliwal3
 
DOC
BFS, Breadth first search | Search Traversal Algorithm
MSA Technosoft
 
PPTX
Lecture 5 - Graph Algorithms BFS and DFS.pptx
mtahanasir65
 
PPTX
Data Structures and Agorithm: DS 21 Graph Theory.pptx
RashidFaridChishti
 
PPT
Graphs
Saurabh Mishra
 
PDF
LEC 12-DSALGO-GRAPHS(final12).pdf
MuhammadUmerIhtisham
 
PPT
Elementary Graph Algo.ppt
SazidHossain9
 
DOCX
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
whittemorelucilla
 
PDF
U1 L5 DAA.pdf
LakshyaBaliyan2
 
PDF
Talk on Graph Theory - I
Anirudh Raja
 
Analysis and design of algorithms part 3
Deepak John
 
Chapter 23 aoa
Hanif Durad
 
Bfs dfs
Praveen Yadav
 
Breadth first search (Bfs)
Ishucs
 
B.tech admission in india
Edhole.com
 
19-graph1 (1).ppt
Himajanaidu2
 
Graphs Presentation of University by Coordinator
haseebanjum2611
 
Graph Traversal Algorithm
jyothimonc
 
Graph Representation, DFS and BFS Presentation.pptx
bashirabdullah789
 
BFS, Breadth first search | Search Traversal Algorithm
MSA Technosoft
 
Lecture 5 - Graph Algorithms BFS and DFS.pptx
mtahanasir65
 
Data Structures and Agorithm: DS 21 Graph Theory.pptx
RashidFaridChishti
 
LEC 12-DSALGO-GRAPHS(final12).pdf
MuhammadUmerIhtisham
 
Elementary Graph Algo.ppt
SazidHossain9
 
graphin-c1.pnggraphin-c1.txt1 22 3 83 44 5.docx
whittemorelucilla
 
U1 L5 DAA.pdf
LakshyaBaliyan2
 
Talk on Graph Theory - I
Anirudh Raja
 
Ad

Recently uploaded (20)

PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 

Graphs bfs dfs

  • 1. Graphs Breadth First Search & Depth First Search Submitted By: Jailalita Gautam
  • 2. Contents       10/27/13 Overview of Graph terminology. Graph representation. Breadth first search. Depth first search. Applications of BFS and DFS. References. NITTTR CHD 2
  • 3. Graph terminology - overview  A graph consists of       set of vertices V = {v1, v2, ….. vn} set of edges that connect the vertices E ={e1, e2, …. em} Two vertices in a graph are adjacent if there is an edge connecting the vertices. Two vertices are on a path if there is a sequences of vertices beginning with the first one and ending with the second one Graphs with ordered edges are directed. For directed graphs, vertices have in and out degrees. Weighted Graphs have values associated with edges. 10/27/13 NITTTR CHD 3
  • 4. Graph representation    There are two standard ways to represent a graph G=(V,E) : as collection of adjacency list or as an adjacency matrix. Adjacency list preferred for sparse graphs- those for which |E| much less than |V|^2. Adjacency matrix preferred for dense graphs- |E| is close to |V|^2. 10/27/13 NITTTR CHD 4
  • 5. Graph representation – undirected graph 10/27/13 Adjacency list NITTTR CHD Adjacency matrix 5
  • 6. Graph representation – directed graph 10/27/13 Adjacency list NITTTR CHD Adjacency matrix 6
  • 7. Breadth first search  Given       a graph G=(V,E) – set of vertices and edges a distinguished source vertex s Breadth first search systematically explores the edges of G to discover every vertex that is reachable from s. It also produces a ‘breadth first tree’ with root s that contains all the vertices reachable from s. For any vertex v reachable from s, the path in the breadth first tree corresponds to the shortest path in graph G from s to v. It works on both directed and undirected graphs. However, we will explore only directed graphs. 10/27/13 NITTTR CHD 7
  • 8. Breadth first search - concepts     To keep track of progress, it colors each vertex - white, gray or black. All vertices start white. A vertex discovered first time during the search becomes nonwhite. All vertices adjacent to black ones are discovered. Whereas, gray ones may have some white adjacent vertices. 10/27/13 NITTTR CHD 8
  • 9. BFS – How it produces a Breadth first tree   The tree initially contains only root. – s Whenever a vertex v is discovered in scanning adjacency list of vertex u  10/27/13 Vertex v and edge (u,v) are added to the tree. NITTTR CHD 9
  • 10. BFS - algorithm BFS(G, s) // G is the graph and s is the starting node 1 for each vertex u ∈ V [G] - {s} 2 do color[u] ← WHITE // color of vertex u 3 d[u] ← ∞ // distance from source s to vertex u 4 π[u] ← NIL // predecessor of u 5 color[s] ← GRAY 6 d[s] ← 0 7 π[s] ← NIL 8 Q←Ø // Q is a FIFO - queue 9 ENQUEUE(Q, s) 10 while Q ≠ Ø // iterates as long as there are gray vertices. Lines 10-18 11 do u ← DEQUEUE(Q) 12 for each v ∈ Adj [u] 13 do if color[v] = WHITE // discover the undiscovered adjacent vertices 14 then color[v] ← GRAY // enqueued whenever painted gray 15 d[v] ← d[u] + 1 16 π[v] ← u 17 ENQUEUE(Q, v) 18 color[u] ← BLACK // painted black whenever dequeued 10/27/13 NITTTR CHD 10
  • 11. Breadth First Search - example 10/27/13 NITTTR CHD 11
  • 12. Breadth first search - analysis    Enqueue and Dequeue happen only once for each node. - O(V). Total time spent in scanning adjacency lists is O(E) . Initialization overhead O(V) Total runtime O(V+E) 10/27/13 NITTTR CHD 12
  • 13. Depth first search    It searches ‘deeper’ the graph when possible. Starts at the selected node and explores as far as possible along each branch before backtracking. Vertices go through white, gray and black stages of color.     White – initially Gray – when discovered first Black – when finished i.e. the adjacency list of the vertex is completely examined. Also records timestamps for each vertex   10/27/13 d[v] f[v] when the vertex is first discovered when the vertex is finished NITTTR CHD 13
  • 14. Depth first search - algorithm DFS(G) 1 for each vertex u ∈ V [G] 2 do color[u] ← WHITE 3 π[u] ← NIL 4 time ← 0 5 for each vertex u ∈ V [G] 6 do if color[u] = WHITE 7 then DFS-VISIT(u) // color all vertices white, set their parents NIL // zero out time // call only for unexplored vertices // this may result in multiple sources DFS-VISIT(u) 1 color[u] ← GRAY ▹White vertex u has just been discovered. 2 time ← time +1 3 d[u] time // record the discovery time 4 for each v ∈ Adj[u] ▹Explore edge(u, v). 5 do if color[v] = WHITE 6 then π[v] ← u // set the parent value 7 DFS-VISIT(v) // recursive call 8 color[u] BLACK ▹ Blacken u; it is finished. 9 f [u] ▹ time ← time +1 10/27/13 NITTTR CHD 14
  • 15. Depth first search – example 10/27/13 NITTTR CHD 15
  • 16. Depth first search - analysis Lines 1-3, initialization take time Θ(V).  Lines 5-7 take time Θ(V), excluding the time to call the DFS-VISIT.  DFS-VISIT is called only once for each node (since it’s called only for white nodes and the first step in it is to paint the node gray).  Loop on line 4-7 is executed |Adj(v)| times. Since ∑vєV |Adj(v)| = Ө (E), the total cost of executing lines 4-7 of DFS-VISIT is θ(E).  The total cost of DFS is θ(V+E) 10/27/13 NITTTR CHD 16
  • 17. BFS and DFS - comparison     Space complexity of DFS is lower than that of BFS. Time complexity of both is same – O(|V|+|E|). The behavior differs for graphs where not all the vertices can be reached from the given vertex s. Predecessor subgraphs produced by DFS may be different than those produced by BFS. The BFS product is just one tree whereas the DFS product may be multiple trees. 10/27/13 NITTTR CHD 17
  • 18. BFS and DFS – possible applications   Possible to use in routing / exploration. E.g.,  I want to explore all the nearest pizza places and want to go to the nearest one with only two intersections.  Find distance from my factory to every delivery center.  Most of the mapping software (GOOGLE maps, YAHOO(?) maps) should be using these algorithms. Applications of DFS  Topologically sorting a directed acyclic graph.   Finding the strongly connected components of a directed graph.  10/27/13 List the graph elements in such an order that all the nodes are listed before nodes to which they have outgoing edges. List all the sub graphs of a strongly connected graph which themselves are strongly connected. NITTTR CHD 18
  • 19. References     Data structures with C++ using STL by Ford, William; Topp, William; Prentice Hall. Introduction to Algorithms by Cormen, Thomas et. al., The MIT press. http://en.wikipedia.org/wiki/Graph_theory http://en.wikipedia.org/wiki/Depth_first_search 10/27/13 NITTTR CHD 19