Graph Theory CS/Math231 Discrete Mathematics Spring2015

Similar documents
Chapter 11: Graphs and Trees. March 23, 2008

CHAPTER 10 GRAPHS AND TREES. Alessandro Artale UniBZ - artale/z

Crossing bridges. Crossing bridges Great Ideas in Theoretical Computer Science. Lecture 12: Graphs I: The Basics. Königsberg (Prussia)

Introduction III. Graphs. Motivations I. Introduction IV

CHAPTER 10 GRAPHS AND TREES. Copyright Cengage Learning. All rights reserved.

Varying Applications (examples)

Graphs: Definitions Trails, Paths, and Circuits Matrix Representations Isomorphisms. 11. Graphs and Trees 1. Aaron Tan. 30 October 3 November 2017

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. An Introduction to Graph Theory

Graph and Digraph Glossary

CS 441 Discrete Mathematics for CS Lecture 26. Graphs. CS 441 Discrete mathematics for CS. Final exam

Elements of Graph Theory

Graph Theory. 1 Introduction to Graphs. Martin Stynes Department of Mathematics, UCC January 26, 2011

How can we lay cable at minimum cost to make every telephone reachable from every other? What is the fastest route between two given cities?

March 20/2003 Jayakanth Srinivasan,

v V Question: How many edges are there in a graph with 10 vertices each of degree 6?

6.2. Paths and Cycles

Basics of Graph Theory

Graph Theory. Part of Texas Counties.

GRAPHS, GRAPH MODELS, GRAPH TERMINOLOGY, AND SPECIAL TYPES OF GRAPHS

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department

Discrete mathematics II. - Graphs

Characterizing Graphs (3) Characterizing Graphs (1) Characterizing Graphs (2) Characterizing Graphs (4)

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7

Math 776 Graph Theory Lecture Note 1 Basic concepts

Hamilton paths & circuits. Gray codes. Hamilton Circuits. Planar Graphs. Hamilton circuits. 10 Nov 2015

Introduction to Graph Theory

CPCS Discrete Structures 1

CHAPTER 2. Graphs. 1. Introduction to Graphs and Graph Isomorphism

Fundamental Properties of Graphs

Topics Covered. Introduction to Graphs Euler s Theorem Hamiltonian Circuits The Traveling Salesman Problem Trees and Kruskal s Algorithm

Graphs. Pseudograph: multiple edges and loops allowed

Adjacent: Two distinct vertices u, v are adjacent if there is an edge with ends u, v. In this case we let uv denote such an edge.

Graph Theory. Probabilistic Graphical Models. L. Enrique Sucar, INAOE. Definitions. Types of Graphs. Trajectories and Circuits.

DS UNIT 4. Matoshri College of Engineering and Research Center Nasik Department of Computer Engineering Discrete Structutre UNIT - IV

An Introduction to Graph Theory

CS 311 Discrete Math for Computer Science Dr. William C. Bulko. Graphs

8.2 Paths and Cycles

CSC Intro to Intelligent Robotics, Spring Graphs

Introduction to Engineering Systems, ESD.00. Networks. Lecturers: Professor Joseph Sussman Dr. Afreen Siddiqi TA: Regina Clewlow

Graphs. Introduction To Graphs: Exercises. Definitions:

UNDIRECTED GRAPH: a set of vertices and a set of undirected edges each of which is associated with a set of one or two of these vertices.

Foundations of Discrete Mathematics

CHAPTER 10 GRAPHS AND TREES. Alessandro Artale UniBZ - artale/

Assignments are handed in on Tuesdays in even weeks. Deadlines are:

Logic: The Big Picture. Axiomatizing Arithmetic. Tautologies and Valid Arguments. Graphs and Trees

Chapter 2 Graphs. 2.1 Definition of Graphs

Algorithms. Graphs. Algorithms

DEFINITION OF GRAPH GRAPH THEORY GRAPHS ACCORDING TO THEIR VERTICES AND EDGES EXAMPLE GRAPHS ACCORDING TO THEIR VERTICES AND EDGES

Algorithms: Graphs. Amotz Bar-Noy. Spring 2012 CUNY. Amotz Bar-Noy (CUNY) Graphs Spring / 95

(5.2) 151 Math Exercises. Graph Terminology and Special Types of Graphs. Malek Zein AL-Abidin

Math 778S Spectral Graph Theory Handout #2: Basic graph theory

Graphs V={A,B,C,D,E} E={ (A,D),(A,E),(B,D), (B,E),(C,D),(C,E)}

