GRAPH THEORY
CHAPTER 3
Topics Covered
 Definitions
 Types
 Terminology
 Representation
 Sub-graphs
 Connectivity
 Hamilton and Euler definitions
 Shortest Path
 Planar Graphs
 Graph Coloring
Graph
 Many real problems require the data to be presented in a two dimensional plane.
 Graph theory is a branch of mathematics that deals with graphs, networks, and their properties.
 Graph theory is used in transportation planning, logistics, routing, and cost analysis.
 Finding the shortest or fastest route between two points on the map is certainly one of the most commonly
used applications of graph theory.
 Graph theory has many applications in transportation planning, including modeling road networks,
selecting efficient routes, and optimizing traffic flow.
 A database of links between web pages is called a “web graph”.
These graphs are used by search engines such as Google, Bing, and Yahoo!.
Varying Applications (examples)
 Computer networks
 Distinguish between two chemical compounds with the same molecular
formula but different structures.
 Solve shortest path problems between cities.
 Scheduling exams and assign channels to television stations.
Definitions - Graph
A generalization of the simple concept of a set of dots, links, edges or arcs.
A graph G is a non linear data structure represented as an ordered pair as G=<V,E>.
A graph G is mathematical structure consisting of two sets V and E where V is non-empty set of
vertices and E is a non-empty set of edges.
Representation:
Graph G = (V, E)
 Set of vertices denoted by V, or by V(G) and
 Set of edges E, or E(G)
Example: Suppose there is a graph G = (V, E), where
V = {a, b, c, d}, and
E = {(a, b), (a, c), (b, c), (c, d)}.
Basic Terminology
1. Trivial Graph: A graph consisting only one vertex and no edge.
Example :
2. Null Graph:- A Graph consisting n vertex and no edge.
Definitions – Edge Type
3. Directed: Ordered pair of vertices. Represented as (u, v) directed from vertex u to v.
A set of vertices, which are connected with the directed edges.
In the directed graph, the edges have a direction which is associated with the vertices.
A graph consist the direction of the edges then this is called directed graph.
4. Undirected: Unordered pair of vertices. Represented as {u, v}.
A graph which is not directed then it is called undirected graph.
A set of vertices which are connected together by the undirected edges.
All the edges of this graph are bidirectional.
u v
u v
e1
e2
e3
e1
Definitions – Edge Type
5. Loop: A loop is an edge whose endpoints are equal.
i.e., An edge joining a vertex to it self is called a loop. Represented as {u, u} = {u}
6. Multiple Edges: A collection of two or more edges joining the same
pair of vertices.
u
Definitions – Graph Type
7. Proper edge:- An edge which is not self loop is called proper edge.
8. Simple Graph: A graph does not contain any self loop and multiage. Each edge is associated with an
unordered pair of vertices.
Representation Example: G(V, E), V = {u, v, w}, E = {{u, v}, {v, w}, {u, w}}
u v
w
Dig A Dig B
Definitions – Graph Type
9. Multigraph: A graph does not contain any self loop but contain multiedge is called multigraph.
G(V,E), consists of set of vertices V, set of Edges E and a function f from E to {{u, v}| u, v V, u ≠ v}.
The edges e1 and e2 are called multiple or parallel edges if f (e1) = f (e2).
Representation Example: V = {u, v, w}, E = {e1, e2, e3}
u
v
w
e1
e2
e3
Definitions – Graph Type
10. Pseudograph: A graph contain both self loop and multiedge is called pseudograph.
Representation Example: V = {u, v, w}, E = {e1, e2, e3, e4}
u
v
w
e1
e3
e2
e4
Definitions – Graph Type
Example:-
Directed Graph: G(V, E), set of vertices V, and set of Edges E, that are ordered pair of elements of V
(directed edges)
Representation Example: G(V, E), V = {u, v, w}, E = {(u, v), (v, w), (w, u)}
u
w
v
Definitions – Graph Type
Example:-
11. Directed Multigraph: G(V,E), consists of set of vertices V, set of Edges E and a
function f from E to {{u, v}| u, v V}. The edges e1 and e2 are multiple edges if f(e1) =
f(e2)
Representation Example: V = {u, v, w}, E = {e1, e2, e3, e4} u
u
u
e1
e2
e3
e4
Graph Type
Type Edges
Multiple Edges
Allowed ?
Loops Allowed ?
Simple Graph Undirected No No
Multigraph Undirected Yes No
Pseudograph Undirected Yes Yes
Directed Graph Directed No Yes
Directed
Multigraph
Directed Yes Yes
Definitions – Graph Type
12. Incidence and adjacency
Two vertices, u and v in an undirected graph G are called adjacent (or neighbors) in G,
if {u, v} is an edge of G.
An edge e connecting u and v is called incident with vertices u and v, or is said to
connect u and v.
The vertices u and v are called endpoints of edge {u, v}.
Here e1 is incident of V1 and V2 and V1 and V2 are adjacent.
V1
V3 V2
e1
e2
e3
Terminology – Directed graphs
13. 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.
14. Finite Graph:- A graph with finite vertex set is called a finite graph.
Terminology – Directed graphs
Parallel Edge :- If there are more than one edge between two nodes then they are known as parallel
edges.
Not a parallel edges because ()u,v) and (v,u) are two different edges
u
u v
v
u v
Definitions – Graph Type
15 Digraph Graph:
A graph G = (V, E) with a mapping f such that every edge maps onto some ordered pair of vertices (Vi, Vj)
are called a Digraph. It is also called Directed Graph.
The ordered pair (Vi, Vj) means an edge between Vi and Vj with an arrow directed from Vi to Vj. Here in
the figure: e1 = (V1, V2) e2 = (V2, V3) e4 = (V2, V4)
Definitions – Graph Type
16. 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.
Definitions – Graph Type
17. Symmetric Digraph:
A digraph in which each pair of vertices have either one edge or no edges
is known as symmetric digraph.
18 Asymmetric Digraph
A digraph in which each pair of vertices x, y have either no edges or two
edges <x, y> and <y, x>
Definitions – Graph Type
Connected and Disconnected Graph:-
A graph is said to be connected if every pair of vertices in the graph is connected. This means that there
is a path between every pair of vertices.
An undirected graph that is not connected is called disconnected.
Terminology – Undirected graphs
Degree of Vertex (deg (v)):
The degree of a vertex in an undirected graph is the number of edges incident with it, except that a loop at a vertex
contributes twice to the degree of that vertex.
Pendant :- A vertex is pendant if and only if it has degree one.
A pendant vertex is adjacent to exactly one other vertex.
Pendant Vertex: deg (v) =1
Isolated Vertex : A vertex of degree zero is called isolated. K
Isolated Vertex: deg (k) = 0
Representation Example: For V = {u, v, w} , E = { {u, w}, {u, w}, (u, v) }, deg (u) = 2, deg (v) = 1, deg (w) = 1, deg (k) = 0, w and
v are pendant , k is isolated
u
k
w
v
deg( e ) = 0
deg( b ) = 6
Find the degree of all the other vertices. deg( a )=2 deg( c )= 4 deg( f)=3 deg( g )=4
deg( d ) = 1
Terminology – Undirected graphs
Terminology – Directed graphs
For the edge (u, v), u is adjacent to v OR v is adjacent from u, u – Initial vertex, v – Terminal vertex
In-degree (deg- (u)): Number of edges for which u is terminal vertex
Out-degree (deg+ (u)): Number of edges for which u is initial vertex
Note: A loop contributes 1 to both in-degree and out-degree (why?)
Representation Example: For V = {u, v, w} , E = { (u, w), ( v, w), (u, v) }, deg- (u) = 0,
deg+ (u) = 2, deg- (v) = 1, deg+ (v) = 1, and deg- (w) = 2, deg+ (u) = 0
u
w
v
Example
Example
Theorems: The Handshaking theorem:
Sum of degree of all the vertices is twice the number of edges contained in it.
Example 1
Example 2
2. A simple graph G has 24 edges and degree of each vertex is 4. Find the number of vertices.
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
n = 2 x 6
∴ n = 12
Thus, Number of vertices in the graph = 12
Example 3
A graph contains 21 edges, 3 vertices of
degree 4 and all other vertices of degree 2.
Find total number of vertices.
Solution-
Given-
• Number of edges = 21
• Number of degree 4 vertices = 3
• All other vertices are of degree 2
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-
3 x 4 + (n-3) x 2 = 2 x 21
12 + 2n – 6 = 42
2n = 42 – 6
2n = 36
∴ n = 18
Thus, Total number of vertices in the graph = 18.
Example 4
A graph has 24 edges and degree of each vertex is k, then which of the following is possible number of
vertices?
A. 20 B. 15 C. 10 D. 8
Given-
• Number of edges = 24
• Degree of each vertex = k
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 k = 2 x 24
k = 48 / n
Now,
• It is obvious that the degree of any vertex must be a
whole number.
• So in the above equation, only those values of ‘n’
are permissible which gives the whole value of ‘k’.
Now, let us check all the options one by one-
• For n = 20, k = 2.4 which is not allowed.
• For n = 15, k = 3.2 which is not allowed.
• For n = 10, k = 4.8 which is not allowed.
• For n = 8, k = 6 which is allowed
Simple graphs – special cases
Complete graph: Kn, is the simple graph that contains exactly one edge between each
pair of distinct vertices.
Representation Example: K1, K2, K3, K4
K2
K1
K4
K3
• Each vertex is connected with all the remaining vertices through exactly one edge.
Simple graphs – special cases
Cycle: A simple graph of ‘n’ vertices (n>=3) and n edges forming a cycle of length ‘n’ is called as a cycle
graph.
In a cycle graph, all the vertices are of degree 2.
Cn, n ≥ 3 consists of n vertices v1, v2, v3 … vn and edges {v1, v2}, {v2, v3}, {v3, v4} … {vn-1, vn}, {vn, v1}
Representation Example: C3, C4
C3 C4
Simple graphs – special cases
Cyclic Graph-
 A graph containing at least one cycle in it is called as a cyclic graph.
