Graphs: Presented By, M.Sangeetha, Ap/Cse, Kongu Engineering College
Graphs: Presented By, M.Sangeetha, Ap/Cse, Kongu Engineering College
Graphs: Presented By, M.Sangeetha, Ap/Cse, Kongu Engineering College
Presented By,
M.Sangeetha,
AP/CSE,
Kongu Engineering College
A Graph is a data structure that consists of
the following two components:
1. A finite set of vertices also called as nodes.
2. A finite set of ordered pair of the form (u,
v) called as edge. ((u, v) indicates that there
is an edge from vertex u to vertex v)
The edges may contain weight/value/cost.
A graph G is represented as G = ( V , E ),
connected to a vertex
Outdegree - Total number of outgoing edges
connected to a vertex
Simple Graph
A graph is said to be simple if there are no
Path
A path is a sequence of alternate vertices
Self-loop
Edge (undirected or directed) is a self-loop if its two endpoints coincide
with each other.
• A directed graph is strongly connected if there
is a path from every node to every other node.
• A directed graph is weakly connected if,
treating all edges as being undirected, there is
a path from every node to every other node.
DAG: A directed graph that has no cyclic paths is called a DAG (a
Directed Acyclic Graph).
in a graph.
There are two graph traversal techniques and
stack is empty.
BFS (Breadth First Search)
Queue data structure with maximum size as
queue is empty.
Shortest Path Algorithm
Single source shortest path algorithm
(Dijkstra’s Algorithm)
Dijkstra’s Algorithm
Dijkstra’s Algorithm
Example 2
Spanning Trees
A spanning tree is a sub-graph of an
undirected and a connected graph, which
includes all the vertices of the graph having a
minimum possible number of edges(Forms
no cycle)