CMSC 380. Graph Terminology and Representation

Chapter 3: Paths and Cycles

Graph Algorithms Using Depth First Search

Introduction to Graphs

Chapter 9. Graph Theory

Dieter Jungnickel (2008), Graphs, Networks and Algorithms, 3rd edition, which is available online via SpringerLink.

Graph theory: basic concepts

Grades 7 & 8, Math Circles 31 October/1/2 November, Graph Theory

Trees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017

Lecture 3: Graphs and flows

Section 8.2 Graph Terminology. Undirected Graphs. Definition: Two vertices u, v in V are adjacent or neighbors if there is an edge e between u and v.

An undirected graph is a tree if and only of there is a unique simple path between any 2 of its vertices.

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur

Brief History. Graph Theory. What is a graph? Types of graphs Directed graph: a graph that has edges with specific directions

Definition of Graphs and Trees. Representation of Trees.

Graph Overview (1A) Young Won Lim 5/9/18

Discrete Mathematics for CS Spring 2008 David Wagner Note 13. An Introduction to Graphs

3 Euler Tours, Hamilton Cycles, and Their Applications

Graph (1A) Young Won Lim 4/19/18

Graph Theory S 1 I 2 I 1 S 2 I 1 I 2

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 8

Chapter 1 Graph Theory

Section Summary. Introduction to Trees Rooted Trees Trees as Models Properties of Trees

Artificial Intelligence

Assignment 4 Solutions of graph problems

An Introduction to Graph Theory

2. CONNECTIVITY Connectivity

Paths. Path is a sequence of edges that begins at a vertex of a graph and travels from vertex to vertex along edges of the graph.

Euler and Hamilton paths. Jorge A. Cobb The University of Texas at Dallas

Graph Theory. Defining a Graph

North Bank. West Island. East Island. South Bank

MATH 363 Final Wednesday, April 28. Final exam. You may use lemmas and theorems that were proven in class and on assignments unless stated otherwise.

Discrete Mathematics (2009 Spring) Graphs (Chapter 9, 5 hours)

1 Digraphs. Definition 1

Intermediate Math Circles Wednesday, February 22, 2017 Graph Theory III

Introduction to Graphs

Chapter 2: Graph Theory

Lecture 5: Graphs & their Representation

Math.3336: Discrete Mathematics. Chapter 10 Graph Theory

Introduction to Graphs. Tecniche di Programmazione A.A. 2017/2018

Introduction to Graphs

5 Graphs

MATH 139 W12 Review 1 Checklist 1. Exam Checklist. 1. Introduction to Predicates and Quantified Statements (chapters ).

Vertex-Edge Graphs. Vertex-Edge Graphs In the Georgia Performance Standards. Sarah Holliday Southern Polytechnic State University

MATH 682 Notes Combinatorics and Graph Theory II. One interesting class of graphs rather akin to trees and acyclic graphs is the bipartite graph:

Discrete Structures CISC 2315 FALL Graphs & Trees

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph

K 4 C 5. Figure 4.5: Some well known family of graphs

Transcription:

1 Graphs Definition 1 A directed graph (or digraph) G is a pair (V, E), where V is a finite set and E is a binary relation on V. The set V is called the vertex set of G, and its elements are called vertices (singular: vertex). The set E is called the edge set of G, and its elements are called edges. In an undirected graph G = (V, E), the edge set E consists of unordered pairs of vertices, rather than ordered pairs. You need to understand the following terminologies: endpoints loop parallel edges isolated vertex Example 1 [Vegetarians and Cannibals] There are two types of people on an island, either vegetarians or cannibals. Initially, two vegetarians and two cannibals are on the left bank of a river. With them is a boat that can hold a maximum of two people. Find a way to transport all the vegetarians and cannibals to the right bank of the river. Note that at no time can the number of cannibals on either bank outnumber the number of vegetarians. Solution. Figure 1: solution to Example 1 1.1 Special Graphs A simple graph is a graph that does not have any loops or parallel edges. In a simple graph, an edge with endpoints v and w is denoted {v, w}. Let n be a positive integer. A complete graph on n vertices, denoted K n, is a simple undirected graph with n vertices and exactly one edge connecting each pair of distinct vertices. A bipartite graph is an undirected graph G = (V, E) in which V can be partitioned into two sets V 1 and V 2 such that (u, v) E implies either u V 1 and v V 2 or u V 2 and v V 1. That is, all edges go between the two sets V 1 and V 2. 1

