Graph Theory Complete Notes
Graph Theory Complete Notes
Isomorphism - Isomorphic Graphs - Sub-graph - Euler graph - Hamiltonian Graph - Related Theorems.
A Graph is a non-linear data structure consisting of nodes and edges. The nodes are sometimes also referred to
as vertices and the edges are lines or arcs that connect any two nodes in the graph. More formally a Graph can
be defined as, A Graph consisting of a finite set of vertices(or nodes) and a set of edges that connect a pair of
nodes.
Definition − A graph (denoted as G=(V,E)G=(V,E)) consists of a non-empty set of vertices or nodes V and a set of edges E.
Degree of a Vertex − The degree of a vertex V of a graph G (denoted by deg (V)) is the number of edges incident with the
vertex V.
a 2 even
b 2 even
c 3 odd
d 1 odd
Even and Odd Vertex − If the degree of a vertex is even, the vertex is called an even vertex and if the degree of a vertex is odd,
the vertex is called an odd vertex.
Degree of a Graph − The degree of a graph is the largest vertex degree of that graph. For the above graph the degree of the
graph is 3.
Types of Graphs
1. Finite Graphs
A graph is said to be finite if it has a finite number of vertices and a finite number of edges.
2. Infinite Graph:
A graph is said to be infinite if it has an infinite number of vertices as well as an infinite number of edges.
3. Trivial Graph:
A graph is said to be trivial if a finite graph contains only one vertex and no edge.
4. Simple Graph:
A simple graph is a graph that does not contain more than one edge between the pair of vertices. A simple railway track connecting
conne
different cities is an example of a simple graph.
5. Multi Graph:
Any graph which contains some parallel edges but doesn’t contain any self
self-loop
loop is called a multigraph. For example a Road Map.
Parallel Edges: If two vertices are connected with more than one edge then such edges are called parallel edges that are many
routes but one destination.
Loop: An edge of a graph that starts from a vertex and ends at the same vertex is called a loop or a self-loop.
self
6. Null Graph:
A graph of order n and size zero is a graph wher
wheree there are only isolated vertices with no edges connecting any pair of vertices.
7. Complete Graph:
A simple graph with n vertices is called a complete graph if the degree of each vertex is n
n-1,
1, that is, one vertex is attached with n-1
n
edges or the rest of the vertices in the graph. A complete graph is also called Full Graph.
8. Pseudo Graph:
A graph G with a self-loop
loop and some multiple edges is called a pseudo graph.
9. Regular Graph:
A simple graph is said to be regular if all vertices of graph G are of equal degree. All complete graphs are regular but vice versa is
not possible.
13. Subgraph:
A graph G1 = (V1, E1) is called a subgraph of a graph G(V, E) if V1(G) is a subset of V(G) and E1(G) is a subset of E(G) such that
each edge of G1 has same end vertices as in G.
Adjacency Matrix
Adjacency List
Adjacency Matrix
An Adjacency Matrix A[V][V] is a 2D array of size V×VV×V where VV is the number of vertices in a undirected graph. If there is an
edge between VxVx to VyVy then the value of A[Vx][Vy]=1A[Vx][Vy]=1 and A[Vy][Vx]=1A[Vy][Vx]=1, otherwise the value will be zero.
And for a directed graph, if there is an edge between VxVx to VyVy, then the value of A[Vx][Vy]=1A[Vx][Vy]=1, otherwise the value will
be zero.
Adjacency Matrix of an Undirected Graph
Let us consider the following undirected graph and construct the adjacency matrix −
Adjacency matrix of the above undirected graph will be −
a b c d
a 0 1 1 0
b 1 0 1 0
c 1 1 0 1
d 0 0 1 0
a b c d
a 0 1 1 0
b 0 0 1 0
c 0 0 0 1
d 0 0 0 0
Adjacency List
In adjacency list, an array (A[V])(A[V]) of linked lists is used to represent the graph G with VV number of vertices. An
entry A[Vx]A[Vx] represents the linked list of vertices adjacent to the Vx−thVx−th vertex. The adjacency list of the undirected graph is as
shown in the figure below −
Subgraph:
A graph G1 = (V1, E1) is called a subgraph of a graph G(V, E) if V1(G) is a subset of V(G) and E1(G) is a subset of E(G) such that
each edge of G1 has same end vertices as in G.
Types of Subgraphs:
Vertex disjoint subgraph: Any two graph G1 = (V1, E1) and G2 = (V2, E2) are said to be vertex disjoint of a
graph G = (V, E) if V1(G1) intersection V2(G2) = null. In the figure, there is no common vertex between G1 and
G2.
Edge disjoint subgraph: A subgraph is said to be edge-disjoint if E1(G1) intersection E2(G2) = null. In the
figure, there is no common edge between G1 and G2.
Note: Edge disjoint subgraph may have vertices in common but a vertex disjoint graph cannot have a common
edge, so the vertex disjoint subgraph will always be an edge-disjoint subgraph.
Multigraph – A graph in which multiple edges may connect the same pair of vertices is called a multigraph.
Since there can be multiple edges between the same pair of vertices, the multiplicity of edge tells the number of
edges between two vertices.
The above graph is a multigraph since there are multiple edges between B and C. The multiplicity of the edge is
2.
In some graphs, unlike the one’s shown above, the edges are directed. This means that the relation between the
objects is one-way only and not two-way. The direction of the edges may be important in some
applications. Based on whether the edges are directed or not we can have directed graphs and undirected
graphs. This property can be extended to simple graphs and multigraphs to get simple directed or undirected
simple graphs and directed or undirected multigraphs.
2. Cycles – Cycles are simple graphs with vertices n>=3 and edges{1,2}{2,3}{3,4}……{n-1,n}&{n,1} . Cycle
with vertices is denoted as Cn . Total number of edges are n with n vertices in cycle graph.
3. Wheels – A wheel is just like a cycle, with one additional vertex which is connected to every other vertex.
Wheels of n vertices with 1 addition vertex are denoted by Wn. Total number of edges are 2*(n-1) with n vertices
in wheel graph.
4. Hypercube – The Hypercube or n-cube is a graph with 2n vertices each represented by a n-bit string. The
vertices which differ by at most 1-bit are connected by edges. A hypercube of 2 n vertices is denoted by Qn. Total
number of edges are n*2n-1 with 2n vertices in cube graph.
5. Bipartite Graphs – A simple graph G is said to be bipartite if its vertex set V can be divided into two disjoint
sets such that every edge in G has its initial vertex in the first set and the terminal vertex in the second set. Total
number of edges are (n*m) with (n+m) vertices in bipartite graph.
Regular Graph:
A graph is called regular graph if degree of each vertex is equal. A graph is called K regular if degree of each
vertex in the graph is K.
Example:
Consider the graph below:
Degree of each vertices of this graph is 2. So, the graph is 2 Regular.. Similarly, below graphs are 3 Regular and 4
Regular respectively.
2. For a K Regular graph, if K is odd, then the number of vertices of the graph must be even.
Proof:
Lets assume, number of vertices,
es, N is odd.
From Handshaking Theorem we know,
Sum of degree of all the vertices = 2 * Number of edges of the graph …….(1)
The R.H.S of the equation (1) is a even number.
For a K regular graph, each vertex is of degree K. Sum of degree of all the vertices = K * N, where K and N
both are odd.So their product (sum of degree of all the vertices) must be odd. This makes L.H.S of the
equation (1) is a odd number. So L.H.S not equals R.H.S. So our initial assumption that N is odd, was wrong.
So, number of vertices(N) must be even.
A graph can exist in different forms having the same number of vertices, edges, and also the same edge
connectivity. Such graphs are called isomorphic graphs.
Any two graphs will be known as isomorphism if they satisfy the following four conditions:
Important Points
o For any two graphs to be an isomorphism, the necessary conditions are the above
above-defined
defined four conditions.
o It is not necessary that the above
above-defined
defined conditions will be sufficient to show that the given graphs are
isomorphic.
o If two graphs satisfy the above-defined
defined four conditions, even then, it is not necessary that the graphs will
surely isomorphism.
o If the graph fails to satisfy any conditions, then we can say that the graphs are surely not an isomorphism.
o If the complement graphs of both the graphs are isomorphism, then these graphs will surely be an isomorphism.
o If the adjacent matrices of both the graphs are the same, then these graphs will be an isomorphism.
o If the corresponding graphs of two graphs are obtained with the help of deleting some vertices of one graph, and their
corresponding images in other images are isomorphism, only then these graphs will not be an isomorphism.
Example 1:
In this example, we have shown whether the following graphs are isomorphism.
Solution: For this, we will check all the four conditions of graph isomorphism, which are described as follows:
Condition 1:
Here,
There are an equal number of vertices in both graphs G1 and G2. So these graphs satisfy condition 1. Now we will check the
second condition.
Condition 2:
Here,
There does not have an equal number of edges in both graphs G1 and G2. So these graphs do not satisfy condition 2. Now we
cannot check all the remaining conditions.
Since, these graphs violate condition 2. So these graphs are not an isomorphism.
∴ Graph G1 and graph G2 are not isomorphism graphs.
v1’= f(v1)
v2’ = f(v5)
v3’= f(v3)
v4’ = f(v4)
v5’ = f(v2)
Similarly, it can be shown that the adjacency is preserved for all vertices.
Proving that the above graphs are isomorphic was easy since the graphs were small, but it is often difficult to
determine whether two simple graphs are isomorphic. This is because there are n! possible bijective functions
between the vertex sets of two simple graphs with n vertices. Testing the correspondence for each of the
functions is impractical
practical for large values of n.
Although sometimes it is not that hard to tell if two graphs are not isomorphic. In order, to prove that the given
graphs are not isomorphic, we could find out some property that is characteristic of one graph and not the
other.
ther. If they were isomorphic then the property would be preserved, but since it is not, the graphs are not
isomorphic.
Some graph-invariants include- the number of vertices, the number of edges, degrees of the vertices, and
length of cycle, etc.
Important Note : The complementary of a graph has the same vertices and has edges between any two
vertices if and only if there was no edge between them in the original graph. Consequently, a graph G is said to
be self-complementary
complementary if the graph and its co
complement are isomorphic.
Example 2:
In this example, we have shown whether the following graphs are isomorphism.
Solution: For this, we will check all the four conditions of graph isomorphism, which are described as follows:
Condition 1:
Here,
There are an equal number of vertices in all graphs G1, G2 and G3. So these graphs satisfy condition 1. Now we will check the
second condition.
Condition 2:
Here,
o There are an equal number of edges in both graphs G1 and G2. So these graphs satisfy condition 2.
o But there does not have an equal number of edges in the graphs (G1, G2) and G3. So the graphs (G1, G2) and G3 do not
satisfy condition 2.
Since, the graphs (G1, G2) and G3 violate condition 2. So we can say that these graphs are not an isomorphism.
Since the graphs, G1 and G2 satisfy condition 2. So we can say that these graphs may be an isomorphism.
Now we will check the third condition for graphs G1 and G2.
Condition 3:
o In the graph 1, the degree of sequence s is {2, 2, 3, 3}, i.e., G1 = {2, 2, 3, 3}.
o In the graph 2, the degree of sequence s is {2, 2, 3, 3}, i.e., G2 = {2, 2, 3, 3}.
Here
There are an equal number of degree sequences in both graphs G1 and G2. So these graphs satisfy condition 3. Now we will
check the fourth condition.
Condition 4:
Graph G1 forms a cycle of length 3 with the help of vertices {2, 3, 3}.
Graph G2 also forms a cycle of length 3 with the help of vertices {2, 3, 3}.
Here,
It shows that both the graphs contain the same cycle because both graphs G1 and G2 are forming a cycle of length 3 with the
help of vertices {2, 3, 3}. So these graphs satisfy condition 4.
Thus,
o The graphs G1 and G2 satisfy all the above four necessary conditions
conditions.
o So G1 and G2 may be an isomorphism.
Now we will check sufficient conditions to show that the graphs G1 and G2 are an isomorphism.
As we have learned that if the complement graphs of both the graphs are isomorphism, the two graphs will surely be an
isomorphism.
So we will draw the complement graphs of G1 and G2, which are described as follows:
In the above complement graphs of G1 and G2, we can see that both the graphs are isomorphism.
Example 3:
In this example, we have shown whether the following graphs are isomorphism.
Solution: For this, we will check all the four conditions of graph isomorphism, which are described as follows:
Condition 1:
Here,
There are an equal number of vertices in both graphs G1 and G2. So these graphs satisfy condition 1. Now we will check the
second condition.
Condition 2:
Here,
There are an equal number of edges in both graphs G1 and G2. So these graphs satisfy condition 2. Now we will check the third
condition.
Condition 3:
o In the graph 1, the degree of sequence s is {2, 2, 2, 2, 3, 3, 3, 3}, i.e., G1 = {2, 2, 2, 2, 3, 3, 3, 3}.
o In the graph 2, the degree of sequence s is {2, 2, 2, 2, 3, 3, 3, 3}, i.e., G2 = {2, 2, 2, 2, 3, 3, 3, 3}.
Here
There are an equal number of degree sequences in both graphs G1 and G2. So these graphs satisfy condition 3. Now we will
check the fourth condition.
Condition 4:
Here,
Both the graphs G1 and G2 do not form the same cycle with the same length. So these graphs violate condition 4.
Since, Graphs G1 and G2 violate condition 4. So because of the violation of condition 4, these graphs will not be an isomorphism.
Euler Graph
If all the vertices of any connected graph have an even degree, then this type of graph will be known as the Euler graph. In other
words, we can say that an Euler graph is a type of connected graph which have the Euler circuit. The simple example of Euler
graph is described as follows:
The above graph is a connected graph, and the vertices of this graph contain the even degree. Hence we can say that this graph
grap
is an Euler graph.In other words, we can say that this graph is an Euler graph because it has the Euler circuit as BACEDCB. Play
Videox
Euler Path
We can also call the Euler path as Euler walk or Euler Trail. The definition of Euler trail and Euler walk is described as follows:
o If there is a connected graph with a trail that has all the edges of the graph, then that type of trail will be known as the
Euler trail.
o If there is a connected graph, which has a walk that passes through each and every edge of the graph only once,
onc then
that type of walk will be known as the Euler walk.
Note: If more than two vertices of the graph contain the odd degree, then that type of graph will be known as the Euler Path.
There are a lot of examples of the Euler path, and some of them are described as follows:
Example 1: In the following image, we have a graph with 4 nodes. Now we have to determine whether this graph contains an
Euler path.
Solution:
The above graph will contain the Euler path if each edge of this gr
graph
aph must be visited exactly once, and the vertex of this can be
repeated. So if we begin our path from vertex B and then go to vertices C, D, B, A, and D, then in this process, each and every
eve
edge is visited exactly once, and it also contains repeated vert
vertex.
ex. So the above graph contains an Euler path, which is described
as follows:
Example 2: In the following image, we have a graph with 6 nodes. Now we have to determine whether this graph contains an
Euler path.
Solution:
The above graph will contain the Euler path if each edge of this graph must be visited exactly once, and the vertex of this can be
repeated. So if we begin our path from vertex B and then go to vertices C, D, F, B, E, D, A, and B, then in this process, each
eac and
everyy edge is visited exactly once, and it also contains repeated vertex. So the above graph contains an Euler path, which is
described as follows: Euler path = BCDFBEDAB
Example 3: In the following image, we have a graph with 5 nodes. Now we have to determine whether this graph contains an
Euler path.
Solution:
The above graph will contain the Euler path if each edge of this graph must be visited exactly once, and the vertex of this can
c be
repeated. So if we begin our path from A, then we can only go to vert
vertex
ex A, C, D or B, C, E. That means this graph cannot visit all
the edges only once. So the above graph does not contain an Euler path.
Euler Circuit:
We can also call the Euler circuit as Euler Tour and Euler Cycle. There are various definitions of the Euler
Eule circuit, which are
described as follows:
o If there is a connected graph with a circuit that has all the edges of the graph, then that type of circuit will be known as
the Euler circuit.
o If there is a connected graph, which has a walk that passes through e
each
ach and every edge of the graph only once, then
that type of walk will be known as the Euler circuit. In this walk, the starting vertex and ending vertex must be the same,
and this walk can contain the repeated vertex, but it is not compulsory.
o If an Euler trail contains the same vertex at the start and end of the trail, then that type of trail will be known as the Euler
Circuit.
o A closed Euler trail will be known as the Euler Circuit.
Note: If all the vertices of the graph contain the even degree, then that type of graph will be known as the Euler circuit.
There are a lot of examples of the Euler circuit, and some of them are described as follows:
Example 1: In the following image, we have a graph with 4 nodes. Now we have to de
determine
termine whether this graph contains an
Euler circuit.
Solution:
The above graph will contain the Euler circuit if the starting vertex and end vertex are the same, and this graph visits each and
every edge only once. The Euler circuit can contain the repeated vertex. If we begin our path from vertex A and then go to
vertices B, C, D, and A, then in this process, the condition of same starting and end vertex is satisfied, but another condition
condit of
covering all edges is not satisfied because there is one edge from vertex D to B, which is not covered. If we try to cover this edge,
then the edges will be repeated. So the above graph does not contain an Euler circuit.
Example 2: In the following image, we have a graph with 6 nodes. Now we have to determine wh
whether
ether this graph contains an
Euler circuit.
Solution:
The above graph will contain the Euler circuit if the starting vertex and end vertex are the same, and this graph visits each and
every edge only once. The Euler circuit can contain the repeated verte vertex.
x. So if we begin our path from vertex A and then go to
vertices B, C, D, F, B, E, D and then A, in this process, the starting and end vertex are the same. The path (A, B, C, D, F, B, E, D, and
A) also covers all the edges only once, and it does not contai
containn any repeated vertex except the starting one. So the above graph
contains an Euler circuit, which is described as follows:
Euler circuit = ABCDFBEDA
Example 3: In the following image, we have a graph with 5 nodes. Now we have to determine whether this graph
gr contains an
Euler circuit.
Solution:
The above graph will contain the Euler circuit if the starting vertex and end vertex are the same, and this graph visits each and
every edge only once. The Euler circuit can contain the repeated vertex. If we begi begin n our path from vertex A and then go to
vertices C, D or C, E, then in this process, the condition of same start and end vertex is not satisfied, but another condition
conditi of
covering all edges is not satisfied. This is because if we follow the path (A, C, D o orr A, C, E), many edges are repeated in this
process, which violates the Euler circuit. So if we try to cover all the edges and vertices, the edges will be repeated. So the
t above
graph does not contain an Euler circuit.
If there is a connected graph that does not have an Euler circuit, but it has an Euler trail, then that type of graph will be known as
the semi-Euler
Euler graph. Any graph will be known as semi Euler graph if it satisfies two conditions, which are described as follows:
o For this,
his, the graph must be connected
o This graph must contain an Euler trail
In this example, we have a graph with 4 nodes. Now we have to determine whether this graph is a semi-Euler
semi graph.
Solution
Here,
o There is an Euler trail in this graph, i.e., BCDBAD.
o But there is no Euler circuit.
o Hence, this graph is a semi-Euler graph.
Important Notes:
When we learn the concept of Euler graph, then there are some points that we should keep in our minds, which are described as
follows:
Note 1:
We have two ways through which we can check whether any graph is Euler or not. We can use any of the ways to do this, which
are described as follows:
o If there is a connected graph with an Euler circuit, then that type of graph will be an Euler graph.
o If there is an even degree for all the vertices of the graph, then that type of graph will be an Euler graph.
Note 2:
We can use the following way through which we can check whether any graph has an Euler circuit:
o We will check whether all the vertices of a graph have an even degree.
o If it contains an even degree, then that type of graph will be an Euler circuit. Otherwise, it will not be an Euler circuit.
Note 3:
We can use the following way through which we can check whether any graph is a Semi Euler graph:
o We will check whether there is a connected graph that has an Euler circuit.
o If it is a connected graph and it has an Euler circuit, then that type of graph will be a Semi Euler Graph. Otherwise, it will
not be a Semi Euler graph.
Note 4:
We can use the following way through which we can check whether any graph has an Euler trail:
o We will check whether more than two vertices of the graph contain the odd degree.
o If more than two vertices contain an odd degree, then that type of graph will be an Euler Trail. Otherwise, it will not be
an Euler trail.
Note 5:
o If there is a connected graph, which contains an Euler circuit, then that graph will also contain an Euler trail.
o If there is a connected graph, which contains an Euler trail, then that graph may or may not have an Euler circuit.
Note 6:
o If there is an Euler graph, then that graph will surely be a Semi Euler graph.
o But it is compulsory that a semi-Euler
Euler graph is also an Euler graph.
There are a lot of examples of the Euler graphs, and some of them are described as follows:
Example 1: In the following graph, we have 6 nodes. Now we have to determine whether this graph is an Euler graph.
Solution:
If the above graph contains the Euler circuit, then it will be an Euler Graph. A graph will contain an Euler circuit if the starting
vertex and end vertex are the same, and this graph visits each and every edge only once. So when we begin our path from vertexverte
A and then go to vertices E, D, F, B, C, D and then A in this process, the starting and end vertex are the same. This path covers all
the edges only once and contains the repeated vertex. So this graph contains the Euler circuit. Hence, it is an Euler Graph.
Solution:
If the above graph contains the Euler circuit, then it will be an Euler Graph. A graph will contain an Euler circuit if the starting
s
vertex and end vertex are the same, and this graph visits each and every edge only once. So If we begin our path from vertex A
and then go to vertices B, D or A, B, E, then in this process, the condition of same starting and end vertex is satisfied, but
bu another
condition of covered all edges only once is not satisfied. So when we follow the path (A, B, D or A, B, E), many edges are
repeated in this process, which violates the definition of Euler circuit. So the above graph does not contain an Euler circuit. circui
Hence, it is not an Euler Graph.
Example 3: In the following graph,, we have 8 nodes. Now we have to determine whether this graph is an Euler graph.
Solution:
If the above graph contains the Euler circuit, then it will be an Euler Graph. A graph will contain an Euler circuit if the starting
s
vertex and end vertex are the same, and this graph visits each and every edge only once. So if we begin our path from vertex A
and then go to vertices D, H, E, F, G, C, B and then A, then in this process, the condition of same starting and end vertex is i
satisfied, but another condition
n of covered all edges only once is not satisfied. So when we follow the path (A, D, H, E, F, G, C, B,
A), in this process, many edges are not covered, i.e., A to E, G to H, F to B, and D to C, which violates the definition of Euler
E circuit.
So the above graph
raph does not contain an Euler circuit. Hence, it is not an Euler Graph.
Example 4: In the following graph, we have 7 nodes. Now we have to determine whether this graph is an Euler graph.
Solution:
If the above graph contains the Euler circuit, then it will be an Euler Graph. So if we begin our path from vertex A and then go to
vertices F, E, G, C, D, B and then A, then in this process, the condition of same starting and end vertex is satisfied, but another
a
condition of covered all edges only once is not satisfied. This is because the Euler circuit cannot repeat the edges. So when we
follow the path (A, F, E, G, C, D, B, A), in this process, many edges are not covered, i.e., F to G, A to E, e to D, and B to C, which
violates the definition of Euler circuit.
t. So the above graph does not contain an Euler circuit. Hence, it is not an Euler Graph.
Example 5: In the following graph, we have 5 nodes. Now we have to determine whether this graph is an Euler graph.
Solution:
If the above graph contains the Euler circuit, then it will be an Euler Graph. So when we begin our path from vertex A and then
go to vertices B, C, D, B, E and then A, in this process, the starting and end vertex are the same. This path covers all the edges
only once, and it contains the repeated
ated vertex. So this graph contains the Euler circuit. Hence, it is an Euler Graph.
Example 6: In the following graph, we have 9 nodes. Now we have to determine whether this graph is an Euler graph.
Solution:
If the above graph contains the Euler circuit, it, then it will be an Euler Graph. So if we begin our path from vertex A and then go to
vertices B, C, D, E, F, G, H, I and then A, then the condition of same starting and end vertex is satisfied in this process, but another
condition of covered all edges only once is not satisfied. So when we follow the path (A, B, C, D, E, F, G, H, I, A), in this process,
one edge is not covered, i.e., A to F, which violates the definition of Euler circuit. So the above graph does not contain an Euler
circuit. Hence, it is not an Euler Graph
Hamiltonian Graph
The graph will be known as a Hamiltonian graph if there is a closed walk in a connected graph, which passes each and every
vertex of the graph exactly once except the root vertex or starting vertex. The Hamiltonian walk must not repeat any edge. One
more definition of a Hamiltonian graph says a graph will be known as a Hamiltonian graph if there is a connected graph, which
contains a Hamiltonian circuit. The vertex of a graph is a set of points, which are interconnec
interconnected
ted with the set of lines, and these
lines are known as edges. The example of a Hamiltonian graph is described as follows:
Hamiltonian Path
In a connected graph, if there is a walk that passes each and every vertex of a graph only once, this walk will be known as the
Hamiltonian path. In this walk, the edges should not be repeated. There is one more definition to describe the Hamiltonian path:
if a connected graph contains a Path with all the vertices of the graph, this type of path will be known as the Hamiltonian path.
There are a lot of examples of the Hamiltonian path, which are described as follows:
Play VideoExample 1: I
Solution:
In the above graph, we can see that when we start from A, then we can go to B, C, D, and then E. So this is the path that contains
all the vertices (A, B, C, D, and E) only once, and there is no repeating edge. That's why we can say that this graph has a
Hamiltonian path, which is described as follows:
Example 2: In the following graph, we have 5 nodes. Now we have to determine whether this graph contains a Hamiltonian
path.
Solution:
In the above graph, we can see that when we start from the E, then we can go to A, B, C, and then D. So this is the path that
contains all the vertices (A, B, C, D, and E) only once, and there is no repeating edge. That's why we can say that this graph has a
Hamiltonian path, which is described as follows:
Solution:
In the above graph, we can see that there is no path that covers all the vertices (A, B, C, D, and E) only once. If we start from F,
then we will go to A, B, C. After C, we can either go to D or F, but we cannot go to both the vertices. That's why we can say that
this graph does not contain a Hamiltonian path.
Hamiltonian Circuit
In a connected graph, if there is a walk that passes each and every vertex of the graph only once and after completing the walk,
return to the starting vertex, then this type of walk will be known as a Hamiltonian circuit. For the Hamiltonian circuit, there must
be no repeated edges. We can also be called Hamiltonian circuit as the Hamiltonian cycle.
o If there is a Hamiltonian path that begins and ends at the same vertex, then this type of cycle will be known as a
Hamiltonian circuit.
o In the connected graph, if there is a cycle with all the vertices of the graph, this type of cycle will be known as a
Hamiltonian circuit.
o A closed Hamiltonian path will also be known as a Hamiltonian circuit.
There are a lot of examples of the Hamiltonian circuit, which are described as follows:
Example 1: In the following graph, we have 5 nodes. Now we have to determine whether this graph contains a Hamiltonian
circuit.
Solution: =
The above graph contains the Hamiltonian circuit if there is a path that starts and ends at the same vertex. So when we start
from the A, then we can go to B, C, E, D, and then A. So this is the path that contains all the vertices (A, B, C, D, and E) only once,
except the starting vertex, and there is no repeating edge. That's why we can say that this graph has a Hamiltonian circuit, which
is described as follows:
Example 2: In the following graph, we have 5 nodes. Now we have to determine whether this graph contains a Hamiltonian
circuit.
Solution:
The above graph contains the Hamiltonian circuit if there is a path that starts and ends at the same vertex. So we will start from
the E, then we can go A, B, C, D. To react to the same vertex E, we can have to again go to vertex A. So this is the path that
contains all the vertices (A, B, C, D, and E), but vertex A is repeated to reach the initial vertex. That's why we can say that this
graph does not contain a Hamiltonian circuit.
Example 3: In the following graph, we have 6 nodes. Now we have to determine whether this graph contains a Hamiltonian
circuit.
Solution:
The above graph contains the Hamiltonian circuit if there is a path that starts and ends at the same vertex. So we will start from
the F, then we can go A, B, C, E. This path does not cover all the vertices (A, B, C, D, E, and F). That's why we can say that this
graph does not contain a Hamiltonian circuit.
Important Points
o If we remove one of the edges of Hamiltonian path, then it will be converted into any Hamiltonian circuit.
o If any graph has a Hamiltonian circuit, then it will also have the Hamiltonian path. But the vice versa in this case will not
be possible.
o A graph can contain more than one Hamiltonian path and Hamiltonian circuit.
There are a lot of examples of the Hamiltonian graphs, which are described as follows:
Example 1: In the following graph, we have 6 nodes. Now we have to determine whether this graph is a Hamiltonian graph.
Solution:
This graph does not contain a Hamiltonian path because when we start from A, then we can go to vertices B, C, D, and E, but in
this path, vertex F is not covered. This graph does not contain the Hamiltonian circuit also because when we start from A, we can
go to vertices B, C, D, E, and A. This can make a circuit, but vertex F is also not covered in this path. So we can say that this graph
does not contain a Hamiltonian path and Hamiltonian circuit. Hence, this graph is not a Hamiltonian Graph.
Example 2: In the following graph, we have 5 nodes. Now we have to determine whether this graph is a Hamiltonian graph.
Solution:
This graph does not contain a Hamiltonian path because when we start from A and B, then we can go to one of the three places
C, D, and E. So this path does not cover all the vertices. This graph does not contain the Hamiltonian circuit also because any
path cannot cover all the vertices and make a circuit. So we can say that this graph is not a Hamiltonian path and a Hamiltonian
circuit. Hence, this graph is not a Hamiltonian Graph.
Example 3: In the following graph, we have 7 nodes. Now we have to determine whether this graph is a Hamiltonian graph.
Solution:
This graph contains a Hamiltonian path because when we start from A, then we can go to vertices B, C, D, E, F, and G. This graph
also contains the Hamiltonian circuit because when we start from A, then we can go to vertices B, C, D, E, F, G, and A. So we can
say that this graph contains a Hamiltonian path and Hamiltonian circuit. The Hamiltonian path and Hamiltonian circuit are
described as follows:
Example 4: In the following graph, we have 9 nodes. Now we have to determine whether this graph is a Hamiltonian graph.
Solution:
This graph contains a Hamiltonian path because when we start from A, then we can go to vertices B, C, D, E, F, G, H, and I. This
graph also contains the Hamiltonian circuit because when we start from A, then we can go to vertices B, C, D, E, F, G, H, I, and A.
So we can say that this graph contains a Hamiltonian path and Hamiltonian circuit. The Hamiltonian path and Hamiltonian circuit
are described as follows:
Example 5: In the following graph, we have 5 nodes. Now we have to determine whether this graph is a Hamiltonian graph.
Solution:
This graph does not contain a Hamiltonian path because when we start from A, then we can go to vertices B, C, and D, but in this
path, vertex E is not covered. Because of the same reason, this graph also does not contain the Hamiltonian circuit. So we can say
that this graph is not a Hamiltonian path and a Hamiltonian circuit. Hence, this graph is not a Hamiltonian Graph.
Example 6: In the following graph, we have 5 nodes. Now we have to determine whether this graph is a Hamiltonian graph.
Solution:
This graph contains a Hamiltonian path because when we start from A, then we can go to vertices B, C, D, and E. This graph also
contains the Hamiltonian circuit because when we start from A, then we can go to vertices B, C, D, E, and A. So we can say that
this graph contains a Hamiltonian path and Hamiltonian circuit. The Hamiltonian path and Hamiltonian circuit are described as
follows:
Tree
o In graph theory, a tree is an undirected, connected and acyclic graph. In other words, a connected
graph that does not contain even a single cycle is called a tree.
o A tree represents hierarchical structure in a graphical form.
o The elements of trees are called their nodes and the edges of the tree are called branches.
o A tree with n vertices has (n-1) edges.
o Trees provide many useful applications as simple as a family tree to as complex as trees in data
structures of computer science.
o A leaf in a tree is a vertex of degree 1 or any vertex having no children is called a leaf.
Example
In the above example, all are trees with fewer than 6 vertices.
Properties of Trees
1. Every tree which has at least two vertices should have at least two leaves.
2. Trees have many characterizations:
Let T be a graph with n vertices, then the following statements are equivalent:
o T is a tree.
o T contains no cycles and has n-1 edges.
o T is connected and has (n -1) edge.
o T is connected graph, and every edge is a cut-edge.
o Any two vertices of graph T are connected by exactly one path.
o T contains no cycles, and for any new edge e, the graph T+ e has exactly one cycle.
3. Every edge of a tree is cut -edge.
4. Adding one edge to a tree defines exactly one cycle.
For instance, some of the paths between vertices v1 and v2 in Fig are (a,e), (a, c, f), (b, c, e), (b, f), (b, g, h),
and (b, g, i, k). There are two shortest paths,(a, e) and (b, f), each of length two. Hence d(v1, v2) = 2.In a tree,
since there is exactly one path between any two vertices the determination of distance is much easier
A Metric: Before we can legitimately call a function f(x, y) of two variables a“distance” between them, this
function must satisfy certain requirements. These are
A function that satisfies these three conditions is called a metric. That the distance d(vi, vj) between two
vertices of a connected graph satisfies conditions 1 and 2 is immediately evident. Since d(vi, vj) is the length of
the shortest path between vertices vi and vj, this path cannot be longer than another path between vi and vj,
which goes through a specified vertex vk. Hence d(vi, vj) ≤ d(vi, vk) +d(vk, vj).
center
A vertex with minimum eccentricity in graph G is called a center of G. The eccentricities of the four vertices in
Fig. 3-7 are E(a) = 2, E(b) = 1, E(c) = 2, and E(d) = 2. Hence vertex b is the center of that tree.
On the other hand, consider the tree in the following FigThe eccentricity of each of its six vertices is shown
next to the vertex. This tree has two vertices having the same minimum eccentricity.
Pendent Vertex
By using degree of a vertex, we have a two special types of vertices. A vertex with degree one is called a
pendent vertex.
Example
Here, in this example, vertex 'a' and vertex 'b' have a connected edge 'ab'. So with respect to the vertex 'a',
there is only one edge towards vertex 'b' and similarly with respect to the vertex 'b', there is only one edge
towards vertex 'a'. Finally, vertex 'a' and vertex 'b' has degree as one which are also called as the pendent
vertex.
Isolated Vertex
Spanning tree
In this article, we will discuss the spanning tree and the minimum spanning tree. But before moving
directly towards the spanning tree, let's first see a brief description of the graph and its types.
Graph
A graph can be defined as a group of vertices and edges to connect these vertices. The types of
graphs are given as follows -
o Undirected graph: An undirected graph is a graph in which all the edges do not point to any particular
direction, i.e., they are not unidirectional; they are bidirectional. It can also be defined as a graph with a
set of V vertices and a set of E edges, each edge connecting two different vertices.
o Connected graph: A connected graph is a graph in which a path always exists from a vertex to any
other vertex. A graph is connected if we can reach any vertex from any other vertex by following edges
in either direction.
o Directed graph: Directed graphs are also known as digraphs. A graph is a directed graph (or digraph) if
all the edges present between any vertices or nodes of the graph are directed or have a defined
direction.
spanning tree
A spanning tree consists of (n-1) edges, where 'n' is the number of vertices (or nodes).
Edges of the spanning tree may or may not have weights assigned to them.
All the possible spanning trees created from the given graph G would have the same number of
vertices, but the number of edges in the spanning tree would be equal to the number of vertices in the
given graph minus 1.
A complete undirected graph can have nn-2 number of spanning trees where n is the number of vertices in the
graph. Suppose, if n = 5, the number of maximum possible spanning trees would be 55-2 = 125.
Basically, a spanning tree is used to find a minimum path to connect all nodes of the graph. Some of the
common applications of the spanning tree are listed as follows -
o Cluster Analysis
o Civil network planning
o Computer network routing protocol
Now, let's understand the spanning tree with the help of an example.
As discussed above, a spanning tree contains the same number of ver vertices
tices as the graph, the number of
vertices in the above graph is 5; therefore, the spanning tree will contain 5 vertices. The edges in the spanning
tree will be equal to the number of vertices in the graph minus 1. So, there will be 4 edges in the spanning tree.
Some of the possible spanning trees that will be created from the above graph are given as follows -
Properties of spanning-tree
So, a spanning tree is a subset of connected graph G, and there is no spanning tree of a disconnected graph.
A minimum spanning tree can n be defined as the spanning tree in which the sum of the weights of the edge is
minimum. The weight of the spanning tree is the sum of the weights given to the edges of the spanning tree. In
the real world, this weight can be considered as the distance, ttraffic
raffic load, congestion, or any random value.
Let's understand the minimum spanning tree with the help of an example.
The sum of the edges of the above graph is 16. Now, some of the possible spanning trees created from the
th
above graph are -
So, the minimum spanning tree that is selected from the above spanning trees for the given weighted graph is -
Applications of minimum spanning tree
A minimum spanning tree can be found from a weighted graph by using the algorithms given below -
o Prim's Algorithm
o Kruskal's Algorithm
The idea behind Prim’s algorithm is simple, a spanning tree means all vertices must be connected. So the
two disjoint subsets
bsets (discussed above) of vertices must be connected to make a Spanning Tree. And they
must be connected with the minimum weight edge to make it a Minimum Spanning Tree.
Follow the given steps to find MST using Prim’s Algorithm:
Create a set mstSet that keeps eeps track of vertices already included in MST.
Assign a key value to all vertices in the input graph. Initialize all key values as INFINITE. Assign the key
value as 0 for the first vertex so that it is picked first.
While mstSet doesn’t include all vertices
Pick a vertex u which is not there in mstSet and has a minimum key value.
Include u in the mstSet.
Update the key value of all adjacent vertices of u.. To update the key values, iterate through all
adjacent vertices. For every adjacent vertex v, if the weight of edge u-v
v is less than the
previous key value of v,, update the key value as the weight of u-v
The idea of using key values is to pick the minimum weight edge from the cut.. The key values are used only
for vertices that are not yet included in MST, the key value for these vertices indicates the minimum weight
edges connecting them to the set of vertices included in MST.
Step 1: The set mstSet is initially empty and keys assigned to vertices are {0, INF, INF, INF, INF, INF, INF,
INF} where INF indicates infinite. Now pick the vertex with the minimum key value. The vertex 0 is picked,
include it in mstSet. So mstSet becomes {0}. After including it to mstSet, update key values of adjacent
vertices. Adjacent vertices of 0 are 1 and 7. The key values of 1 and 7 are updated as 4 and 8. Following
subgraph shows vertices and their key values, only the vertices with finite key values are shown. The
vertices included in MST are shown in green color.
Step 2: Pick the vertex with minimum key value and which is not already included in the MST (not in
mstSET). The vertex 1 is picked and added to mstSet. So mstSet now becomes {0, 1}. Update the key
values of adjacent
Step 3: Pick the vertex with minimum key value and which is not already included in the MST (not in
mstSET). We can either pick vertex 7 or vertex 2, let vertex 7 is picked. So mstSet now becomes {0, 1, 7}.
Update the key values of adjacent vertices of 7. The key value of vertex 6 and 8 becomes finite (1 and 7
respectively).
Step 4: Pick the vertex with minimum key value and not already included in MST (not in mstSET). Vertex 6
is picked. So mstSet now becomes {0, 1, 7, 6}. Update the key values of adjacent vertices of 6. The key
value of vertex 5 and 8 are updated.
Step 5: Repeat the above steps until mstSet includes all vertices of given graph. Finally, we get the following
graph.
Kruskal’s algorithm
Below are the steps for finding MST using Kruskal’s algorithm:
1. Sort all the edges in non-decreasing
decreasing order of their weight.
2. Pick the smallest edge. Check if it forms a cycle with the spanning tree formed so far. If the cycle is not
formed, include this edge. Else, discard it.
3. Repeat step#2 until there are (V-1)
1) edges in the spanning tree.
Step #2 uses the Union-Find algorithm to detect cycles.
So we recommend reading the following post as a prerequisite.
Kruskal’s algorithm to find the minimum cost spanning tree uses the greedy approach. The Greedy Choice
Cho is
to pick the smallest weight edge that does not cause a cycle in the MST constructed so far. Let us
understand it with an example:
Below is the illustration of the above approach:
Input Graph:
The graph contains 9 vertices and 14 edges. So, the minimum spanning tree formed will be having (9 – 1) =
8 edges.
After sorting:
Weight Src Dest
1 7 6
2 8 2
2 6 5
4 0 1
4 2 5
6 8 6
7 2 3
7 7 8
8 0 7
8 1 2
9 3 4
10 5 4
11 1 7
14 3 5
Now pick all edges one by one from the sorted list of edges
Step 1: Pick edge 7-6:
6: No cycle is formed, include it.
Step 6: Pick edge 8-6: Since including this edge results in the cycle, discard it.
Step 7: Pick edge 2-3: No cycle is formed, include it.
Step 8: Pick edge 7-8: Since including this edge results in the cycle, discard it.
Step 9: Pick edge 0-7: No cycle is formed, include it.
Step 10: Pick edge 1-2: Since including this edge results in the cycle, discard it.
Step 11: Pick edge 3-4: No cycle is formed, include it.
Note: Since the number of edges included in the MST equals to (V – 1), so the algorithm stops here.
cut-set:
A cut set matrix is a minimal collection of interconnected graph branches that, when removed, cause the
graph to be divided into precisely two sections. Graph theory is the graphical representation of any electric
circuit. Complex circuits can be easily analyzed by converting them into network graphs. From the network
graphs, the incidence matrix, fundamental loop matrix or tie
tie-set matrix, and cut-set
set matrix can be determined.
Every cut-set
set in a connected graph G must contain at least one branch of every spanning tree of G.
In a connected graph G, any minimal set of edges containing at least one branch of every spanning
tree of G is a cut-set.
Every circuit has an even number of edges in common with any cut
cut-set.
The ring sum of any two cutsets in a graph is either a third cut
cut-sett or an edgedisjoint union of cutsets.
Cut Vertices
A vertex in an undirected connected graph is an articulation point (or cut vertex) if removing it (and
edges through it) disconnects the graph.
They are useful for designing reliable networks. For a disconnected undirected graph, an articulation
point is a vertex removal which increases the number of con nected components.
connected
Examples:
Input:
Output: 0, 3
Input:
Output: 1, 2
Input:
Output: 1
In the following graph, vertices 'e' and 'c' are the cut vertices.
Again, the vertex connectivity of a tree is one. The vertex connectivities of the above graphs are one,
and two, respectively.
Note that from the way we have defined it vertex connectivity is meaningful only for graphs that have three or
more vertices and are not complete.
Separable Graph:
A connected graph is said to be separable if its vertex connectivity is one. All other connected graphs
are called non separable.
An equivalent definition is that a connected graph G is said to be separable if thereexists a subgraph g
in G such that (the complement of g in G) and g have only one vertex in common.
In a separable graph a vertex whose removal disconnects the graph is called a cut-vertex, a cut-node,
or an articulation point.
For example, in below Fig. vertex v4 is a cut-vertex.
Planarity – “A graph is said to be planar if it can be drawn on a plane without any edges crossing. Such a drawing is
called a planar representation of the graph.”
For example consider the complete graph K4 and its two possible planar representations –
There are a total of 6 regions with 5 bounded regions and 1 unbounded region .
All the planar representations of a graph split the plane in the same number of regions. Euler found out the
number of regions in a planar graph as a function of the number of vertices and number of edges in the graph.
For example, this graph divides the plane into four regions: three inside and the exterior.
It's maybe not obvious that the number of regions is the same for any planar representation of this graph. or
any representation of a particular planar graph.
Theorem: [Euler's Formula] For a connected planar simple graph G=(V,E) with e=|E| and v=|V|, if
we let r be the number of regions that are created when drawing a planar representation of the graph,
then
r=e−v+2.
Example – What is the number of regions in a connected planar simple graph with 20 vertices each with
a degree of 3?
Solution: There are five regions in the above graph, i.e. r 1,r2,r3,r4,r5.
DUAL GRAPH
Dual
ual graph of a plane graph G is a graph that has a vertex for each face of G.
The dual graph has an edge for each pair of faces in G that are separated from each other by an edge,
and a self-loop
loop when the same face appears on both sides of an edge.
Thus, each edge e of G has a corresponding dual edge, wh whose
ose endpoints are the dual vertices
corresponding to the faces on either side of e.
The definition of the dual depends on the choice of embedding of the graph G, so it is a property of
plane graphs (graphs that are already embedded in the plane) rather th than
an planar graphs (graphs that
may be embedded but for which the embedding is not yet known).
For planar graphs generally, there may be multiple dual graphs, depending on the choice of planar
embedding of the graph.
The red graph is the dual graph of the blue graph, and vice versa
Geometric Dual Graph
*
Given a planar graphG its geometric dual G is constructed by placing a vertex in each region of (including
the exterior region) and, if two regions have an edge x in common, joining the corresponding vertices by an
*
edge X crossing onlyx . The result is always a planar pseudo graph. However, an abstract graph with more
than one embedding on the sphere can give rise to more than one dual.
Consider the plane representation of a graph in followingFig(a). with six regionsor faces F1, F2, F3, F4, F5,
and F6, Let us place six points p1, p2, . . . , p6, one in each of the regions, as shown in Fig. 5-10(b). Next let us
join these six points according to the following procedure:
joining points pi and pj that intersects the common edge between Fi and Fjexactly once. If there is more than
one edge common between Fi and Fj, drawone line between points pi and pj for each of the common edges.
For an edge e lying entirely in one region, say Fk, draw a self-loop at point pk intersecting e exactly once. By
this procedure we obtain a new graph G* [in broken lines in Fig. 5-10(c)] consisting of six vertices, p1, p2, . . . ,
p6 and of edges joining these vertices. Such a graph G* is called a dual (or strictly speaking, a geometric dual)
of G.Clearly, there is a one-to-one correspondence between the edges of graph G and its dual G*−one edge of
G* intersecting one edge of G. Some simpleobservations that can be made about the relationship between a
planar graph G and its dual G* are
5. Remarks 1-4 are the result of the general observation that the number of edges constituting the boundary of
a region Fi in G is equal to the degree ofthe corresponding vertex pi in G*, and vice versa.
8. If n, e, f, r, and μ denote as usual the numbers of vertices, edges, regions, rank, and nullity of a connected
planar graph G, and if n*, e*, f*, r*, and μ* are the corresponding numbers in dual graph G*, then
n* = f,
e* = e,
f* = n.
r* = μ,
μ* = r.
COMBINATORIAL DUAL
A necessary and sufficient condition for two planar graphs G1 and G2 to be duals of each other is as follows:
There is a one-to-one correspondence between the edges in G1 and the edges in G2 such that a set of edges
in G1 forms a circuitif and only if the corresponding set in G2 forms a cut-set.
Let m(G) be the cycle rank of a graph G, m*(G) be the cocycle rank, and the relative complement G-H of a
subgraph H of G be defined as that subgraph obtained by deleting the lines of H. Then a graph G* is a
combinatorial dual of G if there is a one-to-one correspondence between their sets of lines such that for any
choice Y and Y* of corresponding subsets of lines,
m*(G-Y)=m*(G)-m(<Y*>),
Two planar graphs G and G* are said to be duals (or combinatorial duals) ofeach other if there is a one-to-one
correspondence between the edges of G and G* such that if g is any subgraph of G and h is the corresponding
subgraphofG*,
Digraph
The directed graph is also known as the digraph, which is a collection of set of vertices edges. Here the
edges will be directed edges, and each edge will be connected with order pair of vertices. In a graph, the
directed edge or arrow points from
rom the first/ original vertex to the second/ destination vertex in the pair.
In the V-vertex
vertex graph, we will represent vertices by the name 0 through V V-1.
1. If there are two vertices, x
and y, connected with an edge (x, y) in a directed graph, it is not nece
necessary
ssary that the edge (y, a) is also
available in that graph.
a digraph is allowed to have loops. That means they can contain the arrows which directly connects
nodes to themselves. If the directed graph has loops, that graph will be known as the loop digraph. In the
following directed graph, there are only directed eedges.
dges. It contains a directed edge from one vertex to
any other vertex and a loop.
A narrower definition is allowed by some authors, which says that the digraph is not allowed to contain
the loops. More specifically, if the digraph does not have the loops
loops,, that graph will be known as the
simple directed graph. In the following directed graph, there are only directed edges. It contains a
directed edge from one vertex to any other vertex, and it is not allowing looping.
Euler digraph
Essentially, the same conditions for regular graphs being Eulerian hold for digraphs being Eulerian,
however, we are now regarding Eulerian trails with regards to arcs. For example, the following digraph is
Eulerian:
3.
4. We should also not that the underlying graph being Eulerian does not imply that a digraph with that
underlying graph is Eulerian. For example, the following orientation of the arcs of the graph above no
longer make DEulerian:
5.
UNIT - IV: Matrix Representation - Adjacency matrix
matrix- Incidence matrix- Circuit matrix -Cut
Cut-set matrix - Path
Matrix- Properties - Related Theorems - Correlations. Graph Coloring -Chromatic
Chromatic Polynomial - Chromatic
Partitioning - Matching - Covering - Related Theorems.
Representation of Graphs
There are two principal ways to represent a graph G with the matrix, i.e., adjacency matrix and incidence
matrix representation.
(a)Representation
ation of the Undirected Graph:
1. Adjacency Matrix Representation: If an Undirected Graph G consists of n vertices then the adjacency
matrix of a graph is an n x n matrix A = [aij] and defined by
If there exists an edge between vertex vi and vj, where i is a row and j is a column then the value of aij=1.
There is a row for every vertex and a column for every edge in the incident matrix.
The number of ones in an incidence matrix of the undirected graph (without loops) is equal to the sum of the
degrees of all the vertices in a graph.
Solution: The undirected graph consists of four vertices and five edges. Therefore, the incidence matrix is an
4 x 5 matrix, which is shown in Fig:
(b)Representation of Directed Graph:
1. Adjacency Matrix Representation: If a directed graph G consists of n vertices then the adjacency matrix of
a graph is an n x n matrix A = [aij] and defined by
If there exists an edge between vertex V i and Vj, with Vi as initial vertex and Vj as a final vertex, then the value
of aij=1.
If there is no edge between vertex Vi and Vj, then the value of aij=0.
The number of ones in the adjacency matrix of a directed graph is equal to the number of edges.
Example: Consider the directed graph shown in fig. Determine its adjacency matrix MA.
Solution: Since the directed graph G consists of five vertices. Therefore, the adjacency matrix will be a 5 x 5
matrix. The adjacency matrix of the directed graphs is as follow
follows:
2. Incidence Matrix Representation: If a directed graph G consists of n vertices and m edges, then the
incidence matrix is an n x m matrix C = [c ij] and defined by
The number of ones in an incidence matrix is equal to the number of edges in the grap
graph.
h.
Example: Consider the directed graph G as shown in fig. Find its incidence matrix M I.
Solution: The directed graph consists of four vertices and five edges. Therefore, the incidence matrix is a 4 x
5 matrix which is show in fig:
(c)Representation of Multigraph:
(i)Adjacency matrix representation of multigraph: If a multigraph G consists of vertices, then the adjacency
matrix of graph is an n x n matrix A = [aij] and is defined by
If there exist one or more than one edges between vertex vi and vj then aij=N, where is the number of edges
between vi and vj.
Example: Consider the multigraph shown in Fig, Determine its adjacency matrix.
Solution: Since the multigraph consist of five vertices. Therefore the adjacency matrix will be an 5 x 5 matrix.
The adjacency matrix of the multigraph is as follows:
Circuit Matrix:
For a given directed graph, it is always possible to state which branches are involved in the formation of loops
or closed circuits or meshes. For a given oriented graph, loops can be identified by marking each loop with
orientation of loop current by a curved
rved arrow. This enables to write the nodes in the loop in cyclic order. In
complicated networks with many loops, it is advisable to list the nodes in selected cyclic order to avoid the
confusion between oriented loop Loop currents. A loop matrix or circui
circuitt matrix is represented by Ba. For a
graph with n nodes and b branches, loop matrix Ba is a rectangular matrix with b columns (equal to number of
branches) and as many as rows as there are loops. The elements b hk of loop matrix has following values.
Circuit 1 : [1, 2, 3]
Circuit 2 : [3, 4, 5]
Circuit 3 : [2, 6]
Circuit 4 : [1, 2, 4, 5]
For a given graph, select any tree and remove its all links. Then replace each link one at a time, it will form a
closed path or loop or closed circuit along with some of the tree branches existing. The circuits formed by
replacing each link in tree are called fundamental circuits or f-circuits or tie-sets. It is very important to
select the orientation of f-circuit to coincide with that of the link completing the f -circuit.
The number of f-circuits equals the number of links. For a graph with ‘b’ branches and ‘n’ nodes, the possible f-
circuits are given by [b – (n – 1)].
As shown above, twigs 2, 3, 4 are forming tree while 1, 5, 6 are the links which are not the part of tree. When
these links are replaced, we will have three f-circuits as shown in the Fig. 5.13 (c). The orientation of each loop
is coinciding the orientation of the connecting link in each f-circuit. The f-circuits or tiesets are given by writing
link entry first’ and then other branches in sequence as follows,
We can write this information about f-circuits in tabular form which is known as tieset schedule. The tieset
schedule for above f-circuits is as
In general, matrix B is arranged such that first columns corresponding to entries of links and then columns
corresponding to entries of links and then columns corresponding to entries of twigs as given below.
where BL is the matrix corresponding to link entries called link matrix. It is always identity matrix. BT is the twig
matrix corresponding to twig entries.
Fundamental cut set matrix is represented with letter C. This matrix gives the relation between branch
voltages and twig voltages.
If there are ‘n’ nodes and ‘b’ branches are present in a directed graph, then the number of twigs present in a
selected Tree of given graph will be n-1. So, the fundamental cut set matrix will have ‘n-1’ rows and ‘b’
columns. Here, rows and columns are corresponding to the twigs of selected tree and branches of given graph.
Hence, the order of fundamental cut set matrix will be (n-1) × b.
The elements of fundamental cut set matrix will be having one of these three values, +1, -1 and 0.
Follow these steps in order to find the fundamental cut set matrix of given directed graph.
Select a Tree of given directed graph and represent the links with the dotted lines.
By removing one twig and necessary links at a time, we will get one f-cut set. Fill the values of elements
corresponding to this f-cut set in a row of fundamental cut set matrix.
Repeat the above step for all twigs.
Example
Consider the same directed graph , which we discussed in the section of incidence matrix. Select the
branches d, e & f of this directed graph as twigs. So, the remaining branches a, b & c of this directed graph will
be the links.
The twigs d, e & f are represented with solid lines and links a, b & c are represented with dotted lines in the
following figure.
By removing one twig and necessary links at a time, we will get one f-cut set. So, there will be three f-cut sets,
since there are three twigs. These three f-cut sets are shown in the following figure.
We will be having three f-cut sets by removing a set of twig and links of C1, C2 and C3. We will get the row wise
element values of fundamental cut set matrix from each f-cut set. So, the fundamental cut set matrix of the
above considered Tree will be
The rows and columns of the above matrix represents the twigs and branches of given directed graph. The
order of this fundamental cut set matrix is 3 × 6.
The number of Fundamental cut set matrices of a directed graph will be equal to the number of Trees of
that directed graph. Because, every Tree will be having one Fundamental cut set matrix.
The number of fundamental cut-sets will always be equal to the number of twigs present in the tree.
The procedure to find the fundamental cut-sets is already discussed. There are some properties of the cut set
matrix that need to be fulfilled for the validation of these fundamental cut-sets. These properties are:
A fundamental cut-set can contain only one branch of a tree and the remaining elements are links.
A cut-set divides the tree into two separate parts after removing the tree branch of that particular cut-
set.
Each branch of the cut-set has one of its terminal’s incidents at a node in one subset of the tree and its
other terminal at a node in the other part of the tree.
The direction of the cut-set is chosen the same as the direction of the branch current of the tree in that
cut-set.
A path matrixis a matrix representing a graph, where each value in m’th row and n’th column project
whether there is a path from node m to node n. The path may be direct or indirect. It may have a single edge or
multiple edge.
Graph coloring
Graph coloring is the procedure of assignment of colors to each vertex of a graph G such that no adjacent
vertices get same color. The objective is to minimize the number of colors while coloring a graph. The smallest
number of colors required to color a graph G is called its chromatic number of that graph. Graph coloring
problem is a NP Complete problem.
The steps required to color a graph G with n number of vertices are as follows −
Step 2 − Choose the first vertex and color it with the first color.
Step 3 − Choose the next vertex and color it with the lowest numbered color that has not been colored on any
vertices adjacent to it. If all the adjacent vertices are colored with this color, assign a new color to it. Repeat
this step until all the vertices are colored.
Example
In the above figure, at first vertex a iscolored red. As the adjacent vertices of vertex a are again adjacent,
vertex b and vertex d arecolored with different color, green and blue respectively. Then vertex c is colored as
red as no adjacent vertex of c is colored red. Hence, we could color the graph by 3 colors. Hence, the
chromatic number of the graph is 3.
Register Allocation
Map Coloring
Bipartite Graph Checking
Mobile Radio Frequency Assignment
Making time table, etc
Chromatic Number: The smallest number of colors needed to color a graph G is called its chromatic number.
For example, the following can be colored minimum 2 colors.
Chromatic number of this graph is 2 because in this above diagram we can use to color red and green
.
Painting all the vertices of a graph with colors such that no two adjacentvertices have the same color is called
the proper coloring (or sometimes simplycoloring) of a graph. A graph in which every vertex has been assigned
a coloraccording to a proper coloring is called a properly colored graph. Usually agiven graph can be properly
colored in many different ways. Figure 8-1 showsthree different proper colorings of a graph.
Fig. 8-1 Proper colorings of a graph.The proper coloring which is of interest to us is one that requires the
minimumnumber of colors. A graph G that requires κ different colors for its propercoloring, and no less, is
called a κ-chromatic graph, and the number κ is called the chromatic number of G. You can verify that the
graph in Fig. 8-1 is 3-chromatic.
Some observations that follow directly from the definitions just introduced are
2. A graph with one or more edges (not a self-loop, of course) is at least 2-chromatic (also called bichromatic).
3. A complete graph of n vertices is n-chromatic, as all its vertices are adjacent. Hence a graph containing a
complete graph of r vertices is at least r-chromatic. For instance, every graph having a triangle is at least 3-
chromatic.
4. A graph consisting of simply one circuit with n ≥ 3 vertices is 2-chromatic if n is even and 3-chromatic if n is
odd. (This can be seen by numbering vertices 1, 2, . . ., n in sequence and assigning one color to odd vertices
and another to even. If n is even, no adjacent vertices will have the same color. if n is odd, the nth and first
vertex will be adjacent and will have the same color, thus requiring a third color for proper coloring.)
the regions of a planar graph are said to be properly colored if no two contiguous oradjacent regions have the
same color. (Two regions are said to be adjacent ifthey have a common edge between them. )The proper
coloring of regions isalso called map coloring, referring to the fact that in an atlas different countriesare colored
such that countries with common boundaries are shown in differentcolors.
We are interested in a coloring that uses the minimum number ofcolors. This leads us to the most famous
conjecture in graph theory. Theconjecture is that every map (i.e., a planar graph) can be properly colored with
four colors. That at least four colors are necessary to properly color a graph is immediatefrom Fig. 8-14, and
that five colors will suffice for any planar graph will beshown shortly.
The four color theorem was proved in 1976 by Kenneth Appel and Wolfgang Haken after many false
proofs and counterexamples (unlike the five color theorem, proved in the 1800s, which states that five
colors are enough to color a map).
If the regions of a Map M are colored so that adjacent regions are different , then no more than 4 colors
are required.
Every planar graph is 4-colorable (Vertex Coloring) but when a triangle is a graph or sub-graph we
need only 3 colors .
How to color ?
Take any map and divide it into a set of connected regions : R1,R2 … Rn with continuous boundaries.
There must be some way to assign each region Ri -> in the set {R, G, B, Y} , such that if two regions Ri
and Rj are “touching” (i.e. they share some nonzero length of boundary between them), they must receive
different colors.
Example –
1.. The four-color map is shown below :
A planar map
Here, as you can see, every region that touches another region has a different color than the touching one &
we required a total of a maximum of four colors to color this map – Red, Green, Blue & yellow.
Map G
Here you can see that every region that touches another region has a different color than the touching one &
we required a total of maximum four colors to color this map – Red, Green, Blue & yellow.
Map H
Here also you can see that every region that touches another region has a different color than the touching one
& we required a total of a maximum of four colors to color this map – Red, Green, Blue & yellow.
CHROMATIC POLYNOMIAL
In general, a given graph G of n vertices can be properly colored in manydifferent ways using a sufficiently
large number of colors. This property of a graph is expressed elegantly by means of a polynomial. This
polynomial is called the chromatic polynomial of G and is defined as follows :
there are[λ i] different ways of properly coloringG using exactly i colors out of λcolors.Since i can be any
positive integer from 1 to n (it is not possible to use morethann colors on n vertices), the chromatic polynomial
is a sum of these terms;that is,
Each ci has to be evaluated individually for the given graph. For example, anygraph with even one edge
requires at least two colors for proper coloring, and therefore
c1 = 0.
A graph with n vertices and using n different colors can be properly colored in n! ways; that is, cn = n!. As an
illustration, let us find the chromatic polynomial of the graph given inFig. 8-4.
Since
Since the graph in Fig. 8-4 has a triangle, it will require at least three differentcolors for proper coloring.
Therefore,
c1 = c2 = 0 and c5 = 5!.
Moreover, to evaluate c3, suppose that we have three colorsx, y, and z. These three colors can be assigned
properly to vertices v1, v2, and v3 in 3! = 6 different ways. Having done that, we have no more choices left,
because vertex v5 must have the same color as v3, and v4 must have the same color as v2. Therefore,
c3 = 6.
Similarly, with four colors, v1, v2, and v3 can be properly colored in 4·6 = 24 different ways. The fourth color
can be assigned to v4 or v5, thus providing two choices. The fifth vertex provides no additional choice.
Therefore, c4 = 24·2 = 48.
Substituting these coefficients in P5(λ), we get, for the graph in Fig. 8-4,
P5(λ) = λ (λ − 1)(λ − 2) + 2λ(λ − 1)(λ − 2)(λ − 3)+ λ(λ − 1)(λ − 2)(λ − 3)(λ − 4)
= λ(λ − 1)(λ − 2)(λ2 − 5λ + 7).
The presence of factors λ – 1 and λ – 2 indicates that G is at least 3-chromatic.
CHROMATIC PARTITIONING
A proper coloring of a graph naturally induces a partitioning of the vertices into different subsets. For example,
the coloring in Fig. (c) produces the partitioning
No two vertices in any of these three subsets are adjacent. Such a subset of vertices is called an independent
set; more formally: A set of vertices in a graph is said to be an independent set of vertices or simply an
independent set (or an internally stable set) if no two vertices in theset are adjacent. For example;’ in Fig. 8-3,
{a, c, d} is an independent set. A single vertex in any graph constitutes an independent set. A maximal
independent set (or maximal internally stable set) is an independent set to which no other vertex can be added
without destroying itsindependence property. The set {a, c, d, f} in Fig. 8-3 is a maximal independent set. The
set {b, f} is another maximal independent set. The set {b, g} is a third one. From the preceding example, it is
clear that a graph, in general, has many maximal independent sets; and they may be of different sizes. Among
all maximal independent sets, one with the largest number of vertices is often of particular interest.
Suppose that the graph in Fig. 8-3 describesthe problem. Each of the seven vertices of the graph is a possible
code word to be used in some communication. Some words are so close (say, in sound) to others that they
might be confused for each other. Pairs of such words that may be mistaken for one another are joined by
edges. Find a largest set of code words for a reliable communication. This is a problem of finding a maximal
independent set with largest number of vertices. In this simple example, {a, c, d, f} is an answer.
Given a simple, connected graph G, partition all vertices of G into the smallest possible number of disjoint,
independent sets.This problem, known as the chromatic partitioning of graphs, is perhaps the most important
problem in partitioning of graphs. By enumerating all maximal independent sets and then selecting the smallest
number of sets that include all vertices of the graph, we just solved this problem.The following four are some
chromatic partitions of the graph in Fig. 8-3, for
example.
{(a, c, d, f), (b, g), (e)},
{(a, c, d, g), (b, f), (e)},
{(c, d, f), (b, g), (a, e)},
{(c, d, g), (b, f), (a, e)}.
Matching
A matching graph is a subgraph of a graph where there are no edges adjacent to each other. Simply, there
should not be any common vertex between any two edges.
Let ‘G’ = (V, E) be a graph. A subgraph is called a matching M(G), if each vertex of G is incident with at
most one edge in M, i.e.,
deg(V) ≤ 1 ∀ V ∈ G
which means in the matching graph M(G), the vertices should have a degree of 1 or 0, where the edges should
be incident from the graph G.
Notation − M(G)
Example
In a matching,
In a matching, no two edges are adjacent. It is because if any two edges are adjacent, then the degree of the
vertex which is joining those two edges will have a degree of 2 which violates the matching rule.
Maximal Matching
A matching M of graph ‘G’ is said to maximal if no other edges of ‘G’ can be added to M.
Example
M1, M2, M3 from the above graph are the maximal matching of G.
Maximum Matching
It is also known as largest maximal matching. Maximum matching is defined as the maximal matching with
maximum number of edges.
The number of edges in the maximum matching of ‘G’ is called its matching number.
Example
For a graph given in the above example, M1 and M2 are the maximum matching of ‘G’ and its matching
number is 2. Hence by using the graph G, we can form only the subgraphs with only 2 edges maximum. Hence
we have the matching number as two.
Perfect Matching
A matching (M) of graph (G) is said to be a perfect match, if every vertex of graph g (G) is incident to exactly
one edge of the matching (M), i.e.,
deg(V) = 1 ∀ V
The degree of each and every vertex in the subgraph should have a degree of 1.
Example
A maximum matching of graph need not be perfect. If a graph ‘G’ has a perfect match, then the number of
vertices |V(G)| is even. If it is odd, then the last vertex pairs with the other vertex, and finally there remains a
single vertex which cannot be paired with any other vertex for which the degree is zero. It clearly violates the
perfect matching principle.
Example
Note − The converse of the above statement need not be true. If G has even number of vertices, then M1
need not be perfect.
Example
It is matching, but it is not a perfect match, even though it has even number of vertices.
Graph Covering
A covering graph is a subgraph which contains either all the vertices or all the edges corresponding to some
other graph. A subgraph which contains all the vertices is called a line/edge covering. A subgraph which
contains all the edges is called a vertex covering.
Line Covering
Let G = (V, E) be a graph. A subset C(E) is called a line covering of G if every vertex of G is incident with at
least one edge in C, i.e.,
deg(V) ≥ 1 ∀ V ∈ G
because each vertex is connected with another vertex by an edge. Hence it has a minimum degree of 1.
Example
Line covering of ‘G’ does not exist if and only if ‘G’ has an isolated vertex. Line covering of a graph with ‘n’
vertices has at least [n/2] edges.
Example
In the above graph, the subgraphs having line covering are as follows −
Here, C1, C2, C3 are minimal line coverings, while C4 is not because we can delete {b, c}.
It is also known as Smallest Minimal Line Covering. A minimal line covering with minimum number of edges
is called a minimum line covering of ‘G’. The number of edges in a minimum line covering in ‘G’ is called the
line covering number of ‘G’ (α1).
Example
In the above example, C1 and C2 are the minimum line covering of G and α1 = 2.
Vertex Covering
Let ‘G’ = (V, E) be a graph. A subset K of V is called a vertex covering of ‘G’, if every edge of ‘G’ is incident
with or covered by a vertex in ‘K’.
Example
Take a look at the following graph −
The subgraphs that can be derived from the above graph are as follows −
K1 = {b, c}
K2 = {a, b, c}
K3 = {b, c, d}
K4 = {a, d}
Here, K1, K2, and K3 have vertex covering, whereas K4 does not have any vertex covering as it does not cover
the edge {bc}.
A vertex ‘K’ of graph ‘G’ is said to be minimal vertex covering if no vertex can be deleted from ‘K’.
Example
In the above graph, the subgraphs having vertex covering are as follows −
K1 = {b, c}
K2 = {a, b, c}
K3 = {b, c, d}
Here, K1 and K2 are minimal vertex coverings, whereas in K3, vertex ‘d’ can be deleted.
It is also known as the smallest minimal vertex covering. A minimal vertex covering of graph ‘G’ with minimum
number of vertices is called the minimum vertex covering.
The number of vertices in a minimum vertex covering of ‘G’ is called the vertex covering number of G (α 2).
Example
In the following graph, the subgraphs having vertex covering are as follows −
K1 = {b, c}
K2 = {a, b, c}
K3 = {b, c, d}
Connectedness
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.
Cut Vertex
Let ‘G’ be a connected graph. A vertex V ∈ G is called a cut vertex of ‘G’, if ‘G-V’ (Delete ‘V’ from ‘G’) results in
a disconnected graph. Removing a cut vertex from a graph breaks it in to two or more graphs.
Example
In the following graph, vertices ‘e’ and ‘c’ are the cut vertices.
Without ‘g’, there is no path between vertex ‘c’ and vertex ‘h’ and many other. Hence it is a disconnected graph
with cut vertex as ‘e’. Similarly, ‘c’ is also a cut vertex for the above graph.
Cut Edge (Bridge)
Let ‘G’ be a connected graph. An edge ‘e’ ∈ G is called a cut edge if ‘G-e’ results in a disconnected graph.
If removing an edge in a graph results in to two or more graphs, then that edge is called a Cut Edge.
Example
By removing the edge (c, e) from the graph, it becomes a disconnected graph.
In the above graph, removing the edge (c, e) breaks the graph into two which is nothing but a disconnected
graph. Hence, the edge (c, e) is a cut edge of the graph.
a cut edge e ∈ G if and only if the edge ‘e’ is not a part of any cycle in G.
the maximum number of cut edges possible is ‘n-1’.
whenever cut edges exist, cut vertices also exist because at least one vertex of a cut edge is a cut
vertex.
if a cut vertex exists, then a cut edge may or may not exist.
Let ‘G’= (V, E) be a connected graph. A subset E’ of E is called a cut set of G if deletion of all the edges of E’
from G makes G disconnect.
If deleting a certain number of edges from a graph makes it disconnected, then those deleted edges are called
the cut set of the graph.
Example
Take a look at the following graph. Its cut set is E1 = {e1, e3, e5, e8}.
After removing the cut set E1 from the graph, it would appear as follows −
Similarly, there are other cut sets that can disconnect the graph −
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.
Vertex connectivity (K(G)), edge connectivity (λ(G)), minimum number of degrees of G(δ(G)).
Example
Solution
K(G) ≥ 2 (2)
Therefore,
λ(G) = 2
Dijkstra's Algorithm
Dijkstra's algorithm allows us to find the shortest path between any two vertices of a graph.
It differs from the minimum spanning tree because the shortest distance between two vertices might not
include all the vertices of the graph.
Here, we consider A as a source vertex. A vertex is a source vertex so entry is filled with 0 while other vertices
filled with ∞. The distance from source vertex to source vertex is 0, and the distance from the source vertex to
other vertices is ∞.
ABCDE
∞∞∞∞∞
Since 0 is the minimum value in the above table, so we select vertex A and added in the second row shown as
below:
ABCDE
A0 ∞∞∞∞
As we can observe in the above graph that there are two vertices directly connected to the vertex A, i.e., B and
C. The vertex A is not directly connected to the vertex E, i.e., the edge is from E to A. Here we can calculate
the two distances, i.e., from A to B and A to C. The same formula will be used as in the previous problem.
AB CDE
A0 ∞ ∞∞∞
10 5 ∞ ∞
As we can observe in the third row that 5 is the lowest value so vertex C will be added in the third row.
We have calculated the distance of vertices B and C from A. Now we will compare the vertices to find the
vertex with the lowest value. Since the vertex C has the minimum value, i.e., 5 so vertex C will be selected.
Since the vertex C is selected, so we consider all the direct paths from the vertex C. The direct paths from the
vertex C are C to B, C to D, and C to E.
First, we consider the vertex B. We calculate the distance from C to B. Consider vertex C as 'x' and vertex B as
'y'.
Since 8 is less than the infinity so we update d(B) from ∞ to 8. Now the new row will be inserted in which value
8 will be added under the B column.
AB CDE
A0 ∞ ∞∞∞
10 5 ∞ ∞
8
We consider the vertex D. We calculate the distance from C to D. Consider vertex C as 'x' and vertex D as 'y'.
Since 14 is less than the infinity so we update d(D) from ∞ to 14. The value 14 will be added under the D
column.
AB CD E
A0 ∞ ∞∞ ∞
C 10 5 ∞ ∞
8 14
We consider the vertex E. We calculate the distance from C to E. Consider vertex C as 'x' and vertex E as 'y'.
1. d(x, y) = d(x) + c(x, y) < d(y)
2. = (5 + 2) < ∞
3. = 7 < ∞
Since 14 is less than the infinity so we update d(D) from ∞ to 14. The value 14 will be added under the D
column.
A B C D E
A0 ∞ ∞∞ ∞
C 10 5 ∞ ∞
8 14 7
As we can observe in the above table that 7 is the minimum value among 8, 14, and 7. Therefore, the vertex E
is added on the left as shown in the below table:
A B C D E
A0 ∞ ∞∞ ∞
C 10 5 ∞ ∞
E 8 14 7
The vertex E is selected so we consider all the direct paths from the vertex E. The direct paths from the vertex
E are E to A and E to D. Since the vertex A is selected, so we will not consider the path from E to A.
Since 13 is less than the infinity so we update d(D) from ∞ to 13. The value 13 will be added under the D
column.
A B C D E
A0 ∞ ∞∞ ∞
C 10 5 ∞ ∞
E 8 14 7
B 8 13
The value 8 is minimum among 8 and 13. Therefore, vertex B is selected. The direct path from B is B to D.
Since 9 is less than 13 so we update d(D) from 13 to 9. The value 9 will be added under the D column.
A B C D E
A0 ∞ ∞∞ ∞
C 10 5 ∞ ∞
E 8 14 7
B 8 13
D 9
A spanning tree can be defined as the subgraph of an undirected connected graph. It includes all the vertices
along with the least possible number of edges. If any vertex is missed, it is not a spanning tree. A spanning
tree is a subset of the graph that does not have cycles, and it also cannot be disconnected.
A spanning tree consists of (n-1) edges, where 'n' is the number of vertices (or nodes). Edges of the spanning
tree may or may not have weights assigned to them. All the possible spanning trees created from the given
graph G would have the same number of vertices, but the number of edges in the spanning tree would be
equal to the number of vertices in the given graph minus 1.
A complete undirected graph can have nn-2 number of spanning trees where n is the number of vertices in the
graph. Suppose, if n = 5, the number of maximum possible spanning trees would be 55-2 = 125.
Basically, a spanning tree is used to find a minimum path to connect all nodes of the graph. Some of the
common applications of the spanning tree are listed as follows -
Cluster Analysis
Civil network planning
Computer network routing protocol
Now, let's understand the spanning tree with the help of an example.
Some of the possible spanning trees that will be created from the above graph are given as follows -
Properties of spanning-tree
So, a spanning tree is a subset of connected graph G, and there is no spanning tree of a disconnected graph.
A minimum spanning tree can be defined as the spanning tree in which the sum of the weights of the edge is
minimum. The weight of the spanning tree is the sum of the weights given to the edges of the spanning tree. In
the real world, this weight can be considered
sidered as the distance, traffic load, congestion, or any random value.
Let's understand the minimum spanning tree with the help of an example.
The sum of the edges of the above graph is 16. Now, some of the possible span
spanning
ning trees created from the
above graph are -
So, the minimum spanning tree that is selected from the above spanning trees for the given weighted graph is -
Applications of minimum spanning tree
Prim's Algorithm
Kruskal's Algorithm
Prim's algorithm - It is a greedy algorithm that starts with an empty spanning tree. It is used to find
fi the
minimum spanning tree from the graph. This algorithm finds the subset of edges that includes every vertex of
the graph such that the sum of the weights of the edges can be minimized.