Graph Theory Topics to be covered:

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Chapter 8 Topics in Graph Theory
Chapter 9 Graphs.
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.
Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
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.
Lecture 21 Paths and Circuits CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Section 14.1 Intro to Graph Theory. Beginnings of Graph Theory Euler’s Konigsberg Bridge Problem (18 th c.)  Can one walk through town and cross all.
Introduction This chapter explores graphs and their applications in computer science This chapter explores graphs and their applications in computer science.
Data Structures Using C++
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
9.2 The Traveling Salesman Problem. Let us return to the question of finding a cheapest possible cycle through all the given towns: We have n towns (points)
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
Last time: terminology reminder w Simple graph Vertex = node Edge Degree Weight Neighbours Complete Dual Bipartite Planar Cycle Tree Path Circuit Components.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Graphs. Overview What is a graph? Some terminology Types of graph Implementing graphs (briefly) Some graph algorithms Graphs 2/18.
Section 2.1 Euler Cycles Vocabulary CYCLE – a sequence of consecutively linked edges (x 1,x2),(x2,x3),…,(x n-1,x n ) whose starting vertex is the ending.
Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department.
Representing Graphs Wade Trappe. Lecture Overview Introduction Some Terminology –Paths Adjacency Matrix.
Euler and Hamilton Paths
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
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:
Data Structures Using C++ 2E
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
May 5, 2015Applied Discrete Mathematics Week 13: Boolean Algebra 1 Dijkstra’s Algorithm procedure Dijkstra(G: weighted connected simple graph with vertices.
EECS 203: It’s the end of the class and I feel fine. Graphs.
Slide 14-1 Copyright © 2005 Pearson Education, Inc. SEVENTH EDITION and EXPANDED SEVENTH EDITION.
1 Excursions in Modern Mathematics Sixth Edition Peter Tannenbaum.
Chapter 2 Graph Algorithms.
May 1, 2002Applied Discrete Mathematics Week 13: Graphs and Trees 1News CSEMS Scholarships for CS and Math students (US citizens only) $3,125 per year.
Can you connect the dots as shown without taking your pen off the page or drawing the same line twice.
Euler and Hamilton Paths. Euler Paths and Circuits The Seven bridges of Königsberg a b c d A B C D.
1 CS104 : Discrete Structures Chapter V Graph Theory.
CS 200 Algorithms and Data Structures
Module #19: Graph Theory: part II Rosen 5 th ed., chs. 8-9.
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
Data Structures & Algorithms Graphs
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Discrete Mathematical Structures: Theory and Applications
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
AND.
Graph theory and networks. Basic definitions  A graph consists of points called vertices (or nodes) and lines called edges (or arcs). Each edge joins.
Lecture 52 Section 11.2 Wed, Apr 26, 2006
Chapter 9: Graphs.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Chapter 14 Section 3 - Slide 1 Copyright © 2009 Pearson Education, Inc. AND.
1 Euler and Hamilton paths Jorge A. Cobb The University of Texas at Dallas.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Paths and circuits.
(CSC 102) Lecture 30 Discrete Structures. Graphs.
Grade 11 AP Mathematics Graph Theory Definition: A graph, G, is a set of vertices v(G) = {v 1, v 2, v 3, …, v n } and edges e(G) = {v i v j where 1 ≤ i,
1 GRAPH Learning Outcomes Students should be able to: Explain basic terminology of a graph Identify Euler and Hamiltonian cycle Represent graphs using.
An Introduction to Graph Theory
Excursions in Modern Mathematics Sixth Edition
Graph theory Definitions Trees, cycles, directed graphs.
Agenda Lecture Content: Introduction to Graph Path and Cycle
EECS 203 Lecture 20 More Graphs.
Advanced Algorithms Analysis and Design
Introduction to Graph Theory Euler and Hamilton Paths and Circuits
Graph Theory.
Graphs Chapter 13.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Presentation transcript:

Graph Theory Topics to be covered: Use graphs to model and solve problems such as shortest paths, vertex coloring, critical paths, routing, and scheduling problems Convert from a graph to an adjacency matrix and vice versa. Use directed graphs, spanning tress, rooted trees, binary trees, or decision trees to solve problems. Demonstrate understanding of algorithms such as depth-first and breadth-first walk of a tree or maximal matching. Use matching or bin-packing techniques to solve optimization and other problems. Compare and contrast different graph algorithms in terms of efficiency and types of problems that can be solved.

Basic Terminology A graph consists of a finite set of vertices and edges. Vertex Parallel edges Loop

Degrees of Vertices The degree of a vertex is determined by the number of edges it is connected to. If all the vertices of a graph have the same degree, then it is a regular graph. The handshake theorem says that the sum of the degree of all the vertices in graph G is equal to twice the number of edges in G A corollary of this theorem is that the total degree of a graph is even. This is an example of a regular graph. It is also a complete graph, because every vertex is connected to every other vertex.

Adjacency Matrixes Every graph can be represented by an nxn matrix, where n is the number of vertices in the graph. For the matrix A = (ai,j) if ai,j = 1 then there is an edge from vertex i to vertex j. If 0 then there is no edge.

Adjacency Matrix Example

Vertex Coloring To obtain the proper coloring of a graph you must color each vertex so that it is a different color from all adjacent vertices. The least number of colors possible to color a graph is called its chromatic number. We use the notation X(G) for the chromatic number of graph G. Unplugged activity: http://www.csunplugged.org/graph-colouring A properly colored graph with a chromatic number of 2.

Applications of Vertex Coloring Graph coloring can be used to solve problems like scheduling. Ex. Suppose you want to schedule final exams and, being very considerate, you want to avoid having a student do more than one exam a day. We shall call the courses 1,2,3,4,5,6,7 . In the table below a star in entry i,j means that course i and j have at least one student in common so you can't have them on the same day. What is the least number of days you need to schedule all the exams? Show how you would schedule the exams. . 1 2 3 4 5 6 7 * -

Applications of Vertex Coloring To solve the problem mentioned previously you could use that table as an adjacency matrix to construct a graph like the one shown here This graph can be colored with a minimum of 4 colors

Paths and Circuits Definitions Let G be a graph, and v and w be vertices in G. A walk from v to w is a finite series of adjacent vertices and edges of G. A path from v to w is a walk from v to w that does not contain a repeated edge. A simple path from v to w is a path 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 does not contain a repeated edge. A simple circuit is a circuit that does not have any other repeated vertex except for the first and last.

Paths and Circuits Definitions Continued Repeated Edge? Repeated Vertex? Starts and ends at same point? Walk Allowed Path No Simple Path Closed Walk Yes Circuit Simple Circuit First and Last Only

Euler Circuits and Paths An Euler Circuit for graph G is a circuit that contains every vertex and every edge of G. If a graph has an Euler circuit, then every vertex of that graph has an even degree. If any vertex of a graph has an odd degree then that graph does not have an Euler circuit. If every vertex of a nonempty graph has an even degree and if the graph is connected then the graph has an Euler circuit. An Euler Path from v to w for graph G is a path from v to w that passes through every vertex at least once, and traverses every edge exactly once. There is an Euler path from v to w if, and only if, v and w have both even or odd degrees, and all other vertices of G have an even degree.

Application of an Euler Path The most famous Euler Circuit was that of the 7 bridges of Königsberg. This was when Euler created the field of graph theory. This problem is described as follows: You must find a walk through the city that crossed each bridge once and only once. The islands could not be reached by any route other than bridges, and each bridge must be crossed completely every time. Euler simplified the problem into this graphical representation. This graph makes it clear that all 4 vertices have odd degrees. This makes it impossible for an Euler path to be created.

Hamiltonian Circuits A Hamiltonian circuit for graph G is a simple circuit that includes every vertex of G. Note that edges can be omitted, and often are in the optimal solution. If graph G has a nontrivial 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 and vertices. Every vertex of H has degree 2. Therefore, if graph G does not have a subgraph H with those properties, then graph G does not have a Hamiltonian circuit.

Application of Hamiltonian Circuits: The Traveling Salesman Problem In the Traveling Salesman Problem you must visit each city exactly once, starting and ending in city A. Which route can you take to minimize the total distance traveled? This problem can be solved by writing all of the possible Hamiltonian Circuits: Route Total Distance A B C D A 30 + 30 + 25 + 40 = 125 A B D C A 30 + 35 + 25 + 50 = 140 A C B D A 50 + 30 + 35 + 40 = 155 A C D B A 140 A D B C A 155 A D C B A 125 Thus either route A B C D A or route A D C B A gives a minimum total distance of 125.

NP-Complete Problems The general traveling salesman problem involves finding a Hamiltonian circuit to minimize the total distance traveled for a graph with n vertices in which each edge is marked with a distance. One way to solve it is the method used above; that of listing out all possible circuits. This becomes impossible with larger graphs, though: For a complete graph with 30 vertices, there would be 29! = 8.84 x 1030 different circuits. Even if a circuit could be found and computed in 1 nanosecond, it would still take 2.8 x 1014 years to finish the computation. This problem is an example of an NP-complete problem – a set of problems that take a very long time to solve, but have answers that can be verified quickly. However, there are efficient algorithms that find “pretty good” solutions in a reasonable amount of time.

Finding the Shortest Path Edges on graphs can be given weights representing the cost to travel from one vertex to another. There are a number of algorithms to find the shortest path on a weighted graph, the most notable of which is Dijkstra’s algorithm.

Dijkstra’s Algorithm The goal of this algorithm is to find the shortest path between two vertices on a graph. Once the distance from the start point to a vertex has been calculated, that vertex is considered marked. For the current node it will consider all adjacent unmarked nodes and determine their distance from the initial node. If it is less than the previously recorded distance, overwrite it. Once all adjacent nodes have been considered the current node is marked and the algorithm continues to the next node with the shortest distance. This process repeats until the terminal vertex has been found.

Example of Dijkstra’s Algorithm

Trees A graph is a tree if, and only if, it has no loops and is connected. A rooted tree is a tree in which one vertex is distinguished from the others and is called the root. A Binary tree is a rooted tree in which every parent has at most two children. Each child is either a left child or a right child.

Binary Trees + * / – c d e a b Binary trees are used to represent algebraic expressions in computers: ((a – b) * c) + (d/e): + * / – c d e a b

Spanning Trees A spanning tree of graph G is a subgraph of G that contains every vertex of G and is a tree. A minimum spanning tree is a spanning tree for which the sum of the weights of all the edges is as small as possible. Unplugged Activity: http://www.csunplugged.org/minimal-spanning-trees