A graph G = (V, E ) is a subgraph of G = (V, E) if V V and E E. Given a set V V, the subgraph of G induced by V is the graph G = (V, E ) where E = {(u, v) E : u, v V }. Figure 2: Directed and undirected graphs. 1.2 Degree and the Handshake Theorem Definition 2 The degree of a vertex in an undirected graph is the number of edges incident on it. In a directed graph, the out-degree of a vertex is the number of edges leaving it, and the in-degree of a vertex is the number of edges entering it. The degree of a vertex in a directed graph is its in-degree plus its out-degree. The total degree of G is the sum of the degrees of all the vertices of G. Theorem 1 (The Handshake Theorem) If G is any graph, then the sum of the degrees of all the vertices of G equals twice the number of edges of G. Specifically, if the vertices of G are v 1, v 2,..., v n, where n is a nonnegative integer, then the total degree of G = deg(v 1 ) + deg(v 2 ) + + deg(v n ) = 2 (the number of edges of G). Corollary 1 The total degree of a graph is even. Example 2 Draw a graph with the specified properties or show that no such graph exists. A graph with four vertices of degrees 1, 1, 2, and 3 A graph with four vertices of degrees 1, 1, 3, and 3 A simple graph with four vertices of degrees 1, 1, 3, and 3 Theorem 2 In any graph there are an even number of vertices of odd degree. Proof.[sketch] total degree of all vertices is even sum of even-degree vertices is even sum of odd-degree vertices is even Is there a graph with ten vertices of degrees 1, 1, 2, 2, 2, 3, 4, 4, 4, and 6? 2

2 Trails, Paths and Circuits Figure 3: The Seven Bridges of Königsberg The town of Königsberg in Prussia (now Kaliningrad in Russia) was built at a point where two branches of the Pregel River came together. It consisted of an island and some land along the river banks (see Figure 3). Is it possible for a person to take a walk around town, starting and ending at the same location and crossing each of the seven bridges exactly once? Definition 3 Let G be a graph, and let v and w be vertices in G. A walk from v to w is a finite alternating sequence of adjacent vertices and edges of G. Thus a walk has the form v 0 e 1 v 1 e 2... v n 1 e n v n, where the v s represent vertices, the e s represent edges, v 0 = v, v n = w, and for all i = 1, 2,..., n, v i 1 and v i are the endpoints of e i. The trivial walk from v to v consists of the single vertex v. A trail from v to w is a walk from v to w that does not contain a repeated edge. A path from v to w is a trail that does not contain a repeated vertex. A closed walk is a walk that starts and ends at the same vertex. A circuit is a closed walk that contains at least one edge and does not contain a repeated edge. A simple circuit is a circuit that does not have any other repeated vertex except the first and last. 2.1 Connectedness An undirected graph is connected if every vertex is reachable from all other vertices. The connected components of a graph are the equivalence classes of vertices under the is reachable from relation. Example 3 Consider the graph in Figure 2 (b). How many connected components are there? What are they? 3

An undirected graph is connected if it has exactly one connected component. The edges of a connected component are those that are incident on only the vertices of the component; in other words, edge (u, v) is an edge of a connected component only if both u and v are vertices of the component. A directed graph is strongly connected if every two vertices are reachable from each other. The strongly connected components of a directed graph are the equivalence classes of vertices under the are mutually reachable relation. A directed graph is strongly connected if it has only one strongly connected component. Example 4 Consider the graph in Figure 2 (a). How many strongly connected components are there? 2.2 Euler Circuit Definition 4 (Euler circuit) Let G be a graph. An Euler circuit for G is a circuit that contains every vertex and every edge of G. That is, an Euler circuit for G is a sequence of adjacent vertices and edges in G that has at least one edge, starts and ends at the same vertex, uses every vertex of G at least once, and uses every edge of G exactly once. Theorem 3 If a graph has an Euler circuit, then every vertex of the graph has positive even degree. How to test whether a graph does not have an Euler Circuit? Theorem 4 If every vertex of a connected graph has even degree, then the graph has an Euler circuit. Proof. Constructive proof. See procedure Euler. procedure Euler(G: connected multigraph with all vertices of even degree) circuit := a circuit in G beginning at an arbitrarily chosen vertex with edges successively added to form a path that returns to this vertex H := G with the edges of this circuit removed while H has edges do subcircuit := a circuit in H beginning at a vertex in H that also is an endpoint of an edge of circuit H := H with edges of subcircuit and all isolated vertices removed circuit := circuit with subcircuit inserted at the appropriate vertex end while return circuit {circuit is an Euler circuit} From both Theorems 3 and 4, we have: Theorem 5 A graph G has an Euler circuit if, and only if, G is connected and every vertex of G has positive even degree. 2.3 Hamiltonian Circuits Definition 5 A Hamiltonian circuit (Hamiltonian cycle) of an undirected graph G = (V, E) is a simple cycle that contains each vertex in V. A graph that contains a hamiltonian cycle is said to be hamiltonian; otherwise, it is nonhamiltonian. 4

