(CSC 102) Lecture 30 Discrete Structures. Graphs.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

CSE 211 Discrete Mathematics
Chapter 8 Topics in Graph Theory
Lecture 5 Graph Theory. Graphs Graphs are the most useful model with computer science such as logical design, formal languages, communication network,
22C:19 Discrete Math Graphs Fall 2010 Sukumar Ghosh.
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
Walks, Paths and Circuits Walks, Paths and Circuits Sanjay Jain, Lecturer, School of Computing.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Graph-02.
Introduction to Graphs
13 May 2009Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Introduction.
1 Lecture 5 (part 2) Graphs II Euler and Hamiltonian Path / Circuit Reading: Epp Chp 11.2, 11.3.
Lecture 21 Paths and Circuits CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Applied Discrete Mathematics Week 12: Trees
Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department.
KNURE, Software department, Ph , N.V. Bilous Faculty of computer sciences Software department, KNURE Discrete.
9.3 Representing Graphs and Graph Isomorphism
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
Let us switch to a new topic:
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
22C:19 Discrete Math Graphs Spring 2014 Sukumar Ghosh.
Copyright © Cengage Learning. All rights reserved.
GRAPH Learning Outcomes Students should be able to:
Graphs Chapter 10.
Graph Theory Topics to be covered:
(CSC 102) Lecture 29 Discrete Structures. Graphs.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
CSNB143 – Discrete Structure Topic 9 – Graph. Learning Outcomes Student should be able to identify graphs and its components. Students should know how.
1 CS104 : Discrete Structures Chapter V Graph Theory.
Based on slides by Y. Peng University of Maryland
Graphs.  Definition A simple graph G= (V, E) consists of vertices, V, a nonempty set of vertices, and E, a set of unordered pairs of distinct elements.
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Aaron Tan October Graphs and Trees 1 Graphs: DefinitionsTrails, Paths, and CircuitsMatrix RepresentationsIsomorphisms 1.
Discrete Mathematical Structures: Theory and Applications
Foundations of Discrete Mathematics Chapters 9 and 10 By Dr. Dalia M. Gil, Ph.D.
Lecture 10: Graph-Path-Circuit
Introduction to Graphs. This Lecture In this part we will study some basic graph theory. Graph is a useful concept to model many problems in computer.
Graphs 9.1 Graphs and Graph Models أ. زينب آل كاظم 1.
Lecture 52 Section 11.2 Wed, Apr 26, 2006
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 5 The Mathematics of Getting Around 5.1Euler Circuit Problems 5.2What.
Introduction to Graph Theory
Chapter 11 - Graph CSNB 143 Discrete Mathematical Structures.
Chapter 9: Graphs.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Paths and circuits.
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
1 Lecture 5 (part 2) Graphs II (a) Circuits; (b) Representation Reading: Epp Chp 11.2, 11.3
رياضيات متقطعة لعلوم الحاسب MATH 226. Chapter 10.
Chapter Chapter Summary Graphs and Graph Models Graph Terminology and Special Types of Graphs Representing Graphs and Graph Isomorphism Connectivity.
An Introduction to Graph Theory
Excursions in Modern Mathematics Sixth Edition
Applied Discrete Mathematics Week 14: Trees
CSNB 143 Discrete Mathematical Structures
Graphs: Definitions and Basic Properties
Special Graphs By: Sandeep Tuli Astt. Prof. CSE.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Graphs Slides are adopted from “Discrete.
Aaron Tan 30 October – 3 November 2017
Copyright © Cengage Learning. All rights reserved.
Based on slides by Y. Peng University of Maryland
Lecture 15: Graph Theory II
CS100: Discrete structures
Discrete Math II Howon Kim
5 The Mathematics of Getting Around
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Copyright © Cengage Learning. All rights reserved.
Discrete Math II Howon Kim
Discrete Math II Howon Kim
Applied Discrete Mathematics Week 13: Graphs
Based on slides by Y. Peng University of Maryland
Agenda Review Lecture Content: Shortest Path Algorithm
Presentation transcript:

