Graph Theory
Graph Theory
In the domain of mathematics and computer science, graph theory is the study of graphs that
concerns with the relationship among edges and vertices. It is a popular subject having its
applications in computer science, information technology, biosciences, mathematics, and
linguistics to name a few. Without further ado, let us start with defining a graph.
What is a Graph?
A graph is a pictorial representation of a set of objects where some pairs of objects are
connected by links. The interconnected objects are represented by points termed as vertices,
and the links that connect the vertices are called edges.
Formally, a graph is a pair of sets (V, E), where V is the set of vertices and E is the set of
edges, connecting the pairs of vertices. Take a look at the following graph −
V = {a, b, c, d, e}
FUNDAMENTALS
A graph is a diagram of points and lines connected to the points. It has at least one line
joining a set of two vertices with no vertex connecting itself. The concept of graphs in graph
theory stands up on some basic terms such as point, line, vertex, edge, degree of vertices,
properties of graphs, etc. Here, in this chapter, we will cover these fundamentals of graph
theory.
Point
A point is a particular position in a one-dimensional, two-dimensional, or three-dimensional
space. For better understanding, a point can be denoted by an alphabet. It can be represented
with a dot.
Example
Line
A Line is a connection between two points. It can be represented with a solid line.
Example
Here, ‘a’ and ‘b’ are the points. The link between these two points is called a line.
Vertex
A vertex is a point where multiple lines meet. It is also called a node. Similar to points, a
vertex is also denoted by an alphabet.
Example
Edge
An edge is the mathematical term for a line that connects two vertices. Many edges can be
formed from a single vertex. Without a vertex, an edge cannot be formed. There must be a
starting vertex and an ending vertex for an edge.
Example
Here, ‘a’ and ‘b’ are the two vertices and the link between them is called an edge.
Graph
A graph ‘G’ is defined as G = (V, E) Where V is a set of all vertices and E is a set of all edges
in the graph.
Example 1
In the above example, ab, ac, cd, and bd are the edges of the graph. Similarly, a, b, c, and d
are the vertices of the graph.
Example 2
In this graph, there are four vertices a, b, c, and d, and four edges ab, ac, ad, and cd.
Loop
In a graph, if an edge is drawn from vertex to itself, it is called a loop.
Example 1
In the above graph, V is a vertex for which it has an edge (V, V) forming a loop.
Example 2
In this graph, there are two loops which are formed at vertex a, and vertex b.
Degree of Vertex
It is the number of vertices adjacent to a vertex V.
Notation − deg(V).
deg(v) ≤ n – 1 ∀ v ∈ G
A vertex can form an edge with all other vertices except by itself. So the degree of a vertex
will be up to the number of vertices in the graph minus 1. This 1 is for the self-vertex as it
cannot form a loop by itself. If there is a loop at any of the vertices, then it is not a Simple
Graph.
Undirected Graph
Directed Graph
Example 1
Example 2
The vertex ‘e’ is an isolated vertex. The graph does not have any pendent vertex.
Indegree of a Graph
Indegree of vertex V is the number of edges which are coming into the vertex V.
Notation − deg−(V).
Outdegree of a Graph
Outdegree of vertex V is the number of edges which are going out from the vertex V.
Notation − deg+(V).
Example 1
Take a look at the following directed graph. Vertex ‘a’ has two edges, ‘ad’ and ‘ab’, which
are going outwards. Hence its outdegree is 2. Similarly, there is an edge ‘ga’, coming towards
vertex ‘a’. Hence the indegree of ‘a’ is 1.
The indegree and outdegree of other vertices are shown in the following table −
a 1 2
b 2 0
c 2 1
d 1 1
e 1 1
f 1 1
g 0 2
Example 2
Take a look at the following directed graph. Vertex ‘a’ has an edge ‘ae’ going outwards from
vertex ‘a’. Hence its outdegree is 1. Similarly, the graph has an edge ‘ba’ coming towards
vertex ‘a’. Hence the indegree of ‘a’ is 1.
The indegree and outdegree of other vertices are shown in the following table −
a 1 1
b 0 2
c 2 0
d 1 1
e 1 1
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
A vertex with degree zero is called an isolated vertex.
Example
Here, the vertex ‘a’ and vertex ‘b’ has a no connectivity between each other and also to any
other vertices. So the degree of both the vertices ‘a’ and ‘b’ are zero. These are also called as
isolated vertices.
Adjacency
Here are the norms of adjacency −
In a graph, two vertices are said to be adjacent, if there is an edge between the two
vertices. Here, the adjacency of vertices is maintained by the single edge that is
connecting those two vertices.
In a graph, two edges are said to be adjacent, if there is a common vertex between the
two edges. Here, the adjacency of edges is maintained by the single vertex that is
connecting two edges.
Example 1
‘a’ and ‘b’ are the adjacent vertices, as there is a common edge ‘ab’ between them.
‘a’ and ‘d’ are the adjacent vertices, as there is a common edge ‘ad’ between them.
ab’ and ‘be’ are the adjacent edges, as there is a common vertex ‘b’ between them.
be’ and ‘de’ are the adjacent edges, as there is a common vertex ‘e’ between them.
Example 2
a’ and ‘d’ are the adjacent vertices, as there is a common edge ‘ad’ between them.
‘c’ and ‘b’ are the adjacent vertices, as there is a common edge ‘cb’ between them.
‘ad’ and ‘cd’ are the adjacent edges, as there is a common vertex ‘d’ between them.
ac’ and ‘cd’ are the adjacent edges, as there is a common vertex ‘c’ between them.
Parallel Edges
In a graph, if a pair of vertices is connected by more than one edge, then those edges are
called parallel edges.
In the above graph, ‘a’ and ‘b’ are the two vertices which are connected by two edges ‘ab’
and ‘ab’ between them. So it is called as a parallel edge.
Multi Graph
A graph having parallel edges is known as a Multigraph.
Example 1
In the above graph, there are five edges ‘ab’, ‘ac’, ‘cd’, ‘cd’, and ‘bd’. Since ‘c’ and ‘d’ have
two parallel edges between them, it a Multigraph.
Example 2
In the above graph, the vertices ‘b’ and ‘c’ have two edges. The vertices ‘e’ and ‘d’ also have
two edges between them. Hence it is a Multigraph.
Example 1
Vertex A b c d e
Connecting to b,c a,d a,d c,b,e d
Degree 2 2 2 3 1
In the above graph, for the vertices {d, a, b, c, e}, the degree sequence is {3, 2, 2, 2, 1}.
Example 2
Vertex A b c d e f
Degree 2 2 2 2 2 0
In the above graph, for the vertices {a, b, c, d, e, f}, the degree sequence is {2, 2, 2, 2, 2, 0}.
Notation − d(U,V)
There can be any number of paths present from one vertex to other. Among those, you need
to choose only the shortest one.
Example
Here, the distance from vertex ‘d’ to vertex ‘e’ or simply ‘de’ is 1 as there is one edge
between them. There are many paths from vertex ‘d’ to vertex ‘e’ −
da, ab, be
df, fg, ge
de (It is considered for distance between the vertices)
df, fc, ca, ab, be
da, ac, cf, fg, ge
Eccentricity of a Vertex
The maximum distance between a vertex to all other vertices is considered as the eccentricity
of vertex.
Notation − e(V)
The distance from a particular vertex to all other vertices in the graph is taken and among
those distances, the eccentricity is the highest of distances.
Example
So the eccentricity is 3, which is a maximum from vertex ‘a’ from the distance between ‘ag’
which is maximum.
In other words,
e(b) = 3
e(c) = 3
e(d) = 2
e(e) = 3
e(f) = 3
e(g) = 3
Notation − r(G)
From all the eccentricities of the vertices in a graph, the radius of the connected graph is the
minimum of all those eccentricities.
Example − In the above graph r(G) = 2, which is the minimum eccentricity for ‘d’.
Diameter of a Graph
The maximum eccentricity from all the vertices is considered as the diameter of the Graph G.
The maximum among all the distances between a vertex to all other vertices is considered as
the diameter of the Graph G.
Notation − d(G)
From all the eccentricities of the vertices in a graph, the diameter of the connected graph is
the maximum of all those eccentricities.
Central Point
If the eccentricity of a graph is equal to its radius, then it is known as the central point of the
graph. If
e(V) = r(V),
Example − In the example graph, ‘d’ is the central point of the graph.
e(d) = r(d) = 2
Centre
The set of all central points of ‘G’ is called the centre of the Graph.
Circumference
The number of edges in the longest cycle of ‘G’ is called as the circumference of ‘G’.
Example − In the example graph, the circumference is 6, which we derived from the longest
cycle a-c-f-g-e-b-a or a-c-f-d-e-b-a.
Girth
The number of edges in the shortest cycle of ‘G’ is called its Girth.
Notation − g(G).
Example − In the example graph, the Girth of the graph is 4, which we derived from the
shortest cycle a-c-f-d-a or d-f-g-e-d or a-b-e-d-a.
Corollary 1
Corollary 2
In any non-directed graph, the number of vertices with Odd degree is Even.
Corollary 3
k|V| = 2|E|
Corollary 4
k|V| ≤ 2|E|
Corollary 5
k|V| ≥ 2|E|
TYPES OF GRAPH
There are various types of graphs depending upon the number of vertices, number of edges,
interconnectivity, and their overall structure. We will discuss only a certain few important
types of graphs in this chapter.
Null Graph
A graph having no edges is called a Null Graph.
Example
In the above graph, there are three vertices named ‘a’, ‘b’, and ‘c’, but there are no edges
among them. Hence it is a Null Graph.
Trivial Graph
A graph with only one vertex is called a Trivial Graph.
Example
In the above shown graph, there is only one vertex ‘a’ with no other edges. Hence it is a
Trivial graph.
Non-Directed Graph
A non-directed graph contains edges but the edges are not directed ones.
Example
In this graph, ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’ are the vertices, and ‘ab’, ‘bc’, ‘cd’, ‘da’, ‘ag’, ‘gf’,
‘ef’ are the edges of the graph. Since it is a non-directed graph, the edges ‘ab’ and ‘ba’ are
same. Similarly other edges also considered in the same way.
Directed Graph
In a directed graph, each edge has a direction.
Example
In the above graph, we have seven vertices ‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, and ‘g’, and eight edges
‘ab’, ‘cb’, ‘dc’, ‘ad’, ‘ec’, ‘fe’, ‘gf’, and ‘ga’. As it is a directed graph, each edge bears an
arrow mark that shows its direction. Note that in a directed graph, ‘ab’ is different from ‘ba’.
Simple Graph
A graph with no loops and no parallel edges is called a simple graph.
The maximum number of edges possible in a single graph with ‘n’ vertices is nC2
where nC2 = n(n – 1)/2.
The number of simple graphs possible with ‘n’ vertices = 2nc2 = 2n(n-1)/2.
Example
In the following graph, there are 3 vertices with 3 edges which is maximum excluding the
parallel edges and loops. This can be proved by using the above formulae.
The maximum number of edges with n=3 vertices −
n
C2 = n(n–1)/2
= 3(3–1)/2
= 6/2
= 3 edges
2nC2 = 2n(n-1)/2
= 23(3-1)/2
= 23
= 8
Connected Graph
A graph G is said to be connected if there exists a path between every pair of vertices.
There should be at least one edge for every vertex in the graph. So that we can say that it is
connected to some other vertex at the other side of the edge.
Example
In the following graph, each vertex has its own edge connected to other edge. Hence it is a
connected graph.
Disconnected Graph
A graph G is disconnected, if it does not contain at least two connected vertices.
Example 1
The following graph is an example of a Disconnected Graph, where there are two
components, one with ‘a’, ‘b’, ‘c’, ‘d’ vertices and another with ‘e’, ’f’, ‘g’, ‘h’ vertices.
The two components are independent and not connected to each other. Hence it is called
disconnected graph.
Example 2
In this example, there are two independent components, a-b-f-e and c-d, which are not
connected to each other. Hence this is a disconnected graph.
Regular Graph
A graph G is said to be regular, if all its vertices have the same degree. In a graph, if the
degree of each vertex is ‘k’, then the graph is called a ‘k-regular graph’.
Example
In the following graphs, all the vertices have the same degree. So these graphs are called
regular graphs.
In both the graphs, all the vertices have degree 2. They are called 2-Regular Graphs.
Complete Graph
A simple graph with ‘n’ mutual vertices is called a complete graph and it is denoted by ‘Kn’.
In the graph, a vertex should have edges with all other vertices, then it called a complete
graph.
In other words, if a vertex is connected to all other vertices in a graph, then it is called a
complete graph.
Example
In the following graphs, each vertex in the graph is connected with all the remaining vertices
in the graph except by itself.
In graph I,
a b c
In graph II,
p q r s
Cycle Graph
A simple graph with ‘n’ vertices (n >= 3) and ‘n’ edges is called a cycle graph if all its edges
form a cycle of length ‘n’.
If the degree of each vertex in the graph is two, then it is called a Cycle Graph.
Notation − Cn
Example
Graph III has 5 vertices with 5 edges which is forming a cycle ‘ik-km-ml-lj-ji’.
Wheel Graph
A wheel graph is obtained from a cycle graph Cn-1 by adding a new vertex. That new vertex is
called a Hub which is connected to all the vertices of Cn.
Notation − Wn
Example
Take a look at the following graphs. They are all wheel graphs.
In graph I, it is obtained from C3 by adding an vertex at the middle named as ‘d’. It is denoted
as W4.
In graph II, it is obtained from C4 by adding a vertex at the middle named as ‘t’. It is denoted
as W5.
In graph III, it is obtained from C6 by adding a vertex at the middle named as ‘o’. It is
denoted as W7.
Cyclic Graph
A graph with at least one cycle is called a cyclic graph.
Example
In the above example graph, we have two cycles a-b-c-d-a and c-f-g-e-c. Hence it is called a
cyclic graph.
Acyclic Graph
A graph with no cycles is called an acyclic graph.
Example
In the above example graph, we do not have any cycles. Hence it is a non-cyclic graph.
Bipartite Graph
A simple graph G = (V, E) with vertex partition V = {V1, V2} is called a bipartite graph if
every edge of E joins a vertex in V1 to a vertex in V2.
In general, a Bipertite graph has two sets of vertices, let us say, V1 and V2, and if an edge is
drawn, it should connect any vertex in set V1 to any vertex in set V2.
Example
In this graph, you can observe two sets of vertices − V1 and V2. Here, two edges named ‘ae’
and ‘bd’ are connecting the vertices of two sets V1 and V2.
In general, a complete bipartite graph connects each vertex from set V1 to each vertex from
set V2.
Example
The following graph is a complete bipartite graph because it has edges connecting each
vertex from set V1 to each vertex from set V2.
If |V1| = m and |V2| = n, then the complete bipartite graph is denoted by Km, n.
n2 4
K7, 3=21
K8, 2=16
K9, 1=9
If n=9, k5, 4 = ⌊ n2 4 ⌋ = ⌊ 92 4 ⌋ = 20
K7, 2=14
K8, 1=8
‘G’ is a bipartite graph if ‘G’ has no cycles of odd length. A special case of bipartite graph is
a star graph.
Star Graph
A complete bipartite graph of the form K1, n-1 is a star graph with n-vertices. A star graph is a
complete bipartite graph if a single vertex belongs to one set and all the remaining vertices
belong to the other set.
Example
In the above graphs, out of ‘n’ vertices, all the ‘n–1’ vertices are connected to a single vertex.
Hence it is in the form of K1, n-1 which are star graphs.
Complement of a Graph
Let 'G−' be a simple graph with some vertices as that of ‘G’ and an edge {U, V} is present in
'G−', if the edge is not present in G. It means, two vertices are adjacent in 'G−' if the two
vertices are not adjacent in G.
If the edges that exist in graph I are absent in another graph II, and if both graph I and graph
II are combined together to form a complete graph, then graph I and graph II are called
complements of each other.
Example
In the following example, graph-I has two edges ‘cd’ and ‘bd’. Its complement graph-II has
four edges.
Note that the edges in graph-I are not present in graph-II and vice versa. Hence, the
combination of both the graphs gives a complete graph of ‘n’ vertices.
Example
Let ‘G’ be a simple graph with nine vertices and twelve edges, find the number of edges in
'G-'.
12 + |E('G-')| =
9(9-1) / 2 = 9C2
12 + |E('G-')| = 36
|E('G-')| = 24
‘G’ is a simple graph with 40 edges and its complement 'G−' has 38 edges. Find the number
of vertices in the graph G or 'G−'.
40 + 38 = n(n-1) 2
156 = n(n-1)
13(12) = n(n-1)
n = 13
Isomorphic Graphs
Two graphs G1 and G2 are said to be isomorphic if −
Note − In short, out of the two isomorphic graphs, one is a tweaked version of the other. An
unlabelled graph also can be thought of as an isomorphic graph.
Note
If G1 ≡ G2 then −
|V(G1)| = |V(G2)|
|E(G1)| = |E(G2)|
If the vertices {V1, V2, .. Vk} form a cycle of length K in G1, then the vertices {f(V1),
f(V2),… f(Vk)} should form a cycle of length K in G2.
All the above conditions are necessary for the graphs G1 and G2 to be isomorphic, but not
sufficient to prove that the graphs are isomorphic.
(G1 ≡ G2) if and only if (G1− ≡ G2−) where G1 and G2 are simple graphs.
Example
Connectivity
A graph is said to be connected if there is a path between every pair of vertex. From every
vertex to any other vertex, there should be some path to traverse. That is called the
connectivity of a graph. A graph with multiple disconnected vertices and edges is said to be
disconnected.
Example 1
In the following graph, it is possible to travel from one vertex to any other vertex. For
example, one can traverse from vertex ‘a’ to vertex ‘e’ using the path ‘a-b-e’.
Example 2
In the following example, traversing from vertex ‘a’ to vertex ‘f’ is not possible because there
is no path between them directly or indirectly. Hence it is a disconnected graph.
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.
By removing ‘e’ or ‘c’, the graph will become a disconnected graph.
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.
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.
Note − Let ‘G’ be a connected graph with ‘n’ vertices, then
a cut edge e ∈ G if and only if the edge ‘e’ is not a part of any cycle in G.
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.
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 −
An Euler path is a path that uses every edge of a graph exactly once.
An Euler circuit is a circuit that uses every edge of a graph exactly once.
An Euler path starts and ends at different vertices.
An Euler circuit starts and ends at the same vertex.
Theorem – “A connected multigraph (and simple graph) with at least two vertices has a
Euler circuit if and only if each of its vertices has an even degree.”
Proof of the above statement is that every time a circuit passes through a vertex, it adds twice
to its degree. Since it is a circuit, it starts and ends at the same vertex, which makes it
contribute one degree when the circuit starts and one when it ends. In this way, every vertex
has an even degree.
Since the Koningsberg graph has vertices having odd degrees, a Euler circuit does not exist in
the graph.
Theorem – “A connected multigraph (and simple graph) has an Euler path but not an Euler
circuit if and only if it has exactly two vertices of odd degree.”
The proof is an extension of the proof given above. Since a path may start and end at
different vertices, the vertices where the path starts and ends are allowed to have odd degrees.
Example – Which graphs shown below have an Euler path or Euler circuit?
Solution – has two vertices of odd degree and and the rest of them have even
degree. So this graph has an Euler path but not an Euler circuit. The path starts and
ends at the vertices of odd degree. The path is- .
has four vertices all of even degree, so it has a Euler circuit. The circuit is –
.
Hamilonian Path – A simple path in a graph that passes through every vertex exactly
once is called a Hamiltonian path.
Hamilonian Circuit – A simple circuit in a graph that passes through every vertex exactly
once is called a Hamiltonian circuit.
Unlike Euler paths and circuits, there is no simple necessary and sufficient criteria to
determine if there are any Hamiltonian paths or circuits in a graph. But there are certain
criteria which rule out the existence of a Hamiltonian circuit in a graph, such as- if there is a
vertex of degree one in a graph then it is impossible for it to have a Hamiltonian circuit.
There are certain theorems which give sufficient but not necessary conditions for the
existence of Hamiltonian graphs.
Dirac’s Theorem- “If is a simple graph with vertices with such that the
degree of every vertex in is at least , then has a Hamiltonian circuit.”
Ore’s Theorem- “If is a simple graph with vertices with such that
for every pair of non-adjacent vertices and in ,
then has a Hamiltonian circuit.”
As mentioned above that the above theorems are sufficient but not necessary conditions for
the existence of a Hamiltonian circuit in a graph, there are certain graphs which have a
Hamiltonian circuit but do not follow the conditions in the above-mentioned theorem. For
example, the cycle has a Hamiltonian circuit but does not follow the theorems.
There are many practical problems which can be solved by finding the optimal Hamiltonian
circuit. One such problem is the Travelling Salesman Problem which asks for the shortest
route through a set of cities.
Solution- No the above graph does not have a Hamiltonian circuit as there are two
vertices with degree one in the graph.
Dijkstra’s algorithm is very similar to Prim’s algorithm for minimum spanning tree. Like
Prim’s MST, we generate a SPT (shortest path tree) with given source as root. We maintain
two sets, one set contains vertices included in shortest path tree, other set includes vertices
not yet included in shortest path tree. At every step of the algorithm, we find a vertex which
is in the other set (set of not yet included) and has a minimum distance from the source.
Below are the detailed steps used in Dijkstra’s algorithm to find the shortest path from a
single source vertex to all other vertices in the given graph.
Algorithm
1) Create a set sptSet (shortest path tree set) that keeps track of vertices included in shortest
path tree, i.e., whose minimum distance from source is calculated and finalized. Initially, this
set is empty.
2) Assign a distance value to all vertices in the input graph. Initialize all distance values as
INFINITE. Assign distance value as 0 for the source vertex so that it is picked first.
3) While sptSet doesn’t include all vertices
….a) Pick a vertex u which is not there in sptSet and has minimum distance value.
….b) Include u to sptSet.
….c) Update distance value of all adjacent vertices of u. To update the distance values, iterate
through all adjacent vertices. For every adjacent vertex v, if sum of distance value of u (from
source) and weight of edge u-v, is less than the distance value of v, then update the distance
value of v.
The set sptSet is initially empty and distances assigned to vertices are {0, INF, INF, INF,
INF, INF, INF, INF} where INF indicates infinite. Now pick the vertex with minimum
distance value. The vertex 0 is picked, include it in sptSet. So sptSet becomes {0}. After
including 0 to sptSet, update distance values of its adjacent vertices. Adjacent vertices of 0
are 1 and 7. The distance values of 1 and 7 are updated as 4 and 8. Following subgraph shows
vertices and their distance values, only the vertices with finite distance values are shown. The
vertices included in SPT are shown in green colour.
Pick the vertex with minimum distance value and not already included in SPT (not in
sptSET). The vertex 1 is picked and added to sptSet. So sptSet now becomes {0, 1}. Update
the distance values of adjacent vertices of 1. The distance value of vertex 2 becomes 12.
Pick the vertex with minimum distance value and not already included in SPT (not in
sptSET). Vertex 7 is picked. So sptSet now becomes {0, 1, 7}. Update the distance values of
adjacent vertices of 7. The distance value of vertex 6 and 8 becomes finite (15 and 9
respectively).
Pick the vertex with minimum distance value and not already included in SPT (not in
sptSET). Vertex 6 is picked. So sptSet now becomes {0, 1, 7, 6}. Update the distance values
of adjacent vertices of 6. The distance value of vertex 5 and 8 are updated.
We repeat the above steps until sptSet does include all vertices of given graph. Finally, we get
the following Shortest Path Tree (SPT).
PLANAR GRAPH
A graph 'G' is said to be planar if it can be drawn on a plane or a sphere so that no two edges
cross each other at a non-vertex point.
Example
Regions
Every planar graph divides the plane into connected areas called regions.
Example
deg(1) = 3
deg(2) = 4
deg(3) = 4
deg(4) = 3
deg(5) = 8
Degree of an unbounded region r = deg(r) = Number of edges enclosing the regions r.
deg(R1) = 4
deg(R2) = 6
1. In a planar graph with 'n' vertices, sum of degrees of all the vertices is
Based on the above theorem, you can draw the following conclusions −
In a planar graph,
K|R| = 2|E|
K|R| ≤ 2|E|
K|R| ≥ 2|E|
Where, |V| is the number of vertices, |E| is the number of edges, and |R| is the number of
regions.
If 'G' is a connected planar graph with degree of each region at least 'K' then,
K.|R| ≤ 2|E|
(K - 2)|E| ≤ K(|V| - 2)
|E| ≤ 3|V| − 6
|R| ≤ 2|V| − 4
6. If 'G' is a simple connected planar graph (with at least 2 edges) and no triangles, then
|E| ≤ {2|V| – 4}
7. Kuratowski's Theorem
A graph 'G' is non-planar if and only if 'G' has a subgraph which is homeomorphic to K5 or
K3,3.
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 is colored red. As the adjacent vertices of vertex a are again
adjacent, vertex b and vertex d are colored 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.