This graph contains two cycles in it.
Therefore, it is a cyclic graph
Acyclic Graph-
A graph not containing any cycle in it is called as an acyclic graph.
This graph do not contain any cycle in it.
Simple graphs – special cases
Wheels: Wn, obtained by adding additional vertex to Cn and connecting all vertices to this new vertex by
new edges.
Representation Example: W3, W4
W3 W4
Simple graphs – special cases
N-cubes: Qn, vertices represented by 2n bit strings of length n.
Two vertices are adjacent if and only if the bit strings that they represent differ by exactly one bit
positions
Representation Example: Q1, Q2
0
10
1
00
11
Q1
01
Q2
Simple graphs – special cases
Regular Graph:-
A graph in which degree of all the vertices is same is called as a regular graph.
If all the vertices in a graph are of degree ‘k’, then it is called as a “k-regular graph“.
n these graphs,
•All the vertices have degree-2.
•Therefore, they are 2-Regular graphs.
https://www.geeksforgeeks.org/regular-graph-in-graph-theory/?ref=rp
Bipartite graphs
A bipartite graph, also called a bigraph, is a set of graph vertices decomposed into two disjoint sets such
that no two graph vertices within the same set are adjacent.
If the vertex set V of a graph G can be partitioned into two non empty disjoint subsets X and Y in such way
that each edge of G has one end in X and one end in Y then G is called Bigraph or bipartite graph.
A bipartite graph is a special kind of graph with the following properties-
• It consists of two sets of vertices X and Y.
• The vertices of set X join only with the vertices of set Y.
• The vertices within the same set do not join.
V
x Y
Bipartite graphs
The vertices of the graph can be decomposed into two sets.
The two sets are X = {A, C} and Y = {B, D}.
The vertices of set X join only with the vertices of set Y and vice-versa.
The vertices within the same set do not join.
Therefore, it is a bipartite graph
Bipartite graphs
Bipartite graphs
Note:- If a graph is connected then it will not bipartite
Complete Bipartite graphs
A graph G = (V, E) is called a complete bipartite graph if its vertices V can be partitioned into two subsets
V1 and V2 such that each vertex of V1 is connected to each vertex of V2. The
number of edges in a complete bipartite graph is m.n as each of the m vertices is connected to each of the n
vertices.
Km,n is the graph that has its vertex set portioned into two subsets of m and n vertices, respectively There is an
edge between two vertices if and only if one vertex is in the first subset and the other vertex is in the second
subset.
Representation example: K2,3, K3,3
K2,3 K3,3
A bipartite graph where every vertex of set X is joined
to every vertex of set Y is called as complete bipartite
graph
Complete Bipartite graphs
K3,3
K5,3
K1,5
Problem-01:
Is the following graph a bipartite graph?
Sol: The given graph may be redrawn as-
This graph consists of two sets of vertices.
The two sets are X = {1, 4, 6, 7} and Y = {2, 3, 5, 8}.
The vertices of set X are joined only with the vertices of set Y
and vice-versa.
Also, any two vertices within the same set are not joined.
This satisfies the definition of a bipartite graph
Bipartite graphs
• In any bipartite graph with bipartition X and Y,
Sum of degree of vertices of set X = Sum of degree of vertices of set Y
Maximum Number Of Edges-
Any bipartite graph consisting of ‘n’ vertices can have at most (1/4) x n2 edges.
Maximum possible number of edges in a bipartite graph on ‘n’ vertices = (1/4) x n2.
Problem 2
The maximum number of edges in a bipartite graph on 12 vertices is _________?
Solution-
We know, Maximum possible number of edges in a bipartite graph on ‘n’ vertices = (1/4) x n2.
Substituting n = 12, we get-
Maximum number of edges in a bipartite graph on 12 vertices
= (1/4) x (12)2
= (1/4) x 12 x 12
= 36
Therefore, Maximum number of edges in a bipartite graph on 12 vertices = 36.
Subgraphs
When edges and vertices are removed from a graph, without removing endpoints of any remaining edges, a smaller
graph is obtained. Such a graph is called a subgraph of the original graph.
A graph G1 = (V1, E1) is called a subgraph of a graph G(V, E) if V1(G) is a subset of V(G) and E1(G) is a subset of E(G)
such that each edge of G1 has same end vertices as in G.
A subgraph of a graph G = (V, E) is a graph H =(V’, E’) where V’ is a subset of V and E’ is a subset of E
Application example: solving sub-problems within a graph
Representation example: V = {u, v, w}, E = ({u, v}, {v, w}, {w, u}}, H1 , H2
u
v w
u
u
w
v v
H1 H2
G
Subgraphs
When edges and vertices are removed from a graph, without removing endpoints of any remaining edges, a smaller
graph is obtained. Such a graph is called a subgraph of the original graph.
A subgraph of a graph G = (V, E) is a graph H =(V’, E’) where V’ is a subset of V and E’ is a subset of E
Application example: solving sub-problems within a graph
Representation example: V = {u, v, w}, E = ({u, v}, {v, w}, {w, u}}, H1 , H2
u
v
w w
v
w
u
G1 G2 G
Union and Intersection
Given two graphs G1 and G2, the task is to find the union and intersection of the two given graphs,
i.e. (G1 ∪ G2) and (G1 ∩ G2).
Complement of Graph
The complement of a graph G is a graph G’ on the same set of vertices as of G such that there will be an
edge between two vertices (v, e) in G’, if and only if there is no edge in between (v, e) in G.
Complement of graph G(v, e) is denoted by G'(v, e’).
Note: The number of vertices remains unchanged in the complement of the graph.
Graph Complement Graph
Complement of Graph
Relation between G and G`:
1. Number of vertices in G = Number of vertices in G’.
|V(G)| = |V(G’)|
2. The sum of total number of edges in G and G’ is equal to the total number of edges in a complete
graph.
|E(G)| + |E(G’)|
= C(n,2)
= n(n-1) / 2
Problem
Problem-01:
A simple graph G has 10 vertices and 21 edges. Find total number of edges in its complement graph G’.
Solution-
Given-
Number of edges in graph G, |E(G)| = 21
Number of vertices in graph G, n = 10
We know |E(G)| + |E(G’)| = n(n-1) / 2.
Substituting the values, we get-
21 + |E(G’)| = 10 x (10-1) / 2
|E(G’)| = 45 – 21
∴ |E(G’)| = 24
Thus, Number of edges in complement graph G’ = 24.
Representation
Graph representation, means the technique to be used to store some graph into the computer's memory.
There are two ways to store Graphs into the computer's memory:
1. Incidence (Matrix): Most useful when information about edges is more desirable than information
about vertices.
2. Adjacency (Matrix/List): Most useful when information about the vertices is more desirable than
information about the edges.
These two representations are also most popular since information about the vertices is often more
desirable than edges in most applications
Representation- Incidence Matrix
Representation of the Undirected Graph:
G = (V, E) be an unditected graph. Suppose that v1, v2, v3, …, vn are the vertices and e1, e2, …, em are the edges of
G. Then the incidence matrix with respect to this ordering of V and E is the n x m matrix
M = [m ij], where Can also be used to represent :
Incidence matrix also be used to represent Multiple edges and loops.
Multiple edges: by using columns with identical entries, because these edges are incident with the same pair
of vertices.
Loops: by using a column with exactly one entry equal to 1, corresponding to the vertex that is incident with
the loop




otherwise
0
ith v
incident w
is
e
edge
when
1
m
i
j
ij
Representation- Incidence Matrix
Representation Example: G = (V, E)
e1 e2 e3
v 1 0 1
u 1 1 0
w 0 1 1
v w
u
e1
e3
e2
Example
Example
Representation- Incidence Matrix
Representation of the directed Graph:
If a directed graph G consists of n vertices and m edges, then the incidence matrix is an n x m
matrix C = [cij] and defined by
The number of ones in an incidence matrix is equal to the number of edges in the graph.
Example
Consider the directed graph G as shown in fig. Find its incidence matrix MI.
Representation- Adjacency Matrix
Representation of the Undirected Graph:
 A Adjacency Matrix is a N*N binary matrix in which value of [i,j]th cell is 1 if there exists an edge originating
from ith vertex and terminating to jth vertex, otherwise the value is 0.
 There is an N x N matrix, where |V| = N , the Adjacenct Matrix (NxN) A = [aij]
For undirected graph
 For directed graph
 This makes it easier to find subgraphs, and to reverse graphs if needed.




otherwise
0
G
of
edge
an
is
)
v
,
(v
if
1
a
j
i
ij




otherwise
0
G
of
edge
an
is
}
v
,
{v
if
1
a
j
i
ij
Representation- Adjacency Matrix
Adjacency is chosen on the ordering of vertices. Hence, there as are as many as n! such matrices.
The adjacency matrix of simple graphs are symmetric (aij = aji) (why?)
When there are relatively few edges in the graph the adjacency matrix is a sparse matrix
Directed Multigraphs can be represented by using aij = number of edges from vi to vj
Representation- Adjacency Matrix
Example: Undirected Graph G (V, E)
v u w
v 0 1 1
u 1 0 1
w 1 1 0
u
v w
Representation- Adjacency Matrix
Example: directed Graph G (V, E)
v u w
v 0 1 0
u 0 0 1
w 1 0 0
u
v w
Example
Find the adjacency matrix MA of graph G shown in Fig:
Example
Consider the directed graph shown in fig. Determine its adjacency matrix MA.
The directed graph G consists of five vertices. Therefore,
the adjacency matrix will be a 5 x 5 matrix.
The adjacency matrix of the directed graphs is as follows:
Example
Representation- Adjacency List
Adjacency List specify the vertices that are adjacent to each vertex of the graph.
Each node (vertex) has a list of which nodes (vertex) it is adjacent
Example: undirected graph G (V, E)
node Adjacency List
u v , w
v w, u
w u , v
u
v w
Example Use adjacency lists to describe the graph given below
Example Use adjacency lists to describe the graph given below
Example
Example
Exercises
Graph - Isomorphism
The simple G1 = (V1, E2) and G2 = (V2, E2) are isomorphic if there is a one-to-one and
onto function f from V1 to V2 with the property that a and b are adjacent in G1 if and only if f
(a) and f (b) are adjacent in G2, for all a and b in V1. Such a function f is called isomorphism.
When two graphs G and G` are said to be isomorphic if there is a one-to-one
correspondence between their vertices and edges such that the adjacency of vertices are
preserved.
Such graphs will have the same structure, differencing only in the way of their vertices and
edges are labeled.
Graph - Isomorphism
Criteria for checking two graphs are isomorphic or not:-
1. Both graph have same number of Vertices .
2. Both graph have same number of edges.
3. Both graph have an equal number of vertices with a given degree.
4. one-to-one correspondence between the vertices of two graphs.
5. Edge preserving is also satisfied between two graphs (one-to-one correspondence ).
6. Smallest possible cycle length is same for two graphs.
7. Adjacency matrices of two graphs should be same.
Graph - Isomorphism
Representation example: G1 = (V1, E1) , G2 = (V2, E2)
u1
u3
u4
u2
v3
v4
v1 v2
1. Vertices -4
2. Edges – 4
3. Degree of each Vertices are 2
4. Edge correspondence
f(u1) = v1, f(u2) = v4, f(u3) = v3, f(u4) = v2,
6.
Graph - Isomorphism
1. Number of vertices are same
2. Number of edges are same
3. An equal number of vertices with
given degree
4. U1=2
5. U2=3
6. U3 =2
7. U4= 3
8. U5= 2
9. U6=2
V1= 2
V2= 2
V3= 3
V4= 2
V5 =3
V6= 2
Graph - Isomorphism
Graph - Isomorphism
Graph - Isomorphism
Representation- Incidence Matrix
e1 e2 e3
a 1 0 0
b 1 1 0
c 0 1 1
d 0 0 1
e 0 0 0
f 0 0 0
e4 e5 e6 e7
0 0 0 1
0 0 0 0
0 1 1 0
1 0 0 0
1 1 0 0
0 0 1 1
a b
c d
e
f
e1
e2
e3
e4
e5
e6
e7
Isomorphism - revisited
A isomorphic invariant for simple graphs is the existence of a simple circuit of length k ,
k is an integer > 2 (why ?)
Representation example: G1 and G2 are isomorphic since we have the invariants, similarity in degree of
nodes, number of edges, length of circuits
G1 G2
Question
Connectivity
Basic Idea: In a Graph Reachability among vertices by traversing the edges
Application Example:
- In a city to city road-network, if one city can be reached from another city.
- Problems if determining whether a message can be sent between two
computer using intermediate links
- Efficiently planning routes for data delivery in the Internet
Connectivity
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. Beginning and ending with the same or different vertices.
Note: Vertices and Edges can be repeated.
Connectivity
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.
1->2->3->4->5->3 is an open walk.
1->2->3->4->5->3->1 is a closed walk.
Length of a walk: The total number of edges covered in a walk.
Ex. Ex 1- Length is 5
Connectivity
2. Trail –
Trail is an open walk in which no edge is repeated.
Vertex can be repeated
3. Circuit –
Traversing a graph such that not an edge is repeated but vertex can be repeated and it is closed walk.
i.e. it is a closed trail.
Vertex can be repeated.
Edge can not be repeated.
Here 1->2->4->3->6->8->3->1 is a circuit.
Connectivity
4. 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. As path is also a trail, thus it is also an open walk.
Vertex not repeated
Edge not repeated
Here 6->8->3->1->2->4 is a Path
Connectivity
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 can not have repeat
anything (neither edges nor vertices).
Connectivity – Path
A Path is a sequence of edges that begins at a vertex of a graph and travels along edges of the graph,
always connecting pairs of adjacent vertices.
Representation example: G = (V, E), Path P represented, from u to v is {{u, 1}, {1, 4}, {4, 5}, {5, v}}
1
u
3
4 5
2
v
Connectivity – Path
Definition for Directed Graphs
A Path of length n (> 0) from u to v in G is a sequence of n edges e1, e2 , e3, …, en of G such that f (e1) = (xo, x1),
f (e2) = (x1, x2), …, f (en) = (xn-1, xn), where x0 = u and xn = v. A path is said to pass through x0, x1, …, xn or traverse
e1, e2 , e3, …, en
For Simple Graphs, sequence is x0, x1, …, xn
In directed multigraphs when it is not necessary to distinguish between their edges, we can use sequence of
vertices to represent the path
Circuit/Cycle: u = v, length of path > 0
Simple Path: does not contain an edge more than once
Connectivity – Connectedness
Undirected Graph
An undirected graph is connected if there exists is a simple path between every pair of vertices.
Representation Example: G (V, E) is connected since for V = {v1, v2, v3, v4, v5}, there exists a path between
{vi, vj}, 1 ≤ i, j≤ 5
v1
v2
v3
v5
v4
Connectivity – Connectedness
Undirected Graph
Articulation Point (Cut vertex): removal of a vertex produces a subgraph with more connected components
than in the original graph. The removal of a cut vertex from a connected graph produces a graph that is not
connected
Cut Edge: An edge whose removal produces a subgraph with more connected components than in the original
graph.
Representation example: G (V, E), v3 is the articulation point or edge {v2, v3}, the number of connected
components is 2 (> 1)
v1
v2
v3
v4
v5
Connectivity – Connectedness
Directed Graph
A directed graph is strongly connected if there is a path from a to b and from b to a whenever a and b
are vertices in the graph
A directed graph is weakly connected if there is a (undirected) path between every two vertices in the
underlying undirected path
A strongly connected Graph can be weakly connected but the vice-versa is not true (why?)
Connectivity – Connectedness
Directed Graph
Representation example: G1 (Strong component), G2 (Weak Component), G3 is undirected graph representation of
G2 or G1
G2
G1 G3
Connectivity – Connectedness
Directed Graph
Strongly connected Components: subgraphs of a Graph G that are strongly connected
Representation example: G1 is the strongly connected component in G
G1
G
Counting Paths
Theorem: Let G be a graph with adjacency matrix A with respect to the ordering v1, v2, …, Vn (with directed on
undirected edges, with multiple edges and loops allowed). The number of different paths of length r from Vi to Vj,
where r is a positive integer, equals the (i, j)th entry of (adjacency matrix) Ar.
Proof: By Mathematical Induction.
Base Case: For the case N = 1, aij =1implies that there is a path of length 1. This is true since this corresponds to an edge between
two vertices.
We assume that theorem is true for N = r and prove the same for N = r +1. Assume that the (i, j)th entry of Ar is the number of
different paths of length r from vi to vj. By induction hypothesis, bik is the number of paths of length r from vi to vk.
Counting Paths
Case r +1: In Ar+1 = Ar. A,
The (i, j)th entry in Ar+1 , bi1a1j + bi2 a2j + …+ bin anj
where bik is the (i, j)th entry of Ar.
By induction hypothesis, bik is the number of paths of length r from vi to vk.
The (i, j)th entry in Ar+1 corresponds to the length between i and j and the length is r+1. This path is made up of
length r from vi to vk and of length from vk to vj. By product rule for counting, the number of such paths is bik* akj The
result is bi1a1j + bi2 a2j + …+ bin anj ,the desired result.
Counting Paths
a ------- b
| |
| |
c -------d
A = 0 1 1 0 A4 = 8 0 0 8
1 0 0 1 0 8 8 0
1 0 0 1 0 8 8 0
0 1 1 0 8 0 0 8
Number of paths of length 4 from a to d is (1,4) th entry of A4 = 8.
Euler - definitions
EULERIAN PATH is a path in a graph that visits every edge
exactly once.
Is it possible to draw a given graph without lifting pencil
from the paper and without tracing any of the edges more
than once”.
Euler - definitions
visits every edge exactly once.
Euler - definitions
EULERIAN CIRCUIT is an Eulerian Path that starts and ends on the same
vertex.
If there exists a walk in the connected graph that starts and ends at the
same vertex and visits every edge of the graph exactly once with or
without repeating the vertices, then such a walk is called as an Euler
circuit.
A graph will contain an Euler circuit if and only if all its vertices are of
even degree.
A graph is called Eulerian if it has an Eulerian Cycle .
A graph is called Semi-Eulerian if it has an Eulerian Path.
Euler - definitions
Euler Graph
An Euler Graph is a connected graph that contains an Euler Circuit.
Any connected graph is called as an Euler Graph if and only if all its vertices are of even degree.
Euler - definitions
Eulerian Cycle: An undirected graph has Eulerian cycle if following two conditions are true.
1. All vertices with non-zero degree are connected. We don’t care about vertices with zero degree because they
don’t belong to Eulerian Cycle or Path (we only consider all edges).
2. All vertices have even degree.
Eulerian Path: An undirected graph has Eulerian Path if following two conditions are true.
Same as condition (a) for Eulerian Cycle.
1. If zero or two vertices have odd degree and all
2. Other vertices have even degree.
Note that only one vertex with odd degree is not possible in an undirected graph (sum of all degrees is always even in
an undirected graph) Note that a graph with no edges is considered Eulerian because there are no edges to traverse.
Euler - definitions
An Eulerian path (Eulerian trail, Euler walk) in a graph is a path that uses each edge precisely once. If
such a path exists, the graph is called traversable.
An Eulerian cycle (Eulerian circuit, Euler tour) in a graph is a cycle that uses each edge precisely once. If
such a cycle exists, the graph is called Eulerian (also unicursal).
Representation example: G1 has Euler path a, c, d, e, b, d, a, b
a b
c d e
Hamiltonian Path
Hamiltonian path (also called traceable path) is a path that visits each vertex exactly once.
If there exists a walk in the connected graph that visits every vertex of the graph exactly once without
repeating the edges, then such a walk is called as a Hamiltonian path.
In Hamiltonian path, all the edges may or may not be covered but edges must not repeat.
A graph that contains a Hamiltonian path is called a traceable graph.
Hamiltonian Path
Hamiltonian Circuit
A Hamiltonian cycle (also called Hamiltonian circuit, vertex tour or graph cycle) is a cycle that visits each
vertex exactly once (except for the starting vertex, which is visited once at the start and once again at the
end).
If there exists a walk in the connected graph that visits every vertex of the graph exactly once (except
starting vertex) without repeating the edges and returns to the starting vertex, then such a walk is called
as a Hamiltonian circuit.
Any Hamiltonian cycle can be converted to a Hamiltonian path by removing one of its edges, but a
Hamiltonian path can be extended to Hamiltonian cycle only if its endpoints are adjacent.
Hamiltonian Circuit
Hamiltonian Graph
A graph that contains a Hamiltonian cycle is called a
Hamiltonian graph.
This graph contains a closed walk ABCDEFA.
It visits every vertex of the graph exactly once except starting
vertex.
The edges are not repeated during the walk.
Therefore, it is a Hamiltonian graph
Hamiltonian Graph
BCEDAB
Hamiltonian Graph
Question
KONIGSBERG BRIDGE PROBLEM IN GRAPH THEORY
 Konigsberg is the former name of a German city that is now in Russia.
 The following picture shows the inner city of Konigsberg with the river Pregel.
 The river Pregel divides the city into four land areas A, B, C and D.
 In order to travel from one part of the city to another, there exists seven bridges.
