Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

Discrete Structures

Unit IV : Graphs ( Refer T-1 and R-6 )


• Introduction, Basic Terminology
• Multigraphs and Weighted Graphs
• Paths and Circuits, Shortest Paths in Weighted
Graphs
• Eulerian Paths and Circuits
• Hamiltonial Paths and Circuits
• The Traveling Salesperson Problem
• Factors of a Graph, Planner Graphs
• Unit IV at a Glance
Unit IV : Graphs
Objective :

To Discuss the concepts and terminologies


associated. with graph theory and their applications.

Introduction :
• Many real life problems can be abstracted as problems
concerning sets of discrete objects and binary relations on
them. For example, consider a number of cities connected by
highways, and we might want to determine whether there is a
highway route between two cities.
• In many problems dealing with discrete objects and binary
relations , a graphical representation of the objects and the
binary relations on them is a very convenient form of
Unit IV : Graphs
Basic Terminology :
Directed Graph : A directed graph or digraph G = (V, E), is defined
abstractly as an ordered pair (V, E), where V is a set and E is a binary
relation on V. For example,
V = {a, b, c, d) and E = {(a,b),(b,a),(b,d),(d,a),(d,d),(c,c)}.
Elements in V are called as vertices and elements in E are called
as ordered pairs or (directed) edges.
The edge (a,b) is incident with the vertices a and b i.e. it is
incident from a and incident into b. Vertex a is called as initial
vertex and vertex b is called as terminal vertex
An edge that is incident from and into the same vertex is called as
a loop, e.g. edge (c,c)
Two vertices are said to be adjacent if they are joined by an edge
e.g. for an edge (a, b), vertex a is said to be adjacent to vertex b
and vertex b is said to be adjacent from vertex a. Vertex c is
isolated vertex since there is no edge incident to c.
Unit IV : Graphs
Basic Terminology contd…:
Undirected Graph : An undirected graph or digraph G = (V, E), is
defined abstractly as an ordered pair (V, E), where V is a set and E is a
set of multisets of two elements from V. For example,
V = {a, b, c, d) and E = {(a,b),(a,d),(b,c),(b,d), (c,c)}.

Simple Graph : A graph that has no self loops or parallel edges.

Asymmetric Digraph : Digraph having only one directed edge


between each pair of vertices but can have self loops.

Symmetric Digraph : Digraph in which for each edge (x,y), there is


also an edge (y,x).

Isomorphic Graphs : Two graphs are said to be isomorphic if there is


one-to-one correspondence between their vertices and between their
edges such that incidences are preserved.
Unit IV : Graphs
Basic Terminology contd… :
Subgraph : Let G = (V, E) be a graph. A Graph G’ =
(V’, E’) is said to be a subgraph of G if E’ is a subset
of E and V’ is a subset of V such that the edges in E’
are incident only on the vertices in V’, For example,
V = {a, b, c, d, e, f, g, h},
E = {(a, b),(b ,c),(c, d),(d, e),(e, f),(f, a),(b, g),(g, f),
(g, h),(g, c),(h, d),(h, e)}
V’ = {b, c, d, e, f, g, h},
E’= {(d, e),(e, f),,(b, g),(g, f),(h, d),(h, e)}
Spanning subgraph : If V = V’ then it is said to be a
spanning subgraph.
Unit IV : Graphs
Basic Terminology contd… :

Complete Graph : The undirected complete graph of n


vertices, denoted as Kn , is a graph with n vertices in which
there is an edge between each pair of distinct vertices.
.
Unit IV : Graphs
Exercise:
1.Define Graph and Multigraph. Give any two
applications of graph and represent them in graph
notation.
2.What are self complementary graphs? Are there any self
complementary graphs with 4 and 5 vertices: if yes draw
them.
3.Draw isomorphic graph of a given graph shown below
but no crossover of edges. [Ref Q-8 (c ) of Nov-Dec-
2011]
Unit IV : Graphs
Basic Terminology contd… :
Directed Complete Graph : The directed complete graph of
n vertices, is a graph with n vertices in which there is a
directed edge (only one) between each pair of distinct
vertices.
Directed Multigraph : A graph G = (V, E) a directed
multigraph, where V is a set of vertices and E is a multiset of
ordered pairs from VxV
Weighted Graph : In real life problem, there are many
occasions in which we wish to attach additional information
to the vertices and / or the edges of the graph. For example, a
graph that represents the highway connection among cities.
Unit IV : Graphs
Basic Terminology contd… :

Representation of Graph: i) Incidence Matrix ii) Adjacency Matrix


Unit IV : Graphs
Operations on Graphs:
Since graphs are defined in terms of sets of vertices &
edges, following set operations can be applied to graphs.
Union : Given G1 = (V1, E1) and G2 = (V2, E2) then
G3 = G1 U G2 = (V3, E3) such that
V3 = (V1 U V2) and E3 = (E1 U E2) Example

