Introduction To Graph Theory
Introduction To Graph Theory
1.2 Introduction:
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.
Definition of 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 −
In the above graph,
V = {a, b, c, d, e}
E = {ab, ac, bd, cd, de}
Directed Graph
A directed graph is a graph in which the edges are directed by arrows.
Example:
In the above graph, each edge is directed by the arrow. A directed edge has an arrow from A to
B, means A is related to B, but B is not related to A.
Undirected Graph
An undirected graph is a graph whose edges are not directed.
Example
In the above graph since there is no directed edges, therefore it is an undirected graph.
Weighted Graph
A weighted graph is a graph whose edges have been labeled with some weights or numbers.
The length of a path in a weighted graph is the sum of the weights of all the edges in the path.
Example
In the above graph, if path is a -> b -> c -> d -> e -> g then the length of the path is 5 + 4 + 5 + 6
+ 5 = 25.
Degree of a Vertex:
The degree of a vertex is the number of edges incident on a vertex v. The self-loop is counted
twice. The degree of a vertex is denoted by d (v)
Example1: Consider the graph G shown in fig. Determine the degree of each vertex.
Solution: The degree of each vertex is as follows:
Example2 : Verify that the sum of the degrees of all the vertices is even for the graph shown in
fig:
Path:
A path of length n is a sequence of n+1 vertices of a graph in which each pair of vertices is an
edge of the graph.
1. A Simple Path: The path is called simple one if no edge is repeated in the path, i.e., all
the vertices are distinct except that first vertex equal to the last vertex.
2. An Elementary Path: The path is called elementary one if no vertex is repeated in the
path, i.e., all the vertices are distinct.
3. Circuit or Closed Path: The circuit or closed path is a path in which starts and ends at
the same vertex, i.e., v0=vn.
4. Simple Circuit Path: The simple circuit is a simple path which is a circuit.
Example: Consider the graph shown in fig: Give an example of the following:
Pendant Vertex:
A vertex with degree one is called a Pendant Vertex.
Pendant Edge:
The only edge which is an incident with a pendant vertex is called the Pendant Edge.
Odd Vertex:
A vertex having degree odd is called an odd vertex.
Even Vertex:
A vertex having a degree even is called an even vertex.
Incident Edge:
An edge is called incident with the vertices is connects.
Adjacent Vertices:
Two vertices are called adjacent if an edge links them. If there is an edge (u, v), then we can say
vertex u is adjacent to vertex v, and vertex v is adjacent to vertex u.
Solution:
Self-Loop:
A self-loop is an edge e if it has the same endpoint.
The graph shown in fig contains the self-loop at vertex b, i.e., e=(b, b).
Isolated Vertex:
A vertex with degree 0 is called Isolated Vertex.
Handshaking Theorem:
Statement: The sum of degrees of the vertices of a graph is twice the number of edges.
Σ deg G(V) = 2E
Proof: Since the degree of a vertex is the number of edges incident with that vertex, the sum of
degree counts the total number of times an edge is incident with a vertex.
Since every edge is incident with exactly two vertices , each edge gets counted twice, once at
each end.
Thus the sum of the degrees is equal twice the number of edges.
Remark:
This theorem applies even if multiple edges and loops are present. The theorem holds this rule
that if several people shake hands, the total number of hands shake must be even that is why
the theorem is called handshaking theorem.
Example:
A simple graph G has 24 edges and degree of each vertex is 4. Find the number of vertices.
Solution:
Given
Number of edges = 24
Degree of each vertex = 4
Graph Representations
In graph theory, a graph representation is a technique to store graph into the memory of
computer.
To represent a graph, we just need the set of vertices, and for each vertex the neighbors of the
vertex (vertices which is directly connected to it by an edge). If it is a weighted graph, then the
weight will be associated with each edge.
There are different ways to optimally represent a graph, depending on the density of its edges,
type of operations to be performed and ease of use.
1. Adjacency Matrix
o Adjacency matrix is a sequential representation.
o It is used to represent which nodes are adjacent to each other. i.e. is there any edge
connecting nodes to a graph.
o In this representation, we have to construct a nXn matrix A. If there is any edge from a
vertex i to vertex j, then the corresponding element of A, ai,j = 1, otherwise ai,j= 0.
o If there is any weighted graph then instead of 1s and 0s, we can store the weight of the
edge.
Example
In the above examples, 1 represents an edge from row vertex to column vertex, and 0 represents
no edge from row vertex to column vertex.
Cons: It takes a lot of space and time to visit all the neighbors of a vertex, we have to traverse all
the vertices in the graph, which takes quite some time.
2. Incidence Matrix
In Incidence matrix representation, graph can be represented using a matrix of size:
It means if a graph has 4 vertices and 6 edges, then it can be represented using a matrix of 4X6
class. In this matrix, columns represent edges and rows represent vertices.
Example
In computer science graph theory is used for the study of algorithms like:
o Dijkstra's Algorithm
o Prims's Algorithm
o Kruskal's Algorithm
Practice Questions
1. In any graph, the number of vertices of odd degree is even.
2. Determine number of edges in a graph with 5 nodes, 2 of degree 3 and 3 of degree 2
FAQ
Q.1 What is the purpose of graph theory?
Ans: In mathematics, graph theory is the study of graphs, which are mathematical structures
used to model pairwise relations between objects. A graph in this context is made up of vertices
(also called nodes or points) which are connected by edges (also called links or lines).
Ans: Eulerian refers to the Swiss mathematician Leonhard Euler, who invented graph theory in
the 18th century.
Summary
In this lecture, we have discussed about
Introduction to Graph
Various properties in graph
Handshaking theorem
Representation of graph
REFERENCES
Books
[1] Elements of Discrete Mathematics, (Second Edition) C. L. Liu, McGraw Hill, New Delhi,
2017
[2] G. Ronald, Knuth, Donald and Patashik Oren, concrete Mathematics: A Foundation for
Computer Science", Addison-Wesley.
Websites
[1] https://www.tutorialspoint.com/graph_theory/graph_theory_fundamentals.htm
[2] https://www.javatpoint.com/introduction-of-graphs
Courses
[1] https://www.coursera.org/specializations/discrete-mathematics
[2] https://www.classcentral.com/course/swayam-discrete-mathematics-12929
Video Links
[1] https://www.youtube.com/watch?v=gbPFyGP_EzU
[2] https://www.youtube.com/watch?v=HkNdNpKUByM