Open In App

Fundamentals of Graph Theory

Last Updated : 05 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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.

What is a Graph?

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).

Definition of Graph

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,

  • V = {a, b, c, d, e, f}
  • E = {ab, af, bc, cd, de, ef}

This graph can be represented as follows:

Examples in Real Life

Some common real life examples of graphs are:

  • Social Networks: Vertices represent people, and edges represent friendships.
  • Transportation Networks: Vertices represent locations, and edges represent routes or connections.
  • Computer Networks: Vertices represent computers or devices, and edges represent communication links.

Basic Concepts in Graph Theory

Some of the basic concepts in graph theory are:

  • Vertex
  • Edge
  • Loop

Let's discuss these concepts in detail as follows:

Vertex or Nodes

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.

Multiple Edges

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.

Loop

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.

Types of Graphs

There are various types of graphs in graph theory, some of these are:

  • Null Graph
  • Trivial Graph
  • Simple Graph
  • Undirected Graph
  • Directed Graph
  • Weighted Graphs
  • Complete Graph
  • Bipartite Graphs

Let's discuss these types in detail as follows:

Null Graph

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:

  • Vertex set V: {A, B, C}
  • Edge set E: { } or Ï•

Note: Each vertex in a null graph has a degree of zero, since there are no edges connected to any vertex.

Trivial Graph

A trivial graph is the simplest type of graph, consisting of exactly one vertex and no edges.

Consider a trivial graph with one vertices:

  • Vertex set V: {A}
  • Edge set E: { } or Ï•

Simple Graph

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:

  • Vertex set V: {A, B, C, D}
  • Edge set E: { {A, B}, {A, C}, {B, D}, {C, D} }

Undirected Graph

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:

  • Vertex set V: {A, B, C, D}
  • Edge set E: { {A, B}, {A, C}, {B, D}, {C, D} }

Directed Graph

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:

  • Vertex set V: {A, B, C, D}
  • Edge set E: { (A, B), (A, C), (B, D), (C, D)}

Weighted Graphs

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

  • Vertex set V: {A, B, C, D}
  • Edge set E: { (A, B, 3), (A, C, 5), (B, D, 2), (C, D, 1) }

Complete Graph

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:

  • Vertex set V: {A, B, C, D}
  • Edge set E: { {A, B}, {A, C}, {A, D}, {B, C}, {B, D}, {C, D} }

Note: Number of Edges in complete graphs with n vertices is n(n - 1)/2.

Bipartite Graphs

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:

  • Vertex sets V1​: {A, B}, V2​: {C, D}
  • Edge set E: { {A, C}, {A, D}, {B, C} }

Cycle Graph

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:

  • Vertex set V: {A, B, C, D}
  • Edge set E: {{A, B}, {B, C}, {C, D}, {D, A} }

Some other Important Graphs

Some other important graphs includes:

  • Tree
  • Eulerian Graph
  • Hamiltonian Graph

Tree

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:

  • Vertex set V: {A, B, C, D, E}
  • Edge set E: { {A, B}, {A, C}, {B, D}, {B, E} }

Eulerian Graph

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:

  • V = {A, B, C, D}
  • E = {{A,B}, {B,C}, {C,D}, {D,A}, {A,C}, {B,D}}

Hamiltonian Graph

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:

  • V = {A, B, C, D, E}
  • E = {{A,B}, {B,C}, {C,D}, {D,E}, {E,A}, {A,C}, {B,D}}

Representations of Graphs

Other then graphical representation, there are some more important representations of graphs such as

  • Adjacency Matrix
  • Adjacency List
  • Incidence Matrix

Let's discuss these representation with examples:

Adjacency Matrix

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

  • V = {A, B, C, D}
  • E = {{A,B}, {A,C}, {B,C}, {C,D}}

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

Adjacency List

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

  • V = {A, B, C, D}
  • E = {{A,B}, {A,C}, {B,C}, {C,D}}

The adjacency list representation for this graph is:

VertexAdjacent Vertices
AB, C
BA, C
CA, B, D
DC

Incidence Matrix

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

  • V = {A, B, C, D}
  • E = {e1{A,B}, e2{A,C}, e3{B,C}, e4{C,D}, e5{B, D}}

The incidence matrix for this graph is:

Vertex / Edgee1 (A-B)e2 (A-C)e3 (B-C)e4 (C-D)e5 (B-D)
A11000
B10101
C01110
D00011

Applications of Graph Theory

Some of the common applications of graph theory are:

  • Graphs are used to simulate biological systems' interactions between molecules or genes, computer networks' communication linkages, transportation networks' roads and routes, and social networks' friendships and relationships between individuals.
  • Graphs are used by recommendation systems to make content or connection suggestions depending on user interactions.
  • All things considered, graphs are a versatile tool for connection analysis in various settings.
  • Graphs are fundamental in mathematics, especially in combinatorial problems and proofs. Topology studies graph characteristics under transformations.
  • Computer Science Data Structures include trees, heaps, and hash maps implemented using graphs. Computer networks are graphically represented with computers or routers as vertices and connections as edges.
  • Graph theory algorithms include Prim's, Kruskal's, Ford-Fulkerson, Dijkstra's, and Bellman-Ford.
  • Language syntax trees show syntactic structure while semantic networks represent semantic relationships between words and concepts.

Next Article
Article Tags :

Similar Reads