0% found this document useful (0 votes)
13 views19 pages

Graph Theory-2

Graph theory is a mathematical framework that studies graphs, which consist of nodes (vertices) connected by edges. It has numerous applications in real life, including social networks, navigation systems, and e-commerce recommendations. The document also discusses various types of graphs and their properties, such as directed and undirected graphs, cyclic and acyclic graphs, and specific concepts like Eulerian and Hamiltonian paths.

Uploaded by

mayurpanchal5514
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views19 pages

Graph Theory-2

Graph theory is a mathematical framework that studies graphs, which consist of nodes (vertices) connected by edges. It has numerous applications in real life, including social networks, navigation systems, and e-commerce recommendations. The document also discusses various types of graphs and their properties, such as directed and undirected graphs, cyclic and acyclic graphs, and specific concepts like Eulerian and Hamiltonian paths.

Uploaded by

mayurpanchal5514
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Graph Theory

A graph is a data structure that is defined by two components :

1. A node or a vertex.

2. An edge E or ordered pair which is a connection between two nodes u, v that is


identified by unique pair (u, v). The pair (u, v) is ordered because (u, v) is not same as
(v, u) in case of directed graph.

Consider the given below graph,

Applications: Graph is a data structure which is used extensively in our real-life.

1. Social Network: Each user is represented as a node and all their activities, suggestion
and friend list are represented as an edge between the nodes.

2. Google Maps: Various locations are represented as vertices or nodes and the roads
are represented as edges and graph theory is used to find shortest path between two
nodes.

3. Recommendations on e-commerce websites: The “Recommendations for you”


section on various e-commerce websites uses graph theory to recommend items of
similar type to user’s choice.

4. Graph theory is also used to study molecules in chemistry and physics.

Types of Graph
1. Undirected Graphs:

An undirected graph is a graph where the edges do not have a specific direction and
it is bidirectional in nature.
2. Directed Graphs:

A directed graph is a graph that is unidirectional, in this the edges have a specific
direction.

3. Null Graph:

A graph of order n and size zero is a graph where there are only isolated vertices with no
edges connecting any pair of vertices. A null graph is a graph with no edges. In other
words, it is a graph with only vertices and no connections between them.

4. Trivial Graph:

A graph is said to be trivial if a finite graph contains only one vertex and no edge. A
trivial graph is a graph with only one vertex and no edges. It is also known as a singleton
graph or a single vertex graph. A trivial graph is the simplest type of graph and is often
used as a starting point for building more complex graphs.
5. Simple Graph:

A simple graph is a graph that does not contain more than one edge between the pair of
vertices. A simple railway track connecting different cities is an example of a simple
graph.

6. Finite Graphs:

A graph is said to be finite if it has a finite number of vertices and a finite number of
edges. A finite graph is a graph with a finite number of vertices and edges. In other words,
both the number of vertices and the number of edges in a finite graph are limited and can
be counted.

7. Infinite Graph:

A graph is said to be infinite if it has an infinite number of vertices as well as an infinite


number of edges.

8. Multi Graph:

Any graph which contains some parallel edges but doesn’t contain any self-loop is called
a multigraph. For example a Road Map.

 Parallel Edges: If two vertices are connected with more than one edge then such
edges are called parallel edges that are many routes but one destination.
 Loop: An edge of a graph that starts from a vertex and ends at the same vertex is
called a loop or a self-loop.

9. Complete Graph:

A simple graph with n vertices is called a complete graph if the degree of each vertex is
n-1, that is, one vertex is attached with n-1 edges or the rest of the vertices in the graph. A
complete graph is also called Full Graph.

10. Pseudo Graph:


A graph G with a self-loop and some multiple edges is called a pseudo graph. A pseudograph
is a type of graph that allows for the existence of loops (edges that connect a vertex to itself)
and multiple edges (more than one edge connecting two vertices).

11. Regular Graph:

A simple graph is said to be regular if all vertices of graph G are of equal degree. All
complete graphs are regular but vice versa is not possible. A regular graph is a type of
undirected graph where every vertex has the same number of edges or neighbours.
12. Bipartite Graph:

A graph G = (V, E) is said to be a bipartite graph if its vertex set V(G) can be partitioned into
two non-empty disjoint subsets. V1(G) and V2(G) in such a way that each edge e of E(G) has
one end in V1(G) and another end in V2(G). The partition V1 U V2 = V is called Bipartite of
G. Here in the figure: V1(G)={V5, V4, V3} and V2(G)={V1, V2}

13. Labeled Graph:

If the vertices and edges of a graph are labeled with name, date, or weight then it is called a
labeled graph. It is also called Weighted Graph.
14. Connected or Disconnected Graph:

Graph G is said to be connected if any pair of vertices (Vi, Vj) of a graph G is reachable from
one another. Or a graph is said to be connected if there exists at least one path between each
and every pair of vertices in graph G, otherwise, it is disconnected.