Intersection : Given G1 = (V1, E1) and G2 = (V2, E2) then


G3 = G1 ∩ G2 = (V3, E3) such that
V3 = (V1 ∩ V2) and E3 = (E1 ∩ E2) Example

Ring Sum : Given G1 = (V1, E1) and G2 = (V2, E2) then


G3 = G1 sym diff G2 = (V3, E3) such that
Unit IV : Graphs
Paths and Circuits :
Path : In a directed graph, a path is a sequence of edges
(e1,e2, …,ek) such that the terminal vertex of ei coincides with
the initial vertex of ei+1 for 1<=i<k. Example
Simple Path : Does not include the same edge twice.
Elementary Path : Simple path but does not meet the same
vertex twice.
Circuit : In a directed graph, a circuit is a path I(e1,e2, …,ek)
in which the terminal vertex of ek coincides with the initial
vertex of e1. Example
Simple Circuit : Does not include the same edge twice.
Elementary Circuit: Simple circuit but does not meet the
same vertex twice.
Unit IV : Graphs
Shortest Paths in weighted Graphs :
Shortest Path : Let G = (V, E, w) be a weighted graph,
where w is a function from E to the set of positive real
numbers. . Consider V as a set of cities and E as a set of
highways connecting these cities. The weight of an edge (i, j)
is w(i, j) usually referred to as the length of the edge (i, j),
which has the obivous interpretation as the distance between
adjacent cities i and j. The length of the path in G is defined
to be the sum of the lengths of the edges in the path. Now the
problem is to determine a shortest path from one vertex to
another vertex in V. The solution to this problem is
discovered by E. W. Dijkshtra called as Dijkshtra’s algorithm.
Unit IV : Graphs
Shortest Paths in weighted Graphs :
Dijkshtra’s Algorithm:
The procedure (algorithm) for computing the shortest path from
vertex a to any other vertex in a graph G.
1.Initially let P = {a} and T = V – {a} and for every vertex in T let l(t)
= w(a, t). Update the vertex a as the previous vertex for all vertices
in T adjacent to vertex a
2.Select the vertex x in T such that it has the smallest index
(minimum weight edge ) w.r.t. vertices in P
3.If x is the vertex, we want to reach from a then STOP, otherwise let
P’ = P U {x} and T’ = T – {x}
for every vertex t in T’ compute it’s index
l’(t) = min [l(t), l(x) + w(x, t)]
4.Update the vertex x as the previous vertex for all vertices in T
adjacent to vertex x
5.Repeat steps 2 to 4 using P’ as P and T’ as T Example
Unit IV : Graphs
Exercise :
1.Use Dijkshtra’s algorithm to find the shortest path from
a to f (Ref Q-7(b) of Nov-Dec-2011).
Unit IV : Graphs
Connected /Strongly connected /Weakly connected components :
Connected components :
An undirected graph is said to be connected if there is a path
between every two vertices and is said to be disconnected otherwise.
A directed graph is said to be connected if the undirected graph
derived from it by ignoring the directions of the edges is connected
and is said to be disconnected otherwise.
A disconnected graph consists of two or more components each
of which is connected graph.
Strongly connected / Weakly connected components :
A connected digraph is said to be strongly connected if for every
two vertices a and b in the graph there is a path from a to b and from
b to a as well otherwise it is weakly connected. Example
Cut Set :
In connected graph G, cut set is minimal set of
edges whose removal makes graph disconnected
and increases component of a graph by 1.

Edge Connectivity :
It is number of edges in smallest cutset of a simple
connected graph.

Vertex Connectivity:
V.C. of simple connected graph is minimum number
of vertices whose removal makes graph
disconnected.
Unit IV : Graphs
Eulerian Paths and Circuits:
Eulerian Paths :
L. Euler, the father of the theory of graphs, proved in 1736 that it
was not possible to cross each of the seven bridges on the river Pregel
in Konigsberg, Germany, once and only once in a walking tour.
Graphical representation
Euler discovered a very simple criterion for determining whether
there is a path in a graph that traverses each of the edges in the graph
once and only once.
Eulerian Path : Eulerian path in a graph is defined as a path that
traverses each edge in the graph once and only once.
Eulerian Circuit : Eulerian circuit in a graph is defined as a circuit that
traverses each edge in the graph once and only once.
Degree of a vertex : The degree of a vertex is the number of edges
incident with it (note that loop contributes to a count of two edges)
Unit IV : Graphs
Eulerian Paths and Circuits:
Sufficient and necessary conditions for Eulerian paths
and circuits:
In any graph there is an even number of vertices of odd degree since
each edge contributes to a count of one to the degree of each of the two
vertices with which it is incident, the sum of the degrees of the vertices
is equal to twice the number of edges in a graph.