KONIGSBERG BRIDGE PROBLEM IN GRAPH THEORY
 Konigsberg Bridge Problem may be stated as-
 “Starting from any of the four land areas A, B, C, D, is it possible to cross each of the seven bridges
exactly once and come back to the starting point without swimming across the river?”
 In 1735, A Swiss Mathematician Leon hard Euler solved this problem.
 He provided a solution to the problem and finally concluded that such a walk is not possible..
 Euler represented the given situation using a graph as shown below-
KONIGSBERG BRIDGE PROBLEM IN GRAPH THEORY
In this graph,
1. Vertices represent the landmasses.
2. Edges represent the bridges
It was finally concluded that the desired walking tour of Konigsberg is not possible.
Then the citizens of Konigsberg decides to build an eighth bridge from A to C, then-
It would be possible to walk without traversing any bridge twice.
This is because then there will be exactly two odd vertices.
KONIGSBERG BRIDGE PROBLEM IN GRAPH THEORY
Shortest-Path Problems
Shortest-Path problems
◦ Single-source (single-destination). Find a shortest path from a given source (vertex s)
to each of the vertices. The topic of this lecture.
◦ Single-pair. Given two vertices, find a shortest path between them. Solution to single-
source problem solves this problem efficiently, too.
◦ All-pairs. Find shortest-paths for every pair of vertices. Dynamic programming
algorithm.
◦ Unweighted shortest-paths – BFS.
DIJKSTRA'S ALGORITHM
Dijkstra's Algorithm finds the shortest path between a given node (which is called the "source node")
and all other nodes in a graph.
This algorithm uses the weights of the edges to find the path that minimizes the total distance (weight)
between the source node and all other nodes.
Dijkstra's Algorithm can only work with graphs that have positive weights.
https://www.javatpoint.com/discrete-mathematics-dijkstras-algorithm
https://www.freecodecamp.org/news/dijkstras-shortest-path-algorithm-visual-
introduction/#:~:text=Dijkstra's%20Algorithm%20finds%20the%20shortest,node%20and%20all
%20other%20nodes.
Questions
Traveling Salesman Problem
Given a number of cities and the costs of traveling from one to the other, what is the cheapest roundtrip
route that visits each city once and then returns to the starting city?
An equivalent formulation in terms of graph theory is: Find the Hamiltonian cycle with the least weight
in a weighted graph.
It can be shown that the requirement of returning to the starting city does not change the computational
complexity of the problem.
A related problem is the (bottleneck TSP): Find the Hamiltonian cycle in a weighted graph with the
minimal length of the longest edge.
Planar Graphs
A graph (or multigraph) G is called planar if G can be drawn in the plane with its edges intersecting only at
vertices of G, such a drawing of G is called an embedding of G in the plane.
A graph which can be drawn in the plane so that its edges do not cross is called planare.
Application Example: VLSI design (overlapping edges requires extra layers), Circuit design (cannot overlap
wires on board)
Representation examples: K1,K2,K3,K4 are planar, Kn for n>4 are non-planar
K4
Planar Graphs
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.
Example
Example: Consider the graph shown in Fig. Determine the number of
regions, finite regions and an infinite region.
Solution: There are five regions in the above graph, i.e. r1,r2,r3,r4,r5.
There are four finite regions in the graph, i.e., r2,r3,r4,r5.
There is only one infinite region, i.e., r1
Planar Graphs
Properties of Planar Graphs:
1. If a connected planar graph G has e edges and r regions, then r ≤ e.
2. If a connected planar graph G has e edges, v vertices, and r regions, then v-e+r=2.
3. If a connected planar graph G has e edges and v vertices, then 3v-e≥6.
4. A complete graph Kn is a planar if and only if n<5.
5. A complete bipartite graph Kmn is planar if and only if m<3 or n>3.
Planar Graphs
Representation examples: Q3
Planar Graphs
Representation examples: K3,3 is Nonplanar
v1 v2
v5
v4
v3
v6
v1
v2
v4
v4
v5 v1
v2
v5
v3
R1
R2
R21
R1
R22
Theorem : Euler's planar graph theorem
For a connected planar graph or multigraph:
v – e + r = 2
number
of vertices
number
of edges
number
of regions
Planar Graphs
Planar Graphs
Example of Euler’s theorem
K4
R1
R2
R3
A planar graph divides the plane
into several regions (faces), one
of them is the infinite region.
v= 4, e= 6, r= 4,
V – e + r = 2
R4
Planar Graphs
Proof of Euler’s formula: By Induction
Base Case: for G1 , e1 = 1, v1 = 2 and r1= 1
n+1 Case: Assume, rn = en – vn + 2 is true. Let {an+1, bn+1} be the edge that is added to Gn to obtain Gn+1 and we
prove that rn = en – vn + 2 is true. Can be proved using two cases.
R1
v
u
Planar Graphs
Corollary 1: Let G = (V, E) be a connected simple planar graph with |V| = v, |E| = e > 2, and r regions.
Then 3r ≤ 2e and e ≤ 3v – 6
Proof: Since G is loop-free and is not a multigraph, the boundary of each region (including the infinite
region) contains at least three edges. Hence, each region has degree ≥ 3.
Degree of region: No. of edges on its boundary; 1 edge may occur twice on boundary -> contributes 2 to
the region degree.
Each edge occurs exactly twice: either in the same region or in 2 different regions
R
an+1
bn+1
Region Degree
R
R
Degree of R = 3
Degree of R = ?
Planar Graphs
Each edge occurs exactly twice: either in the same region or in 2 different regions
2e = sum of degree of r regions determined by 2e
2e ≥ 3r. (since each region has a degree of at least 3)
r ≤ (2/3) e
From Euler’s theorem, 2 = v – e + r
2 ≤ v – e + 2e/3
2 ≤ v – e/3
So 6 ≤ 3v – e
or e ≤ 3v – 6
Planar Graphs
Corollary 2: Let G = (V, E) be a connected simple planar graph then G has a vertex degree that does not
exceed 5
Proof: If G has one or two vertices the result is true
If G has 3 or more vertices then by Corollary 1, e ≤ 3v – 6
2e ≤ 6v – 12
If the degree of every vertex were at least 6:
by Handshaking theorem: 2e = Sum (deg(v))
 2e ≥ 6v. But this contradicts the inequality 2e ≤ 6v – 12