(CSC 102) Lecture 30 Discrete Structures

Graphs

Previous Lecture  Subgraphs  The Concept of Degree  Walks, Trails, Paths and Circuits  Connectedness  Connected Component of a Graph  Euler Circuits  Finding an Euler Circuit

Today’s Lecture  Euler Circuits  Finding an Euler Circuit  Euler Trails  Finding an Euler Trail  Hamiltonian Circuits  A Traveling Salesman Problem  Matrices and Graphs

Euler Circuits Theorem If a graph has an Euler circuit, then every vertex of the graph has positive even degree. Contrapositive Version of Theorem If some vertex of a graph has odd degree, then the graph does not have an Euler circuit.

Euler Circuits Show that the graph below does not have an Euler circuit. Vertices v 1 and v 3 both have degree 3, which is odd. Hence by (the contrapositive form of theorem), this graph does not have an Euler circuit.

Constructing an Euler Circuit Theorem If a graph G is connected and the degree of every vertex of G is a positive even integer, then G has an Euler circuit. Constructing an Euler Circuit Step I: Pick any vertex v of G at which to start. Step II: Pick any sequence of adjacent vertices and edges, starting and ending at v and never repeating an edge. Call the resulting circuit C. Step III: Check whether C contains every edge and vertex of G. If so, C is an Euler circuit, and we are finished. If not, perform the following steps.

Step IIIa: Remove all edges of C from G and also any vertices that become isolated when the edges of C are removed. Call the resulting subgraph G’. Step IIIb: Pick any vertex w common to both C and G’. Step IIIc: Pick any sequence of adjacent vertices and edges of G’, starting and ending at w and never repeating an edge. Call the resulting circuit C’. Step IIId: Patch C and C’ together to create a new circuit C’’ as follows: Start at v and follow C all the way to w. Then follow C’ all the way back to w. After that, continue along the untraveled portion of C to return to v. Step IIIe: Let C = C’’ and go back to step 3. Since the graph G is finite, execution of the steps outlined in this algorithm must eventually terminate. At that point an Euler circuit for G will have been constructed. Constructing an Euler Circuit

Finding an Euler Circuit Example Check that the graph below has an Euler circuit. Then use the algorithm to find an Euler circuit for the graph. Observe that deg(a) = deg(b) = deg(c) = deg( f ) = deg(g) = deg(i ) = deg( j ) = 2 and that deg(d) = deg(e) = deg(h) = 4. Hence all vertices have even degree. Also, the graph is connected. Thus the graph has an Euler circuit.

Finding an Euler Circuit To construct an Euler circuit using the algorithm, let v = a and let C be C : abcda. C is represented by the labeled edges shown below. Observe that C is not an Euler circuit for the graph but that C intersects the rest of the graph at d.

Finding an Euler Circuit Let C’ be C’: deghjid. Patch C’ into C to obtain C’’: abcdeghjida. Set C = C’’. Then C is represented by the labeled edges shown below. Observe that C is not an Euler circuit for the graph but that it intersects the rest of the graph at e.

Finding an Euler Circuit Let C’ be C’: ef he. Patch C’ into C to obtain C’’: abcde f heghjida. Set C = C’’. Then C is represented by the labeled edges shown below. Since C includes every edge of the graph exactly once, C is an Euler circuit for the graph.

Euler Trails Corollary

Finding an Euler Trail The floor plan shown below is for a house that is open for public viewing. Is it possible to find a trail that starts in room A, ends in room B, and passes through every interior door-way of the house exactly once? If so, find such a trail.

Finding an Euler Trail Let the floor plan of the house be represented by the graph below. Each vertex of this graph has even degree except for A and B, each of which has degree 1. Hence there is an Euler path from A to B. One such trail is AGHFEI HEK J DCB.

Hamiltonian Circuits

Theorem

Showing That a Graph Does Not Have a Hamiltonian Circuit Prove that the graph G shown below does not have a Hamiltonian circuit. If G has a Hamiltonian circuit, then by previous theorem, G has a subgraph H that (1) contains every vertex of G, (2) is connected, (3) has the same number of edges as vertices, and (4) is such that every vertex has degree 2.

