0% found this document useful (0 votes)
8 views80 pages

DM-Unit IV-Graph Th_final

This document provides an overview of graph theory, covering key concepts such as graph terminology, types of graphs, graph representation, isomorphism, connectivity, Euler and Hamilton paths, and the handshaking lemma. It explains various graph types, including simple, complete, bipartite, and weighted graphs, as well as methods for representing graphs like adjacency matrices and lists. Additionally, it discusses the applications of graph theory in fields like computer science and networking.

Uploaded by

nayankokane62
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)
8 views80 pages

DM-Unit IV-Graph Th_final

This document provides an overview of graph theory, covering key concepts such as graph terminology, types of graphs, graph representation, isomorphism, connectivity, Euler and Hamilton paths, and the handshaking lemma. It explains various graph types, including simple, complete, bipartite, and weighted graphs, as well as methods for representing graphs like adjacency matrices and lists. Additionally, it discusses the applications of graph theory in fields like computer science and networking.

Uploaded by

nayankokane62
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/ 80

Unit IV

Graph Theory
 Graph Terminology and Special Types of Graphs
 Representing Graphs
 Graph Isomorphism Connectivity
 Euler and Hamilton Paths
 The handshaking lemma
 Single source shortest path-Dijkstra's Algorithm
 Planar Graphs, Graph Colouring
Graph Terminology
• Mathematical structure which is used to show a particular function
with the help of connecting a set of points.
• To create a pairwise relationship between objects.
• Applications of Graph Theory
• Mathematics and Computer science
• Computer graphics and networks, biology
• GPS (Global positioning system)
Graph Terminology
Definition of Graph Theory
• a study of points and lines
• type of subfield that is used to deal with the study of a graph.
• graph theory is the study of the relationship between edges and vertices.
• a graph can be represented with the help of pair G(V, E).
V -the finite set vertices
E - the finite set edges.
• Hence, the graph basically contains the non-empty set of edges E and set
of vertices V.
• Ex: a graph G = (V, E), where
• V = {a, b, c, d}, and E = {(a, b), (a, c), (b, c), (c, d)}.
Graph Terminology(Examples)
Graph Terminology(Degree of a vertex)
• The number of edges connecting (Incident) to/on that vertex v with
self-loops counted twice
- deg(v)

The vertex 'a' has degree 5, and all the other vertices have a
degree 1.
If any vertex has degree 1, then that type of vertex will be
known as the 'end vertex'.
Graph Terminology(Degree of a vertex)
• Degree of a vertex in an Undirected graph(no directed edge)

Deg(a) = 2 Deg(b) = 3 Deg(d) = 2


Deg(c) = 1. The vertex c is also known as the pendent
vertex
Deg(a) = 0 The vertex e can also be called the isolated
vertex.
Internal vertex
Graph Terminology(Degree of a vertex)
• Degree of a vertex in an Undirected graph(no directed edge)

Degree of vertex a = deg(a) = 2


Degree of vertex b = deg(b) = 2
Degree of vertex c = deg(c) = 2
Degree of vertex d = deg(d) = 2
Degree of vertex e = deg(e) = 0(isolated vertex)
Graph Terminology(Degree of a vertex)
Graph Terminology(Degree of a vertex)
• Degree of a vertex in an directed graph
• In-degree :
-Number of edges coming to the vertex
- To count the number of edges that ends at the vertex.
• out-degree:
-Number of edges coming out from the vertex.
-To count the number of edges that begins from the vertex.
Degree of a vertex
Deg(v) = deg-(v) + deg+(v)
Degree of a vertex in an Directed graph
Degree of a vertex in an Directed graph
In-degree: Out-degree:
In-degree of a vertex v1 = deg(v1) = 1 Out-degree of a vertex v1 = deg(v1) = 2
In-degree of a vertex v2 = deg(v2) = 1 Out-degree of a vertex v2 = deg(v2) = 3
In-degree of a vertex v3 = deg(v3) = 1 Out-degree of a vertex v3 = deg(v3) = 2
In-degree of a vertex v4 = deg(v4) = 5 Out-degree of a vertex v4 = deg(v4) = 0
In-degree of a vertex v5 = deg(v5) = 1 Out-degree of a vertex v5 = deg(v5) = 2
In-degree of a vertex v6 = deg(v6) = 0 Out-degree of a vertex v6 = deg(v6) = 0