What is the relationship between an Euler Circuit and a Hamiltonian Circuit? If a graph G has a Hamiltonian circuit, then G has a subgraph H with the following properties: H contains every vertex of G. H is connected. H has the same number of edges as vertices. Every vertex of H has degree 2. Example 5 (A Traveling Salesman Problem) Imagine that the drawing below is a map showing four cities and the distances in kilome- ters between them. Suppose that a salesman must travel to each city exactly once, starting and ending in city A. Which route from city to city will minimize the total distance that must be traveled? Figure 4: Traveling Salesman Problem Solution. Write all possible Hamiltonian circuits starting and ending at A and calculating the total distance traveled for each. ABCDA: 30+30+25+40 = 125 ABDCA: 30+35+25+50 = 140 ACBDA: 50+30+35+40 = 155 ACDBA: 140 [ A B D C A backwards] ADBCA: 155 [ AC B D A backwards] ADCBA: 125 [ABCDA backwards] Thus either route ABCDA or ADCBA gives a minimum total distance of 125 kilometers. The problem of finding a hamiltonian cycle in an undirected graph has been stud- ied for over a hundred years. Not all graphs are hamiltonian, however. For example, Figure 5 shows a bipartite graph with an odd number of vertices. The hamiltonian-cycle problem is Does a graph G have a hamiltonian cycle? There is no known efficient way to determine whether a graph has a Hamiltonian circuit, or how to find one. 3 Representation of Graphs We can choose between two standard ways to represent a graph G = (V, E) as a collection of adjacency lists or as an adjacency matrix. Either way applies to both directed and undirected graphs. Because the adjacency-list representation provides a compact way to represent sparse graphs-those for which E is much less than V 2 -it is usually the method of choice. 5

Figure 5: (a) A graph representing the vertices, edges, and faces of a dodecahedron, with a hamiltonian cycle shown by shaded edges. (b) A bipartite graph with an odd number of vertices. Any such graph is nonhamiltonian. Figure 6: Two representations of an undirected graph. (a) An undirected graph G with 5 vertices and 7 edges. (b) An adjacency-list representation of G. (c) The adjacency-matrix representation of G. 4 Trees A graph is said to be circuit-free if, and only if, it has no circuits. A graph is called a tree if, and only if, it is circuit-free and connected. A trivial tree is a graph that consists of a single vertex. A graph is called a forest if, and only if, it is circuit-free and not connected. 4.1 Characterizing Trees Lemma 1 Any tree that has more than one vertex has at least one vertex of degree 1. A tree vertex of degree 1 is called a leaf. Others are called internal vertices. Theorem 6 For any positive integer n, any tree with n vertices has n 1 edges. Proof.[sketch] Let P (n) be Any tree with n vertices has n 1 edges. Prove by induction. 6

Figure 7: Two representations of a directed graph. (a) A directed graph G with 6 vertices and 8 edges. (b) An adjacency-list representation of G. (c) The adjacency-matrix representation of G. Lemma 2 If G is any connected graph, C is any circuit in G, and any one of the edges of C is removed from G, then the graph that remains is connected. Theorem 7 For any positive integer n, if G is a connected graph with n vertices and n 1 edges, then G is a tree. 4.2 Rooted Trees A rooted tree is a tree in which there is one vertex that is distinguished from the others and is called the root. The level of a vertex is the number of edges along the unique path between it and the root. The height of a rooted tree is the maximum level of any vertex of the tree. Terminologies: hight children parent siblings ancestor descendant A binary tree is a rooted tree in which every parent has at most two children. Terminologies: left child right child full binary tree left subtree 7

right subtree Theorem 8 If k is a positive integer and T is a full binary tree with k internal vertices, then T has a total of 2k + 1 vertices and has k + 1 terminal vertices. Theorem 9 For all integers h 0, if T is any binary tree with of height h and t terminal vertices, then t 2 h. 8