![]() |
VOOZH | about |
Graph theory is a branch of mathematics that studies the properties and applications of graphs. A graph is a collection of vertices (also called nodes) connected by edges (also called links). Graphs are used to model pairwise relations between objects, making them a powerful tool for representing and analyzing complex systems in various fields.
In this article, we will discuss all the fundamentals of graph theory, from its definition to its types, and various ways to represent graphs as well.
Table of Content
A graph is a mathematical structure used to model pairwise relations between objects. It consists of two primary components: vertices (also called nodes) and edges (also called links).
A graph G can be defined as an ordered pair (V,E) where:
- V is a set of vertices.
- E is a set of edges, where each edge is a pair of vertices from V.
For example, G = (V, E) is a graph such that,
This graph can be represented as follows:
Some common real life examples of graphs are:
Some of the basic concepts in graph theory are:
Let's discuss these concepts in detail as follows:
A vertex is a point where lines meet in a graph and is denoted by an alphabet. It can also be called a node or a junction. In graph theory, a vertex is one of the points that the graph is defined on and can be connected by edges. It is often represented by alphabets, numbers, or alphanumeric values.
In mathematics, a line that joins two vertices to form a link in a graph is called an edge. It can have more than one edge from a single vertex, but it must have a beginning and an ending vertex in order to exist. An edge can be directed (having a defined path) or undirected (having no direction), often referred to as a line, branch, link, or arc. It is analogous to having an undirected edge link two vertices when there are two directed edges between them. Therefore, in mathematical contexts, edges are essential for joining vertices and creating connections.
In graph theory, multiple edges (also known as parallel edges) refer to two or more edges that connect the same pair of vertices. Graphs that allow multiple edges between pairs of vertices are known as multigraphs.
A loop is a special type of graph where both endpoints of an edge are the same vertices or when an edge starts from itself and end on itself too, it is called a loop.
There are various types of graphs in graph theory, some of these are:
Let's discuss these types in detail as follows:
A null graph, also known as an empty graph, is a type of graph in which the vertex setV is non-empty, but the edge set E is empty.
In other words, a null graph has vertices but no edges connecting any pairs of vertices.
Consider a null graph with three vertices:
Note: Each vertex in a null graph has a degree of zero, since there are no edges connected to any vertex.
A trivial graph is the simplest type of graph, consisting of exactly one vertex and no edges.
Consider a trivial graph with one vertices:
A simple graph is a type of graph in which each pair of vertices is connected by at most one edge, and no vertex has an edge to itself.
This means that a simple graph does not contain any loops (edges that connect a vertex to itself) or multiple edges between the same pair of vertices.
Consider a simple graph with four vertices:
An undirected graph is a type of graph in which the edges have no direction.
This means that the relationship between any pair of connected vertices is mutual. In an undirected graph, the edge (u, v) is identical to the edge (v, u).
Consider an undirected graph with four vertices:
A directed graph, also known as a digraph, is a type of graph where the edges have a direction.
In other words, each edge has a starting vertex (source) and an ending vertex (destination), indicating a one-way relationship between the vertices.
Consider a directed graph with four vertices:
A weighted graph is a type of graph in which each edge is assigned a weight (or cost).
These weights can represent various quantities such as distances, costs, capacities, or any other metric that quantifies the relationship between vertices.
Consider a weighted graph with four vertices
If every vertex in a graph G is linked to every other vertex in the graph, then the graph is said to be complete. Therefore, every graph G has to be linked. Kn represents the whole graph with n vertices.
Consider a complete graph with four vertices:
Note: Number of Edges in complete graphs with n vertices is n(n - 1)/2.
A bipartite graph is a type of graph where the vertex set can be divided into two disjoint sets such that no two vertices within the same set are adjacent.
This means that every edge in a bipartite graph connects a vertex in one set to a vertex in the other set.
Consider a bipartite graph with vertex sets:
A cycle graph, also known as a circular graph, is a type of graph that forms a single cycle.
In a cycle graph, each vertex has exactly two neighbors, creating a closed loop.
Consider a cycle graph C4 with four vertices:
Some other important graphs includes:
A tree is a type of graph that is connected and acyclic.
In other words, a tree is a connected graph with no cycles. Trees are fundamental structures in graph theory and have numerous applications in computer science, biology, and other fields.
Consider a tree with five vertices:
An Eulerian graph is a graph in which there exists a trail, called an Eulerian trail, that visits every edge exactly once.
If this trail is a circuit (i.e., it starts and ends at the same vertex), it is called an Eulerian circuit.Eulerian graphs are named after the Swiss mathematician Leonhard Euler, who introduced this concept while solving the famous Seven Bridges of Königsberg problem.
Consider an undirected graph with vertices:
A Hamiltonian graph is a graph that contains a Hamiltonian circuit, which is a cycle that visits each vertex exactly once and returns to the starting vertex.
If the graph contains a Hamiltonian path (a path that visits each vertex exactly once but does not necessarily return to the starting vertex), it is called a semi-Hamiltonian graph.
Consider a Hamiltonian graph with five vertices:
Other then graphical representation, there are some more important representations of graphs such as
Let's discuss these representation with examples:
An adjacency matrix is a way of representing a graph as a matrix of booleans (0s and 1s) or numbers. The matrix is a 2D array of size n × n, where n is the number of vertices in the graph.
Each cell a[i][j] in the matrix indicates whether there is an edge from vertex i to vertex j. In weighted graphs, the cell a[i][j] can contain the weight of the edge instead of a boolean value.
Consider an undirected graph with four vertices
The adjacency matrix for this graph is:
A | B | C | D | |
|---|---|---|---|---|
A | 0 | 1 | 1 | 0 |
B | 1 | 0 | 1 | 0 |
C | 1 | 1 | 0 | 1 |
D | 0 | 0 | 1 | 0 |
An adjacency list is a way of representing a graph where each vertex has a list of all the vertices it is connected to.
This representation is particularly efficient for sparse graphs where the number of edges is much less than the number of vertices squared.
Consider an undirected graph with four vertices
The adjacency list representation for this graph is:
| Vertex | Adjacent Vertices |
|---|---|
| A | B, C |
| B | A, C |
| C | A, B, D |
| D | C |
An incidence matrix is a way of representing a graph that shows the relationship between vertices and edges.
It is a 2D array of size n × m, where n is the number of vertices and m is the number of edges in the graph. Each cell in the matrix indicates whether a given vertex is incident to a given edge.
Consider an undirected graph with four vertices
The incidence matrix for this graph is:
| Vertex / Edge | e1 (A-B) | e2 (A-C) | e3 (B-C) | e4 (C-D) | e5 (B-D) |
|---|---|---|---|---|---|
| A | 1 | 1 | 0 | 0 | 0 |
| B | 1 | 0 | 1 | 0 | 1 |
| C | 0 | 1 | 1 | 1 | 0 |
| D | 0 | 0 | 0 | 1 | 1 |
Some of the common applications of graph theory are: