0% found this document useful (0 votes)
21 views

Lecture 13

The document discusses graphs and graph theory concepts. It defines what a graph is, introduces graph terminology, and describes several special types of graphs including complete graphs, cycles, wheels, n-cubes, and bipartite graphs. It also covers subgraphs, graph complements, and graph isomorphism.

Uploaded by

19-40122-1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Lecture 13

The document discusses graphs and graph theory concepts. It defines what a graph is, introduces graph terminology, and describes several special types of graphs including complete graphs, cycles, wheels, n-cubes, and bipartite graphs. It also covers subgraphs, graph complements, and graph isomorphism.

Uploaded by

19-40122-1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

CS 2336

Discrete Mathematics

Lecture 13
Graphs: Introduction

1
Outline
• What is a Graph?
• Terminology
• Some Special Simple Graphs
• Subgraphs and Complements
• Graph Isomorphism

2
What is a Graph ?
A graph consists of a nonempty set V of vertices
and a set E of edges, where each edge in E
connects two (may be the same) vertices in V.

• Let G be a graph associated with a vertex set V


and an edge set E
We usually write G = (V, E) to indicate the above
relationship

3
Examples

a b 1 2 w x

c d 3 4 y z

• Furthermore, if each edge connects two different


vertices, and no two edges connect the same pair
of vertices, then the graph is a simple graph
• Which of the above is a simple graph ?
4
Directed Graph
• Sometimes, we may want to specify a direction on
each edge
Example : Vertices may represent cities, and edges
may represent roads (can be one-way)
• This gives the directed graph as follows :

A directed graph G consists of a nonempty set V


of vertices and a set E of directed edges, where
each edge is associated with an ordered pair of
vertices. We write G = (V, E) to denote the graph.
5
Examples

1 2 w x w x

3 4 y z y z

6
Test Your Understanding

• Suppose we have a simple graph G with n vertices


What is the maximum number of edges G can
contain, if
(i) G is an undirected graph ?
(ii) G is a directed graph ?

7
Terminology (Undirected Graph)
• Let e be an edge that connects vertices u and v
We say (i) e is incident with u and v
(ii) u and v are the endpoints of e ;
(iii) u and v are adjacent (or neighbors)
(iv) if u = v, the edge e is called a loop

• The degree of a vertex v, denoted by deg(v), is the


number of edges incident with v, except that a
loop at v contributes twice to the degree of v

8
Example
• What are the degrees and neighbors of each
vertex in the following graph ?

a c e

b d f

9
Handshaking Theorem
• Let G = (V, E) be an undirected graph with m edges
Theorem:
 deg(v) = 2m
vV

• Proof : Each edge e contributes exactly twice to


the sum on the left side (one to each endpoint).

Corollary : An undirected graph has an even


number of vertices of odd degree.

10
Terminology (Directed Graph)
• Let e be an edge that connects vertices from u to v
We say (i) u = initial vertex, v = terminal vertex ;
(ii) u is adjacent to v;
(iii) v is adjacent from u;
(iv) if u = v, the edge e is called a loop
• The in-degree of a vertex v, denoted by deg–(v), is
the number of edges with v as terminal vertex
• The out-degree of a vertex u, denoted by deg+(u),
is the number of edges with u as initial vertex
11
Example
• What are the in- and out-degrees of each vertex
in the following graph ?

a c e

b d f

12
Handshaking Theorem
• Let G = (V, E) be directed graph with m edges
Theorem:
 deg–(v) =  deg+(u)
vV uV
= m

• Proof : Each edge e contributes exactly once to


the in-degree and once to the out-degree

13
Some Special Simple Graphs
Definition: A complete graph on n vertices,
denoted by Kn, is a simple graph that contains
one edge between each pair of distinct vertices

Examples :

K1 K2 K3 K4 K5

14
Some Special Simple Graphs
Definition: A cycle Cn, n  3, is a graph that
consists of n vertices v1, v2, …, vn and n edges
{v1, v2}, {v2, v3}, …, {vn – 1, vn}, {vn, v1}

Examples :

C3 C4 C5 C6

15
Some Special Simple Graphs
Definition: A wheel Wn, n  3, is a graph that
consists of a cycle Cn with an extra vertex that
connects to each vertex in Cn

Examples :

W3 W4 W5 W6

16
Some Special Simple Graphs
Definition: An n-cube, denoted by Qn, is a graph
that consists of 2n vertices, each representing a
distinct n-bit string. An edge exists between two
vertices  the corresponding strings differ in
exactly one bit position.

Examples : 110 111


10 11 010 011

100 101
0 1 00 01 000 001
Q1 Q2 Q3 Q4
17
Some Special Simple Graphs
Definition: A bipartite graph is a graph such that
the vertices can be partitioned into two sets V and
W, so that each edge has exactly one endpoint
from V, and one endpoint from W

Examples :

bipartite graphs non-bipartite graphs


18
Some Special Simple Graphs
• Which of the following is a bipartite graph?

a b a b

g g
c c
f f

e d e d

19
Check if a Graph is Bipartite
• The following is a very useful theorem :
Theorem: A simple graph is bipartite if and only if
it is possible to assign one of two different colors
to each vertex, so that no two adjacent vertices
are assigned the same color

• Proof : If there is a way to color the vertices, the


same way shows a possible partition of vertices.
Conversely, if there is a way to partition the
vertices, the same way gives a possible coloring.
20
Check if a Graph is Bipartite
• The above implies the following algorithm to check
if a connected graph is bipartite :
Step 1 : Pick a vertex u. Color it with white ;
Step 2 : While there are uncolored vertices
(i) for each neighbor of a white vertex,
color it with black ;
(ii) for each neighbor of a black vertex,
color it with white ;
Step 3 : Report YES if each edge is colored properly.
Else, report NO ;

21
Some Special Simple Graphs
Definition: A complete bipartite graph Km,n is a
bipartite graph with vertices partitioned into two
subsets V and W of size m and n, respectively,
such that there is an edge between each vertex in
V and each vertex in W

Examples :

K2,2 K3,2 K3,3

22
Subgraphs and Complements
If G = (V, E) is a graph, then G’ = (V’, E’) is called a
subgraph of G if V’  V and E’  E.

• Which one is a subgraph of the leftmost graph G ?


a b a b a b a b

g
c
f

e d e d e d e d

23
Subgraphs and Complements
If G = (V, E) is a graph, then the subgraph of G
induced by U  V is a graph with the vertex set U
and contains exactly those edges from G with
both endpoints from U
a b
Ex : Consider the graph on the
g
right side c
What is its subgraph induced f
by the vertex set { a, b, c, g } ? e d

24
Subgraphs and Complements
If G = (V, E) is a graph, then the complement of G,
denoted by G, is a graph with the same vertex set,
such that
an edge e exists in G  e does not exist in G
a b
Ex : Consider the graph on the
g
right side c
What is its complement ? f

e d

25
Graph Isomorphism
Graphs G = (V, E) and H = (U, F) are isomorphic if
we can set up a bijection f : V  U such that
x and y are adjacent in G
 f(x) and f(y) are adjacent in H

Ex : The following are isomorphic to each other :

26
Graph Isomorphism
The following graphs are isomorphic to each other.
This graph is known as the Petersen graph :

27
Graph Isomorphism
How to show the following are not isomorphic ?

How to show the following are not isomorphic ?

28

You might also like