Degree of vertex
Degree of a vertex v1 = deg(v1) = 1+2 = 3
Degree of a vertex v2 = deg(v2) = 1+3 = 4
Degree of a vertex v3 = deg(v3) = 1+2 = 3
Degree of a vertex v4 = deg(v4) = 5+0 = 5
Degree of a vertex v5 = deg(v5) = 1+2 = 3
Degree of a vertex v6 = deg(v6) = 0+0 = 0
Special Types of Graphs
• Different types of graphs depending upon the number of vertices,
number of edges, interconnectivity, and their overall structure
• Null Graph(Empty Graph):No edges between its vertices

• Trivial Graph
A trivial graph is the graph which has only one vertex.
Special Types of Graphs

• Simple Graph
• A simple graph is the undirected graph with no parallel edges and no
loops.
• n vertices, the degree of every vertex is at most n -1.
Special Types of Graphs
• Undirected Graph: edges are not directed.

• Directed Graph(digraphs)edges are directed by arrows.


Special Types of Graphs
• Complete Graph
• A graph in which every pair of vertices is joined by exactly one edge is
called complete graph. It contains all possible edges.

• Connected Graph
• visit from any one vertex to any other vertex. at least one edge or
path exists between every pair of vertices.
Special Types of Graphs
• Disconnected Graph
• any path does not exist between every pair of vertices.

• Regular Graph: degree of all the vertices is same.


Special Types of Graphs
• Cyclic Graph
• A graph with 'n' vertices (where, n>=3) and 'n' edges forming a cycle
of 'n' with all its edges is known as cycle graph.
• A graph containing at least one cycle in it is known as a cyclic graph.
• n the cycle graph, degree of each vertex is 2.
• The cycle graph which has n vertices is denoted by Cn.
Special Types of Graphs
• Acyclic Graph
• A graph which does not contain any cycle in it is called as an acyclic graph.

• Bipartite Graph
• A bipartite graph is a graph in which the vertex set can be partitioned into
two sets such that edges only go between sets, not within them.
• This graph always has two sets, X and Y, with the vertices.
• In this graph, the vertices of set X can only have a connection with the set
Y.
• We cannot join the vertices within the same set.
Special Types of Graphs
• Bipartite Graph
Special Types of Graphs
• Complete Bipartite Graph
• bipartite graph in which each vertex in the first set is joined to each
vertex in the second set by exactly one edge.
• A complete bipartite graph is a bipartite graph which is complete.
Special Types of Graphs
• Star Graph
• A star graph is a complete bipartite graph in which n-1 vertices have
degree 1 and a single vertex have degree (n -1). This exactly looks like
a star where (n - 1) vertices are connected to a single central vertex.
• A star graph with n vertices is denoted by Sn.
Special Types of Graphs
• Weighted Graph
• A weighted graph is a graph whose edges have been labeled with
some weights or numbers.
• The length of a path in a weighted graph is the sum of the weights of
all the edges in the path.
Special Types of Graphs
• Multi-graph
• A graph in which there are multiple edges between any pair of
vertices or there are edges from a vertex to itself (loop) is called
a multi - graph.

• Pseudograph:A graph in which loops and parallel edges/multiple


edges are allowed
Special Types of Graphs
• Finite graph
• A graph G={V,E} in which both V and E are finite set is called a finite
graph
• V={A,B,C,D}
E={(A,B),(A,D),(B,C),(C,D)}
Questions
Representation of Graphs
• Adjacency Matrix- matrix representation
• Incidence Matrix- matrix representation
• Adjacency List -linked representation
Adjacency Matrix-
Representation of Graphs
Incidence Matrix- matrix representation
• This matrix is filled with either 0 or 1 or -1. Where,
• 0 is used to represent row edge which is not connected to column vertex.
• 1 is used to represent row edge which is connected as outgoing edge to column vertex.
• -1 is used to represent row edge which is connected as incoming edge to column vertex.
Representation of Graphs
Incidence Matrix- matrix representation
Representation of Graphs
Incidence Matrix- matrix representation
Representation of Graphs
Adjacency List -linked representation

Directed graph representation implemented using


linked list:

Representation using array


Graph Isomorphism
• Single graph can have more than one form.
• Two different graphs can have the same number
of edges, vertices, and same edges connectivity
(isomorphism graphs)

Graph Isomorphism
• Conditions for graph isomorphism
1.There will be an equal number of vertices in the
given graphs.
2.There will be an equal number of edges in the
given graphs.
3.There will be an equal amount of degree sequence
in the given graphs.
4.If the first graph is forming a cycle of length k
with the help of vertices {v1, v2, v3, …. vk},
then another graph must also form the same cycle
of the same length k with the help of vertices
{v1, v2, v3, …. vk}.
• The Degree sequence of a graph can be described as a sequence
of degree of all the vertices in ascending order.
Example
Example
Connectivity
• From every vertex to any other vertex, there should be some path to
traverse
• Connectivity defines whether a graph is connected or disconnected
• Subtopics : Edge connectivity and Vertex connectivity
• Cut Vertex:
• Let ‘G’ be a connected graph. A vertex V ∈ G is called a cut vertex of
‘G’, if ‘G-V’ (Delete ‘V’ from ‘G’) results in a disconnected graph.
Removing a cut vertex from a graph breaks it in to two or more
graphs.
• A connected graph ‘G’ may have at most (n–2) cut vertices.
Connectivity
Cut Vertex( Example)