Suppose such a subgraph H exists. In other words, suppose there is a connected subgraph H of G such that H has five vertices (a, b, c, d, e) and five edges and such that every vertex of H has degree 2. Since the degree of b in G is 4 and every vertex of H has degree 2, two edges incident on b must be removed from G to create H. Edge {a, b} cannot be removed because if it were, vertex a would have degree less than 2 in H. Similar reasoning shows that edges {e, b}, {b, a}, and {b, d} cannot be removed either. It follows that the degree of b in H must be 4, which contradicts the condition that every vertex in H has degree 2 in H. Hence no such subgraph H exists, and so G does not have a Hamiltonian circuit. Showing That a Graph Does Not Have a Hamiltonian Circuit

A Traveling Salesman Problem Imagine that the drawing below is a map showing four cities and the distances in kilometers 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?

This problem can be solved by writing all possible Hamiltonian circuits starting and ending at A and calculating the total distance traveled for each. A Traveling Salesman Problem Thus either route ABCDA or ADCBA gives a minimum total distance of 125 kilometers.

Matrices and Graphs How can graphs be represented inside a computer? It happens that all the information needed to specify a graph can be conveyed by a structure called a matrix, and matrices are easy to represent inside computers.

Matrices and Graphs The entry a i j in the ith row and j th column of A is called the ijth entry of A. An m × n matrix is said to have size m × n. If A and B are matrices, then A = B if, and only if, A and B have the same size and the corresponding entries of A and B are all equal; that is, a i j = b i j for all i = 1, 2,...,m and j = 1, 2..., n. A matrix for which the numbers of rows and columns are equal is called a square matrix. If A is a square matrix of size n × n, then the main diagonal of A consists of all the entries a 11, a 22,..., a nn

Matrices and Graphs

Matrices and Directed Graphs Example The two directed graphs shown below differ only in the ordering of their vertices. Find their adjacency matrices.

The Adjacency Matrix of a Graph Since both graphs have three vertices, both adjacency matrices are 3 × 3 matrices. For (a), all entries in the first row are 0 since there are no arrows from v1 to any other vertex. For (b), the first two entries in the first row are 1 and the third entry is 0 since from v1 there are single arrows to v 1 and to v 2 and no arrows to v 3. Continuing the analysis in this way, you obtain the following two adjacency matrices.

Obtaining a Directed Graph from a Matrix

Matrices and Undirected Graphs

Solution Matrix is symmetric.

Matrices and Connected Components Consider a graph G, as shown below, that consists of several connected components. Compute the adjacency matrix for the graph.

Matrices and Connected Components Compute the adjacency matrix for the graph.

Their vertex and edge sets are identical, and their edge-endpoint functions are the same. Call this graph G. Isomorphism's of Graphs Now consider the graph G’ represented in Figure

Observe that G’ is a different graph from G (for instance, in G the endpoints of e 1 are v 1 and v 2, whereas in G’ the endpoints of e 1 are v 1 and v 3 ). Yet G’ is certainly very similar to G. In fact, if the vertices and edges of G’ are relabeled, then G’ becomes the same as G. Isomorphism's of Graphs Note that these relabeling functions are one-to-one and onto. Two graphs that are the same except for the labeling of their vertices and edges are called isomorphic. The word isomorphism comes from the Greek, meaning “same form.” Isomorphic graphs are those that have essentially the same form.

Isomorphism's of Graphs

Showing that two graphs are Isomorphic Show that the following two graphs are Isomorphic

Showing that two graphs are Isomorphic

Invariant Property Theorem

Invariant Property Showing That Two Graph Are Not Isomorphic Show that the following pairs of graphs are not isomorphic by finding an isomorphic invariant that they do not share.

Lecture Summary  Euler Circuits  Finding an Euler Circuit  Euler Trails  Finding an Euler Trail  Hamiltonian Circuits  A Traveling Salesman Problem  Matrices and Graphs