Lesson 7
Lesson 7
Lesson 7
PART I
The history of graph theory states it was introduced by the famous Swiss
mathematician named Leonhard Euler, to solve many mathematical problems by
constructing graphs based on given data or a set of points. The graphical
representation shows different types of data in the form of bar graphs, frequency tables, line
graphs, circle graphs, line plots, etc.
Where V represents the finite set vertices and E represents the finite set edges.
Therefore, we can say a graph includes non-empty set of vertices V and set of edges
E.
Vertices, V={a,b,c,d}
Edges, E={{a,b},{a,c},{b,c},{c,d}}
The graphs are basically of two types, directed and undirected. It is best understood by the
figure given below. The arrow in the figure indicates the direction.
Directed Graph
In graph theory, a directed graph is a graph made up of a set of vertices connected by edges,
in which the edges have a direction associated with them.
Undirected Graph
The undirected graph is defined as a graph where the set of nodes are connected together, in
which all the edges are bidirectional. Sometimes, this type of graph is known as the
undirected network.
● Multigraph: A graph with multiple edges between the same set of vertices. It has
loops formed.
● Connected graph: A graph where any two vertices are connected by a path.
● Disconnected graph: A graph where any two vertices or nodes are disconnected by a
path.
● Cycle Graph: A graph that completes a cycle.
● Complete Graph: When each pair of vertices are connected by an edge then such
graph is called a complete graph
● Planar graph: When no two edges of a graph intersect and are all the vertices and
edges are drawn in a single plane, then such a graph is called a planar graph
Graph Terminology
Adjacency: A vertex is said to be adjacent to another vertex if there is an edge connecting
them. Vertices 2 and 3 are not adjacent because there is no edge between them.
Path: A sequence of edges that allows you to go from vertex A to vertex B is called a path.
0-1, 1-2 and 0-2 are paths from vertex 0 to vertex 2.
Directed Graph: A graph in which an edge (u,v) doesn't necessarily mean that there is an
edge (v, u) as well. The edges in such a graph are represented by arrows to show the direction
of the edge.
Graph Representation
Graphs are commonly represented in two ways:
1. Adjacency Matrix
If the value of any element a[i][j] is 1, it represents that there is an edge connecting vertex i
and vertex j.
Edge lookup (checking if an edge exists between vertex A and vertex B) is extremely fast in
adjacency matrix representation but we have to reserve space for every possible link
between all vertices(V x V), so it requires more space.
2. Adjacency List
The index of the array represents a vertex and each element in its linked list represents the
other vertices that form an edge with the vertex.
The adjacency list for the graph we made in the first example is as follows:
PART II
Graph Operations
Graph Traversal
Isomorphism of Graphs
Graph Isomorphism is a phenomenon of existing the same graph in more than one forms.
Such graphs are called as Isomorphic graphs.
Connectivity
A graph is said to be connected if there is a path between every pair of vertex. From every
vertex to any other vertex, there should be some path to traverse. That is called the
connectivity of a graph. A graph with multiple disconnected vertices and edges is said to be
disconnected.
Example 1
In the following graph, it is possible to travel from one vertex to any other vertex. For
example, one can traverse from vertex 'a' to vertex 'e' using the path 'a-b-e'.
Example 2
In the following example, traversing from vertex 'a' to vertex 'f' is not possible because
there is no path between them directly or indirectly. Hence it is a disconnected graph.
Connectivity Types
Graph Connectivity can be classified broadly into two categories −
● Edge Connectivity
● Vertex Connectivity
Edge Connectivity
Let 'G' be a connected graph. The minimum number of edges whose removal makes 'G'
disconnected is called edge connectivity of G.
Notation − λ(G)
In other words, the number of edges in a smallest cut set of G is called the edge
connectivity of G.
Example
Take a look at the following graph. By removing two minimum edges, the connected graph
becomes disconnected. Hence, its edge connectivity (λ(G)) is 2.
Here are the four ways to disconnect the graph by removing two edges −
Vertex Connectivity
Let 'G' be a connected graph. The minimum number of vertices whose removal makes 'G'
either disconnected or reduces 'G' in to a trivial graph is called its vertex connectivity.
Notation − K(G)
Example
In the above graph, removing the vertices 'e' and 'i' makes the graph disconnected.
For graph G1, either {c} or {e} is a vertex cut. Hence, K(G1) = 1
In data structures,
● Shortest path problem is a problem of finding the shortest path(s) between vertices
of a given graph.
● Shortest path between two vertices is a path that has the least cost as compared to all
other existing paths.
Shortest path algorithms are a family of algorithms used for solving the shortest path
problem.
Applications-
Shortest path algorithms have a wide range of applications such as in-
● Google Maps
● Road Networks
● Logistics Research
● It is a shortest path problem where the shortest path between a given pair of
vertices is computed.
● A* Search Algorithm is a famous algorithm used for solving single-pair shortest
path problem.
Single-Source Shortest Path Problem-
● It is a shortest path problem where the shortest path from a given source vertex to
all other remaining vertices is computed.
● Dijkstra’s Algorithm and Bellman Ford Algorithm are the famous algorithms used
for solving single-source shortest path problem.
● It is a shortest path problem where the shortest path from all the vertices to a
single destination vertex is computed.
● By reversing the direction of each edge in the graph, this problem reduces to
single-source shortest path problem.
● Dijkstra’s Algorithm is a famous algorithm adapted for solving single-destination
shortest path problem.
● It is a shortest path problem where the shortest path between every pair of vertices
is computed.
● Floyd-Warshall Algorithm and Johnson’s Algorithm are the famous algorithms
used for solving All pairs shortest path problem.
REFERENCES:
https://byjus.com/maths/graph-theory/#:~:text=Graph%20Theory%2C%20in%20discrete%2
0mathematics%2C%20is%20the%20study,used%20to%20create%20a%20pairwise%20relatio
nship%20between%20objects.
https://www.programiz.com/dsa/graph#:~:text=Graph%20Terminology%201%20Adjacency
%3A%20A%20vertex%20is%20said,is%20an%20edge%20%28v%2C%20u%29%20as%20well.
%20
https://www.gatevidyalay.com/graph-isomorphism/
https://www.gatevidyalay.com/tag/null-graph-definition/
https://www.tutorialspoint.com/connectivity-of-graph
https://www.gatevidyalay.com/shortest-path-algorithms-shortest-path-problems/