### Discrete

### Mathematics

### Chapter-8

### Graphs

### §8.1 Introduction to Graphs

**Def 1.** A (simple) graph G=(V,E) consists
of a nonempty set V of vertices, and E, a
set of unordered pairs of distinct elements
of V called edges.

eg.

V_{1}

V_{2}

V_{3} V_{4}

V_{7}

V_{6}

G=(V,E), where
V={ v_{1},v_{2},…,v_{7} }

E={ {v_{1},v_{2}}, {v_{1},v_{3}}, {v_{2},v_{3}}
{v_{3},v_{4}}, {v_{4},v_{5}}, {v_{4},v_{6}}
{v_{4},v_{7}}, {v_{5},v_{6}}, {v_{6},v_{7}} }

V_{5}

**Def 2.** Multigraph

simple graph + “兩點間允許多條邊”

multiedge

eg.

V1

V2

V3 V4

V5

V7

V6

**Def 3.** pseudo graph :

simple graph + multiedge + loop

( loop即 )

eg.

**Table 1.** Graph Terminology

Type Edges Multiple

Edges

Loops (simple) graph

Multigraph

Pseudo graph Directed graph

Directed multigraph

Directed

表示成 (u,v) Undirected 表示成 {u,v}

Note: directed multigraph 中

U V

是 multiedge 邊為(u,v),(u,v)

U V

不是 multiedge 邊為(u,v),(v,u)

**Exercise : 3,5,6,7,9**

### §8.2 Graph Terminology

**Def 1.** Two vertices u and v in a graph

G are called adjacent in G if {u,v} is an edge of G.

Def 2. The degree of a vertex v, denoted

by deg(v), in an (undirected) graph is the number of edges incident with it.

(undirected)

(Note : 點跟點相連 : adjacent 點跟邊相連 : incident )

(Note : loop要算2次)

**Example 1.** What are the degree of the
vertices in the graph H ?

**Sol :**

a b

c

e d f

H

deg(a)=4 deg(b)=6 deg(c)=1 deg(d)=5 deg(e)=6 deg(f)=0

**Def.** A vertex of degree 0 is called isolated.

eg. “ f ” in Example 1.

**Thm 1.** (The Handshaking Theorem)

Let G=(V,E) be an undirected graph with n edges (i.e., |E|=n).

Then

## ∑

∈

### =

*V*
*v*

