Ds9graphintro Handout
Ds9graphintro Handout
Chapter 9 Ngoc Le
Introduction to Graphs
Discrete Structures for Computing
Contents
Graph definitions
Terminology
Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
1 Graph definitions
Terminology
Special Graphs
Contents
Graph definitions
Exercise
3 Exercise Graph
9.2
Introduction to Graphs
Course outcomes
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
9.3
Introduction to Graphs
Motivations
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
a graph.
9.4
Introduction to Graphs
Graph
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Definition
A graph (đồ thị) G is a pair of (V, E), which are:
• V – nonempty set of vertices (nodes) (đỉnh) Contents
Exercise
1 3 1 3 Graph
Bipartie graph
Isomorphism
9.5
Introduction to Graphs
Undirected Graph (Đồ thị vô hướng)
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
9.6
Introduction to Graphs
Undirected Graph
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Graph definitions
An unordered pair of vertices {u, v} are called multiplicity m (bội Terminology
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
9.7
Introduction to Graphs
Undirected Graph
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
9.8
Introduction to Graphs
Directed Graph
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
A directed edge start at u and end at v is denoted as (u, v). Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
9.9
Introduction to Graphs
Terminologies For Undirected Graph
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Neighborhood
In an undirected graph G = (V, E),
• two vertices u and v ∈ V are called adjacent (liền kề ) if they
are end-points (điểm đầu mút) of edge e ∈ E, and Contents
Representing Graphs
and Graph
Isomorphism
The degree of a vertex Representing Graphs
Graph Isomorphism
The degree of a vertex (bậc của một đỉnh), denoted by deg(v) is Exercise
the number of edges incident with it, except that a loop Graph
Bipartie graph
contributes twice to the degree of that vertex. Isomorphism
9.10
Introduction to Graphs
Example
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Example
What are the degrees and neighborhoods of the vertices in these
graphs?
b c d a b c
Contents
Graph definitions
Terminology
Special Graphs
a f e g e d Representing Graphs
and Graph
G H Isomorphism
Representing Graphs
Graph Isomorphism
Solution Exercise
Graph
Representing Graphs
(Note that this applies even if multiple edges and loops are and Graph
Isomorphism
present.) Representing Graphs
Graph Isomorphism
Exercise
Graph
9.12
Introduction to Graphs
Prove that ...
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
...
If the number of vertices in an undirected graph is an odd number,
then there exists an even-degree vertex. Contents
Graph definitions
... Terminology
Special Graphs
... Exercise
Graph
If the number of vertices in an undirected graph is an even Bipartie graph
number, then the number of vertices with even degree is even. Isomorphism
9.13
Introduction to Graphs
Terminologies for Directed Graph
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Neighborhood
In an directed graph G = (V, E),
• u is said to be adjacent to (nối tới) v and v is said to be
adjacent from (được nối từ) u if (u, v) is an arc of G, and
• u is called initial vertex (đỉnh đầu) of (u, v) Contents
Representing Graphs
and Graph
Isomorphism
The degree of a vertex Representing Graphs
Graph Isomorphism
In a graph G with directed edges: Exercise
Theorem Contents
Exercise
Graph
Bipartie graph
Isomorphism
9.18
Introduction to Graphs
Complete Graphs
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Graph definitions
Terminology
Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
K5 K4
9.20
Introduction to Graphs
Cycles
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Graph definitions
Terminology
Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
C5 C4
9.21
Introduction to Graphs
Wheels
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Graph definitions
Terminology
Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
W5 W4
9.22
Introduction to Graphs
n-cube
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
0 1 Exercise
Graph
Bipartie graph
00 01 000 001 Isomorphism
Q1 Q2 Q3
What’s about Q4 ?
9.23
Introduction to Graphs
Applications of Special Graphs
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Graph definitions
• Star, ring, hybrid Terminology
Representing Graphs
• Linear array and Graph
Isomorphism
• Mesh network Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
9.24
Introduction to Graphs
Exercise
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Exercise (5)
Give the number of edges in function of number of vertices in a
complete graph Kn .
Graph definitions
Give an undirected simple graph G = (V, E) with |V | = n, show Terminology
Representing Graphs
a ∀v ∈ V , deg(v) < n, and Graph
Isomorphism
b there does not exist simultaneously both a vertex of degree 0 Representing Graphs
Graph Isomorphism
and a vertex of degree (n − 1) with n ≥ 2, Exercise
c deduce that there are at least two vertices of the same degree. Graph
Bipartie graph
Isomorphism
Exercise (7)
Is it possible that each person has exactly 3 friends in the same
group of 9 people ?
9.25
Introduction to Graphs
Bipartite Graphs
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Definition
A simple graph G is called bipartite (đồ thị phân đôi) if its vertex
set V can be partitioned into two disjoint sets V1 and V2 such that
every edge in the graph connects a vertex in V1 and a vertex in V2
(so that no edge in G connects either two vertices in V1 or two
Contents
vertices in V2 ) Graph definitions
Terminology
Special Graphs
Example
Representing Graphs
and Graph
C6 is bipartite Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
C6
9.29
Introduction to Graphs
Complete Bipartite Graphs
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Definition
A complete bipartite Km,n is a graph that
• has its vertex set partitioned into two subsets of m and n
vertices, respectively,
Contents
• with an edge between two vertices iff one vertex is in the first Graph definitions
subset and the other is in the second one Terminology
Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
K3,3
9.30
Introduction to Graphs
Bipartite graphs
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
• C6
• Cn
• K3 Contents
• Kn Graph definitions
Terminology
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
9.31
Introduction to Graphs
New Graph From Old
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Definition
A subgraph (đồ thị con) of a graph G = (V, E) is a graph
H = (W, F ) where W ⊆ V and F ⊆ E.
Contents
Definition Graph definitions
Exercise
Graph
Bipartie graph
Isomorphism
G1 G2 G1 ∪ G2
9.32
Introduction to Graphs
Planar Graphs
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Contents
Graph definitions
Terminology
Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
9.33
Introduction to Graphs
Planar Graphs
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Definition
• A graph is called planar (phẳng ) if it can be drawn in the
plane without any edges crossing.
• Such a drawing is called planar representation (biểu diễn
Contents
phẳng ) of the graph. Graph definitions
Terminology
Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
K4 K4 with no crossing
9.34
Introduction to Graphs
Important Corollaries
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Corollary
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
K3,3
Non-planar
K5
Non-planar
9.35
Introduction to Graphs
Elementary Subdivision
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Definition
• Given a planar graph G, an elementary subdivision (phân chia
sơ cấp) is removing an edge {u, v} and adding a new vertex
w together with edges {u, w} and {w, v}. Contents
homeomorphic (đồng phôi) if they can obtained from the Special Graphs
Exercise
Graph
Bipartie graph
Isomorphism
9.36
Introduction to Graphs
Kuratowski’s Theorem
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Theorem
A graph is nonplanar iff it contains a subgraph homeomorphic to
K3,3 or K5 .
Contents
Graph definitions
Terminology
a Special Graphs
Representing Graphs
and Graph
f f d Isomorphism
c j Representing Graphs
e b
j g Graph Isomorphism
a g Exercise
Graph
i h
e Bipartie graph
Isomorphism
i h
d c
9.37
Introduction to Graphs
Exercise
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Exercise
• Is K4 planar?
• Is Q3 planar?
Graph definitions
Terminology
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
010 011 Exercise
Graph
Bipartie graph
Isomorphism
000 001
K4 Q3
9.38
Introduction to Graphs
Adjacency Lists (Danh sách kề)
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
d c, e d c, e Graph definitions
Terminology
e a, c, d e b, c, d Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
9.39
Introduction to Graphs
Adjacency Matrices
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Definition
Adjacency matrix (Ma trận kề ) AG of G = (V, E)
• Dimension |V | × |V |
• Matrixelements
1 if (vi , vj ) ∈ E Contents
aij =
0 otherwise Graph definitions
Terminology
Special Graphs
Representing Graphs
a b and Graph
Isomorphism
Representing Graphs
a b c d
Graph Isomorphism
Exercise
a 0 1 1 1 Graph
b 1 0 1 0 Bipartie graph
Isomorphism
c 1 1 0 0
d 1 0 0 0
c d
9.40
Introduction to Graphs
Examples
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Example
Give the graph defined by the following adjacency matrix
Contents
Graph definitions
A B C D E Terminology
Special Graphs
Representing Graphs
A
0 0 1 1 0
and Graph
Isomorphism
B
0 1 0 1 0
Representing Graphs
C
1 0 0 1 0
Graph Isomorphism
D
1 1 1 0 1
Exercise
Graph
E 0 0 0 1 0 Bipartie graph
Isomorphism
9.41
Introduction to Graphs
Adjacency Matrices
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Example
Give the directed graph defined by the following adjacency matrix
Contents
Graph definitions
A B C D E Terminology
Special Graphs
Representing Graphs
A
1 0 1 1 0
and Graph
Isomorphism
B
0 0 0 0 0
Representing Graphs
C
1 0 0 0 0
Graph Isomorphism
D
1 1 1 0 1
Exercise
Graph
E 1 0 0 0 0 Bipartie graph
Isomorphism
9.42
Introduction to Graphs
Incidence Matrices
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Definition
Incidence matrix (ma trận liên thuộc) MG of G = (V, E)
• Dimension |V | × |E|
• Matrix
elements
1 if ej is incident with vi Contents
mij =
0 otherwise Graph definitions
Terminology
Special Graphs
Representing Graphs
a e2 b and Graph
Isomorphism
Representing Graphs
e1 e2 e3 e4
Graph Isomorphism
Exercise
a 1 1 1 0 Graph
e1 b 0 1 0 1 Bipartie graph
e4 e3 Isomorphism
c 1 0 0 1
d 0 0 1 0
c d
9.43
Introduction to Graphs
Examples
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Example
Give incidence matrix according to the following graph
Contents
F Graph definitions
Terminology
Special Graphs
B C Representing Graphs
and Graph
Isomorphism
Representing Graphs
A Graph Isomorphism
Exercise
Graph
E D Bipartie graph
Isomorphism
G
9.44
Introduction to Graphs
Graph Isomorphism
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Definition
G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are isomorphic (đẳng cấu) if
there is a one-to-one function f from V1 to V2 with the property
that a and b are adjacent in G1 iif f (a) and f (b) are adjacent in Contents
G2 , for all a and b in V1 . Such a function f is called an Graph definitions
isomorphism (một đẳng cấu). Terminology
Special Graphs
(i.e. there is a one-to-one correspondence between vertices of the Representing Graphs
two graphs that preserves the adjacency relationship.) and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
u1 u2 v1 v2
Isomorphism function f : U −→ Exercise
Graph
f (u3 ) = v3 f (u4 ) = v2
u3 u4 v3 v4
9.45
Introduction to Graphs
Bipartie graph
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Contents
Graph definitions
Terminology
Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
9.46
Introduction to Graphs
Isomorphism ?
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
Contents
Graph definitions
Terminology
Special Graphs
Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
Exercise
Graph
Bipartie graph
Isomorphism
9.47
Introduction to Graphs
Isomorphism?
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
A
A B Contents
B Graph definitions
Terminology
Special Graphs
C F C Representing Graphs
and Graph
Isomorphism
Representing Graphs
Graph Isomorphism
D E D Exercise
Graph
G2
F E Bipartie graph
Isomorphism
G1
9.48
Introduction to Graphs
Isomorphism?
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
A1 A2 B2
Contents
Graph definitions
Terminology
D1 E1 E2 F2 Special Graphs
Representing Graphs
and Graph
Isomorphism
F1 Representing Graphs
Graph Isomorphism
Exercise
C1 B1 D2 C2 Graph
G1 G2 Bipartie graph
Isomorphism
9.49
Introduction to Graphs
Isomorphism
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
1 0 0 1 1 0 0 Graph definitions
Terminology
1 1 0 1 0 0 Special Graphs
Representing Graphs
0 1 0 1 0 1 1 1 and Graph
1 0 Isomorphism
0 1 1 0 0 1 Representing Graphs
2
0 0 0 1 1 0 0 1 Graph Isomorphism
1 1 1 0 1 1 1 0 Exercise
Graph
0 1 1 0 0 1 0 1 Bipartie graph
Isomorphism
1 0 0 1 1 0 0 0
3
1 0 0 1 0 0 0 1
0 1 1 0 1 0 1 0
9.50
Introduction to Graphs
Isomorphism
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
Ngoc Le
1 1 0 0 1 1 Special Graphs
Representing Graphs
1 1 0 0 0 0 1 0 0 1 and Graph
Isomorphism
• 1 0 1 0 1 0 1 1 1 0
Representing Graphs
Graph Isomorphism
0 0 0 1 1 1 0 0 1 0
Exercise
0 1 1 1 0 1 0 1 0 1 Graph
Bipartie graph
• Extend the definition of isomorphism of simple graphs to Isomorphism
9.51