vertices ‘e’ and ‘c’ are the cut vertices.


Connectivity :Cut Edge (Bridge)
• Let ‘G’ be a connected graph. An edge ‘e’ ∈ G is called a cut edge if ‘G-
e’ results in a disconnected graph.
• If removing an edge in a graph results in to two or more graphs, then
that edge is called a Cut Edge.

the cut edge is [(c, e)]


Connectivity :Cut Set
• Let ‘G’= (V, E) be a connected graph. A subset E’ of E is called a cut set
of G if deletion of all the edges of E’ from G makes G disconnect.
• If deleting a certain number of edges from a graph makes it
disconnected, then those deleted edges are called the cut set of the
graph.

cut set is E1 = {e1, e3, e5, e8}.


Edge Connectivity

• Let ‘G’ be a connected graph. The minimum number of edges whose


removal makes ‘G’ disconnected is called edge connectivity of G.
• Notation − λ(G)

λ(G)) is 2
Vertex Connectivity

• Let ‘G’ be a connected graph. The minimum number of vertices


whose removal makes ‘G’ either disconnected or reduces ‘G’ in to a
trivial graph is called its vertex connectivity.
• Notation − K(G)
If G has a cut vertex, then K(G) = 1.

Notation − For any connected graph G,

K(G) ≤ λ(G) ≤ δ(G)

Vertex connectivity (K(G)), edge connectivity (λ(G)), minimum


number of degrees of G(δ(G)).
Vertex Connectivity
• Calculate λ(G) and K(G) for theFrom
following
the graph,
graph

δ(G) = 3

K(G) ≤ λ(G) ≤ δ(G) = 3 (1)

K(G) ≥ 2 (2)

Deleting the edges {d, e} and {b, h}, we can disconnect G.

Therefore,

λ(G) = 2

2 ≤ λ(G) ≤ δ(G) = 2 (3)

From (2) and (3), vertex connectivity K(G) = 2


Euler and Hamilton Paths
• Euler’s path contains each edge of ‘G’ exactly once and each
vertex of ‘G’ at least once.
• A connected graph G is said to be traversable if it contains an
Euler’s path.

Euler’s Circuit
Euler’s Paths and Circuit
Euler’s Circuit Theorem(Example)

• A connected graph ‘G’ is traversable if and only if the


number of vertices with odd degree in G is exactly 2 or
0.
• A connected graph G can contain an Euler’s path, but
not an Euler’s circuit, if it has exactly two vertices with
an egree.
Euler’s Path − b-e-a-b-d-c-a is not an Euler’s
circuit, but it is an Euler’s path. Clearly it has
exactly 2 odd degree vertices.
Euler’s Paths and Circuit

• Conditions for Euler Paths and Circuits


• Euler Path: A connected graph has an Euler path if and only if it has
exactly zero or two vertices of odd degree.
• Euler Circuit: A connected graph has an Euler circuit if and only if
every vertex has an even degree.
Hamiltonian Path

• A connected graph is said to be Hamiltonian if it


contains each vertex of G exactly once. Such a path is
called a Hamiltonian path.
Hamiltonian Path and Circuit
Hamiltonian Path and Circuit
The handshaking lemma
• The Handshaking Theorem(Sum of degree theorem)
• A fundamental principle in graph theory, states that in any undirected
graph, the sum of the degrees of all vertices is equal to twice the number
of edges in the graph. Symbolically, for a graph with ‘n vertices and ‘E
edges:

-∑(deg(v)) -represents the sum of the degrees of all vertices in the graph
-deg(v)represents the degree of a vertex ‘v’
-E-represents the edges
Handshaking Theorem
Conclusions in the handshaking theorem
• There must be even numbers for the sum of degree of all the vertices.
• If there are odd degrees for all the vertices, then the sum of degree of
these vertices must always remain even.
• If there are some vertices that have an odd degree, then the number
of these vertices will be even.
Handshaking Theorem Proof
Applications of the Handshaking Theorem
• Computer Networking:
-To determine the total number of connections in a network.
-It helps in understanding the overall structure of the network
-Used to optimize its performance.
• Social Networks:
-To determine the number of connections between individuals.
-It helps in understanding the overall structure of the social network
- to identify influencers or key individuals in the network.
Examples
• Find the number of edges in a graph G with 10 vertices, where each
vertex has a degree of 3.
Examples
• Find the number of vertices in a graph G with 12 edges, where each
vertex has a degree of 2
Examples
• Find the sum of the degrees of all vertices in a graph
G with 7 edges and 5 vertices.
Examples
• Find the number of edges in a graph G with 6 vertices, where one
vertex has a degree of 4, two vertices have a degree of 3, and the
rest have a degree of 2.
Examples
Planar Graph
• A planar graph is a graph that we can draw in a plane in such a way
that no two edges of it cross each other except at a vertex to which
they are incident.
Planar Graph
• Region of a Graph: Consider a planar graph G=(V,E).A region is defined
to be an area of the plane that is bounded by edges and cannot be
further subdivided.
• A planar graph divides the plans into one or more regions.
• One of these regions will be infinite.
• Finite Region: If the area of the region is finite, then that region is
called a finite region.
• Infinite Region: If the area of the region is infinite, that region is
called a infinite region. A planar graph has only one infinite region.
Planar Graph
Properties of Planar Graphs:

Regions : r1,r2,r3,r4,r5
Finite regions :r2,r3,r4,r5
Infinite region, i.e., r1
Planar Graph
Example: Prove that complete graph K4 is planar.

The complete graph K4 contains 4 vertices and 6 edges.

for a connected planar graph 3v-e≥6


for K4, we have 3x4-6=6 which satisfies the property (3)
Thus K4 is a planar graph. Hence Proved.
Non -Planar Graph
• A graph that is not a planar graph is called a non-planar graph. In
other words, a graph that cannot be drawn without at least on pair of
its crossing edges is known as non-planar graph.
Properties of Non-Planar Graphs:

Kurathoski’s Theorem :A graph is non-planar if and only if it


contains a subgraph homeomorphic to K5 or K3,3
Non -Planar Graph
Example1: Show that K5 is non-planar.
Solution: The complete graph K5 contains 5 vertices and 10 edges.
for a connected planar graph 3v-e≥6.
for K5, we have 3 x 5-10=5 (which does not satisfy property 3 because it
must be greater than or equal to 6).
• Thus, K5 is a non-planar graph.
Non -Planar Graph
Example 2: Show that K3,3 is non-planar.
The complete graph K3,3 contains 3 vertices and
9 edges.
for a connected planar graph 3v-e≥6.
for K3,3 we have 3 x 3-9=0 (which does not
satisfy property 3 because it must be greater
than or equal to 6).
Thus, K3,3 is a non-planar graph.
Graph Coloring
• Suppose that G= (V,E) is a graph with no multiple edges. A vertex
coloring of G is an assignment of colors to the vertices of G such that
adjacent vertices have different colors. A graph G is M-Colorable if
there exists a coloring of G which uses M-Colors.
• Proper Coloring: A coloring is proper if any two adjacent vertices u
and v have different colors otherwise it is called improper coloring.
Graph Coloring
• Example: Consider the following graph and color C={r, w, b, y}.Color
the graph properly using all colors or fewer colors.
Graph Coloring
• Chromatic number of G: The minimum number of colors needed to
produce a proper coloring of a graph G is called the chromatic
number of G and is denoted by x(G).
Single source shortest path: Dijkstra’s Algorithm:

• Algorithm for Dijkstra’s Algorithm:


1. Mark the source node with a current distance of 0 and the rest with
infinity.
2. Set the non-visited node with the smallest current distance as the
current node.
3. For each neighbor, N of the current node adds the current distance of the
adjacent node with the weight of the edge connecting 0->1. If it is
smaller than the current distance of Node, set it as the new current
distance of N.
4. Mark the current node 1 as visited.
5. Go to step 2 if there are any nodes are unvisited.
https://youtu.be/Gd92jSu_cZk?si=HWgtcRUSZkCYIiyN
•The Distance from the source node to itself is 0. In this
example the source node is 0.
•The distance from the source node to all other node is
unknown so we mark all of them as infinity.

Example: 0 -> 0, 1-> ∞,2-> ∞,3-> ∞,4-> ∞,5-> ∞,6-> ∞.


Distance: Node 0 -> Node 1 = 2
Distance: Node 0 -> Node 1 -> Node 3 = 2 + 5 = 7
Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 = 2 + 5 + 10 =
17
Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 -> Node 6 = 2
+ 5 + 10 + 2 = 19
Questions
Questions

You might also like