There must be at least one vertex with degree no greater than 5
Planar Graphs
Corollary 3: Let G = (V, E) be a connected simple planar graph with v vertices ( v ≥ 3) , e edges, and no
circuits of length 3 then e ≤ 2v -4
Proof: Similar to Corollary 1 except the fact that no circuits of length 3 imply that degree of region must
be at least 4.
Planar Graphs
Elementary sub-division: Operation in which a graph are obtained by removing an edge {u, v} and adding
the vertex w and edges {u, w}, {w, v}
Homeomorphic Graphs: Graphs G1 and G2 are termed as homeomorphic if they are obtained by
sequence of elementary sub-divisions.
u v u v
w
Planar Graphs
Non-Planar Graph:
A graph is said to be non planar if it cannot be drawn in a plane so that no edge cross.
Ref:- https://www.javatpoint.com/planar-and-non-planar-graphs#:~:text=A%20graph%20is%20said%20to,and%20cannot%20be%20further%20subdivided.
Planar Graphs
Kuwratoski’s Theorem: A graph is non-planar if and only if it contains a subgraph homeomorephic to K3,3 or K5
Representation Example: G is Nonplanar
a
b
c
j
d
i
e
g
f
k
b
a
c
e
d
f
g
h
G
H K5
e
d
c
b
a
GRAPH COLORING PROBLEM
Graph Coloring is also called as Vertex Coloring.
No two adjacent vertices are colored with the same color.
Graph Coloring is a process of assigning colors to the vertices of a graph.
Graph coloring is an assignment of "colors", almost always taken to be consecutive integers starting from
1 without loss of generality, to certain objects in a graph. Such objects can be vertices, edges, faces, or a
mixture of the above.
Application examples: Map Coloring, Scheduling the tasks, Preparing Time Table, Assignment, Conflict
Resolution, Sudoku
GRAPH COLORING PROBLEM
Chromatic Number is the minimum number of colors required to properly color any graph.
OR
Chromatic Number is the minimum number of colors required to color any graph such that no two adjacent vertices
of it are assigned the same color.
Chromatic number: least number of colors needed to color the graph
A graph that can be assigned a (proper) k-coloring is k-colorable, and it is k-chromatic if its chromatic number is
exactly k.
GRAPH COLORING PROBLEM
The problem of finding a minimum coloring of a graph is NP-Hard
The corresponding decision problem (Is there a coloring which uses at most k colors?) is NP-complete
The chromatic number for Cn = 3 (n is odd) or 2 (n is even), Kn = n, Km,n = 2
Cn: cycle with n vertices; Kn: fully connected graph with n vertices; Km,n: complete bipartite graph
C5
K4 K2, 3
C4
GRAPH COLORING PROBLEM
The Four color theorem: the chromatic number of a planar graph is no greater than 4
Example: G1 chromatic number = 3, G2 chromatic number = 4
(Most proofs rely on case by case analysis).
G1 G2
GRAPH COLORING PROBLEM
•No two adjacent vertices are colored with the same color.
•Minimum number of colors required to properly color the vertices = 3.
•Therefore, Chromatic number of this graph = 3.
GRAPH COLORING PROBLEM
Find chromatic number of the following graph-
Vertex a b c d e f g
Color C1 C2 C1 C3 C2 C3 C4
•Minimum number of colors used to color the given graph are 4.
•Therefore, Chromatic Number of the given graph = 4
GRAPH COLORING PROBLEM
Find chromatic number of the following graph-
Vertex a b c d e f
Color C1 C2 C3 C1 C2 C3
•Minimum number of colors used to color the given graph are 3.
•Therefore, Chromatic Number of the given graph = 3.
Graph ASS DBATU.pptx

