discrete mathematics

49
Discrete Mathematics Chapter-8 Graphs 感感 感感感感 感感感感感 感感感感感 感感

Upload: faustus-marlas

Post on 03-Jan-2016

110 views

Category:

Documents


8 download

DESCRIPTION

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. G=(V,E), where V={ v 1 ,v 2 ,…,v 7 } - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Discrete  Mathematics

Discrete Mathematics

Chapter-8

Graphs

感謝 大葉大學 資訊工程系 黃鈴玲老師 提供

Page 2: Discrete  Mathematics

§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.

V1

V2

V3 V4

V7

V5

V6

G=(V,E), where V={ v1,v2,…,v7 }

E={ {v1,v2}, {v1,v3}, {v2,v3}

{v3,v4}, {v4,v5}, {v4,v6}

{v4,v7}, {v5,v6}, {v6,v7} }

Page 3: Discrete  Mathematics

Def 2. Multigraph

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

eg.

V1

V2

V3 V4

V7

V5

V6

Page 4: Discrete  Mathematics

Def 3. pseudo graph :

simple graph + multiedge + loop

( loop 即 )

eg.

Page 5: Discrete  Mathematics

Table 1. Graph Terminology

Type Edges Multiple Edges

Loops

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

Multigraph

Pseudo graph

Directed graph Directed

表示成 (u,v)

Directed multigraph

Page 6: Discrete  Mathematics

Note: directed multigraph 中

U V

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

U V

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

Exercise : 3,5,6,7,9

Page 7: Discrete  Mathematics

§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 次 )

Page 8: Discrete  Mathematics

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

Sol :

ab

c

e d f

H

deg(a)=4

deg(b)=6

deg(c)=1

deg(d)=5

deg(e)=6

deg(f)=0

Page 9: Discrete  Mathematics

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

Vv

nv 2)deg(

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

Page 10: Discrete  Mathematics

eg. Example 1. there are 11 edges, and

Vv

v 32)deg(

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

Sol :10 6 = 2n => n=30

Page 11: Discrete  Mathematics

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

Page 12: Discrete  Mathematics

Def 4.

G=(V,E) : directed graph

vV

deg(v) : # of edges with v as a terminal.

(in-degree)

deg+(v) : # of edges with v as a initial vertex

Page 13: Discrete  Mathematics

Example 3.

a b

c

e df

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

end

deg-(a)=2, deg+(a)=4deg-(b)=2, deg+(b)=1 : : deg-(f)=0, deg+(f)=0

Page 14: Discrete  Mathematics

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

Vv Vv

Evv )(deg)(deg

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

一個 in–degree 給 ba b

Page 15: Discrete  Mathematics

Def : The complete graph on n vertices, denoted by Kn, is the simple graph that contains exactly one edge between each pair of distinct vertices.

Example 4.

K1 K2K3 K4

Note : | E | =n

2

Page 16: Discrete  Mathematics

Example 5. The cycle Cn, n 3, consists of n ≧vertices v1,v2,…,vn and edges

{v1,v2}, {v2,v3},…,{vn-1,vn},{vn,v1}.

C5 C6

| E | = n

Page 17: Discrete  Mathematics

Example 6. Wn : (wheel), Cn 中加一點連至其餘 n 點 (n 3)≧

W5W6

| V | = n + 1| E | = 2n

Page 18: Discrete  Mathematics

Def 5. A simple graph G=(V,E) is called bipartite if V can be partitioned into V1 and V2, V1∩V2=, such that every edge in the graph connect a vertex in V1 and a vertex in V2.

Example 8.

v1

v3

v5

v2

v4

v6

∴ C6 is bipartite.

Page 19: Discrete  Mathematics

Example 10. Is the graph G bipartite ?

a b

g

f

e

d

c

a

b

g

f

e

d

c

Yes !

Page 20: Discrete  Mathematics

Example 11. Complete Bipartite graphs (km,n)

K2,3K3,3

Note. | E | = mn

Page 21: Discrete  Mathematics

Example 14. A subgraph of K5

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

cd

e

a

e b

c

K5

subgraph of K5

Page 22: Discrete  Mathematics

Def 7. The union of two simple graph G1=(V1,E1) and G2=(V2,E2) is the simple graph G1 G∪ 2=(V1 V∪ 2,E1 E∪ 2) Example 15.

a b c

d f

a b c

d e

a b c

d e f

G1 G2

G1∪G2

Page 23: Discrete  Mathematics

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 , vV.

eg. K4 :

is 3-regular.

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

Page 24: Discrete  Mathematics

§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 :

Page 25: Discrete  Mathematics

Example 2. (digraph)

a

b

ed

c

Initial vertex Terminal vertices

a b,c,d,e

b b,d

c a,c,e

d

e b,c,d

Page 26: Discrete  Mathematics

※Adjacency Matrices

Def. G=(V,E) : simple graph, V={v1,v2,…,vn}. ( 順序沒關系 )

A matrix A is called the adjacency matrix of

G if A=[aij]nxn , where

0011

0011

1101

1110

1AExample 3.

a

c

b

d

undirectedgraph 的連通矩陣必“ 對稱”

0111

1001

1001

1110

2A

a b c da

b

c

d

b

d

c

a

b d c a

Page 27: Discrete  Mathematics

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

Def. If A=[aij] is the adjacency matrix for the directed graph, then

0212

2110

1103

2030

A

a b c da

b

c

d

aij =

1 , if

0 , otherwise

故矩陣未必對稱

a b

cd

vi vj

Page 28: Discrete  Mathematics

Def 1.

The simple graphs G1=(V1,E1) and G2=(V2,E2) are isomorphic if there is an one-to-one and onto function f from V1 to V2 with the property that a~b in G1 iff f(a)~f(b) in G2, a,bV1

f is called an isomorphism.

※Isomorphism of Graphs

u1

u3

u2

u4

G

v1

v3

v2

v4

H

G is isomorphicto H

Page 29: Discrete  Mathematics

Example 8.

u1

u3

u2

u4

G

v1

v3

v2

v4

H

f(u1) = v1

f(u3) = v3

f(u2) = v4

f(u4) = v2

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

(3) 相同的 degree 分佈。

Page 30: Discrete  Mathematics

※ 給定二圖,判斷它們是否 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

Page 31: Discrete  Mathematics

Example 10.

Determine whether G and H are isomorphic.

HG

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 的點。

Page 32: Discrete  Mathematics

Example 11. Show that G H

G Hu1 u2

u4 u3

u5

u6

v1

v2

v3

v4

v5v6

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

Page 33: Discrete  Mathematics

§8.4: ConnectivityDef. 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=x0, x1, x2, …, xn=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)