*n* *v* ) 2 deg(

**Pf :** 每條edge {u,v}會貢獻一個degree給u跟v

eg. Example 1. there are 11 edges, and

### ∑

∈### =

*V*
*v*

*v* ) 22 deg(

**Example 2.** How many edges are there in a
graph with 10 vertices each of
degree 6 ?

**Sol :**

10 ⋅ 6 = 2n => n=30

**Thm 2.** An undirected graph has an even
number of vertices of odd degree.

**Def 3.** G: directed graph , G=(V,E)
(u,v)∈E : u is adjacent to v

v is adjacent from u

u : initial vertex , v : terminal vertex

u v

**Def 4.**

G=(V,E) : directed graph, v∈V

deg^{-}(v) : # of edges with v as a terminal.

(in-degree)

deg^{+}(v) : # of edges with v as a initial vertex
(out-degree)

**Example 3.**

a b

c

e d

f

a is adjacent to b , b is adjacent from a a : initial vertex of (a,b)

b : terminal vertex of (a,b)

deg^{-}(a)=2, deg^{+}(a)=4
deg^{-}(b)=2, deg^{+}(b)=1

: :

deg^{-}(f)=0, deg^{+}(f)=0

**Thm 3.** Let G=(V,E) be a digraph. Then

**pf :**

每個 edge貢獻一個 out–degree 給 a

一個 in–degree 給 b

a b

### ∑ ∑

∈ ∈

+

−

### = =

*V*

*v* *v* *V*

*E* *v*

*v* ) deg ( ) (

### deg

**Def :** The complete graph on n vertices, denoted
by K_{n}, is the simple graph that contains

exactly one edge between each pair of distinct vertices.

**Example 4.**

K_{1} K_{2} K_{3} K_{4}

Note : | E | =

n 2

**Example 5.** The cycle C_{n}, n≧3, consists of n
vertices v_{1},v_{2},…,v_{n} and edges

{v_{1},v_{2}}, {v_{2},v_{3}},…,{v_{n-1},v_{n}},{v_{n},v_{1}}.

C_{5} C_{6}

**| E | = n**

Example 6. W_{n} : (wheel), C_{n}中加一點連至
其餘n點(n≧3)

W_{5} W_{6}

**| V | = n + 1**

**| E | = 2n**

**Def 5.** A simple graph G=(V,E) is called

bipartite if V can be partitioned into V_{1} and
V_{2}, V_{1}∩V_{2}=∅, such that every edge in the
graph connect a vertex in V_{1} and a vertex
in V_{2}.

**Example 8.**

v1 v3

v5

v2 v4 v6

**∴ C**_{6} **is bipartite.**

**Example 10.** Is the graph G bipartite ?

a b

g

f

e

d c

a

b

g f e

d

c

**Yes !**

Example 11. Complete Bipartite graphs (k_{m,n}) ???

K_{2,3} K_{3,3}

Note. | E | = mn

**Example 14.** A subgraph of K_{5}

**Def 6.** A subgraph of a graph G=(V,E) is a

graph H=(W,F) where W ⊆ V and F ⊆ E.

(注意 F 要連接 W 裡的點)

a

b

d c e

a

e b

c

subgraph of K_{5}
K_{5}

**Def 7.** The union of two simple graph
G_{1}=(V_{1},E_{1}) and G_{2}=(V_{2},E_{2}) is the

simple graph G_{1}∪G_{2}=(V_{1}∪V_{2},E_{1}∪E_{2})

**Example 15.**

a b c

d f

a b c

d e

a b c

d e f

G_{1} G_{2}

G_{1}∪G_{2}

**ex35上面** A simple graph G=(V,E) is called
**regular** if every vertex of this graph has the
same degree. A regular graph is called

**n-regular** if deg(v)=n , ∀v∈V.

**eg.**

K_{4} :
is 3-regular.

**Exercise : 5,7,21,23,25,35,37**

### §8.3 Representing Graphs and Graph Isomorphism

**※Adjacency list**

**Example 1.** Use adjacency list to describe the simple
graph given below.

b a

e d

c

Vertex Adjacent vertices

a b,c,e

b a

c a,d,e

d c,e

e a,c,d

**Sol :**

**Example 2.** (digraph)

a

b

e

c

d

Initial vertex Terminal vertices

a b,c,d,e

b b,d

c a,c,e

d

e b,c,d

**※Adjacency Matrices**

**Def.** *G=(V,E) : simple graph,*

*V={v*_{1}*,v*_{2}*,…,v** _{n}*}. (順序沒關系)

*A matrix A is called the adjacency matrix of *
*G if A=[a** _{ij}*]

*, where*

_{nxn}⎥⎥

⎥⎥

⎦

⎤

⎢⎢

⎢⎢

⎣

⎡

=

0 0

1 1

0 0

1 1

1 1

0 1

1 1

1 0

*A*1

**Example 3.**

a

c

b

d

**undirected**
**graph 的連**
通矩陣必

**“對稱”**

⎥⎥

⎥⎥

⎦

⎤

⎢⎢

⎢⎢

⎣

⎡

=

0 1

1 1

1 0

0 1

1 0

0 1

1 1

1 0

2
*A*

a b c d

a b c d b d c a

b d c a

**Example 5.** (Pseudograph) (矩陣未必是0,1矩陣.)

**Def.** *If A=[a** _{ij}*] is the adjacency matrix for the directed
graph, then

⎥⎥

⎥⎥

⎦

⎤

⎢⎢

⎢⎢

⎣

⎡

=

0 2 1 2

2 1 1 0

1 1 0 3

2
0
3
0
*A*

a b c d

a b c d

*a*

_{ij}### =

### 1 , if

### 0 , otherwise

故矩陣 未必對稱

a b

c d

*v*_{i}*v*_{j}

**Def 1.**

*The simple graphs G*_{1}*=(V*_{1}*,E*_{1}*) and G*_{2}*=(V*_{2}*,E*_{2})
are isomorphic if there is an one-to-one and
*onto function f from V*_{1} *to V*_{2} with the property
that a~b in G_{1} *iff f(a)~f(b) in G*_{2}, *∀a,b∈V*_{1}

*f is called an isomorphism.*

**※Isomorphism of Graphs**

u_{1}

u_{3}

u_{2}

u_{4}

G

v_{1}

v_{3}

v_{2}

v_{4}

H

**G is isomorphic**
**to H**

**Example 8.**

u_{1}

u_{3}

u_{2}

u_{4}

G

v_{1}

v_{3}

v_{2}

v_{4}

H

**f(u**_{1}**) = v**_{1}**f(u**_{3}**) = v**_{3}**f(u**_{2}**) = v**_{4}**f(u**_{4}**) = v**_{2}

**※Isomorphism Graphs 必有 : **
**(1) 相同的點數。**

**(2) 相同的邊數。**

**(3) 相同的degree分佈。**

※給定二圖，判斷它們是否isomorphic的問題一般來說不 易解，而且答案常是否定的。

**Example 9.**

Show that G and H are not isomorphic.

a

e

b

c

d

b

a

e d

c

**Sol :**

∵ H 有 degree = 1 的點，G 沒有

∴ G ≈ H

G H

**Example 10.**

Determine whether G and H are isomorphic.

G H

a b

d c

e

h

f g

s

v

t

u

w x

z y

**Sol : **

∵ G 中 degree 為 3 的點有d, h, f, b 它們不能接成 4-cycle

但 H 中 degree 為3的點有s, w, z, v 它們可接成 4-cycle

∴ 不是 isomorphic.

另法 : G 中 degree 為 3 的點，旁邊都只連了另一個 deg = 3 的點 但 H 中 deg = 3 的點旁邊都連了 2 個 deg = 3 的點。

**Example 11.** Show that G H

### ≈

G H

u_{1} u_{2}

u_{4} u_{3}

u_{5}

u_{6}

v_{1}

v_{2}

v_{3}

v_{4}

v_{5} v_{6}

**Exercise : 3,7,14,17,19,23,37,39**

**(1) 相同的點數。**

**(2) 相同的邊數。**

**(3) 相同的degree分佈**

### §8.4: Connectivity

**Def. 1,2 :**

In an undirected graph, a path of length n *from *
*u to v is a sequence of adjacent vertices going *
*from vertex u to vertex v. (e.g., P: u=x*_{0}*, x*_{1},

*x*_{2}*, …, x*_{n}*=v)*

*Note. A path of length n has n+1 vertices*，*n *
edges

A path is a circuit *if u=v.*

A path *traverses* the vertices along it.

A path or circuit is *simple* if it contains no vertex
more than once. (simple circuit通常稱為cycle)

### Paths in Directed Graphs

Same as in undirected graphs, but the

path must go in the direction of the arrows.

**Figure 5.**

u v

### Connectedness

**Def. 3:**

An undirected graph is connected (連通) iff there is a path between every pair of distinct vertices in the graph.

**Def:**

*Connected component: maximal *

connected subgraph. (一個不連通的圖 會有好幾個component)

Example 6

### Connectedness

**Def:**

A cut vertex separates one connected component into several components if it is removed.

**Def:**

A cut edge separates one connected component into two components if it is removed.

**Example 8. **

### Connectedness in Digraphs

**Def. 4:**

A directed graph is strongly connected iff there
*is a directed path from a to b for any two *

*vertices a and b. *

**Def. 5: **

It is weakly connected *iff the underlying *

*undirected graph (i.e., with edge directions *
removed) is connected .

*Note strongly implies weakly but not vice-versa.*

### Connectedness in Digraphs

**Example 9.**

**G is strongly/weakly connected**

**H is only weakly connected**

### Paths & Isomorphism

Note that connectedness, and the existence of a
*circuit or simple circuit of length k are graph *

invariants with respect to isomorphism.

**Example 12: Determine whether the graphs G **
**and H shown in Figure 6 are isomorphic **

**Example 12**

Sol: Both G and H have six vertices and eight edges. Each has four vertices of degree three, and two vertices of degree two.

However, H has a simple circuit of length three, namely, v1, v2, v6, v1, whereas G has no simple circuit of length three, as can be determined by inspection (all simple circuits in G gave length at least four). Because the existence of simple

circuit of length three is an isomorphic invariant, G and H are not isomorphic.

### Paths & Isomorphism

**Example 13: Determine whether the graphs G **
**and H shown in Figure 7 are isomorphic **

**Example 13**

Both G and H have five vertices and six edges. Each has two vertices of degree three, and three vertices of degree two, and both have a simple circuit of length

three, a simple circuit of length four, and a simple circuit of length five.

G and H are isomorphic.

### Counting Paths between Vertices

**Let A be the adjacency matrix of graph G.**

**Theorem 2: **

The number of paths of length r *from v*_{i}*to v** _{j}* is

**equal to (A**

*)*

^{r}

_{i,j}**. (The notation (M)**

_{i,j}*denotes m*

_{i,j}*where [m*

_{i,j}

**] = M.)****Example 14.**

**Exercise: 15, 23, 25, 26**

**Example 14.**

How many paths of length four are there from a to d in the simple graph G in Figure 8?

Sol: 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;

a,c,d,c,d.

⎥⎥

⎥⎥

⎦

⎤

⎢⎢

⎢⎢

⎣

⎡

=

0 1

1 0

1 0

0 1

1 0

0 1

0 1

1 0

*A*

⎥⎥

⎥⎥

⎦

⎤

⎢⎢

⎢⎢

⎣

⎡

=

8 0

0 8

0 8

8 0

0 8

8 0

8 0

0 8

*A*4

### §8.5: Euler & Hamilton Paths

**Def. 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.**

**Example 1 **

### Example 2

Which of the directed graphs in Figure 4 have an Euler circuit? Of those that do not, which have Euler path?

### Example

Sol: The graph H2 has Euler circuit, for example, a,g,c,b,g,e,d,f,a.

Neither H1 nor H3 has Euler circuit. H3

has an Euler path, namely, c,a,b,c,d,b, but H1 does not.

### Useful Theorems

**Thm. 1:**

A connected multigraph has an Euler circuit iff each vertex has even degree.

**Thm. 2:**

A connected multigraph has an Euler path (but not an Euler circuit) iff it has exactly 2 vertices of odd degree.

### Example 4

Which graphs shown in Figure 7 have an Euler path?

### Example 4

Sol: G1 contains exactly two vertices of odd

degree, namely, b and d. Hence, it has an Euler path that must have b and d as its endpoints.

One such Euler path is d,a,b,c,d,b.

Similarly, G2 has exactly two vertices of odd

degree, namely, b and d. So it has an Euler path that must have b and d as endpoints. One such Euler path is b,a,g,f,e,d,c,g,b,c,f,d.

G3 has no Euler path because is has six vertices of odd degree.

### Hamilton Paths

**Def. 2:**

A Hamilton circuit is a circuit that

traverses each vertex *in G exactly once.*

A Hamilton path is a path that traverses
each vertex *in G exactly once.*

**Example 5**

Which of the simple graphs in Figure 10 have a Hamilton circuit or, if not, a Hamilton Paths?

**Example 5**

Sol: G1 has a Hamilton circuit: a,b,c,d,e,a.

There is no Hamilton circuit in G2 (this can be seen by nothing that any circuit containing every vertex must contain the edge {a,b} twice), but G2 does have a Hamilton path, namely, a,b,c,d.

G3 has neither a Hamilton circuit nor a Hamilton path, because any path containing all vertices

must contain one of the edges {a,b},{e,f}, and {c,d} more than once.

### Useful Theorems

**Thm. 3 (Dirac’s Thm.):**

*If (but not only if) G is connected, simple, *
*has n≥3 vertices, and deg(v)≥n/2 ∀v, then *
*G has a Hamilton circuit. *

**Exercise: 3, 5, 7, 21, 26, 28, 42, 43.**

### §8.6: Shortest Path Problems

**Def:**

Graphs that have a number assigned to each edge are called weighted graphs.

**Shortest path Problem:**

Determining the path of least sum of the weights between two vertices in a

weighted graph.

### Dijkstra’s Algorithm

**Figure 4.**

**Exercise: 3**

### §8.7: Planar Graphs

**Def. 1:**

A graph is called *planar* if it can be
drawn in the plane without any edge
crossing.

Exercise: 2,3,4

**Example 1**

K_{4} is planar.

**Example 3**

K_{3,3} is nonplanar.

### §8.8: Graph Coloring

**Def. 1:**

A coloring of a simple graph is the

assignment of a color to each vertex of the graph so that no two adjacent

vertices are assigned the same color.

**Def. 2:**

The chromatic number of a graph is the least number of colors needed for a

coloring of this graph. (denoted by χ(G))

### §8.8: Graph Coloring

**Example 2~4:** χ(K_{n}*)=n, *χ(K_{m,n}*)=2, *χ(C_{n}*)=2,3.*

**Example 3’:** If G is a bipartite graph, *χ(G)=2.*

**Theorem 1. (The Four Color Theorem)**

The chromatic number of a planar graph is no greater than four.

**Exercise: 6, 7**

**Example 1**

What are the chromatic number of graphs G and H show in Figure 3?

### Example 2

What is the chromatic number of K_{n}*?*

Sol: Here, the chromatic number of K_{n}*= n.That is,*
χ(K_{n}*)=n.* *(Recall that* K_{n}*is not planar when n >=5, *
so this does not contradict the four color Theorem.)
A coloring of K_{5} using five colors is shown in Figure
5.