Graph ASS DBATU.pptx

  • 1.
  • 2.
    Topics Covered  Definitions Types  Terminology  Representation  Sub-graphs  Connectivity  Hamilton and Euler definitions  Shortest Path  Planar Graphs  Graph Coloring
  • 3.
    Graph  Many realproblems require the data to be presented in a two dimensional plane.  Graph theory is a branch of mathematics that deals with graphs, networks, and their properties.  Graph theory is used in transportation planning, logistics, routing, and cost analysis.  Finding the shortest or fastest route between two points on the map is certainly one of the most commonly used applications of graph theory.  Graph theory has many applications in transportation planning, including modeling road networks, selecting efficient routes, and optimizing traffic flow.  A database of links between web pages is called a “web graph”. These graphs are used by search engines such as Google, Bing, and Yahoo!.
  • 4.
    Varying Applications (examples) Computer networks  Distinguish between two chemical compounds with the same molecular formula but different structures.  Solve shortest path problems between cities.  Scheduling exams and assign channels to television stations.
  • 5.
    Definitions - Graph Ageneralization of the simple concept of a set of dots, links, edges or arcs. A graph G is a non linear data structure represented as an ordered pair as G=<V,E>. A graph G is mathematical structure consisting of two sets V and E where V is non-empty set of vertices and E is a non-empty set of edges. Representation: Graph G = (V, E)  Set of vertices denoted by V, or by V(G) and  Set of edges E, or E(G) Example: Suppose there is a graph G = (V, E), where V = {a, b, c, d}, and E = {(a, b), (a, c), (b, c), (c, d)}.
  • 7.
    Basic Terminology 1. TrivialGraph: A graph consisting only one vertex and no edge. Example : 2. Null Graph:- A Graph consisting n vertex and no edge.
  • 8.
    Definitions – EdgeType 3. Directed: Ordered pair of vertices. Represented as (u, v) directed from vertex u to v. A set of vertices, which are connected with the directed edges. In the directed graph, the edges have a direction which is associated with the vertices. A graph consist the direction of the edges then this is called directed graph. 4. Undirected: Unordered pair of vertices. Represented as {u, v}. A graph which is not directed then it is called undirected graph. A set of vertices which are connected together by the undirected edges. All the edges of this graph are bidirectional. u v u v e1 e2 e3 e1
  • 9.
    Definitions – EdgeType 5. Loop: A loop is an edge whose endpoints are equal. i.e., An edge joining a vertex to it self is called a loop. Represented as {u, u} = {u} 6. Multiple Edges: A collection of two or more edges joining the same pair of vertices. u
  • 10.
    Definitions – GraphType 7. Proper edge:- An edge which is not self loop is called proper edge. 8. Simple Graph: A graph does not contain any self loop and multiage. Each edge is associated with an unordered pair of vertices. Representation Example: G(V, E), V = {u, v, w}, E = {{u, v}, {v, w}, {u, w}} u v w Dig A Dig B
  • 12.
    Definitions – GraphType 9. Multigraph: A graph does not contain any self loop but contain multiedge is called multigraph. G(V,E), consists of set of vertices V, set of Edges E and a function f from E to {{u, v}| u, v V, u ≠ v}. The edges e1 and e2 are called multiple or parallel edges if f (e1) = f (e2). Representation Example: V = {u, v, w}, E = {e1, e2, e3} u v w e1 e2 e3
  • 14.
    Definitions – GraphType 10. Pseudograph: A graph contain both self loop and multiedge is called pseudograph. Representation Example: V = {u, v, w}, E = {e1, e2, e3, e4} u v w e1 e3 e2 e4
  • 15.
    Definitions – GraphType Example:- Directed Graph: G(V, E), set of vertices V, and set of Edges E, that are ordered pair of elements of V (directed edges) Representation Example: G(V, E), V = {u, v, w}, E = {(u, v), (v, w), (w, u)} u w v
  • 16.
    Definitions – GraphType Example:- 11. Directed Multigraph: G(V,E), consists of set of vertices V, set of Edges E and a function f from E to {{u, v}| u, v V}. The edges e1 and e2 are multiple edges if f(e1) = f(e2) Representation Example: V = {u, v, w}, E = {e1, e2, e3, e4} u u u e1 e2 e3 e4
  • 17.
    Graph Type Type Edges MultipleEdges Allowed ? Loops Allowed ? Simple Graph Undirected No No Multigraph Undirected Yes No Pseudograph Undirected Yes Yes Directed Graph Directed No Yes Directed Multigraph Directed Yes Yes
  • 18.
    Definitions – GraphType 12. Incidence and adjacency Two vertices, u and v in an undirected graph G are called adjacent (or neighbors) in G, if {u, v} is an edge of G. An edge e connecting u and v is called incident with vertices u and v, or is said to connect u and v. The vertices u and v are called endpoints of edge {u, v}. Here e1 is incident of V1 and V2 and V1 and V2 are adjacent. V1 V3 V2 e1 e2 e3
  • 19.
    Terminology – Directedgraphs 13. 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. 14. Finite Graph:- A graph with finite vertex set is called a finite graph.
  • 20.
    Terminology – Directedgraphs Parallel Edge :- If there are more than one edge between two nodes then they are known as parallel edges. Not a parallel edges because ()u,v) and (v,u) are two different edges u u v v u v
  • 21.
    Definitions – GraphType 15 Digraph Graph: A graph G = (V, E) with a mapping f such that every edge maps onto some ordered pair of vertices (Vi, Vj) are called a Digraph. It is also called Directed Graph. The ordered pair (Vi, Vj) means an edge between Vi and Vj with an arrow directed from Vi to Vj. Here in the figure: e1 = (V1, V2) e2 = (V2, V3) e4 = (V2, V4)
  • 22.
    Definitions – GraphType 16. 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.
  • 23.
    Definitions – GraphType 17. Symmetric Digraph: A digraph in which each pair of vertices have either one edge or no edges is known as symmetric digraph. 18 Asymmetric Digraph A digraph in which each pair of vertices x, y have either no edges or two edges <x, y> and <y, x>
  • 24.
    Definitions – GraphType Connected and Disconnected Graph:- A graph is said to be connected if every pair of vertices in the graph is connected. This means that there is a path between every pair of vertices. An undirected graph that is not connected is called disconnected.
  • 25.
    Terminology – Undirectedgraphs Degree of Vertex (deg (v)): The degree of a vertex in an undirected graph is the number of edges incident with it, except that a loop at a vertex contributes twice to the degree of that vertex. Pendant :- A vertex is pendant if and only if it has degree one. A pendant vertex is adjacent to exactly one other vertex. Pendant Vertex: deg (v) =1 Isolated Vertex : A vertex of degree zero is called isolated. K Isolated Vertex: deg (k) = 0 Representation Example: For V = {u, v, w} , E = { {u, w}, {u, w}, (u, v) }, deg (u) = 2, deg (v) = 1, deg (w) = 1, deg (k) = 0, w and v are pendant , k is isolated u k w v
  • 26.
    deg( e )= 0 deg( b ) = 6 Find the degree of all the other vertices. deg( a )=2 deg( c )= 4 deg( f)=3 deg( g )=4 deg( d ) = 1 Terminology – Undirected graphs
  • 27.
    Terminology – Directedgraphs For the edge (u, v), u is adjacent to v OR v is adjacent from u, u – Initial vertex, v – Terminal vertex In-degree (deg- (u)): Number of edges for which u is terminal vertex Out-degree (deg+ (u)): Number of edges for which u is initial vertex Note: A loop contributes 1 to both in-degree and out-degree (why?) Representation Example: For V = {u, v, w} , E = { (u, w), ( v, w), (u, v) }, deg- (u) = 0, deg+ (u) = 2, deg- (v) = 1, deg+ (v) = 1, and deg- (w) = 2, deg+ (u) = 0 u w v
  • 28.
  • 31.
  • 32.
    Theorems: The Handshakingtheorem: Sum of degree of all the vertices is twice the number of edges contained in it.
  • 33.
  • 34.
    Example 2 2. Asimple graph G has 24 edges and degree of each vertex is 4. Find the number of vertices. 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 n = 2 x 6 ∴ n = 12 Thus, Number of vertices in the graph = 12
  • 35.
    Example 3 A graphcontains 21 edges, 3 vertices of degree 4 and all other vertices of degree 2. Find total number of vertices. Solution- Given- • Number of edges = 21 • Number of degree 4 vertices = 3 • All other vertices are of degree 2 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- 3 x 4 + (n-3) x 2 = 2 x 21 12 + 2n – 6 = 42 2n = 42 – 6 2n = 36 ∴ n = 18 Thus, Total number of vertices in the graph = 18.
  • 36.
    Example 4 A graphhas 24 edges and degree of each vertex is k, then which of the following is possible number of vertices? A. 20 B. 15 C. 10 D. 8 Given- • Number of edges = 24 • Degree of each vertex = k 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 k = 2 x 24 k = 48 / n Now, • It is obvious that the degree of any vertex must be a whole number. • So in the above equation, only those values of ‘n’ are permissible which gives the whole value of ‘k’. Now, let us check all the options one by one- • For n = 20, k = 2.4 which is not allowed. • For n = 15, k = 3.2 which is not allowed. • For n = 10, k = 4.8 which is not allowed. • For n = 8, k = 6 which is allowed
  • 37.
    Simple graphs –special cases Complete graph: Kn, is the simple graph that contains exactly one edge between each pair of distinct vertices. Representation Example: K1, K2, K3, K4 K2 K1 K4 K3 • Each vertex is connected with all the remaining vertices through exactly one edge.
  • 38.
    Simple graphs –special cases Cycle: A simple graph of ‘n’ vertices (n>=3) and n edges forming a cycle of length ‘n’ is called as a cycle graph. In a cycle graph, all the vertices are of degree 2. Cn, n ≥ 3 consists of n vertices v1, v2, v3 … vn and edges {v1, v2}, {v2, v3}, {v3, v4} … {vn-1, vn}, {vn, v1} Representation Example: C3, C4 C3 C4
  • 39.
    Simple graphs –special cases Cyclic Graph-  A graph containing at least one cycle in it is called as a cyclic graph. This graph contains two cycles in it. Therefore, it is a cyclic graph Acyclic Graph- A graph not containing any cycle in it is called as an acyclic graph. This graph do not contain any cycle in it.
  • 40.
    Simple graphs –special cases Wheels: Wn, obtained by adding additional vertex to Cn and connecting all vertices to this new vertex by new edges. Representation Example: W3, W4 W3 W4
  • 41.
    Simple graphs –special cases N-cubes: Qn, vertices represented by 2n bit strings of length n. Two vertices are adjacent if and only if the bit strings that they represent differ by exactly one bit positions Representation Example: Q1, Q2 0 10 1 00 11 Q1 01 Q2
  • 42.
    Simple graphs –special cases Regular Graph:- A graph in which degree of all the vertices is same is called as a regular graph. If all the vertices in a graph are of degree ‘k’, then it is called as a “k-regular graph“. n these graphs, •All the vertices have degree-2. •Therefore, they are 2-Regular graphs. https://www.geeksforgeeks.org/regular-graph-in-graph-theory/?ref=rp
  • 43.
    Bipartite graphs A bipartitegraph, also called a bigraph, is a set of graph vertices decomposed into two disjoint sets such that no two graph vertices within the same set are adjacent. If the vertex set V of a graph G can be partitioned into two non empty disjoint subsets X and Y in such way that each edge of G has one end in X and one end in Y then G is called Bigraph or bipartite graph. A bipartite graph is a special kind of graph with the following properties- • It consists of two sets of vertices X and Y. • The vertices of set X join only with the vertices of set Y. • The vertices within the same set do not join. V x Y
  • 44.
    Bipartite graphs The verticesof the graph can be decomposed into two sets. The two sets are X = {A, C} and Y = {B, D}. The vertices of set X join only with the vertices of set Y and vice-versa. The vertices within the same set do not join. Therefore, it is a bipartite graph
  • 45.
  • 46.
    Bipartite graphs Note:- Ifa graph is connected then it will not bipartite
  • 47.
    Complete Bipartite graphs Agraph G = (V, E) is called a complete bipartite graph if its vertices V can be partitioned into two subsets V1 and V2 such that each vertex of V1 is connected to each vertex of V2. The number of edges in a complete bipartite graph is m.n as each of the m vertices is connected to each of the n vertices. Km,n is the graph that has its vertex set portioned into two subsets of m and n vertices, respectively There is an edge between two vertices if and only if one vertex is in the first subset and the other vertex is in the second subset. Representation example: K2,3, K3,3 K2,3 K3,3 A bipartite graph where every vertex of set X is joined to every vertex of set Y is called as complete bipartite graph
  • 48.
  • 49.
    Problem-01: Is the followinggraph a bipartite graph? Sol: The given graph may be redrawn as- This graph consists of two sets of vertices. The two sets are X = {1, 4, 6, 7} and Y = {2, 3, 5, 8}. The vertices of set X are joined only with the vertices of set Y and vice-versa. Also, any two vertices within the same set are not joined. This satisfies the definition of a bipartite graph
  • 50.
    Bipartite graphs • Inany bipartite graph with bipartition X and Y, Sum of degree of vertices of set X = Sum of degree of vertices of set Y Maximum Number Of Edges- Any bipartite graph consisting of ‘n’ vertices can have at most (1/4) x n2 edges. Maximum possible number of edges in a bipartite graph on ‘n’ vertices = (1/4) x n2.
  • 51.
    Problem 2 The maximumnumber of edges in a bipartite graph on 12 vertices is _________? Solution- We know, Maximum possible number of edges in a bipartite graph on ‘n’ vertices = (1/4) x n2. Substituting n = 12, we get- Maximum number of edges in a bipartite graph on 12 vertices = (1/4) x (12)2 = (1/4) x 12 x 12 = 36 Therefore, Maximum number of edges in a bipartite graph on 12 vertices = 36.
  • 52.
    Subgraphs When edges andvertices are removed from a graph, without removing endpoints of any remaining edges, a smaller graph is obtained. Such a graph is called a subgraph of the original graph. A graph G1 = (V1, E1) is called a subgraph of a graph G(V, E) if V1(G) is a subset of V(G) and E1(G) is a subset of E(G) such that each edge of G1 has same end vertices as in G. A subgraph of a graph G = (V, E) is a graph H =(V’, E’) where V’ is a subset of V and E’ is a subset of E Application example: solving sub-problems within a graph Representation example: V = {u, v, w}, E = ({u, v}, {v, w}, {w, u}}, H1 , H2 u v w u u w v v H1 H2 G
  • 53.
    Subgraphs When edges andvertices are removed from a graph, without removing endpoints of any remaining edges, a smaller graph is obtained. Such a graph is called a subgraph of the original graph. A subgraph of a graph G = (V, E) is a graph H =(V’, E’) where V’ is a subset of V and E’ is a subset of E Application example: solving sub-problems within a graph Representation example: V = {u, v, w}, E = ({u, v}, {v, w}, {w, u}}, H1 , H2 u v w w v w u G1 G2 G
  • 54.
    Union and Intersection Giventwo graphs G1 and G2, the task is to find the union and intersection of the two given graphs, i.e. (G1 ∪ G2) and (G1 ∩ G2).
  • 55.
    Complement of Graph Thecomplement of a graph G is a graph G’ on the same set of vertices as of G such that there will be an edge between two vertices (v, e) in G’, if and only if there is no edge in between (v, e) in G. Complement of graph G(v, e) is denoted by G'(v, e’). Note: The number of vertices remains unchanged in the complement of the graph. Graph Complement Graph
  • 56.
    Complement of Graph Relationbetween G and G`: 1. Number of vertices in G = Number of vertices in G’. |V(G)| = |V(G’)| 2. The sum of total number of edges in G and G’ is equal to the total number of edges in a complete graph. |E(G)| + |E(G’)| = C(n,2) = n(n-1) / 2
  • 57.
    Problem Problem-01: A simple graphG has 10 vertices and 21 edges. Find total number of edges in its complement graph G’. Solution- Given- Number of edges in graph G, |E(G)| = 21 Number of vertices in graph G, n = 10 We know |E(G)| + |E(G’)| = n(n-1) / 2. Substituting the values, we get- 21 + |E(G’)| = 10 x (10-1) / 2 |E(G’)| = 45 – 21 ∴ |E(G’)| = 24 Thus, Number of edges in complement graph G’ = 24.
  • 58.
    Representation Graph representation, meansthe technique to be used to store some graph into the computer's memory. There are two ways to store Graphs into the computer's memory: 1. Incidence (Matrix): Most useful when information about edges is more desirable than information about vertices. 2. Adjacency (Matrix/List): Most useful when information about the vertices is more desirable than information about the edges. These two representations are also most popular since information about the vertices is often more desirable than edges in most applications
  • 59.
    Representation- Incidence Matrix Representationof the Undirected Graph: G = (V, E) be an unditected graph. Suppose that v1, v2, v3, …, vn are the vertices and e1, e2, …, em are the edges of G. Then the incidence matrix with respect to this ordering of V and E is the n x m matrix M = [m ij], where Can also be used to represent : Incidence matrix also be used to represent Multiple edges and loops. Multiple edges: by using columns with identical entries, because these edges are incident with the same pair of vertices. Loops: by using a column with exactly one entry equal to 1, corresponding to the vertex that is incident with the loop     otherwise 0 ith v incident w is e edge when 1 m i j ij
  • 60.
    Representation- Incidence Matrix RepresentationExample: G = (V, E) e1 e2 e3 v 1 0 1 u 1 1 0 w 0 1 1 v w u e1 e3 e2
  • 61.
  • 62.
  • 63.
    Representation- Incidence Matrix Representationof the directed Graph: If a directed graph G consists of n vertices and m edges, then the incidence matrix is an n x m matrix C = [cij] and defined by The number of ones in an incidence matrix is equal to the number of edges in the graph.
  • 64.
    Example Consider the directedgraph G as shown in fig. Find its incidence matrix MI.
  • 65.
    Representation- Adjacency Matrix Representationof the Undirected Graph:  A Adjacency Matrix is a N*N binary matrix in which value of [i,j]th cell is 1 if there exists an edge originating from ith vertex and terminating to jth vertex, otherwise the value is 0.  There is an N x N matrix, where |V| = N , the Adjacenct Matrix (NxN) A = [aij] For undirected graph  For directed graph  This makes it easier to find subgraphs, and to reverse graphs if needed.     otherwise 0 G of edge an is ) v , (v if 1 a j i ij     otherwise 0 G of edge an is } v , {v if 1 a j i ij
  • 66.
    Representation- Adjacency Matrix Adjacencyis chosen on the ordering of vertices. Hence, there as are as many as n! such matrices. The adjacency matrix of simple graphs are symmetric (aij = aji) (why?) When there are relatively few edges in the graph the adjacency matrix is a sparse matrix Directed Multigraphs can be represented by using aij = number of edges from vi to vj
  • 67.
    Representation- Adjacency Matrix Example:Undirected Graph G (V, E) v u w v 0 1 1 u 1 0 1 w 1 1 0 u v w
  • 68.
    Representation- Adjacency Matrix Example:directed Graph G (V, E) v u w v 0 1 0 u 0 0 1 w 1 0 0 u v w
  • 69.
    Example Find the adjacencymatrix MA of graph G shown in Fig:
  • 70.
    Example Consider the directedgraph shown in fig. Determine its adjacency matrix MA. The directed graph G consists of five vertices. Therefore, the adjacency matrix will be a 5 x 5 matrix. The adjacency matrix of the directed graphs is as follows:
  • 71.
  • 72.
    Representation- Adjacency List AdjacencyList specify the vertices that are adjacent to each vertex of the graph. Each node (vertex) has a list of which nodes (vertex) it is adjacent Example: undirected graph G (V, E) node Adjacency List u v , w v w, u w u , v u v w
  • 73.
    Example Use adjacencylists to describe the graph given below
  • 74.
    Example Use adjacencylists to describe the graph given below
  • 75.
  • 76.
  • 77.
  • 78.
    Graph - Isomorphism Thesimple G1 = (V1, E2) and G2 = (V2, E2) are isomorphic if there is a one-to-one and onto function f from V1 to V2 with the property that a and b are adjacent in G1 if and only if f (a) and f (b) are adjacent in G2, for all a and b in V1. Such a function f is called isomorphism. When two graphs G and G` are said to be isomorphic if there is a one-to-one correspondence between their vertices and edges such that the adjacency of vertices are preserved. Such graphs will have the same structure, differencing only in the way of their vertices and edges are labeled.
  • 79.
    Graph - Isomorphism Criteriafor checking two graphs are isomorphic or not:- 1. Both graph have same number of Vertices . 2. Both graph have same number of edges. 3. Both graph have an equal number of vertices with a given degree. 4. one-to-one correspondence between the vertices of two graphs. 5. Edge preserving is also satisfied between two graphs (one-to-one correspondence ). 6. Smallest possible cycle length is same for two graphs. 7. Adjacency matrices of two graphs should be same.
  • 80.
    Graph - Isomorphism Representationexample: G1 = (V1, E1) , G2 = (V2, E2) u1 u3 u4 u2 v3 v4 v1 v2 1. Vertices -4 2. Edges – 4 3. Degree of each Vertices are 2 4. Edge correspondence f(u1) = v1, f(u2) = v4, f(u3) = v3, f(u4) = v2, 6.
  • 81.
    Graph - Isomorphism 1.Number of vertices are same 2. Number of edges are same 3. An equal number of vertices with given degree 4. U1=2 5. U2=3 6. U3 =2 7. U4= 3 8. U5= 2 9. U6=2 V1= 2 V2= 2 V3= 3 V4= 2 V5 =3 V6= 2
  • 82.
  • 83.
  • 84.
  • 85.
    Representation- Incidence Matrix e1e2 e3 a 1 0 0 b 1 1 0 c 0 1 1 d 0 0 1 e 0 0 0 f 0 0 0 e4 e5 e6 e7 0 0 0 1 0 0 0 0 0 1 1 0 1 0 0 0 1 1 0 0 0 0 1 1 a b c d e f e1 e2 e3 e4 e5 e6 e7
  • 86.
    Isomorphism - revisited Aisomorphic invariant for simple graphs is the existence of a simple circuit of length k , k is an integer > 2 (why ?) Representation example: G1 and G2 are isomorphic since we have the invariants, similarity in degree of nodes, number of edges, length of circuits G1 G2
  • 87.
  • 88.
    Connectivity Basic Idea: Ina Graph Reachability among vertices by traversing the edges Application Example: - In a city to city road-network, if one city can be reached from another city. - Problems if determining whether a message can be sent between two computer using intermediate links - Efficiently planning routes for data delivery in the Internet
  • 89.
    Connectivity Walk – Awalk is a sequence of vertices and edges of a graph i.e. if we traverse a graph then we get a walk. Beginning and ending with the same or different vertices. Note: Vertices and Edges can be repeated.
  • 90.
    Connectivity Open walk- Awalk 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. 1->2->3->4->5->3 is an open walk. 1->2->3->4->5->3->1 is a closed walk. Length of a walk: The total number of edges covered in a walk. Ex. Ex 1- Length is 5
  • 91.
    Connectivity 2. Trail – Trailis an open walk in which no edge is repeated. Vertex can be repeated 3. Circuit – Traversing a graph such that not an edge is repeated but vertex can be repeated and it is closed walk. i.e. it is a closed trail. Vertex can be repeated. Edge can not be repeated. Here 1->2->4->3->6->8->3->1 is a circuit.
  • 92.
    Connectivity 4. Path – Itis 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. As path is also a trail, thus it is also an open walk. Vertex not repeated Edge not repeated Here 6->8->3->1->2->4 is a Path
  • 93.
    Connectivity 5. Cycle – Traversinga 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 can not have repeat anything (neither edges nor vertices).
  • 94.
    Connectivity – Path APath is a sequence of edges that begins at a vertex of a graph and travels along edges of the graph, always connecting pairs of adjacent vertices. Representation example: G = (V, E), Path P represented, from u to v is {{u, 1}, {1, 4}, {4, 5}, {5, v}} 1 u 3 4 5 2 v
  • 95.
    Connectivity – Path Definitionfor Directed Graphs A Path of length n (> 0) from u to v in G is a sequence of n edges e1, e2 , e3, …, en of G such that f (e1) = (xo, x1), f (e2) = (x1, x2), …, f (en) = (xn-1, xn), where x0 = u and xn = v. A path is said to pass through x0, x1, …, xn or traverse e1, e2 , e3, …, en For Simple Graphs, sequence is x0, x1, …, xn In directed multigraphs when it is not necessary to distinguish between their edges, we can use sequence of vertices to represent the path Circuit/Cycle: u = v, length of path > 0 Simple Path: does not contain an edge more than once
  • 96.
    Connectivity – Connectedness UndirectedGraph An undirected graph is connected if there exists is a simple path between every pair of vertices. Representation Example: G (V, E) is connected since for V = {v1, v2, v3, v4, v5}, there exists a path between {vi, vj}, 1 ≤ i, j≤ 5 v1 v2 v3 v5 v4
  • 97.
    Connectivity – Connectedness UndirectedGraph Articulation Point (Cut vertex): removal of a vertex produces a subgraph with more connected components than in the original graph. The removal of a cut vertex from a connected graph produces a graph that is not connected Cut Edge: An edge whose removal produces a subgraph with more connected components than in the original graph. Representation example: G (V, E), v3 is the articulation point or edge {v2, v3}, the number of connected components is 2 (> 1) v1 v2 v3 v4 v5
  • 98.
    Connectivity – Connectedness DirectedGraph A directed graph is strongly connected if there is a path from a to b and from b to a whenever a and b are vertices in the graph A directed graph is weakly connected if there is a (undirected) path between every two vertices in the underlying undirected path A strongly connected Graph can be weakly connected but the vice-versa is not true (why?)
  • 99.
    Connectivity – Connectedness DirectedGraph Representation example: G1 (Strong component), G2 (Weak Component), G3 is undirected graph representation of G2 or G1 G2 G1 G3
  • 100.
    Connectivity – Connectedness DirectedGraph Strongly connected Components: subgraphs of a Graph G that are strongly connected Representation example: G1 is the strongly connected component in G G1 G
  • 101.
    Counting Paths Theorem: LetG be a graph with adjacency matrix A with respect to the ordering v1, v2, …, Vn (with directed on undirected edges, with multiple edges and loops allowed). The number of different paths of length r from Vi to Vj, where r is a positive integer, equals the (i, j)th entry of (adjacency matrix) Ar. Proof: By Mathematical Induction. Base Case: For the case N = 1, aij =1implies that there is a path of length 1. This is true since this corresponds to an edge between two vertices. We assume that theorem is true for N = r and prove the same for N = r +1. Assume that the (i, j)th entry of Ar is the number of different paths of length r from vi to vj. By induction hypothesis, bik is the number of paths of length r from vi to vk.
  • 102.
    Counting Paths Case r+1: In Ar+1 = Ar. A, The (i, j)th entry in Ar+1 , bi1a1j + bi2 a2j + …+ bin anj where bik is the (i, j)th entry of Ar. By induction hypothesis, bik is the number of paths of length r from vi to vk. The (i, j)th entry in Ar+1 corresponds to the length between i and j and the length is r+1. This path is made up of length r from vi to vk and of length from vk to vj. By product rule for counting, the number of such paths is bik* akj The result is bi1a1j + bi2 a2j + …+ bin anj ,the desired result.
  • 103.
    Counting Paths a -------b | | | | c -------d A = 0 1 1 0 A4 = 8 0 0 8 1 0 0 1 0 8 8 0 1 0 0 1 0 8 8 0 0 1 1 0 8 0 0 8 Number of paths of length 4 from a to d is (1,4) th entry of A4 = 8.
  • 104.
    Euler - definitions EULERIANPATH is a path in a graph that visits every edge exactly once. Is it possible to draw a given graph without lifting pencil from the paper and without tracing any of the edges more than once”.
  • 105.
    Euler - definitions visitsevery edge exactly once.
  • 106.
    Euler - definitions EULERIANCIRCUIT is an Eulerian Path that starts and ends on the same vertex. If there exists a walk in the connected graph that starts and ends at the same vertex and visits every edge of the graph exactly once with or without repeating the vertices, then such a walk is called as an Euler circuit. A graph will contain an Euler circuit if and only if all its vertices are of even degree. A graph is called Eulerian if it has an Eulerian Cycle . A graph is called Semi-Eulerian if it has an Eulerian Path.
  • 107.
  • 108.
    Euler Graph An EulerGraph is a connected graph that contains an Euler Circuit. Any connected graph is called as an Euler Graph if and only if all its vertices are of even degree.
  • 109.
    Euler - definitions EulerianCycle: An undirected graph has Eulerian cycle if following two conditions are true. 1. All vertices with non-zero degree are connected. We don’t care about vertices with zero degree because they don’t belong to Eulerian Cycle or Path (we only consider all edges). 2. All vertices have even degree. Eulerian Path: An undirected graph has Eulerian Path if following two conditions are true. Same as condition (a) for Eulerian Cycle. 1. If zero or two vertices have odd degree and all 2. Other vertices have even degree. Note that only one vertex with odd degree is not possible in an undirected graph (sum of all degrees is always even in an undirected graph) Note that a graph with no edges is considered Eulerian because there are no edges to traverse.
  • 110.
    Euler - definitions AnEulerian path (Eulerian trail, Euler walk) in a graph is a path that uses each edge precisely once. If such a path exists, the graph is called traversable. An Eulerian cycle (Eulerian circuit, Euler tour) in a graph is a cycle that uses each edge precisely once. If such a cycle exists, the graph is called Eulerian (also unicursal). Representation example: G1 has Euler path a, c, d, e, b, d, a, b a b c d e
  • 111.
    Hamiltonian Path Hamiltonian path(also called traceable path) is a path that visits each vertex exactly once. If there exists a walk in the connected graph that visits every vertex of the graph exactly once without repeating the edges, then such a walk is called as a Hamiltonian path. In Hamiltonian path, all the edges may or may not be covered but edges must not repeat. A graph that contains a Hamiltonian path is called a traceable graph.
  • 112.
  • 113.
    Hamiltonian Circuit A Hamiltoniancycle (also called Hamiltonian circuit, vertex tour or graph cycle) is a cycle that visits each vertex exactly once (except for the starting vertex, which is visited once at the start and once again at the end). If there exists a walk in the connected graph that visits every vertex of the graph exactly once (except starting vertex) without repeating the edges and returns to the starting vertex, then such a walk is called as a Hamiltonian circuit. Any Hamiltonian cycle can be converted to a Hamiltonian path by removing one of its edges, but a Hamiltonian path can be extended to Hamiltonian cycle only if its endpoints are adjacent.
  • 114.
  • 115.
    Hamiltonian Graph A graphthat contains a Hamiltonian cycle is called a Hamiltonian graph. This graph contains a closed walk ABCDEFA. It visits every vertex of the graph exactly once except starting vertex. The edges are not repeated during the walk. Therefore, it is a Hamiltonian graph
  • 116.
  • 117.
  • 118.
  • 119.
    KONIGSBERG BRIDGE PROBLEMIN GRAPH THEORY  Konigsberg is the former name of a German city that is now in Russia.  The following picture shows the inner city of Konigsberg with the river Pregel.  The river Pregel divides the city into four land areas A, B, C and D.  In order to travel from one part of the city to another, there exists seven bridges.
  • 120.
    KONIGSBERG BRIDGE PROBLEMIN GRAPH THEORY  Konigsberg Bridge Problem may be stated as-  “Starting from any of the four land areas A, B, C, D, is it possible to cross each of the seven bridges exactly once and come back to the starting point without swimming across the river?”  In 1735, A Swiss Mathematician Leon hard Euler solved this problem.  He provided a solution to the problem and finally concluded that such a walk is not possible..  Euler represented the given situation using a graph as shown below-
  • 121.
    KONIGSBERG BRIDGE PROBLEMIN GRAPH THEORY In this graph, 1. Vertices represent the landmasses. 2. Edges represent the bridges It was finally concluded that the desired walking tour of Konigsberg is not possible. Then the citizens of Konigsberg decides to build an eighth bridge from A to C, then- It would be possible to walk without traversing any bridge twice. This is because then there will be exactly two odd vertices.
  • 122.
  • 123.
    Shortest-Path Problems Shortest-Path problems ◦Single-source (single-destination). Find a shortest path from a given source (vertex s) to each of the vertices. The topic of this lecture. ◦ Single-pair. Given two vertices, find a shortest path between them. Solution to single- source problem solves this problem efficiently, too. ◦ All-pairs. Find shortest-paths for every pair of vertices. Dynamic programming algorithm. ◦ Unweighted shortest-paths – BFS.
  • 124.
    DIJKSTRA'S ALGORITHM Dijkstra's Algorithmfinds the shortest path between a given node (which is called the "source node") and all other nodes in a graph. This algorithm uses the weights of the edges to find the path that minimizes the total distance (weight) between the source node and all other nodes. Dijkstra's Algorithm can only work with graphs that have positive weights. https://www.javatpoint.com/discrete-mathematics-dijkstras-algorithm https://www.freecodecamp.org/news/dijkstras-shortest-path-algorithm-visual- introduction/#:~:text=Dijkstra's%20Algorithm%20finds%20the%20shortest,node%20and%20all %20other%20nodes.
  • 125.
  • 126.
    Traveling Salesman Problem Givena number of cities and the costs of traveling from one to the other, what is the cheapest roundtrip route that visits each city once and then returns to the starting city? An equivalent formulation in terms of graph theory is: Find the Hamiltonian cycle with the least weight in a weighted graph. It can be shown that the requirement of returning to the starting city does not change the computational complexity of the problem. A related problem is the (bottleneck TSP): Find the Hamiltonian cycle in a weighted graph with the minimal length of the longest edge.
  • 127.
    Planar Graphs A graph(or multigraph) G is called planar if G can be drawn in the plane with its edges intersecting only at vertices of G, such a drawing of G is called an embedding of G in the plane. A graph which can be drawn in the plane so that its edges do not cross is called planare. Application Example: VLSI design (overlapping edges requires extra layers), Circuit design (cannot overlap wires on board) Representation examples: K1,K2,K3,K4 are planar, Kn for n>4 are non-planar K4
  • 128.
    Planar Graphs Region ofa 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.
  • 129.
    Example Example: Consider thegraph shown in Fig. Determine the number of regions, finite regions and an infinite region. Solution: There are five regions in the above graph, i.e. r1,r2,r3,r4,r5. There are four finite regions in the graph, i.e., r2,r3,r4,r5. There is only one infinite region, i.e., r1
  • 130.
    Planar Graphs Properties ofPlanar Graphs: 1. If a connected planar graph G has e edges and r regions, then r ≤ e. 2. If a connected planar graph G has e edges, v vertices, and r regions, then v-e+r=2. 3. If a connected planar graph G has e edges and v vertices, then 3v-e≥6. 4. A complete graph Kn is a planar if and only if n<5. 5. A complete bipartite graph Kmn is planar if and only if m<3 or n>3.
  • 131.
  • 132.
    Planar Graphs Representation examples:K3,3 is Nonplanar v1 v2 v5 v4 v3 v6 v1 v2 v4 v4 v5 v1 v2 v5 v3 R1 R2 R21 R1 R22
  • 133.
    Theorem : Euler'splanar graph theorem For a connected planar graph or multigraph: v – e + r = 2 number of vertices number of edges number of regions Planar Graphs
  • 134.
    Planar Graphs Example ofEuler’s theorem K4 R1 R2 R3 A planar graph divides the plane into several regions (faces), one of them is the infinite region. v= 4, e= 6, r= 4, V – e + r = 2 R4
  • 135.
    Planar Graphs Proof ofEuler’s formula: By Induction Base Case: for G1 , e1 = 1, v1 = 2 and r1= 1 n+1 Case: Assume, rn = en – vn + 2 is true. Let {an+1, bn+1} be the edge that is added to Gn to obtain Gn+1 and we prove that rn = en – vn + 2 is true. Can be proved using two cases. R1 v u
  • 136.
    Planar Graphs Corollary 1:Let G = (V, E) be a connected simple planar graph with |V| = v, |E| = e > 2, and r regions. Then 3r ≤ 2e and e ≤ 3v – 6 Proof: Since G is loop-free and is not a multigraph, the boundary of each region (including the infinite region) contains at least three edges. Hence, each region has degree ≥ 3. Degree of region: No. of edges on its boundary; 1 edge may occur twice on boundary -> contributes 2 to the region degree. Each edge occurs exactly twice: either in the same region or in 2 different regions R an+1 bn+1
  • 137.
    Region Degree R R Degree ofR = 3 Degree of R = ?
  • 138.
    Planar Graphs Each edgeoccurs exactly twice: either in the same region or in 2 different regions 2e = sum of degree of r regions determined by 2e 2e ≥ 3r. (since each region has a degree of at least 3) r ≤ (2/3) e From Euler’s theorem, 2 = v – e + r 2 ≤ v – e + 2e/3 2 ≤ v – e/3 So 6 ≤ 3v – e or e ≤ 3v – 6
  • 139.
    Planar Graphs Corollary 2:Let G = (V, E) be a connected simple planar graph then G has a vertex degree that does not exceed 5 Proof: If G has one or two vertices the result is true If G has 3 or more vertices then by Corollary 1, e ≤ 3v – 6 2e ≤ 6v – 12 If the degree of every vertex were at least 6: by Handshaking theorem: 2e = Sum (deg(v))  2e ≥ 6v. But this contradicts the inequality 2e ≤ 6v – 12 There must be at least one vertex with degree no greater than 5
  • 140.
    Planar Graphs Corollary 3:Let G = (V, E) be a connected simple planar graph with v vertices ( v ≥ 3) , e edges, and no circuits of length 3 then e ≤ 2v -4 Proof: Similar to Corollary 1 except the fact that no circuits of length 3 imply that degree of region must be at least 4.
  • 141.
    Planar Graphs Elementary sub-division:Operation in which a graph are obtained by removing an edge {u, v} and adding the vertex w and edges {u, w}, {w, v} Homeomorphic Graphs: Graphs G1 and G2 are termed as homeomorphic if they are obtained by sequence of elementary sub-divisions. u v u v w
  • 142.
    Planar Graphs Non-Planar Graph: Agraph is said to be non planar if it cannot be drawn in a plane so that no edge cross. Ref:- https://www.javatpoint.com/planar-and-non-planar-graphs#:~:text=A%20graph%20is%20said%20to,and%20cannot%20be%20further%20subdivided.
  • 143.
    Planar Graphs Kuwratoski’s Theorem:A graph is non-planar if and only if it contains a subgraph homeomorephic to K3,3 or K5 Representation Example: G is Nonplanar a b c j d i e g f k b a c e d f g h G H K5 e d c b a
  • 144.
    GRAPH COLORING PROBLEM GraphColoring is also called as Vertex Coloring. No two adjacent vertices are colored with the same color. Graph Coloring is a process of assigning colors to the vertices of a graph. Graph coloring is an assignment of "colors", almost always taken to be consecutive integers starting from 1 without loss of generality, to certain objects in a graph. Such objects can be vertices, edges, faces, or a mixture of the above. Application examples: Map Coloring, Scheduling the tasks, Preparing Time Table, Assignment, Conflict Resolution, Sudoku
  • 145.
    GRAPH COLORING PROBLEM ChromaticNumber is the minimum number of colors required to properly color any graph. OR Chromatic Number is the minimum number of colors required to color any graph such that no two adjacent vertices of it are assigned the same color. Chromatic number: least number of colors needed to color the graph A graph that can be assigned a (proper) k-coloring is k-colorable, and it is k-chromatic if its chromatic number is exactly k.
  • 146.
    GRAPH COLORING PROBLEM Theproblem of finding a minimum coloring of a graph is NP-Hard The corresponding decision problem (Is there a coloring which uses at most k colors?) is NP-complete The chromatic number for Cn = 3 (n is odd) or 2 (n is even), Kn = n, Km,n = 2 Cn: cycle with n vertices; Kn: fully connected graph with n vertices; Km,n: complete bipartite graph C5 K4 K2, 3 C4
  • 147.
    GRAPH COLORING PROBLEM TheFour color theorem: the chromatic number of a planar graph is no greater than 4 Example: G1 chromatic number = 3, G2 chromatic number = 4 (Most proofs rely on case by case analysis). G1 G2
  • 148.
    GRAPH COLORING PROBLEM •Notwo adjacent vertices are colored with the same color. •Minimum number of colors required to properly color the vertices = 3. •Therefore, Chromatic number of this graph = 3.
  • 149.
    GRAPH COLORING PROBLEM Findchromatic number of the following graph- Vertex a b c d e f g Color C1 C2 C1 C3 C2 C3 C4 •Minimum number of colors used to color the given graph are 4. •Therefore, Chromatic Number of the given graph = 4
  • 150.
    GRAPH COLORING PROBLEM Findchromatic number of the following graph- Vertex a b c d e f Color C1 C2 C3 C1 C2 C3 •Minimum number of colors used to color the given graph are 3. •Therefore, Chromatic Number of the given graph = 3.