Graph Theory - Gate Vidyalay
Graph Theory - Gate Vidyalay
Formal De nition
Formally,
G = (V, E)
Here, V is the set of vertices and E is the set of edges connecting the vertices.
Example-
In this graph,
V={A,B,C,D,E}
E = { AB , AC , BD , CD , DE }
Types of Graphs-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 1/43
8/29/2020 Graph Theory | Gate Vidyalay
https://www.gatevidyalay.com/category/subjects/graph-theory/ 2/43
8/29/2020 Graph Theory | Gate Vidyalay
https://www.gatevidyalay.com/category/subjects/graph-theory/ 3/43
8/29/2020 Graph Theory | Gate Vidyalay
1. Null Graph
2. Trivial Graph
3. Non-directed Graph
4. Directed Graph
5. Connected Graph
6. Disconnected Graph
7. Regular Graph
8. Complete Graph
9. Cycle Graph
10. Cyclic Graph
11. Acyclic Graph
12. Finite Graph
13. Infinite Graph
14. Bipartite Graph
15. Planar Graph
16. Simple Graph
17. Multi Graph
18. Pseudo Graph
19. Euler Graph
20. Hamiltonian Graph
1. Null Graph-
Example-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 4/43
8/29/2020 Graph Theory | Gate Vidyalay
Here,
This graph consists only of the vertices and there are no edges in it.
Since the edge set is empty, therefore it is a null graph.
2. Trivial Graph-
Example-
Here,
This graph consists of only one vertex and there are no edges in it.
Since only one vertex is present, therefore it is a trivial graph.
3. Non-Directed Graph-
A graph in which all the edges are undirected is called as a non-directed graph.
In other words, edges of an undirected graph do not contain any direction.
Example-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 5/43
8/29/2020 Graph Theory | Gate Vidyalay
Here,
4. Directed Graph-
A graph in which all the edges are directed is called as a directed graph.
In other words, all the edges of a directed graph contain some direction.
Directed graphs are also called as digraphs.
Example-
Here,
5. Connected Graph-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 6/43
8/29/2020 Graph Theory | Gate Vidyalay
A graph in which we can visit from any one vertex to any other vertex is called as a connected graph.
In connected graph, at least one path exists between every pair of vertices.
Example-
Here,
In this graph, we can visit from any one vertex to any other vertex.
There exists at least one path between every pair of vertices.
Therefore, it is a connected graph.
6. Disconnected Graph-
A graph in which there does not exist any path between at least one pair of vertices is called as a
disconnected graph.
Example-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 7/43
8/29/2020 Graph Theory | Gate Vidyalay
Here,
7. Regular Graph-
A graph in which degree of all the vertices is same is called as a regular graph.
If all the vertices in a graph are of degree ‘k’, then it is called as a “k-regular graph“.
Examples-
In these graphs,
https://www.gatevidyalay.com/category/subjects/graph-theory/ 8/43
8/29/2020 Graph Theory | Gate Vidyalay
8. Complete Graph-
A graph in which exactly one edge is present between every pair of vertices is called as a complete graph.
A complete graph of ‘n’ vertices contains exactly nC2 edges.
A complete graph of ‘n’ vertices is represented as Kn.
Examples-
In these graphs,
Each vertex is connected with all the remaining vertices through exactly one edge.
Therefore, they are complete graphs.
9. Cycle Graph-
A simple graph of ‘n’ vertices (n>=3) and n edges forming a cycle of length ‘n’ is called as a cycle graph.
In a cycle graph, all the vertices are of degree 2.
Examples-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 9/43
8/29/2020 Graph Theory | Gate Vidyalay
In these graphs,
Example-
Here,
https://www.gatevidyalay.com/category/subjects/graph-theory/ 10/43
8/29/2020 Graph Theory | Gate Vidyalay
Example-
Here,
A graph consisting of finite number of vertices and edges is called as a finite graph.
Example-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 11/43
8/29/2020 Graph Theory | Gate Vidyalay
Here,
A graph consisting of infinite number of vertices and edges is called as an infinite graph.
Example-
Here,
None of the vertices belonging to the same set join each other.
Example-
A planar graph is a graph that we can draw in a plane such that no two edges of it cross each other.
Example-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 13/43
8/29/2020 Graph Theory | Gate Vidyalay
Here,
A graph having no self loops and no parallel edges in it is called as a simple graph.
Example-
Here,
https://www.gatevidyalay.com/category/subjects/graph-theory/ 14/43
8/29/2020 Graph Theory | Gate Vidyalay
A graph having no self loops but having parallel edge(s) in it is called as a multi graph.
Example-
Here,
This graph consists of three vertices and four edges out of which one edge is a parallel edge.
There are no self loops but a parallel edge is present.
Therefore, it is a multi graph.
A graph having no parallel edges but having self loop(s) in it is called as a pseudo graph.
Example-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 15/43
8/29/2020 Graph Theory | Gate Vidyalay
Here,
This graph consists of three vertices and four edges out of which one edge is a self loop.
There are no parallel edges but a self loop is present.
Therefore, it is a pseudo graph.
Euler Graph is a connected graph in which all the vertices are even degree.
Example-
Here,
If there exists a closed walk in the connected graph that visits every vertex of the graph exactly once
(except starting vertex) without repeating the edges, then such a graph is called as a Hamiltonian graph.
Example-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 16/43
8/29/2020 Graph Theory | Gate Vidyalay
Here,
This graph contains a closed walk ABCDEFG that visits all the vertices (except starting vertex) exactly
once.
All the vertices are visited without repeating the edges.
Therefore, it is a Hamiltonian Graph.
Important Points-
Edge set of a graph can be empty but vertex set of a graph can not be empty.
Every polygon is a 2-Regular Graph.
Every complete graph of ‘n’ vertices is a (n-1)-regular graph.
Every regular graph need not be a complete graph.
Remember-
Simple Graph No No
https://www.gatevidyalay.com/category/subjects/graph-theory/ 17/43
8/29/2020 Graph Theory | Gate Vidyalay
1. Electrical Engineering-
The concepts of graph theory are used extensively in designing circuit connections.
The types or organization of connections are named as topologies.
Some examples for topologies are star, bridge, series and parallel topologies.
2. Computer Science-
Kruskal’s Algorithm
Prim’s Algorithm
Dijkstra’s Algorithm
3. Computer Network-
The relationships among interconnected computers in the network follows the principles of graph theory.
4. Science-
5. Linguistics-
6. Other Applications-
Before you go through this article, make sure that you have gone through the previous article on various Types
of Graphs in Graph Theory.
We have discussed-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 19/43
8/29/2020 Graph Theory | Gate Vidyalay
https://www.gatevidyalay.com/category/subjects/graph-theory/ 20/43
8/29/2020 Graph Theory | Gate Vidyalay
Bipartite Graph-
Here,
https://www.gatevidyalay.com/category/subjects/graph-theory/ 21/43
8/29/2020 Graph Theory | Gate Vidyalay
A bipartite graph where every vertex of set X is joined to every vertex of set Y
OR
OR
Here,
https://www.gatevidyalay.com/category/subjects/graph-theory/ 22/43
8/29/2020 Graph Theory | Gate Vidyalay
Note
If graph is bipartite with no edges, then it is 1-colorable.
Example-
Any bipartite graph consisting of ‘n’ vertices can have at most (1/4) x n2 edges.
Maximum possible number of edges in a bipartite graph on ‘n’ vertices = (1/4) x n2.
Explanation
Suppose the bipartition of the graph is (V1, V2) where |V1| = k and |V2| = n-k.
The number of edges between V1 and V2 can be at most k(n-k) which is maximized at k = n/2.
https://www.gatevidyalay.com/category/subjects/graph-theory/ 24/43
8/29/2020 Graph Theory | Gate Vidyalay
Problem-01:
Solution-
Here,
Problem-02:
Solution-
We know, Maximum possible number of edges in a bipartite graph on ‘n’ vertices = (1/4) x n2.
= (1/4) x (12)2
= (1/4) x 12 x 12
= 36
https://www.gatevidyalay.com/category/subjects/graph-theory/ 26/43
8/29/2020 Graph Theory | Gate Vidyalay
Before you go through this article, make sure that you have gone through the previous article on various Types
of Graphs in Graph Theory.
We have discussed-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 27/43
8/29/2020 Graph Theory | Gate Vidyalay
https://www.gatevidyalay.com/category/subjects/graph-theory/ 28/43
8/29/2020 Graph Theory | Gate Vidyalay
Hamiltonian Graph-
If there exists a closed walk in the connected graph that visits every vertex of the graph exactly once
OR
Any connected graph that contains a Hamiltonian circuit is called as a Hamiltonian Graph.
https://www.gatevidyalay.com/category/subjects/graph-theory/ 29/43
8/29/2020 Graph Theory | Gate Vidyalay
Here,
Alternatively, there exists a Hamiltonian circuit ABCDEFA in the above graph, therefore it is a Hamiltonian graph.
Hamiltonian Path-
If there exists a walk in the connected graph that visits every vertex of the graph exactly once without
repeating the edges, then such a walk is called as a Hamiltonian path.
OR
If there exists a Path in the connected graph that contains all the vertices of the graph, then such a path is
called as a Hamiltonian path.
NOTE
In Hamiltonian path, all the edges may or may not be covered but edges must not repeat.
https://www.gatevidyalay.com/category/subjects/graph-theory/ 30/43
8/29/2020 Graph Theory | Gate Vidyalay
Hamiltonian Circuit-
If there exists a walk in the connected graph that visits every vertex of the graph exactly once (except
starting vertex) without repeating the edges and returns to the starting vertex, then such a walk is called as
a Hamiltonian circuit.
OR
If there exists a Cycle in the connected graph that contains all the vertices of the graph, then that cycle is
called as a Hamiltonian circuit.
OR
A Hamiltonian path which starts and ends at the same vertex is called as a Hamiltonian circuit.
OR
https://www.gatevidyalay.com/category/subjects/graph-theory/ 32/43
8/29/2020 Graph Theory | Gate Vidyalay
Important Notes-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 33/43
8/29/2020 Graph Theory | Gate Vidyalay
Any Hamiltonian circuit can be converted to a Hamiltonian path by removing one of its edges.
Every graph that contains a Hamiltonian circuit also contains a Hamiltonian path but vice versa is not true.
There may exist more than one Hamiltonian paths and Hamiltonian circuits in a graph.
Problems-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 34/43
8/29/2020 Graph Theory | Gate Vidyalay
Solutions-
A)
The graph neither contains a Hamiltonian path nor it contains a Hamiltonian circuit.
Since graph does not contain a Hamiltonian circuit, therefore It is not a Hamiltonian Graph.
B)
The graph neither contains a Hamiltonian path nor it contains a Hamiltonian circuit.
Since graph does not contain a Hamiltonian circuit, therefore It is not a Hamiltonian Graph.
C)
The graph contains both a Hamiltonian path (ABCDHGFE) and a Hamiltonian circuit (ABCDHGFEA).
D)
The graph contains both a Hamiltonian path (ABCDEFG) and a Hamiltonian circuit (ABCDEFGA).
E)
The graph neither contains a Hamiltonian path nor it contains a Hamiltonian circuit.
Since graph does not contain a Hamiltonian circuit, therefore It is not a Hamiltonian Graph.
F)
The graph contains both a Hamiltonian path (ABCDEFGHI) and a Hamiltonian circuit (ABCDEFGHIA)
https://www.gatevidyalay.com/category/subjects/graph-theory/ 35/43
8/29/2020 Graph Theory | Gate Vidyalay
In Graph Theory,
Sum of degree of all the vertices is twice the number of edges contained in it.
In any graph,
Problem-01:
https://www.gatevidyalay.com/category/subjects/graph-theory/ 36/43
8/29/2020 Graph Theory | Gate Vidyalay
A simple graph G has 24 edges and degree of each vertex is 4. Find the number of vertices.
Solution-
Given-
Number of edges = 24
Degree of each vertex = 4
n x 4 = 2 x 24
n=2x6
∴ n = 12
Problem-02:
A graph contains 21 edges, 3 vertices of degree 4 and all other vertices of degree 2. Find total number of
vertices.
Solution-
Given-
Number of edges = 21
Number of degree 4 vertices = 3
All other vertices are of degree 2
3 x 4 + (n-3) x 2 = 2 x 21
12 + 2n – 6 = 42
2n = 42 – 6
2n = 36
∴ n = 18
Problem-03:
A simple graph contains 35 edges, four vertices of degree 5, five vertices of degree 4 and four vertices of degree
3. Find the number of vertices with degree 2.
Solution-
Given-
Number of edges = 35
Number of degree 5 vertices = 4
Number of degree 4 vertices = 5
Number of degree 3 vertices = 4
4 x 5 + 5 x 4 + 4 x 3 + n x 2 = 2 x 35
https://www.gatevidyalay.com/category/subjects/graph-theory/ 38/43
8/29/2020 Graph Theory | Gate Vidyalay
20 + 20 + 12 + 2n = 70
52 + 2n = 70
2n = 70 – 52
2n = 18
∴n=9
Problem-04:
A graph has 24 edges and degree of each vertex is k, then which of the following is possible number of vertices?
1. 20
2. 15
3. 10
4. 8
Solution-
Given-
Number of edges = 24
Degree of each vertex = k
n x k = 2 x 24
k = 48 / n
Now,
So in the above equation, only those values of ‘n’ are permissible which gives the whole value of ‘k’.
https://www.gatevidyalay.com/category/subjects/graph-theory/ 40/43
8/29/2020 Graph Theory | Gate Vidyalay
“Starting from any of the four land areas A, B, C, D, is it possible to cross each of the seven bridges
exactly once and come back to the starting point without swimming across the river?”
In 1735,
https://www.gatevidyalay.com/category/subjects/graph-theory/ 41/43
8/29/2020 Graph Theory | Gate Vidyalay
In this graph,
Euler observed that when a vertex is visited during the process of tracing a graph,
Based on this observation, Euler discovered that it depends on the number of odd vertices present in the
network whether any network is traversable or not.
Euler found that only those networks are traversable that have either-
No odd vertices (then any vertex may be the beginning and the same vertex will also be the ending point)
Or exactly two odd vertices (then one odd vertex will be the starting point and other odd vertex will be the
ending point)
Now,
Since the Konigsberg network has four odd vertices, therefore the network is not traversable.
Thus, It was finally concluded that the desired walking tour of Konigsberg is not possible.
NOTE
If the citizens of Konigsberg decides to build an eighth bridge from A to C, then-
https://www.gatevidyalay.com/category/subjects/graph-theory/ 42/43
8/29/2020 Graph Theory | Gate Vidyalay
However, adding a ninth bridge will again make the walking tour once again impossible.
https://www.gatevidyalay.com/category/subjects/graph-theory/ 43/43