Theorem : An undirected graph possesses an Eulerian path if and


only if it is connected and has either zero or two vertices of odd
degree. Example

Corollary : An undirected graph possesses an Eulerian circuit if and


only if it is connected and it’s vertices are all of even degree.
Example
Unit IV : Graphs
Hamiltonian Paths and Circuits:
Hamiltonian Path : Hamiltonian path in a graph is defined
as a path that passes through each of the vertices in the graph
once and only once. Example
Hamiltonian Circuit : Hamiltonian circuit in a graph is
defined as a circuit that passes through each of the vertices in
the graph once and only once. Example

• There is always a Hamiltonian path in a directed complete


graph
• There is no general method of solution to the problem of
proving the non-existence of a Hamiltonian path or circuit
in a graph
Unit IV : Graphs
Exercise :
1.State necessary and sufficient condition for the existence
of Hamiltonian path and circuit in Kmn
Unit IV : Graphs
The Traveling Salesperson Problem [TSP] :

Let G = (V, E, w) be a complete graph of n vertices, where


w is a function from E to the set of positive real numbers
such that for any three vertices i, j, k in V
w(i, j) + w(j, k) >= w(i, j)
We shall refer to w(i, j) as the length of edge (i, j). The
TSP asks for a Hamiltonian circuit of minimum length where
the length of a circuit is defined as the sum of the lengths of
the edges in the circuit.
Unit IV : Graphs
The Traveling Salesperson Problem [TSP] contd…:
Physical interpretation : Consider G as a graph representing
map of n cities, where w(i, j) is the distance between cities i
and j. A salesperson wants to have a tour of the n cities which
starts and ends at the same city and includes visiting each of
(n-1) cities once and only once and further an itinerary that
has a minimum total distance is desired.

The solution to this problem is given by Dynamic


Programming strategy, but it is inefficient for large value of
n. The simple procedure which gives results (not optimal) to
the TSP is Nearest Neighbour Method.
Unit IV : Graphs
The Traveling Salesperson Problem [TSP] contd…:
Nearest Neighbour Method : Following are the steps:
1.Start with an arbitrary vertex and find the vertex that is
nearest to the it to form an initial path of one edge. This
path is augmented in a vertex-by-vertex manner as
described in step 2.
2.Let x denote the latest vertex that was added to path.
Among all vertices that are not in the path, pick the one
that is nearest to vertex x, and add to the path, the edge
connecting vertex x and this nearest vertex.
3.Repeat step 2 until all vertices in the graph are included in
the path.
4.Form a circuit by adding the edge connecting the last
vertex added and the starting vertex. Example
Unit IV : Graphs
Factors of a Graph :
A k-factor of a graph is defined to be a spanning
subgraph of the graph with the degree of it’s vertices being k.
Examples
Planar Graphs : A graph is said to be planar if it can be
drawn on a plane in such a way that no two edges cross one
another, except of course at common vertices.
Examples
Region : A region of a planar graph is defined to be an area
of the plane that is bounded by edges and is not further
divided into subareas. Example
Thorem : For any connected planar graph
i) v – e + r = 2 Proof by M.I. [Euler’s Formula]
ii) e <= 3v – 6 provided no self loops & e >= 2
Unit IV : Graphs
Exercise :
1.Are K5 , K6 and K33 planar graphs? Which of these non-
planar graphs have a property that removal of any vertex
and edges incident with the vertex produces a planar
graph? Draw the diagrams and explain.
Unit IV : Graphs
Unit IV at a Glance:
l Introduction : Why we need to study graph theory
l Basic Terminology: Directed graph, Undirected graph,
edges incident from and into vertex, simple graph,
asymmetric graph, symmetric graph, isomorphic graphs,
subgraph, spanning subgraph, complement of a
subgraph and graph, complete graph, directed complete
graph, multigraph, representation of graph, digraphs and
relations, operations on graph : union, intersection, ring
• Paths : Disjkshtra’s algorithm for shortest paths,
connected / strongly connected / weakly connected
components
• Eulerian Paths and Circuits : Eulerian Paths and
Circuits, necessary & sufficient conditions for Eulerian
Paths and Circuits
Unit IV : Graphs
Unit IV at a Glance contd…:
• Hamiltonian Paths and Circuits : Hamiltonian Paths
and Circuits, necessary & sufficient conditions for
Hamiltonian Paths and Circuits
• Traveling Salesperson Problem [TSP] : Problem
definition, physical representation of TSP, Solution by
Nearest Neighbour Method
• Factors of a graph : k-factor – spanning subgraph with
degree = k for each vertex
• Planar graphs : Euler’s formula : v – e + r = 2,
e <= 3v – 6 for e >=2 and no self loops

You might also like