Graph
Graph
A graph is a set of points, called nodes or vertices, which are interconnected by a set of lines
called edges.
{a,c},{b,c},{c,d}}
Degree of a Vertex − The degree of a vertex V of a graph G (denoted by deg (V)) is the
number of edges incident with the vertex V.
a 2 even
b 2 even
c 3 odd
d 1 odd
Even and Odd Vertex − If the degree of a vertex is even, the vertex is called an even vertex
and if the degree of a vertex is odd, the vertex is called an odd vertex.
Degree of a Graph − The degree of a graph is the largest vertex degree of that graph. For the
above graph the degree of the graph is 3.
The Handshaking Lemma − In a graph, the sum of all the degrees of all the vertices is equal to
twice the number of edges.
Types of Graphs
There are different types of graphs
Null Graph
A null graph has no edges. The null graph of n vertices is denoted by Nn
Simple Graph
A graph is called simple graph/strict graph if the graph is undirected and does not contain any
loops or multiple edges.
Multi-Graph
If in a graph multiple edges between the same set of vertices are allowed, it is called
Multigraph. In other words, it is a graph having at least one loop or multiple edges.
Directed and Undirected Graph
A graph G=(V,E) is called a directed graph if the edge set is made of ordered vertex pair and a
graph is called undirected if the edge set is made of unordered vertex pair.
disconnected, then every maximal connected subgraph of G is called a connected component of
the graph G.
Regular Graph
A graph is regular if all the vertices of the graph have the same degree. In a regular graph G of
Complete Graph
A graph is called complete graph if every two vertices pair are joined by exactly one edge. The
denoted by Cn
Representation of Graphs
There are mainly two ways to represent a graph −
Adjacency Matrix
Adjacency List
Adjacency Matrix
Let us consider the following undirected graph and construct the adjacency matrix −
a b c D
a 0 1 1 0
b 1 0 1 0
c 1 1 0 1
d 0 0 1 0
a b c D
a 0 1 1 0
b 0 0 1 0
c 0 0 0 1
d 0 0 0 0
Isomorphism
If two graphs G and H contain the same number of vertices connected in the same way, they are
Example
Euler Graphs
A connected graph G is called an Euler graph, if there is a closed trail which includes every
edge of the graph G. An Euler path is a path that uses every edge of a graph exactly once. An
Euler path starts and ends at different vertices.
An Euler circuit is a circuit that uses every edge of a graph exactly once. An Euler circuit
always starts and ends at the same vertex. A connected graph G is an Euler graph if and only if
all vertices of G are of even degree, and a connected graph G is Eulerian if and only if its edge
set can be decomposed into cycles.
The above graph is an Euler graph as “a1b2c3d4e5c6f7g” covers all the edges of the graph.
Hamiltonian Graphs
A connected graph G is called Hamiltonian graph if there is a cycle which includes every vertex
of G and the cycle is called Hamiltonian cycle. Hamiltonian walk in graph G is a walk that
passes through each vertex exactly once.