Download presentation
Presentation is loading. Please wait.
1
Discrete Mathematics Chapter-8 Graphs
2
§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={ v1,v2,…,v7 } E={ {v1,v2}, {v1,v3}, {v2,v3} {v3,v4}, {v4,v5}, {v4,v6} {v4,v7}, {v5,v6}, {v6,v7} } V1 V5 V3 V4 V6 V2 V7
3
simple graph + “兩點間允許多條邊”
Def 2. Multigraph simple graph + “兩點間允許多條邊” multiedge eg. V1 V5 V3 V4 V6 V2 V7
4
Def 3. pseudo graph : simple graph + multiedge + loop ( loop即 ) eg.
5
Table 1. Graph Terminology
Type Edges Multiple Edges Loops (simple) graph Undirected表示成 {u,v} Multigraph Pseudo graph Directed graph Directed 表示成 (u,v) Directed multigraph
6
Note: directed multigraph 中
V U V 是 multiedge 邊為(u,v),(u,v) 不是 multiedge 邊為(u,v),(v,u) Exercise : 3,5,6,7,9
7
§8.2 Graph Terminology Def 1. Two vertices u and v in a graph
(undirected) 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. (Note : 點跟點相連 : adjacent 點跟邊相連 : incident ) (Note : loop要算2次)
8
Example 1. What are the degree of the vertices in the graph H ? Sol :
deg(a)=4 deg(b)=6 b a c deg(c)=1 deg(d)=5 deg(e)=6 deg(f)=0 e d f H
9
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 Pf : 每條edge {u,v}會貢獻一個degree給u跟v
10
eg. Example 1. there are 11 edges, and
Example 2. How many edges are there in a graph with 10 vertices each of degree 6 ? Sol : 10 6 = 2n => n=30
11
Def 3. G: directed graph , G=(V,E) (u,v)E : u is adjacent to v
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
12
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 (out-degree)
13
Example 3. deg-(a)=2, deg+(a)=4 deg-(b)=2, deg+(b)=1 : :
: : deg-(f)=0, deg+(f)=0 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)
14
Thm 3. Let G=(V,E) be a digraph. Then
pf : 每個 edge貢獻一個 out–degree 給 a 一個 in–degree 給 b a b
15
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. K3 K1 K2 K4 Note : | E | = n 2
16
{v1,v2}, {v2,v3},…,{vn-1,vn},{vn,v1}.
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
17
Example 6. Wn : (wheel), Cn中加一點連至其餘n點(n≧3)
| V | = n + 1 | E | = 2n
18
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 v2 v3 ∴ C6 is bipartite. v4 v5 v6
19
Example 10. Is the graph G bipartite ?
f e d c a b g f e d c Yes !
20
Note. | E | = mn Example 11. Complete Bipartite graphs (km,n) ??? K3,3
21
Def 6. A subgraph of a graph G=(V,E) is a
graph H=(W,F) where W V and F E. (注意 F 要連接 W 裡的點) Example 14. A subgraph of K5 subgraph of K5 K5 a e b c a b c d e
22
Def 7. The union of two simple graph G1=(V1,E1) and G2=(V2,E2) is the
simple graph G1∪G2=(V1∪V2,E1∪E2) Example 15. a b c d e a b c d f G1 G2 a b c d e f G1∪G2
23
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
24
§8.3 Representing Graphs and Graph Isomorphism
※Adjacency list Example 1. Use adjacency list to describe the simple graph given below. Sol : Vertex Adjacent vertices a b,c,e b c a,d,e d c,e e a,c,d b a e d c
25
Example 2. (digraph) Initial vertex Terminal vertices a b,c,d,e b b,d
a,c,e d e b,c,d a c e d
26
Def. G=(V,E) : simple graph, V={v1,v2,…,vn}. (順序沒關系)
※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 a b c d a Example 3. b c a c b d undirected graph 的連 通矩陣必 “對稱” d b d c a b d c a
27
1 , if aij = 0 , otherwise Example 5. (Pseudograph) (矩陣未必是0,1矩陣.)
b c d a a b b c d d c Def. If A=[aij] is the adjacency matrix for the directed graph, then 1 , if vi vj 故矩陣 未必對稱 aij = 0 , otherwise
28
※Isomorphism of Graphs
v1 v3 v2 v4 u1 u3 u2 u4 G is isomorphic to H G H 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.
29
※Isomorphism Graphs 必有 : (1) 相同的點數。 (2) 相同的邊數。 (3) 相同的degree分佈。
Example 8. v1 v2 u2 u1 v4 v3 u3 u4 H G ※Isomorphism Graphs 必有 : (1) 相同的點數。 (2) 相同的邊數。 (3) 相同的degree分佈。 f(u1) = v1 f(u3) = v3 f(u2) = v4 f(u4) = v2
30
∵ H 有 degree = 1 的點,G 沒有 ∴ G H
※給定二圖,判斷它們是否isomorphic的問題一般來說不易解,而且答案常是否定的。 Example 9. Show that G and H are not isomorphic. a e b c d b a e d c H G Sol : ∵ H 有 degree = 1 的點,G 沒有 ∴ G H
31
Determine whether G and H are isomorphic.
Example 10. Determine whether G and H are isomorphic. a s v t u w x z y b d c e h f g G H 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 的點。
32
Example 11. Show that G H G H v1 u1 u2 v3 u5 v2 u6 v6 v5 u4 u3 v4
(1) 相同的點數。 (2) 相同的邊數。 (3) 相同的degree分佈 Exercise : 3,7,14,17,19,23,37,39
33
§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=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)
34
Paths in Directed Graphs
Same as in undirected graphs, but the path must go in the direction of the arrows. Figure 5. u v
35
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
36
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.
37
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.
38
Connectedness in Digraphs
Example 9. G is strongly/weakly connected H is only weakly connected
39
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
40
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.
41
Paths & Isomorphism Example 13: Determine whether the graphs G and H shown in Figure 7 are isomorphic
42
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.
43
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
44
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.
45
§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.
46
Example 1
47
Example 2 Which of the directed graphs in Figure 4 have an Euler circuit? Of those that do not, which have Euler path?
48
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.
49
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.
50
Example 4 Which graphs shown in Figure 7 have an Euler path?
51
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.
52
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.
53
Example 5 Which of the simple graphs in Figure 10 have a Hamilton circuit or, if not, a Hamilton Paths?
54
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.
55
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.
56
§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.
57
Dijkstra’s Algorithm Figure 4. Exercise: 3
59
§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
60
Example 1 K4 is planar.
61
Example 3 K3,3 is nonplanar.
62
§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 c(G))
63
§8.8: Graph Coloring Example 2~4: c(Kn)=n, c(Km,n)=2, c(Cn)=2,3.
Example 3’: If G is a bipartite graph, c(G)=2. Theorem 1. (The Four Color Theorem) The chromatic number of a planar graph is no greater than four. Exercise: 6, 7
64
Example 1 What are the chromatic number of graphs G and H show in Figure 3?
65
Example 2 What is the chromatic number of Kn ?
Sol: Here, the chromatic number of Kn = n.That is, c(Kn)=n. (Recall that Kn is not planar when n >=5, so this does not contradict the four color Theorem.) A coloring of K5 using five colors is shown in Figure 5.
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.