1.11k likes | 2.13k Views
Discrete and Combinatorial Mathematics R. P. Grimaldi , 5 th edition, 2004. Chapter 7 Graph Theory. In the beginning…. Leonhard Euler Swiss mathematician, 1707-1783. First paper in graph theory. In 1736, he wrote a solution to the problem of Königsberg bridges .
E N D
Discrete and Combinatorial MathematicsR. P. Grimaldi,5th edition, 2004 Chapter 7 Graph Theory
In the beginning… Leonhard Euler • Swiss mathematician, 1707-1783. • First paper in graph theory.In 1736, he wrote a solution to the problem ofKönigsberg bridges. Problem of the Königsberg bridges: • In East Prussia • Starting and ending at the same region, is it possible to cross all seven bridges just once and return to the starting region? Pregel river Kneiphof island
A graph G = (V, E) consists V = V(G) : set of vertices (vertex set) E = E(G) VV : set of edges (edge set) If E(G) is a set of ordered pairs, then G is called a directed graph; otherwise an undirected graph. Example: V = {x, u, v, w} E = {(x,v), (x,u), (u,v), (v,w), (u,w)} Graphs w v x u w v x u
Subgraphs • If G = (V, E) is a graph, then G1 = (V1,E1) is called a subgraph of G if V1 V and E1 E, where each edge in E1 is incident with vertices in V1. w v v x x u u G G1
Edges An edge is labeled by a pair of vertices, for instance e = (v,w). • e is said to be incident with v and w. • v and w are said adjacent. • isolated vertex: a vertex without incident edges. • loop: an edge whose endpoints are equal. • parallel edges: edges with the same endpoints. e v w loop parallel edges isolated vertex
Representations of graphs Adjacency matrix Rows and columns are labeled with ordered vertices. Aij = 1, if there is an edge between the row vertex and the column vertex. Aij = 0 if no edge exists between them. Incidence matrix Label rows with vertices Label columns with edges Iij = 1 if an edge is incident to a vertex, Iij = 0 otherwise.
Simple graph A graph without loops or parallel edges. Weighted graph A graph where each edge is assigned a numerical label or “weight”. Different graphs 1 2 4 6 8
Walks G = (V,E) : an undirected graph, x ,y V (not necessarily distinct) • x-y walk in G: a loop-free finite alternating sequence of vertices and edges, where ei = (xi-1,xi). • length of the walk = n. • x-y walk with x = y: closed walk. • Note: A walk may repeat both vertices and edges.
Trails, Circuits, and Paths • If no edge in the x-y walk is repeated, then the walk is called an x-y trail. • A closed x-y trail is called a circuit. • If no vertex of the x-y walk repeated, then the walk is called an x-y path. • A closed x-y path is called a cycle. y e6 e7 e2 w v e1 e3 e5 e4 x u
Connected graphs • Let G = (V,E) be an undirected graph. We call G connected if there is a path between any two distinct vertices of G; otherwise it is called disconnected. • Each connected subgraph of a disconnected graph G is called a componentof G. G H
Spanning subgraphs • Given a grapg G = (V, E), let G1 = (V1,E1) be a subgraph of G. iIf V1 = V then G1 is called a spanning subgraph of G. w w v v x x u u G G1
Induced subgraphs • Given a grapg G = (V, E). If U V, the subgraph induced by U, denoted by <U>, is the subgraph whose vertex set is U and which contains all edges with both endpoints in U. w v v x x u u G <U>
Complete graphs • The complete graph Kn is the simple graph with n vertices and every pair of vertices is joined by an edge. Example: K5
Complement graphs • Let G be a simple graph with n vertices. The complement of G,denoted by , is the subgraph of Kn consisting of the n vertices in G and all edges that are not in G. Example: G
Bipartite graphs A simple undirected graph is called bipartite if there exists a partition of the vertex set so that V1V2= andno edges incident with two vertices in the same subset Vk, k = 1,2. V2 V1
Complete bipartite graphs A bipartite graph G = (V,E) with vertex partition V1 and V2 , where |V1| = m and |V2| = n, is the complete bipartite graph, denoted by Km,n, if every vertex in V1 is joined to a vertex in V2 and vice versa. V2 V1
Isomorphic graphs G1 and G2 are isomorphicif there exist one-to-one onto functions f: V(G1) → V(G2) and g: E(G1) → E(G2) such that an edge e is adjacent to vertices v, w in G1 if and only if g(e) is adjacent to f(v) and f(w) in G2 aq, bv, cu, dy, er, fw, gx, ht, iz, js
Degree of a vertex The degree of a vertex v, denoted by deg(v), is the number of edges incident on v. Example: • deg(a) = 4, deg(b) = 3, deg(c) = 2, deg(d) = 3. a b c d
Sum of vertex degrees Theorem 11.2 If G = (V,E) is an undirected graph, then Proof. Each edge contributes exactly two counts, one count (degree) for each endpoint. • # Corollary 11.1 For any undirected graph, the number of vertices of odd degree must be even.
Regular graphs An undirected graph where each vertex has the same degree is called a regular graph. If deg(v) = k for all vertices v, then the graph is called k-regular. Hypercube Qn: n regular. 001 011 010 000 111 101 100 110
Let G = (V,E) be an undirected graph with no isolated vertices. Then G is said to have an Euler circuit if there is a circuit in G that traverses every edge of the graph exactly once. The Königsberg bridge problem: Starting and ending at the same region, is it possible to cross all seven bridges just once and return to the starting region? This problem can be represented by a graph. Edges represent bridges and each vertex represents a region. Euler circuit
Euler graphs Theorems 11.3 Let G = (V,E) be an undirected graph with no isolated vertices. Then G has an Euler circuit if and only if G is connected and all its vertices have even degree. Therefore, the Konigsberg bridge problem has no solution.
Proof(1) () Trivial. () Step 1. Start from an arbitrary vertex, go through an unused edge whenever it exists, and terminate at a vertex whose incident edges are all used. 1 2 1265461 6 3 5 4
Proof(2) Step 2. Remove used edges and repeat step 1. for the remaining graph (start from a visited vertex). 1 2 2342 6 3 5 4
Proof(3) Step 3. Augment the path obtained so far with the result of step 2. 1234265461 Step 4. Repeat step 2 and step 3 until all the edges are used. #
Planar graphs A graph G is planar if it can be drawn in the plane with its edges intersecting only at vertices of G; otherwise it is nonplanar. a b c d a nonplanar graph a planar graph
Let G = (V,E) be a loop-free undirected graph, where E. An elementary subdivision of G results when an edge e = (u,w) is removed from G and then the edges (u,v), (v,w) are added to G-e, where vV. Elementary subdivision v u w
Homeomorphic graphs The loop-free undirected graphs G1 and G2 are called homeomorphic if they are isomorphic or if they can both be obtained from the same loop-free undirected graph H by a sequence of elementary subdivisions.
Kuratowski’s Theorem A graph is nonplanarif and only if it contain a subgraph that is homeomorphic to either K5 or K3,3. a j d a g f e j b h g c i i h e f b c d Peterson graph
Euler’s Theorem Theorem 11.6 Let G = (V,E) be a connected planar graph with |V| =v and |E| = e. Let r be the number of regions in the plane determined by a planar embedding. Then v – e + r = 2. Proof. By induction. v = 4 e = 6 r = 4 v – e + r = 2. R3 R4 R1 R2
Variant of Euler’s Theorem Corollary 11.3 Let G = (V,E) be a loop-free connected planar graph with |V| =v and |E| = e > 2, and r regions. Then 3r 2e and e 3v - 6. Proof. For each region R, the degree of R, denoted by deg(R), is the number of edges traversed in a closed walk about the boundary of R. Each region has at least three edges. Each region has degree 3. The sum of the degrees of the r regions is 2e. 2e 3r. e 3v – 6. (By Euler’s Theorem) #
Hamilton’s toy William Rowan Hamilton • Irish mathematician, 1805-1865 • In 1859, he developed a game sold to a Dublin toy manufacturer. The object of the game was to find a cycle containing all vertices.
Hamilton paths and cycles If G = (V,E) is a graph with |V| 3, we say that G has a Hamilton cycle if there is a cycle in G that contains every vertex in V. Theorem 11.8 Let G = (V,E) be a loop-free graph with |v| = n 2. If deg(x) + deg(y) n – 1 for all x, y V, x y, then G has a Hamilton path. A Hamilton path is a path in G that contains each vertex. Theorem 11.9 Let G = (V,E) be a loop-free graph with |v| = n 3. If deg(x) + deg(y) n – 1 for all nonadjacent x, y V, then G has a Hamilton cycle.
Gray code A Gray code is a sequence s1, s2,…, such that • every n-bit string appears somewhere in the sequence • sk and sk+1 differ in exactly one bit • and s1 differ in exactly one bit. 000001011010110111101 100
A Hamiltonian cycle on the hypercube 001 011 010 000 111 101 100 110
Trees and Forests Let G = (V,E) be a loop-free undirected graph. The graph G is called tree if G is connected and contains no cycles. G is called forest if G contains no cycles and is not connected. forest tree
Properties of Trees Theorem 12.1 If a, b are distinct vertices in a tree T = (V,E), then there is a unique path that connects a and b. Proof. By contradiction. Theorem 12.3 In any tree T = (V,E), |V| = |E| + 1. Proof. By Mathematical Induction on |E|.
Properties of Trees (cont.) Theorem 12.4 For every tree T = (V,E), if |V| 2, then T has at least 2 vertices of degree 1. Proof. From Theorem 12.3 on Theorem 12.5 The following statements are equivalent for a loop-free undirected graph G = (V,E). • G is a tree. • G is connected, but the removal of any edge from G disconnects G into two subgraphs that are trees. • G contains no cycles, and |V| = |E| + 1. • G is connected, and |V| = |E| + 1.
Brainstorm 將1~9數字填入九個圓圈中,相鄰的數字(有邊連結)之差不能小於3。數字不能重複,題目已經預填兩個數。 8 6
Brainstorm 根據已故的麻省理工( MIT )哲學及邏輯家George Boolos,以下的趣味邏輯問題可算是全世界最難的一個。 有甲、乙、丙三位精靈,其中一位只說真話,另外一位只說假話,還有一位隨機地決定何時說真話,何時說假話。你可以向這三位精靈發問三個是非題,而你的任務是從他們的答案找出誰說真話,誰說假話,誰是隨機答話。你每次可選擇任何一位精靈問話,問的問題可以取決於上一題的答案。這個難題困難的地方是這些精靈會以「Da」或「Ja」回答,但你並不知道它們的意思,只知道其中一個字代表「對」,另外一個字代表「錯」。你應該問那三個問題呢? 答案見 Boolos (1998) Logic, Logic, and Logic Harvard University Press, 弟29章.