You are on page 1of 4

Graph

Graph is a collection of nodes and edges in which nodes are connected with edges.
Generally, a graph G is represented as G = ( V , E ), where V is set of vertices and E is set
of edges.

Example: The following is a graph with 5 vertices and 6 edges. This graph G can be
defined as G = ( V , E )

Where V = {A,B,C,D,E} and E = {(A,B),(A,C)(A,D),(B,D),(C,D),(B,E),(E,D)}.

Graph data structure is represented using following representations...

 Adjacency Matrix
 Incidence Matrix
 Adjacency List

RUBEL HOSEN 1
Adjacency Matrix:

Incidence Matrix:

RUBEL HOSEN 2
Adjacency List

DFS (Depth First Search)

Applications of Depth First Search

 Detecting cycle in a graph


 Path Finding
 Topological Sorting
 Finding Strongly Connected Components of
a graph
 To test if a graph is Bipartite

Final Result:

RUBEL HOSEN 3
BFS (Breadth First Search)

Final Result:

Applications of Breadth First Traversal

 Shortest Path and Minimum Spanning Tree for unweighted graph


 Peer to Peer Networks
 Crawlers in Search Engines
 Social Networking Websites
 GPS Navigation systems
 Broadcasting in Network
 In Garbage Collection
 Cycle detection in undirected graph
 Finding all nodes within one connected component
 Path Finding
 To test if a graph is Bipartite

RUBEL HOSEN 4

You might also like