Chapter 8 Graphs
Chapter 8 Graphs
Discrete Mathematics
Course No. : CSE 2101
Chapter 8: Graphs
Prepared By : Julia Rahman
8.1 Graphs and Graphs Models
a e g
f
In the figure deg(a) = 2, deg(b) = deg(c) = deg(f) = 4, deg(e) = 3, deg(d) = 1 and
deg(g) = 0. Julia Rahman, Dept. CSE, RUET 08
8.2 Graph Terminology and Special Types of Graphs
a b c
e d
In the figure deg(a)=4, deg(b)=6, deg(c)=1, deg(d)=5, deg(e)=6
Theorem 1:
Let G be an undirected (simple, multi-, or pseudo-) graph with vertex set V and
edge set E. Then
∑
2e =deg ( )
∈𝑉
Note that this applies even if multiple edges and loops are present.
Example 3. How many edges are there in a graph with 10 vertices each of degree
six?
Solution: Because the sum of the degrees of the vertices is 6 · 1 0 = 60, it
follows that 2e = 60. Therefore, e = 30.
Julia Rahman, Dept. CSE, RUET 09
8.2 Graph Terminology and Special Types of Graphs
Theorem 2:
The number of vertices in a graph with odd degree is even.
Proof: and be the set of vertices of even degree and odd degree.
2e = = +
deg(v) is even for € V1, the first term in right-hand side of equality is even.
Hence the second term in the sum is also even. Because all the terms in this
sum are odd. Thus there are an even number of vertices of odd degree.
Definition-3:
Let G be a directed (possibly multi-) graph, and let e be an edge of G that is (or
maps to) (u,v). Then we say:
u is adjacent to v, v is adjacent from u
e comes from u, e goes to v.
e connects u to v, e goes from u to v
the initial vertex of e is u
the terminal vertex of e is v
is 3-regular.
K1 K2 K3 K4
Julia Rahman, Dept. CSE, RUET 12
8.2 Graph Terminology and Special Types of Graphs
Cycles:
The cycle Cn, n3, consists of n vertices v1, v2, …, vn and edges {v1,v2}, {v2,v3},
…, {vn-1,vn}, {vn,v1}.
C6
C3 C4 C5
Note Cn is 2-regular, |V(Cn)| = n, |E(Cn)| = n
Wheels:
For any n 3, a wheel Wn, is a simple graph obtained by taking the cycle Cn and
adding one extra vertex and n extra edges {{, }, {, },. . . . , { }}.
W3 W4 W5 W6
v3 v4
C6
C6 is bipartite. Because
v5 v6
V1 V2
Example: Is C3 bipartite?
No, because there is no way to partition the vertices into two sets so that there
are no edges with both endpoints in the same set.
C3
a b a
c
g
c e
b
f
f d d
g
e
K3,2 K3,4
a a
e b e b
d c subgraph of K5 c
K5
G1 G2
d e d f
a b c
G1∪G2
d e f
Julia Rahman, Dept. CSE, RUET 18
8.3 Representing Graphs and
Graph Isomorphism
a c a b,c,e
b a
c a,d,e
e d
d c,e
e a,c,d
Adjacency Matrices:
G=(V, E) : simple graph, V={v1,v2,…,vn}.
A matrix A is called the adjacency matrix of G
if A=[aij]nn , where aij = 1, if {vi,vj}E,
0, otherwise.
Incidence Matrices:
Let G = (V, E) be an undirected graph. The vertices and edges of G are listed
in arbitrary order as v1, v2, …, vn and e1, e2, …, em, respectively.
The incidence matrix of G with respect to this listing of the vertices and
edges is the nm zero-one matrix with 1 as its (i, j) entry when edge ej is
incident with vi, and 0 otherwise.
1 , if edge ej is incident with vi
mij = 0 , otherwise
Example 6: Using
v2 an eincidence matrix, represent the following
e1 e2 e3 e4 eundirected
5 e6
v1 v
graph: 6 3 v1 1 1 0 0 0 0
e 0
2
v2 0 1 1 0 1
e4
e5 0 0 0 0 1 1
e1 e3 v3
v4 1 0 1 0 0 0
v4 v5 Julia Rahman, Dept. CSE, RUET
0 1 0 1 1 0 23
v
8.3 Representing Graphs and Graph Isomorphism
Isomorphism of Graph
Definition 1:
The simple graphs G1 = (V1,E1) 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 an isomorphism.
Necessary condition for G1 = (V1,E1) to be isomorphic to G2 = (V2,E2):
V1 = V2, and E1 = E2
The number of vertices with degree n is the same in both graphs.
For every proper subgraph g of one graph, there is a proper subgraph of the
other graph that is isomorphic to g..
Exampleu8: Show thatu2 the graphs vG1 = (V,E) and H =v2 (W,F) are isomorphic.
1
u3 u4 v3 H v4
G
Solution: The function f with f(u1) = v1, f(u2) = v4, f(u3) = v3, f(u4) = v2 is a one-to-one
correspondence between V and W. f(u1) = v1 and f(u2) = v4, f(u1) = v1 and f(u3) = v3,
f(u2) = v4 and f(u3) = v3, and f(u1) = vJulia
1 and f(uDept.
Rahman, 4) = v2 RUET
CSE, are adjacent in H. 24
8.3 Representing Graphs and Graph Isomorphism
Example 9: Show that G and H are not isomorphic.
G H
Solution: Both G and H have five vertices and six edges. However, H has a
vertex of degree one, namely, e , whereas G has no vertices of degree one. It
follows that G and H are not isomorphic .
Example 10: Determine whether G and H are isomorphic.
a b s t
w x
e
f
g z y
h
d c v u
Solution: G and H are not isomorphic. Because deg(a) = 2 in G, a must
correspond to either t, u , x , or y in H, because these are the vertices of degree
Julia Rahman, Dept. CSE, RUET 25
8.3 Representing Graphs and Graph Isomorphism
two in H . However, each of these four vertices in H is adjacent to another
vertex of degree two in H, which is not true for a in G.
Another way to see that G and H are not isomorphic is to note that the
subgraphs of G and H made up of vertices of degree three and the edges
connecting them must be isomorphic if these two graphs are isomorphic.
Example 11: Determine whether the graphs G and H are isomorphic.
G v1 H v3
u1 u2
u5 v2
u6
v6
u4 u3 v5
v4
G H
u1 v1
u2 v8 v2
u8
u3 v3
u7 v7
u6 u4 v6 v4
u5 v5
Solution: Yes
a b a b
f
c c
d d e
g e
𝐺2
𝐺1 Julia Rahman, Dept. CSE, RUET 30
8.4
Theorem 1: Connectivity
There is a simple path between every pair of distinct vertices of a connected
undirected graph.
Connected component: connected subgraph
Example 6: What are the connected components of the graph H?
𝐻1 𝐻2 f
b 𝐻3
d e
a c h g
H
G c H c
e d e d
Solution: G is strongly connected because there is a path between any two
vertices in this directed graph. Hence, G is also weakly connected.
The graph H is not strongly connected. There is no directed path from a to b in
this graph. However, H is weakly connected, because there is a path between
any two vertices in the underlying undirected graph of H.
Example 6: What are the connected components of the graph H?
u3 u5 v3 v5
G H v4
u4
Solution: Both G and H have 6 vertices and 8 edges. Each has 4 vertices of degree 3,
and 2 vertices of degree 2. However, H has a simple circuit of length 3, namely, v 1,
v2, v6, v1 whereas G has no simple circuit of length 3, as can be determined by
inspection (all simple circuits in G have length at least four). G and H are not
isomorphic. Julia Rahman, Dept. CSE, RUET 34
8.4
Connectivity
Example 13. Determine whether the graphs G and H are isomorphic.
u2 v1
G H
u1 u3 v5 v2
u5 u4 v4 v3
Solution: Both G and H have 5 vertices, 6 edges, two vertices of deg 3, three
vertices of deg 2, a 3-cycle, a 4-cycle, and a 5-cycle. G and H may be
isomorphic.
The function f with f(u1) = v1, f(u2) = v4, f(u3) = v3, f(u4) = v2 and f(u5) = v5 is a one-
to-one correspondence between V(G) and V(H). G and H are isomorphic.
Counting Paths between Vertices
Theorem 2:
Let G be a graph with adjacency matrix A with respect to the ordering v1, v2, …,
vn (with directed or 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
35
integer is equals to the (i, j)th entry of Ar.
8.4
Example 14: Connectivity
How many paths of length 4 are there from a to d in the simple
graph G? a b
G
d c
Solution: The adjacency matrix of G
a b c d
0
a 1 1 0 8 0 0 8
0 0
b 1 0 0 1 8 8
A A4
0
8
c 1 0 0 1 8 8 0
d 0 1 1 0 8 0 0 8
there are exactly eight paths of length four from a to d. By inspection of the
graph, we see that a , b, a , b, d; a , b, a , c, d; a , b, d, b, d; a , b, d, c, d; a , c,
a , b, d; a , c, a , c, d; a , c, d, b, d; and a , c, d, c, d are the eight paths from a
to d. (ordering as a, b, c, d) is
D
a d
A
b
B Fig-2: multigraph model of the
Fig-a: the seven bridges of konigsberg town of konigsberg
Julia Rahman, Dept. CSE, RUET 38
8.5 Euler & Hamilton Paths
Definition 1:
An Euler circuit in a graph G is a simple circuit containing every edge of G.
An Euler path in G is a simple path containing every edge of G.
Example 1: Which of the following graphs have an Euler circuit or an Euler
path? a a b G3
a b b
G1 e G2 e
d c d c c d e
g
c
f
d
e
each vertex has deg n/2 =3.5
Hamilton circuit exists: a, c, e, g, b, d, f, a
g
c
f
d
e
each nonadjacent vertex pair has deg sum n = 7
Hamilton circuit exists: a, d, f, e, c, b, g, a
K4
Example 2: Is Q3 planar?
Solution: Q3 is planar, because it can be drawn without any edges crossing.
Q3
Julia Rahman, Dept. CSE, RUET 50
8.7 Planar Graphs
Example 3: Show that K3,3 is nonplanar.
a b c
d e f
Solution: Not possible to drawing without crossing.
a R1 e a e
R2 c
f
d b d b
Solution: 6
Theorem 1: (Euler’s Formula)
Let G be a connected planar simple graph with e edges and v vertices. Let r be the
number of regions in a planar representation of G. Then r = e-v +2.
Example 4: Suppose that a connected planar graph has 20 vertices, each of degree
3. Into how many regions does a representation of this planar graph split the plane?
Solution: v = 20, 2e = 320 = 60, e = 30
r = e-v+2 = 30-20+2 = 12
2e 6v (e 3v - 6)
Corollary 3:
If a connected planar simple graph has e edges and v vertices with v 3 and no
circuits of length three, then e 2v - 4.
d e f
Kuratowski’s Theorem:
If a graph is planar, so will be any graph obtained by removing an edge {u, v} and
adding a new vertex w together with edges {u, w} and {v, w}.
u v
Solution:
7
1 6
It is homeomorphic to K3,3.
5 8 1 2 3
2 3
8
4 9
9 7
4 5 6
Julia Rahman, Dept. CSE, RUET 56
8.8 Graph Coloring
1 2 1 1
5
1
4 3 3 2
Definition 2:
The chromatic number of a graph is the least number of colors needed for a
coloring of this graph. (denoted by c(G))
Example 2: c(K5)=5
1 2
5 3
Note: c(Kn)=n
Julia Rahman, Dept. CSE, RUET 58
4
8.8 Graph Coloring
Example: c(K2,3) = 2.
1 1
2 2 2
Note: c(Km,n) = 2
Note: If G is a bipartite graph, c(G) = 2.
Example 1: What are the chromatic numbers of the graphs G and H?
2 3
1 1 1 a g
3 2 H
Solution: G has a 3-cycle Solution: any 3-coloring for
c(G)3 H-{(a,g)} gives the same color to a and g
G has a 3-coloring c(H)>3
c(G)3 4-coloring exists c(H)=4
c(G)=3 Julia Rahman, Dept. CSE, RUET 59
8.8 Graph Coloring
Example 4: c(Cn) =
{ 2 if n is even,
3 if n is odd. 1 2