Page 34: Discrete  Mathematics

Paths in Directed Graphs Same as in undirected graphs, but the

path must go in the direction of the arrows.

Figure 5.

Page 35: Discrete  Mathematics

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

Page 36: Discrete  Mathematics

ConnectednessDef:

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.

Page 37: Discrete  Mathematics

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.

Example 9.

Page 38: Discrete  Mathematics

Connectedness in DigraphsDef. 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.

Example 9.

Page 39: Discrete  Mathematics

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.

Example 13.

Page 40: Discrete  Mathematics

Counting Paths between Vertices

Let A be the adjacency matrix of graph G.

Theorem 2: The number of paths of length r from vi to vj is equal to (Ar)i,j. (The notation (M)i,j denotes mi,j where [mi,j] = M.)

Example 14.

Exercise: 15, 23, 25, 26

Page 41: Discrete  Mathematics

§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.

Page 42: Discrete  Mathematics

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.

Page 43: Discrete  Mathematics

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.

Page 44: Discrete  Mathematics

Useful Theorems

Thm. 3 (Dirac’s Thm.):If (but not only if) G is connected, simple, has n3 vertices, and deg(v)n/2 v, then G has a Hamilton circuit.

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

Page 45: Discrete  Mathematics

§8.6: Shortest Path ProblemsDef:

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.

Page 46: Discrete  Mathematics

Dijkstra’s Algorithm

Figure 4.

Exercise: 3

Page 47: Discrete  Mathematics

§8.7: Planar GraphsDef. 1:

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

Example 1: K4 is planar.

Example 3: K3,3 is nonplanar.

Exercise: 2,3,4

Page 48: Discrete  Mathematics

§8.8: Graph ColoringDef. 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))

Page 49: Discrete  Mathematics

§8.8: Graph ColoringExample 1

Example 2~4: (Kn)=n, (Km,n)=2, (Cn)=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 isno greater than four.

Exercise: 6, 7