2. BHAM RAHELA A (150063131003)
AGRAVAT DIVYA H (150063131001)
BODRA BHUMI A (150063131004)
CHODVADIYA JYOTSNA B (150063131005)
3. Traversing a Graph
Breadth First search(BFS)
Depth first search(DFS)
Topological sort
Connected component
4. A graph search (or traversal) technique visits every
node exactly one in a systematic fashion.
Two standard graph search techniques have been
widely used:
DFS
BFS
In the case of rooted binary trees, three recursive
traversal techniques are widely used:
InorderTraversal
PreorderTraversal
PostorderTraversal
5. Can be used to attempt to visit all nodes of a
graph in a systematic manner
The basic idea behind this algorithm is that it
traverses the graph using recursion
In DFS, go as far as possible along a single
path until reach a dead end (a vertex with no
edge out or no neighbor unexplored) then
backtrack
6. DFS-iterative (G, s): //where G is graph and s is source vertex.
let S be stack
S.push( s ) // inserting s in stack
mark s as visited.
while ( S is not empty): // pop a vertex from stack to visit next
v = S.top( )
S.pop( )
//push all the neighbours of v in stack that are not visited
for all neighbours w of v in Graph G:
If w is not visited :
S.push( w )
mark w as visited DFS-recursive(G, s):
mark s as visited
for all neighbours w of s in Graph G:
if w is not visited:
DFS-recursive(G, w)
7.
8. In BFS, one explore a graph level by level away (explore all
neighbors first and then move on)
The breath first forest is a collection of a tree in which
the traversal starting vertex serve as a root of first tree.
Rule 1 −Visit unvisited vertex. Mark it visited.
Display it. Insert it in a queue.
Rule 2 − If no vertex found, remove the first
vertex from queue.
Rule 3 − Repeat Rule 1 and Rule 2 until queue
is empty.
9. BFS (G, s)
//where G is graph and s is source node.
let Q be queue.
Q.enqueue( s )
//inserting s in queue until all its neighbor vertices are marked.
mark s as visited.
while ( Q is not empty)
// removing that vertex from queue, whose neighbor will be visited now.
v = Q.dequeue( )
//processing all the neighbors of v
for all neighbors w of v in Graph G
if w is not visited
Q.enqueue(w)
//stores w in Q to further visit its neighbor
mark w as visited.
12. Topological sorting of vertices of
a Directed Acyclic Graph is an
ordering of the vertices
v1,v2,...vn in such a way, that if
there is an edge directed
towards vertex vj from vertex vi,
then vi comes before vj
13. To understand the sorting with the help of
two algorithm
DFS based algorithm (using stack)
Source removal algorithm (removing source)
Use divide and conquer method
14. Find node with no incoming vertex and
remove it with its out going edges(if more
then such vertex then select randomly)
Note that vertex which is deleted
All the recorded vertexes gives
topologically sorted list
19. Biconnected graph: A graph with no
articulation point called biconnected. In
other words, a graph is biconnected if and
only if any vertex is deleted, the graph
remains connected.
20. Biconnected component:
A biconnected component of a graph is a
maximal biconnected subgraph- a
biconnected subgraph that is not properly
contained in a larger biconnected
subgraph.
A graph that is not biconnected can divide
into biconnected components, sets of
nodes mutually accessible via two distinct
paths.
21. Steps to find articulation points
The root of the DFS tree is an articulation
point.
A leaf node of DFS tree is not an articulation
point
If u is an internal node then it is not
articulation point if and only if from every
child w and u is possible to reach an ancestor
of u using only a pathmade up of descendant
of w and back edge