Introduction to Graph Theory (original) (raw)

Last Updated : 26 Dec, 2025

In many real-world situations, we often deal with a set of objects and the relationships between them. For example, cities connected by roads, people linked through friendships, or computers connected in a network. To study such relationships mathematically, we utilize graph theory.

Given below are some applications of graph theory in real life:

Graph Theory is a branch of mathematics that deals with graphs—structures made up of vertices (points) and edges (lines). These graphs help us model and solve problems in computer science, engineering, biology, logistics, and many other fields.

Definition of Graph

A graph is a mathematical structure used to represent a set of objects and the connections between them:

Graph

A Simple Graph

Formally: A graph G is defined as: G - (V, E)

Where:

Basic Concepts

Below are the basic terminologies used in graph theory.

**Vertex (Node): A fundamental element of a graph, representing an object, entity, or point.

**Edge (Link): A connection between two vertices, showing a relationship or pathway.

**Adjacent Vertices: Two vertices that are directly connected by an edge.

**Degree of a Vertex: The number of edges incident on a vertex.

**Path: A sequence of vertices connected by edges, with no vertex repeated.

**Cycle: A path that begins and ends at the same vertex, forming a closed loop.

**Connected Graph: A graph in which there exists a path between every pair of vertices.

**Subgraph: A smaller graph formed using a subset of the vertices and edges of a larger graph.

**Loop: An edge that connects a vertex back to itself.

**Parallel Edges: Two or more edges that connect the same pair of vertices.

Introduction-to-Graphs

**Explanation of the image above:

**Types of Graphs

Graphs are of two types based on the type of edge, these are:

8

Graph Classification

**Directed Graph

A graph in which the direction of the edge is defined for a particular node is a directed graph.

unidirected

**Directed Acyclic: It is a directed graph with no cycle. For a vertex ‘v’ in DAG, there is no directed edge starting and ending with vertex ‘v’. The arrows go in one direction only (Directed), and you can’t go in a circle or loop (Acyclic).

**Tree: A tree is just a restricted form of graph. That is, it is a DAG with a restriction that a child can have only one parent.

**Undirected Graph

An undirected graph in which the direction of the edge is not defined. So if an edge exists between node ‘u’ and ‘v’, then there is a path from node ‘u’ to ‘v’ and vice versa.

directed-

**Connected graph: A graph is connected when there is a path between every pair of vertices. In a connected graph, there is no unreachable node.

**Complete graph: A graph in which each pair of graph vertices is connected by an edge. In other words, every node ‘u’ is adjacent to every other node ‘v’ in graph ‘G’. A complete graph would have n(n-1)/2 edges.

**Biconnected graph: A connected graph that cannot be broken down into any further pieces by the deletion of any vertex. It is a graph with no articulation point.

**Some Important Graphs

**1. Regular Graph: A graph in which every vertex x has the same/equal degree. A K-regular graph means every vertex has k edges. Every complete graph Kn will have (n-1)-regular graph, which means the degree is n-1.

regular-Graphs

Regular Graphs

**2. Bipartite Graph: It is a graph G in which the vertex set can be partitioned into two subsets U and V such that each edge of G has one end in U and another end point in V.

Bipartite-Graph

Bipartite Graph

**3. Complete Bipartite graph: It is a simple graph with a vertex set partitioned into two subsets, u and w.

U = {v1, v2 , v3, ..., vm} and W = {w1, w2, w3, ..., wn}

The elements in these sets are the vertices.

  1. There is an edge from each vi to each wj.
  2. There is no self-loop.

Complete-Bipartite

Complete Bipartite graph

**4. Cycle graph: It is a connected graph where each vertex has degree 2, forming a single closed loop without any branches or endpoints. This graph contains at least 3 vertices. Suppose a graph has the following vertices:

v1, v2, v3, ..., vn

This graph will be a cycle graph if it has edges as follows:

(v1,v2), (v2,v3), (v3,v4), ..., (vn-1,vn), (vn,v1).

Cycle-Graph

Cycle Graphs

**Applications of Graph Theory in CS

The major applications of Graph Theory in Computer Science are:

Solved Question on Basic Graph Theory

**Question 1: If a vertex has 4 edges connected to it in an undirected graph, what is its degree?

**Solution:

The degree is 4.

In an undirected graph, the degree of a vertex is simply the number of edges incident to (connected to) it.

**Question 2: In an undirected graph with 6 vertices, can the maximum degree of a vertex be 6? Why or why not?

**Solution:

No, it cannot be 6. The maximum possible degree is 5.

**Why?
A vertex cannot connect to itself (in a simple graph), and it can connect to at most all the _other vertices.
If there are 6 vertices total, one vertex can connect to at most the other 5 vertices.

So, maximum degree = n−1=5n - 1 = 5n−1=5.

**Question 3: For V = {1, 2, 3, 4}, find all unordered pairs and total edges in K4.

**Solution:

Unordered pairs =
{1, 2}, {1, 3}, {1, 4}, {2, 3}, {2, 4}, {3, 4}

Total = 6 edges.
Formula check: (n(n − 1))/2 = (4 × 3)/2 = 6

**Question 4: Graph with edges E = {{A, B}, {B, C}, {C, D}, {D, A}}. Find the order and size of the graph and determine the degree of each vertex.

**Solution:

**Question 5: Find the degree of each vertex in the graph having edges E = {ab, bc, cd, da, ac}

**Solution :

Vertices are a, b, c,d

Unsolved Question on Basic Graph Theory

**Question 1: Graph with vertices V = {1, 2, 3, 4, 5}. Find the number of edges in the complete graph K5.

**Question 2: Graph with edges E = {{1, 2}, {2, 3}, {3, 4}, {4, 5}}. Find the order, size, and degree of each vertex.

**Question 3: Find the number of edges and degree of each vertex in the complete bipartite graph K3,4.

**Question 4: Find the number of spanning trees in K4.