mahi-graphs-reva
mahi-graphs-reva
WHY GRAPHS,
INTRODUCTION
APPLICATIONS OF GRAPHS
TYPES OF GRAPHS,
REPESENTATIONS
TRAVERSALS
PROBLEM SOLVING
WHY GRAPHS?
• Graphs are used to represent many real-life entities.
• Consider a social network where people can follow other
people.
WHY GRAPHS?
• A graph can represent cities linked by roads.
GRAPHS
Google maps uses graphs for building transportation systems, where intersection of
two(or more) roads are considered to be a vertex and the road connecting two vertices
is considered to be an edge, thus their navigation system is based on the algorithm to
calculate the shortest path between two vertices.
In Facebook, users are considered to be the vertices and if they are friends then there
is an edge running between them. Facebook’s Friend suggestion algorithm uses graph
theory. Facebook is an example of undirected graph.
In World Wide Web, web pages are considered to be the vertices. There is an edge
from a page u to other page v if there is a link of page v on page u. This is an example
of Directed graph. It was the basic idea behind Google Page Ranking Algorithm.
In Operating System, we come across the Resource Allocation Graph where each
process and resources are considered to be vertices. Edges are drawn from resources
to the allocated process, or from requesting process to the requested resource. If this
leads to any formation of a cycle then a deadlock will occur.
TYPES OF GRAPHS
Simple Graph
Non Simple Graph
GRAPHS
ADJACENCY ADJACENCY
MATRIX LIST
ADJACENCY MATRIX
ADJACENCY MATRIX
REPRESENTATION OF DIRECTED GRAPH
ADJACENCY LIST
REPRESENTATION OF UNDIRECTED GRAPH
ADJACENCY MATRIX
REPRESENTATION OF UNDIRECTED GRAPH
ADJACENCY LIST
REPRESENTATION OF WEIGHTED GRAPH
ADJACENCY MATRIX
REPRESENTATION OF WEIGHTED GRAPH
ADJACENCY LIST
GRAPH TRAVERSALS
TRAVERSALS
Breadth-first search (BFS) is a graph search algorithm that begins at the root node
and explores all the neighbouring nodes.
Then for each of those nearest nodes, the algorithm explores their unexplored
neighbour nodes, and so on, until it finds the specified node.
The depth-first search algorithm progresses by expanding the starting node and then
going deeper until the goal node is found, or until a node that has no children is
encountered.
When a dead-end is reached, the algorithm backtracks, returning to the most recent
node that has not been completely explored.