BITS Pilani: Discrete Structures For Computer Science

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 59

Discrete Structures for Computer Science

(CS F222)
Topic: Graph Theory
Dr. Raghunath Reddy
BITS Pilani
Hyderabad Campus
Introduction

 Bridges of Konigsberg (today’s Kaliningrad): walk all 7 bridges


without crossing a bridge twice.

BITS Pilani, Hyderabad Campus


Graph

 Definition: A graph G = (V, E)


 V, a nonempty set of vertices (or nodes) and
 E, a set of edges.
 Each edge has either one or two vertices associated with it, called its endpoints.
 An edge is said to connect its endpoints.

 Note: In this course, we assume that V is a finite set (G is a finite graph)

BITS Pilani, Hyderabad Campus


Undirected Graph

 Each edge is of the form {u, v},


 We say the edge incident with the vertices u and v and
 The edge is said to connect u and v.
 Further, we say u and v are adjacent

 Whenever, there is an edge {u, v} in the graph, we can also say


that {v, u} is also an edge in the graph.

BITS Pilani, Hyderabad Campus


Undirected Graph

 Graphs that may have multiple edges connecting the same vertices are called multigraphs.

 An edge which connects to itself is called a self-loop.

 A graph that has no self-loops and multiple edges between every pair of vertices is called a simple graph.

BITS Pilani, Hyderabad Campus


Directed Graph

 A directed graph (or digraph) (V, E) consists of a nonempty set of vertices V


and a set of directed edges (or arcs) E.
 Each directed edge is associated with an ordered pair of vertices.
 The directed edge associated with the ordered pair (u, v) is said to start at u
and end at v.
 The vertex u is called the initial vertex of (u, v), and v is called the terminal
or end vertex of (u, v). The initial vertex and terminal vertex of a loop are
the same.

BITS Pilani, Hyderabad Campus


Directed Graph

 Directed multigraphs

BITS Pilani, Hyderabad Campus


Degree of a vertex (undirected graphs)
 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.
 The degree of the vertex v is denoted by deg(v).

 Isolated vertex: degree is zero


 Pendent vertex: degree one

BITS Pilani, Hyderabad Campus


Degree of a vertex (undirected graphs)

BITS Pilani, Hyderabad Campus


Degree of a vertex (undirected graphs)

BITS Pilani, Hyderabad Campus


Degree of a vertex (directed graphs)

BITS Pilani, Hyderabad Campus


Simple Graphs: Revisit

BITS Pilani, Hyderabad Campus


Special Graphs

BITS Pilani, Hyderabad Campus


Special Graphs

BITS Pilani, Hyderabad Campus


Bipartite Graphs

BITS Pilani, Hyderabad Campus


Bipartite Graphs
 Is the following graph bipartite?

BITS Pilani, Hyderabad Campus


Complete Bipartite Graphs

BITS Pilani, Hyderabad Campus


Job Assignment Problem as a bipartite graph

BITS Pilani, Hyderabad Campus


Job Assignment Problem as a bipartite graph

 Assign an employee to each job so that every job has an


employee assigned to it, and so that no employee is assigned
more than one job.

BITS Pilani, Hyderabad Campus


Matching in a graph

BITS Pilani, Hyderabad Campus


Matching in a graph

 A vertex that is the endpoint of an edge of a matching M is said


to be matched in M; otherwise it is said to be unmatched.

 A maximum matching is a matching with the largest number of


edges.

BITS Pilani, Hyderabad Campus


Complete Matching in a bipartite graph

BITS Pilani, Hyderabad Campus


Neighborhood

BITS Pilani, Hyderabad Campus


HALL’S MARRIAGE THEOREM

BITS Pilani, Hyderabad Campus


Perfect Matching in a graph

BITS Pilani, Hyderabad Campus


New graphs from old

BITS Pilani, Hyderabad Campus


New graphs from old

BITS Pilani, Hyderabad Campus


Representation of graphs

 Adjacency list

 Adjacency Matrix

 Incidence Matrix

BITS Pilani, Hyderabad Campus


Adjacency List Representation of graphs

 Adjacency lists, which specify the vertices that are adjacent to


each vertex of the graph.

BITS Pilani, Hyderabad Campus


Adjacency Matrix Representation of graphs

BITS Pilani, Hyderabad Campus


Adjacency Matrix Representation of graphs

BITS Pilani, Hyderabad Campus


Incidence Matrix Representation of graphs

BITS Pilani, Hyderabad Campus


Isomorphism of Graphs

BITS Pilani, Hyderabad Campus


Graph Isomorphism
 Do the given two graphs have the same structure (when we ignore
the identities of their vertices)?

BITS Pilani, Hyderabad Campus


Graph Isomorphism

BITS Pilani, Hyderabad Campus


Checking two Graphs are Isomorphic ?
 It is often difficult to determine whether two simple graphs are
isomorphic.

 Sometimes it is not hard to show that two graphs are not


isomorphic. In particular, we can show that two graphs are not
isomorphic if we can find a property only one of the two graphs
has.

BITS Pilani, Hyderabad Campus


Checking two Graphs are Isomorphic ?

BITS Pilani, Hyderabad Campus


Connectivity in Graphs

BITS Pilani, Hyderabad Campus


Path

BITS Pilani, Hyderabad Campus


Simple Path

BITS Pilani, Hyderabad Campus


Circuit and cycle

BITS Pilani, Hyderabad Campus


Paths and Simple paths

BITS Pilani, Hyderabad Campus


Connected graphs
 An undirected graph is called connected if there is a path
between every pair of distinct vertices of the graph.
 An undirected graph that is not connected is called disconnected.

BITS Pilani, Hyderabad Campus


Connected graphs
 Theorem: There is a simple path between every pair of distinct
vertices of a connected undirected graph.

BITS Pilani, Hyderabad Campus


Planar Graphs

BITS Pilani, Hyderabad Campus


Planar graphs

 Is it possible to join these houses and utilities so that none of the


connections cross ?

BITS Pilani, Hyderabad Campus


Planar graphs

BITS Pilani, Hyderabad Campus


Planar graphs

BITS Pilani, Hyderabad Campus


Planar graphs

BITS Pilani, Hyderabad Campus


Planar graphs: regions
 A planar representation of a graph splits the plane into regions,
including an unbounded region.

 Degree of a region: The number of edges in the closed path that


forms the boundary of the region.

BITS Pilani, Hyderabad Campus


Planar graphs: regions

BITS Pilani, Hyderabad Campus


Planar graphs: Euler’s formula

BITS Pilani, Hyderabad Campus


Planar graphs: Euler’s formula

BITS Pilani, Hyderabad Campus


Planar graphs: Euler’s formula

BITS Pilani, Hyderabad Campus


Graphs coloring

BITS Pilani, Hyderabad Campus


Vertex coloring

BITS Pilani, Hyderabad Campus


Chromatic number

BITS Pilani, Hyderabad Campus


Chromatic number

BITS Pilani, Hyderabad Campus


Thank You!!

BITS Pilani, Hyderabad Campus

You might also like