NOTE: A null graph with n vertices is a disconnected graph consisting of n components.


Each component consists of one vertex and no edge.

15. Cyclic Graph:

A cyclic graph is defined as a graph that contains at least one cycle which is a path that
begins and ends at the same node, without passing through any other node twice.

16. Acyclic Graph:

A acyclic graph is defined as a graph with no cycle.

17. Complete Bipartite Graph


Complete bipartite graph is a special type of bipartite graph where every vertex of one set is
connected to every vertex of other set.
18. Planar Graph

A planar graph is a graph that we can draw in a plane in such a way that no two edges
intersect each other except at a vertex to which they meet.

19. Non-Planar Graph in Graph Theory

A graph that cannot be drawn without at least one pair of its crossing edges is known as a
non-planar graph.

Degree of Vertex of a Graph


In graph theory, the degree of a vertex is defined as the count of the number of connections of
edges with that vertex.

It is generally represented by, deg(V).

A vertex with degree one (i.e., deg(V)=1) is called a pendant vertex. Whereas a vertex with
degree zero (i.e., deg(V)=0 is called an isolated vertex.

How to Find the Degree of a Vertex

Degree of vertex can be considered under two cases of graphs −

 Undirected Graph
 Directed Graph

Degree of Vertex in an Undirected Graph

In an undirected graph degree of vertex ‘v’ is denoted as deg(v). It is equal to no. of edges
incident with the vertex.

Note: In undirected graph a loop at a vertex is counted as 2 degree.

Example 1

Take a look at the following graph −

In the above Undirected Graph,

 deg(a) = 2, as there are 2 edges meeting at vertex 'a'.


 deg(b) = 3, as there are 3 edges meeting at vertex 'b'.
 deg(c) = 1, as there is 1 edge formed at vertex 'c' So 'c' is a pendent vertex.
 deg(d) = 2, as there are 2 edges meeting at vertex 'd'.
 deg(e) = 0, as there are 0 edges formed at vertex 'e'. So 'e' is an isolated vertex.

Degree of Vertex in a Directed Graph

In directed graphs, we have two types of degrees:

 In degree, and
 Out degree.

In degree of a Graph

 In degree of vertex V is the number of edges which are coming into the vertex V.
 Notation : deg−(V).

Out degree of a Graph

 Out degree of vertex V is the number of edges which are going out from the vertex V.
 Notation : deg+(V).
Hence, in a directed graph, the degree of a vertex is equal to the sum of the in-degree and out-
degree of a vertex, i.e., deg(V)= deg−(V)+ deg+(V).

Consider the following examples.

In degree Out degree Degree


deg-(A)=1 deg+(A)=2 deg(A)=3
deg-(B)=1 deg+(B)=1 deg(B)=2
deg-(C)=1 deg+(C)=2 deg(C)=3
deg-(D)=2 deg+(D)=0 deg(D)=2

Handshaking Theorem

Handshaking Theorem is also known as Handshaking Lemma or Sum of Degree Theorem.

In Graph Theory, Handshaking Theorem states in any given graph, Sum of degree of all the
vertices is twice the number of edges contained in it.

∑ ( )

Where, v is vertex and E is edges.

Questions:
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

Let number of vertices in the graph = n.

Using Handshaking Theorem, we have-

Sum of degree of all vertices = 2 x Number of edges

Substituting the values, we get

n x 4 = 2 x 24
NOTE: In any graph,

 The sum of degree of all the vertices is always even.


 The sum of degree of all the vertices with odd degree is always even.
 The number of vertices with odd degree are always even.

Subgraph:

A subgraph G of a graph G’ whose vertex set and edge set subsets of the graph G. In simple
words a graph is said to be a subgraph if it is a part of another graph.

There are 2 different types of subgraph:

Vertex Disjoint in Graph Theory

A subgraph with no common vertex is called a vertex disjoint subgraph of the parent graph
G. Since the vertices in a vertex disjoint graph cannot have a common edge, a vertex disjoint
subgraph will always be an edge-disjoint subgraph.

Edge Disjoint in Graph Theory

A subgraph with no common edge is called an edge-disjoint subgraph of graph G.


Isomorphic Graph:

Definition: If G1(v1, e1) and G2(v2, e2) are said to be isomorphic if there exists one to one
corresponding between their vertices and edges.

If two graphs are isomorphic, they must have:

- the same number of vertices

- the same number of edges

- the same degrees for corresponding vertices

- the same number of connected components

- the same number of loops

- the same number of parallel edges.

- both graphs are connected or both graphs are not connected, and

- pairs of connected vertices must have the corresponding pair of vertices connected.
Firstly, label the graphs. It “looks” true, so check all the things we know:

Number of vertices: both 5.

Number of edges: both 5.

Degrees of corresponding vertices: all degree 2.

Connectedness: Each is fully connected.

Number of connected components: Both 1.

Pairs of connected vertices: All correspond.

Number of loops: 0.

Number of parallel edges: 0.

Everything is equal and so the graphs are isomorphic.

Homemorphic Graph

Two graph G1 and G2 are said to be homeomorphic graphs, if one can be obtained from
other by introduction of new vertices on existing edges.
Example:

G1 G2

Both the graph G1 and G2 are homeomorphic Graph.

Graph Representation:

Graph can be represented in the following ways:

1. Set Representation: Set representation of a graph involves two sets: Set of vertices V
= {V1, V2, V3, V4} and set of edges E = {{V1, V2}, {V2, V3}, {V3, V4}, {V4, V1}}. This
representation is efficient for memory but does not allow parallel edges.

2. Sequential Representation: This representation of a graph can be represented by


means of matrices: Adjacency Matrix, Incidence matrix and Path matrix.
o Adjacency Matrix: This matrix includes information about the adjacent
nodes. Here, aij = 1 if there is an edge from Vi to Vj otherwise 0. It is a matrix
of order V×V.

o Incidence Matrix: This matrix includes information about the incidence of


edges on the nodes. Here, aij = 1 if the jth edge Ej is incident on ith vertex Vi
otherwise 0. It is a matrix of order V×E.

o Path Matrix: This matrix includes information about the simple path between
two vertices. Here, Pij = 1 if there is a path from Vi to Vj otherwise 0. It is also
called as reachability matrix of graph G.

Adjacency Matrix

Example:

Create an adjacency matrix for a given undirected graph


Adjacency Matrix for undirected graph

vertex v0 v1 v2 v3 v4
v0 0 1 1 1 0
v1 1 0 0 1 1
v2 1 0 0 1 0
v3 1 1 1 0 1
v4 0 1 0 1 0

Adjacency Matrix for directed graph

vertex v0 v1 v2 v3 v4
v0 0 1 1 1 0
v1 0 0 0 1 1
v2 0 0 0 1 0
v3 0 0 0 0 1
v4 0 0 0 0 0

Example: Adjacency Matrix


Incidence Matrix

Example:

Example:
Path and Circuit

1. Walk –

A walk is a sequence of vertices and edges of a graph i.e. if we traverse a graph


then we get a walk.
Edge and Vertices both can be repeated.

Here, 1->2->3->4->2->1->3 is a walk.

Walk can be open or closed.

Open walk- A walk is said to be an open walk if the starting and ending vertices are different
i.e. the origin vertex and terminal vertex are different.
Closed walk- A walk is said to be a closed walk if the starting and ending vertices are
identical i.e. if a walk starts and ends at the same vertex, then it is said to be a closed walk.

2. Trail –
Trail is an open walk in which no edge is repeated.

Vertex can be repeated.

Here 1->3->8->6->3->2 is trail


Also 1->3->8->6->3->2->1 will be a closed trail

2. Circuit –
Traversing a graph such that not an edge is repeated but vertex can be repeated and it is
closed also i.e. it is a closed trail.

Vertex can be repeated.


Edge cannot be repeated.
Here 1->2->4->3->6->8->3->1 is a circuit.

Circuit is a closed trail.

These can have repeated vertices only.

3. Path –
It is a trail in which neither vertices nor edges are repeated i.e. if we traverse a graph such
that we do not repeat a vertex and nor we repeat an edge.

Vertex not repeated


Edge not repeated

Here 6->8->3->1->2->4 is a Path

5. Cycle –
Traversing a graph such that we do not repeat a vertex nor we repeat a edge but the starting
and ending vertex must be same i.e. we can repeat starting and ending vertex only then we
get a cycle.

Vertex not repeated


Edge not repeated
Here 1->2->4->3->1 is a cycle.

Cycle is a closed path.

These cannot have repeat anything (neither edges nor vertices).

Eulerian Path and Eulerian Circuit

Eulerian path is a path in a graph that visits every edge exactly once. Eulerian Circuit is an
Eulerian Path that starts and ends on the same vertex.
To detect the path and circuit, we have to follow these conditions −

 The graph must be connected.


 A graph will contain an Euler path if it contains at most two vertices of odd degree.
 A graph will contain an Euler circuit if all vertices have even degree

Hamiltonian paths and circuits

 Hamiltonian Path – A Hamiltonian path in a graph is a path that visits every vertex
exactly once. In other words, it is a sequence of vertices in a graph such that no vertex
is visited more than once.

Hamiltonian Circuit – A Hamiltonian circuit (or cycle) in a graph is a closed path that
visits every vertex exactly once, except for the starting vertex which is also the ending
vertex.

In the above example of Hamiltonian path

Graph a. has a Hamilton circuit (one example is ACDBEA)

Graph b. has no Hamilton circuits, though it has a Hamilton path (one example is
ABCDEJGIFH)

Graph c. has a Hamilton circuit (one example is AGFECDBA)

You might also like