Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Chapter 9 Tien Thinh, Mai Xuan Toan, Tran Hong Tai Introduction to Graphs Discrete Structures for Computing on January 4, 2023 Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Isomorphism Xuan Toan, Tran Hong Tai Faculty of Computer Science and Engineering University of Technology - VNUHCM trtanh@hcmut.edu.vn 9.1 Contents Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai 1 Graph definitions Terminology Special Graphs Bipartie graph 2 Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs 3 Exercise Graph Graph Isomorphism Exercise Graph Isomorphism Isomorphism 9.2 Course outcomes Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Course learning outcomes L.O.1 Understanding of logic and discrete structures L.O.1.1 Describe definition of propositional and predicate logic L.O.1.2 Define basic discrete structures: set, mapping, graphs L.O.2 Represent and model practical problems with discrete structures L.O.2.1 Logically describe some problems arising in Computing L.O.2.2 Use proving methods: direct, contrapositive, induction L.O.2.3 Explain problem modeling using discrete structures L.O.3 L.O.4 Understanding of basic probability and random variables L.O.3.1 Define basic probability theory L.O.3.2 Explain discrete random variables Compute quantities of discrete structures and probabilities L.O.4.1 Operate (compute/ optimize) on discrete structures L.O.4.2 Compute probabilities of various events, conditional ones, Bayes theorem Toan, Tran Hong Tai Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.3 Motivations Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai The need of the graph Its applications • Representation/Storing • Electric circuit/board • Searching/sorting • Chemical structure • Optimization • Networking • Map, geometry, Contents Graph definitions Terminology ... Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism • Graph theory is useful for analysing things that are connected to other things. • Some difficult problems become easy when represented using Representing Graphs Graph Isomorphism Exercise Graph Isomorphism a graph. 9.4 Graph Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Definition A graph (ç • V • E thà ) G is a pair of (V, E ), which are: nonempty set of vertices (nodes) (¿nh) Contents set of edges (c¤nh) Graph definitions Terminology A graph captures abstract relationships between vertices. Special Graphs Bipartie graph 2 2 4 4 Representing Graphs and Graph Isomorphism Representing Graphs 1 3 Undirected graph 1 3 Directed graph Graph Isomorphism Exercise Graph Isomorphism 9.5 Undirected Graph (ç thà væ h÷îng) Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Definition (Simple graph (ìn ç thà)) • Each edge connects two different vertices, and • No two edges connect the same pair of vertices An edge between two vertices u and v is denoted as Contents Graph definitions {u, v} Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.6 Undirected Graph Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Definition (Multigraph (a ç thà)) Graphs that may have multiple edges connecting the same vertices. An unordered pair of vertices m) if it has m {u, v} are called multiplicity different edges between. m (bëi Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.7 Undirected Graph Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Definition (Pseudograph (gi£ ç thà)) Are multigraphs that have • loops (khuy¶n) edges that connect a vertex to itself Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.8 Terminologies For Undirected Graph Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Neighborhood In an undirected graph • G = (V, E), u and v ∈ V are called adjacent (li·n k· ) if they end-points (iºm ¦u mót ) of edge e ∈ E , and e is incident with (c¤nh li¶n thuëc ) u and v e is said to connect (c¤nh nèi ) u and v ; two vertices are • • Contents Graph definitions Terminology Special Graphs Bipartie graph The degree of a vertex The degree of a vertex (bªc cõa mët ¿nh), denoted by deg(v) is the number of edges incident with it, except that a loop contributes twice to the degree of that vertex. • isolated vertex (¿nh cæ lªp ): vertex of degree 0 (¿nh treo ): vertex of degree 1 • pendant vertex Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.9 Example Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Example Tien Thinh, Mai Xuan Toan, Tran Hong Tai What are the degrees and neighborhoods of the vertices in these graphs? b c d a c b Contents Graph definitions a f e g e Terminology d Special Graphs Bipartie graph G H Solution In G, deg(a) = 2, deg(b) = deg(c) = deg(f ) = 4, deg(d) = 1, . . . Neiborhoods of these vertices are N (a) = {b, f }, N (b) = {a, c, e, f }, . . . In H , deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1, . . . Neiborhoods of these vertices are N (a) = {b, d, e}, N (b) = {a, b, c, d, e}, . . . Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.10 Basic Theorems Introduction to Graphs Nguyen An Khuong, Theorem (The Handshaking Theorem) Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Let G = (V, E) be an undirected graph with m edges. Then X 2m = deg(v) Toan, Tran Hong Tai v∈V (Note that this applies even if multiple edges and loops are present.) Contents Graph definitions Terminology Special Graphs Example Bipartie graph What are the degrees and neighborhoods of the vertices in these Representing Graphs and Graph Isomorphism Representing Graphs graphs? Graph Isomorphism b c d a c b Exercise Graph Isomorphism a f G e g e d H 9.11 Prove that ... Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Theorem An undirected graph has an even number of odd-degree vertices. ... If the number of vertices in an undirected graph is an odd number, then there exists an even-degree vertex. Contents Graph definitions Terminology Special Graphs ... If the number of vertices in an undirected graph is an odd number, then the number of vertices with even degree is odd. ... Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism If the number of vertices in an undirected graph is an even number, then the number of vertices with even degree is even. 9.12 Exercise Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Exercise (1) Toan, Tran Hong Tai Is there any undirected simple graph including four vertices that their degrees are respectively 1, 1, 2, 2 ? Exercise (2) Is there any undirected simple graph including six vertices that their degree are respectively 2, 3, 3, 3, 3, 3 ? Contents Graph definitions Terminology Special Graphs Bipartie graph Exercise (3) An undirected simple graph G has 15 edges, 3 vertices of degree 4 and other vertices having degree 3. What is the number of vertices of the graph G? Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism Exercise (4) Is it possible that each person has exactly 5 friends in the same group of 9 people ? 9.13 Exercise Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Exercise (6) Give an undirected simple graph G = (V, E) with |V | = n, show Contents Graph definitions that a) ∀v ∈ V , deg(v) < n, b) there does not exist simultaneously and a vertex of degree c) Terminology Special Graphs Bipartie graph both a vertex of degree 0 (n − 1), deduce that there are at least two vertices of the same degree. Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.14 Directed Graph Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Definition (Directed Graph (ç thà câ h÷îng)) A directed graph • V • E G is a pair of (V, E ), in which: nonempty set of vertices set of directed edges (c¤nh A directed edge start at u câ h÷îng, arcs ) v is denoted as (u, v). and end at Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.15 Terminologies for Directed Graph Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Neighborhood Tien Thinh, Mai Xuan Toan, Tran Hong Tai In an directed graph • u is said to be G = (V, E), adjacent to (nèi tîi ) v and v is said to be adjacent from (÷ñc nèi tø ) u if (u, v) is an arc of G, and • u is called initial vertex (¿nh ¦u ) of (u, v) • v is called terminal (¿nh cuèi ) or end vertex of (u, v) • the initial vertex and terminal vertex of a loop are the same. Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism The degree of a vertex In a graph • • G with directed edges: in-degree (bªc v o) Representing Graphs of a vertex the number of edges with v the number of edges with v v, denoted by deg (v), is − as their terminal vertex. out-degree (bªc ra) of a vertex v, denoted by deg+ (v), is Graph Isomorphism Exercise Graph Isomorphism as their initial vertex. Note: a loop at a vertex contributes 1 to both the in-degree and the out-degree of this vertex. 9.16 Basic Theorem Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Theorem Let G = (V, E) be a graph with directed edges. Then X v∈V deg− (v) = X v∈V deg+ (v) = |E|. Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.17 Complete Graphs Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen A complete graph (ç thà ¦y õ ) Tien Thinh, Mai Xuan on n vertices, Kn , is a simple Toan, Tran Hong Tai graph that contains exactly one edge between each pair of distinct vertices. Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism K5 K4 Exercise What is the largest number of edges a undirected simple graph with 10 vertices can have? Kn can have? 9.18 Cycles Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai A cycle (ç thà váng ) Cn , n ≥ 3, consists of n vertices v1 , v2 , . . . , vn and edges {v1 , v2 }, {v2 , v3 }, . . . , {vn−1 , vn }, {vn , v1 }. and Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism C5 C4 9.19 Wheels Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai We obtain a wheel (ç thà h¼nh b¡nh xe ) Wn when we add an Cn , for n ≥ 3, and connect this new n vertices in Cn . additional vertex to a cycle vertex to each of the Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism W5 W4 9.20 n-cube Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan An n-dimensional hypercube (khèi has vertices representing the 2n n chi·u ), Qn , Toan, Tran Hong Tai is a graph that bit strings of length n. Two vertices are adjacent iff the bit strings that they represent differ in exactly one bit position. 110 10 11 111 Contents Graph definitions Terminology 100 101 Special Graphs Bipartie graph 0 010 1 011 Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism 00 01 000 001 Exercise Graph Isomorphism Q1 What's about Q2 Q3 Q4 ? 9.21 Applications of Special Graphs Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai • Local networks topologies • Star, ring, hybrid • Parallel processing • Linear array • Mesh network Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.22 Graph Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai • One goat, a cabbage and a wolf are on a side of river; a boatman wishes to transport them to the other side but, his boat being too small, he could transport only one of them at once. • How does he proceed not to leave them together without Contents surveillance: the wolf and the goat, as well as the goat and Graph definitions the cabbage? Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.23 Bipartite Graphs Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Definition Toan, Tran Hong Tai thà ph¥n æi ) if its vertex V1 and V2 such that every edge in the graph connects a vertex in V1 and a vertex in V2 (so that no edge in G connects either two vertices in V1 or two vertices in V2 ) A simple graph set V G is called bipartite (ç can be partitioned into two disjoint sets Contents Graph definitions Example Terminology Special Graphs Bipartie graph C6 is bipartite Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism C6 9.24 Complete Bipartite Graphs Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Definition A complete bipartite • Km,n is a graph that has its vertex set partitioned into two subsets of m and n vertices, respectively, • with an edge between two vertices iff one vertex is in the first Contents subset and the other is in the second one Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism K3,3 9.25 Bipartite graphs Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Example (Bipartite graphs?) Toan, Tran Hong Tai • C6 • Cn • K3 • Kn • the Contents Graph definitions following graph Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.26 Bipartie graph Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.27 New Graph From Old Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Definition A subgraph (ç thà con) of a graph G = (V, E) is a graph H = (W, F ) where W ⊆V and F ⊆ E. Definition The union (hñp) of two simple graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) is a simple graph with vertex set V1 ∪ V2 and edge set E1 ∪ E2 . The union of G1 and G2 is denoted by G1 ∪ G2 . Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism G1 G2 G1 ∪ G2 9.28 Planar Graphs Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.29 Planar Graphs Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Definition • A graph is called planar (ph¯ng ) if it can be drawn in the plane without any edges crossing. • Such a drawing is called planar representation (biºu ph¯ng ) di¹n Contents of the graph. Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism K4 K4 with no crossing 9.30 Example Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Example • Is K5 planar? • Is Q3 planar? 110 111 Contents Graph definitions 100 Terminology 101 Special Graphs Bipartie graph 010 011 Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph 000 K5 001 Isomorphism Q3 9.31 Important Corollaries Corollary • If G is a connected planar simple graph with e edges and v vertices where v ≥ 3, then e ≤ 3v − 6. • If G is a connected planar simple graph with e edges and v vertices where v ≥ 3, and no circuits of length 3, then e ≤ 2v − 4. Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Contents Graph definitions Example Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.32 Elementary Subdivision Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Definition G, an elementary subdivision (ph¥n chia sì c§p ) is removing an edge {u, v} and adding a new vertex w together with edges {u, w} and {w, v}. • Graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are called homeomorphic (çng phæi ) if they can obtained from the • Given a planar graph same graph by a sequence of elementary subdivisions. Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.33 Kuratowski's Theorem Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Theorem A graph is nonplanar iff it contains a subgraph homeomorphic to K3,3 or K5 . Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism K3,3 Exercise Non-planar Graph K5 Isomorphism Non-planar 9.34 Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Example A graph is nonplanar iff it contains a subgraph homeomorphic to K3,3 . Contents a Graph definitions Terminology f e d j h Representing Graphs e c Bipartie graph Representing Graphs and Graph Isomorphism g a i Special Graphs c b g j d f Graph Isomorphism i h Exercise Graph Isomorphism 9.35 Adjacency Lists (Danh s¡ch k·) Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Vertex Adjacent vertices Initial vertex Terminal vertices a b, c, e a b, c, d, e b a b b, d c a, d, e c a, c, e d c, e d c, e e a, c, d e b, c, d Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.36 Adjacency Matrices Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Definition Toan, Tran Hong Tai Adjacency matrix (Ma trªn k· ) AG • Dimension • Matrixelements 1 if (vi , vj ) aij = 0 of G = (V, E) |V | × |V | ∈E Contents otherwise Graph definitions Terminology Special Graphs a b Bipartie graph a b c d c a 0 1 1 1 b c 1 1 0 1 1 0 0 0 d 1 0 0 0 Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism d 9.37 Examples Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Example Give the graph defined by the following adjacency matrix Contents A B C D E Graph definitions Terminology Special Graphs A B C D E 0 0 1 1 0 0 0 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 0 Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.38 Adjacency Matrices Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Example Give the directed graph defined by the following adjacency matrix Contents A B C D E Graph definitions Terminology Special Graphs A B C D E 1 0 1 1 1 0 0 0 1 0 1 0 0 1 0 1 0 0 0 0 0 0 0 1 0 Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.39 Incidence Matrices Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Definition Toan, Tran Hong Tai Incidence matrix (ma trªn li¶n thuëc ) MG • Dimension • Matrix elements 1 if ej is incident with mij = of G = (V, E) |V | × |E| 0 vi Contents otherwise Graph definitions Terminology Special Graphs a e2 b Bipartie graph Representing Graphs and Graph Isomorphism e1 e2 e3 e4 e1 c a b c d e4 e3 1 1 1 0 0 1 0 1 1 0 0 1 0 0 1 0 Representing Graphs Graph Isomorphism Exercise Graph Isomorphism d 9.40 Examples Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Example Give incidence matrix according to the following graph Contents F Graph definitions Terminology B C Special Graphs Bipartie graph A Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism E D G Exercise Graph Isomorphism 9.41 Graph Isomorphism Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Definition G1 = (V1 , E1 ) there is a b are adjacent in G1 iif f (a) and f (b) are adjacent a and b in V1 . Such a function f is called an isomorphism (mët ¯ng c§u). that G2 , a and G2 = (V2 , E2 ) are isomorphic (¯ng c§u ) if one-to-one function f from V1 to V2 with the property and in for all (i.e. there is a one-to-one correspondence between vertices of the u2 v1 v2 u4 v3 v4 Terminology Special Graphs Representing Graphs and Graph Isomorphism Representing Graphs Isomorphism function V u3 Graph definitions Bipartie graph two graphs that preserves the adjacency relationship.) u1 Contents f : U −→ f (u1 ) = v1 f (u3 ) = v3 Graph Isomorphism Exercise with f (u2 ) = v4 f (u4 ) = v2 Graph Isomorphism 9.42 Isomorphism ? Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.43 Isomorphism? Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai A A B Contents B Graph definitions Terminology F C G1 Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism D F C Representing Graphs E E G2 D Graph Isomorphism Exercise Graph Isomorphism 9.44 Isomorphism? Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai A1 A2 B2 Contents Graph definitions D1 E2 E1 F2 Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism F1 Representing Graphs C1 B1 G1 D2 C2 G2 Graph Isomorphism Exercise Graph Isomorphism 9.45 Isomorphism Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Are the simple graphs with the following adjacency matrices isomorphic ? 1 2 3 0 0 1 0 1 0 1 0 1 1 0 0 0 1 1 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0 0 1 1 0 0 1 1 1 0 0 1 0 0 0 1 1 1 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0 1 Contents Graph definitions Terminology 1 1 1 0 1 0 1 0 Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.46 Isomorphism Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Determine whether the graphs (without loops) with the incidence matrices are isomorphic. • • • 1 0 1 1 1 0 0 0 1 1 1 0 0 1 1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 1 1 0 1 0 0 1 1 1 0 1 0 1 1 0 1 0 Contents Graph definitions Terminology Special Graphs 0 1 0 1 0 1 1 0 1 0 0 1 Extend the definition of isomorphism of simple graphs to undirected graphs containing loops and multiple edges. • Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism Define isomorphism of directed graphs 9.47 Revision Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai ç thà G1 v G2 t÷ìng ùng vîi c¡c ma trªn li·n k· v li¶n thuëc d÷îi ¥y. (G1 ) A B C D E A B C D E 0 1 1 1 1 1 0 0 1 0 1 0 0 1 0 1 1 1 0 1 1 0 0 1 0 (G2 ) A B C D E e1 1 1 0 0 0 e2 0 1 1 0 0 e3 0 0 1 1 0 e4 0 1 0 1 0 e5 1 0 1 0 0 e6 1 0 0 0 1 e7 0 0 0 1 1 Contents Graph definitions Terminology Special Graphs Bipartie graph H¢y cho bi¸t quan h» cõa hai ç thà A) B) C) D) ¯ng c§u G1 v G2 . Representing Graphs and Graph Isomorphism Representing Graphs Khæng ¯ng c§u Thù tü T÷ìng ÷ìng Graph Isomorphism Exercise Graph Isomorphism 9.48 Revision Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai X²t ç thà ¦y õ K5 v ç thà ph¥n æi ¦y õ K3,2 . Khi â ta câ: Contents Graph definitions Terminology A) K3,2 v K5 l B) K3,2 v K5 câ còng sè ¿nh. C) K3,2 v K5 câ còng sè c¤nh. D) K3,2 v K5 l E) khæng ¯ng c§u. ¯ng c§u. C¡c ¡p ¡n kh¡c ·u sai. Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.49 Revision Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Chån ph¡t biºu óng vîi ç thà ìn væ h÷îng (undirected graph) câ n simple Contents ¿nh. Graph definitions A) B) C) D) E) Bªc cõa mët ¿nh b§t ký trong ç thà nhä hìn Tçn t¤i mët ¿nh trong ç thà câ bªc l 1. Khæng thº chùa ¿nh cæ lªp. Tçn t¤i hai ¿nh trong ç thà câ còng sè bªc. C¡c ¡p ¡n kh¡c ·u sai. n − 2. Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism 9.50 Prove that ... Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai ... There are 101 invited people in a party. Suppose that A knows B⇒B knows A. Prove that 1 2 at least one people knows an even number of other people. Contents at least two people who know the same number of people Graph definitions (but not considering himself). Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism A chess tournament of n persons plays according to the circle competition. Prove that at any moment of the tournament there are always two players having identical number of games played. And if n ≥ 4, at any intermediate moment of the tournament, Representing Graphs Graph Isomorphism Exercise Graph Isomorphism there are always two players having identical number of games that they are the winner. 9.51 Revision Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan In a tournament with n teams participated (n ≥ 4), n + 1 Toan, Tran Hong Tai competition games were happening. Prove that there exists a team that has played at least three matches. With any four of the n people (n ≥ 4), there exists a person who knows the three others. Prove that there exists a person who knows all n−1 others. Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism In a party of 6 people, prove that there are 3 people who know each other or 3 people who do not know each other. Representing Graphs Graph Isomorphism Exercise Graph Isomorphism During a summer vacation, 7 friends are vacationing away. They promised each other that during the holidays each person must write to exactly three of them. Prove that there is someone who does not write back to the his sender. 9.52 Revision Trong ký Hoa Sìn luªn vã, n«m và cao thõ ¢ g°p nhau º x¡c ành danh hi»u » nh§t: æng T , T¥y ëc, Nam ¸, B­c C¡i v Trung Th¦n Thæng. º ph¥n bi»t th­ng thua th¼ hå §u tøng c°p æi v khæng giîi h¤n thíi gian. Nh væ àch l ng÷íi câ nhi·u trªn th­ng nh§t. æng T khæng thº ¡nh b¤i Nam ¸, nh÷ng æng ta ¢ ¡nh b¤i T¥y ëc. Do dòng nhi·u sùc trong méi trªn §u n¶n Nam ¸ ch¿ th­ng hai trªn ¦u ti¶n. B­c C¡i ch¿ th­ng ÷ñc Nam ¸. T¥y ëc khæng thº chi¸n th­ng Trung Th¦n Thæng, nh÷ng l¤i chi¸n th­ng Nam ¸ v B­c C¡i. Ri¶ng Trung Th¦n Thæng ch¿ bà th§t b¤i mët trªn §u. H¢y cho bi¸t Trung Th¦n Thæng ¢ bà ¡nh b¤i bði và n o? Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph A) B) C) D) Nam ¸ Nam ¸ ho°c æng T æng T T¥y ëc Isomorphism 9.53 Revision Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Mët dü ¡n gçm c¡c cæng vi»c A, B , C , D , E , F v G c¦n thüc hi»n. Thíi l÷ñng (theo ng y) c¦n thi¸t º xû lþ c¡c cæng vi»c l¦n l÷ñt l pA 5 pB 2 pC 6 pD 7 pE 9 pF 3 pG 2 Contents Graph definitions Ta kþ hi»u Terminology Special Graphs Bipartie graph X1 + X2 + . . . + Xn Y1 + Y2 + . . . + Ym Xi (i = 1, . . . , n) ·u c¦n ho n c¡c cæng vi»c Yk (k = 1, . . . , m). biºu di¹n c¡c cæng vi»c tr÷îc khi khði ëng X²t thíi gian b­t ¦u khði ëng dü ¡n l Representing Graphs and Graph Isomorphism th nh 0. Dü ¡n ÷ñc gåi l k¸t thóc khi t§t c£ c¡c cæng vi»c trong dü ¡n ·u ho n th nh. Bi¸t r¬ng: Representing Graphs Graph Isomorphism Exercise Graph Isomorphism A B + C ; B + C D; C F + G; E F . Häi dü ¡n n y s³ k¸t thóc sîm nh§t v o ng y n o? 9.54 Revision Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Mët ban ch¿ huy qu¥n sü muèn thi¸t lªp mët m°t trªn gçm c¡c a, b, . . ., g . cù iºm C¡c cù iºm n y v ÷íng nèi trüc ti¸p giúa chóng t¤o n¶n mët ç thà ìn væ h÷îng. Do sè l÷ñng thi¸t gi¡p câ giîi h¤n n¶n ban ch¿ huy quy¸t ành ch¿ çn tró thi¸t gi¡p t¤i mët sè cù iºm m c b thæi. Tuy nhi¶n, º £m b£o t½nh t¡c chi¸n nhanh châng n¶n ta y¶u c¦u: n¸u cù iºm n o g a d khæng câ çn tró thi¸t gi¡p th¼ ½t nh§t mët cù iºm b¶n c¤nh (¿nh k·) ph£i câ f e ìn và thi¸t gi¡p çn tró. Häi câ bao nhi¶u c¡ch triºn khai thi¸t gi¡p ¸n c¡c cù iºm cho m°t trªn nh÷ Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism ç thà b¶n ? 9.55 Revision Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai B A C Contents Graph definitions Terminology D Special Graphs Bipartie graph F Representing Graphs and Graph Isomorphism E Representing Graphs a) H¢y x¡c ành danh s¡ch k·, ma trªn k· v ma trªn li¶n thuëc cõa ç thà tr¶n. b) H¢y cho bi¸t ç thà n y câ ph£i l Graph Isomorphism Exercise Graph ç thà ph¥n æi khæng. Isomorphism N¸u câ, h¢y v³ l¤i d÷îi d¤ng mët ç thà ph¥n æi. 9.56 Revision Introduction to Graphs Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Do khâi, böi v hìi n÷îc bèc l¶n tø mët mi»ng nói lûa b¶n d÷îi m°t sæng b«ng Eyjafjallajokull ð Iceland v o ng y thù t÷ (14/04/2010), hìn 90.000 chuy¸n bay ð ch¥u công l u ¢ bà hõy. ¥y mët minh chùng v· sü b§t ên cõa thi¶n nhi¶n câ thº g¥y tên h¤i tîi cæng vi»c kinh doanh to n c¦u. º gi£m thiºu thi»t h¤i v· kinh t¸, cì quan qu£n lþ tèi ÷u hâa v lªp làch ÷íng bay EuroControl cè g­ng ti¸p töc duy tr¼ mët sè ÷íng bay i v London (D ). Tuy nhi¶n, do £nh h÷ðng cõa mæi tr÷íng thi¶n nhi¶n nâi tr¶n, ch¿ câ A h÷îng ¸n B v D, D, tø D h÷îng ¸n B . mët v i chuy¸n bay câ thº ho¤t ëng: tø B h÷îng ¸n a) b) c) C, tø C h÷îng ¸n A v Graph definitions Terminology ¸n Vi»t Nam, li¶n quan ¸n c¡c th nh phè lîn nh÷: Hç Ch½ Minh (A), Paris (B ), Berlin (C ), v Contents tø H¢y v³ ç thà câ h÷îng t÷ìng ùng. Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism Vi¸t ma trªn k· M cho ç thà câ h÷îng n y H¢y t½nh M + M2 + M3 v cho bi¸t þ ngh¾a cõa ma trªn n y. 9.57 Revision Introduction to Graphs Hai lîp ÷ñc ành ngh¾a nh÷ c¡c h¼nh b¶n d÷îi tr¡i. H¢y v³ ç thà biºu di¹n h m th nh vi¶n câ thº ÷ñc gåi tø mët h m. (Chó þ : Mët cung tø h m u ¸n h m v biºu di¹n class X r¬ng v câ thº ÷ñc gåi bði u.) V½ dö. public: X(); X(); X :: b() a(); protected: b(); private: X :: a() X :: c() c(); class Y public: Y(); Y(); e(); private: d(); Nguyen An Khuong, Tran Tuan Anh, Nguyen Tien Thinh, Mai Xuan Toan, Tran Hong Tai Contents Graph definitions Terminology Special Graphs Bipartie graph Representing Graphs and Graph Isomorphism Representing Graphs Graph Isomorphism Exercise Graph Isomorphism Y :: e() Y :: d() Câ bao nhi¶u ÷íng i ìn kh¡c nhau tø ¿nh X::a() ¸n ¿nh Y::d() ? 9.58