Graph Algorithms Mathematical Structures for Computer Science Chapter 6 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesGraph Algorithms.

Slides:



Advertisements
Similar presentations
Chapter 8 Topics in Graph Theory
Advertisements

Introduction to Graph Theory Instructor: Dr. Chaudhary Department of Computer Science Millersville University Reading Assignment Chapter 1.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 – CHAPTER 4 GRAPHS 1.
Graph-02.
1 Lecture 5 (part 2) Graphs II Euler and Hamiltonian Path / Circuit Reading: Epp Chp 11.2, 11.3.
Graph Algorithms Mathematical Structures for Computer Science Chapter 6 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesGraph Algorithms.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
BY: MIKE BASHAM, Math in Scheduling. The Bridges of Konigsberg.
MIT and James Orlin © Introduction to Networks Eulerian Tours Hamiltonian Tours The Shortest Path Problem Dijkstra’s Algorithm for Solving the Shortest.
Sequential Circuits Problems(II) Prof. Sin-Min Lee Department of Mathematics and Computer Science Algorithm = Logic + Control.
Discrete Structures Chapter 7B Graphs Nurul Amelina Nasharuddin Multimedia Department.
An Euler Circuit is a cycle of an undirected graph, that traverses every edge of the graph exactly once, and ends at the same node from which it began.
Graphs and Trees This handout: Eulerian Cycles: Sufficiency of the condition Hamiltonian tour.
Representing Graphs Wade Trappe. Lecture Overview Introduction Some Terminology –Paths Adjacency Matrix.
Linked Lists1 Part-B3 Linked Lists. Linked Lists2 Singly Linked List (§ 4.4.1) A singly linked list is a concrete data structure consisting of a sequence.
4/17/2017 Section 8.5 Euler & Hamilton Paths ch8.5.
Proofs, Recursion, and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Traveling-Salesman Problem Ch. 6. Hamilton Circuits Euler circuit/path => Visit each edge once and only once Hamilton circuit => Visit each vertex once.
Chapter 11 Graphs and Trees This handout: Terminology of Graphs Eulerian Cycles.
Applied Discrete Mathematics Week 10: Equivalence Relations
GRAPH Learning Outcomes Students should be able to:
Graphs Chapter 10.
Eulerian Tour What is a Eulerian tour and how to find one.
Slide 14-1 Copyright © 2005 Pearson Education, Inc. SEVENTH EDITION and EXPANDED SEVENTH EDITION.
Graph Theoretic Concepts. What is a graph? A set of vertices (or nodes) linked by edges Mathematically, we often write G = (V,E)  V: set of vertices,
Graph Theory Topics to be covered:
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Euler paths and tours.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Chapter 2: Graphs and Networks Lesson 2: Hello Mr Euler…
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Permutations and Hamiltonian Circuits Larry Griffith Basic Notions Seminar October 10, 2007.
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.
Embedding long paths in k-ary n-cubes with faulty nodes and links
Fall 2015 COMP 2300 Discrete Structures for Computation Donghyun (David) Kim Department of Mathematics and Physics North Carolina Central University 1.
Topics Paths and Circuits (11.2) A B C D E F G.
Discrete Mathematical Structures: Theory and Applications
Lecture 10: Graph-Path-Circuit
Shortest Path Based Sufficiency Condition for Hamiltonian Graphs
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
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.
Euler Paths and Circuits. The original problem A resident of Konigsberg wrote to Leonard Euler saying that a popular pastime for couples was to try.
Eulerian Paths and Cycles. What is a Eulerian Path Given an graph. Find a path which uses every edge exactly once. This path is called an Eulerian Path.
MAT 2720 Discrete Mathematics Section 8.2 Paths and Cycles
Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 14.2 Euler Paths, and Euler Circuits.
Section 13  Questions  Graphs. Graphs  A graph representation: –Adjacency matrix. Pros:? Cons:? –Neighbor lists. Pros:? Cons:?
Chapter 6: Graphs 6.1 Euler Circuits
Excursions in Modern Mathematics, 7e: Copyright © 2010 Pearson Education, Inc. 5 The Mathematics of Getting Around 5.1Euler Circuit Problems 5.2What.
Review Euler Graph Theory: DEFINITION: A NETWORK IS A FIGURE MADE UP OF POINTS (VERTICES) CONNECTED BY NON-INTERSECTING CURVES (ARCS). DEFINITION: A VERTEX.
Graphs and Trees Mathematical Structures for Computer Science Chapter 5 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesGraphs and Trees.
Graph Theory Def: A graph is a set of vertices and edges G={V,E} Ex. V = {a,b,c,d,e} E = {ab,bd,ad,ed,ce,cd} Note: above is a purely mathematical definition.
Week 11 - Wednesday.  What did we talk about last time?  Graphs  Paths and circuits.
(CSC 102) Lecture 30 Discrete Structures. Graphs.
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
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean Logic.
Graph Algorithms Mathematical Structures for Computer Science Chapter 6 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesGraph Algorithms.
Chapter Chapter Summary Graphs and Graph Models Graph Terminology and Special Types of Graphs Representing Graphs and Graph Isomorphism Connectivity.
Decision Trees DEFINITION: DECISION TREE A decision tree is a tree in which the internal nodes represent actions, the arcs represent outcomes of an action,
Graphs: Definitions and Basic Properties
Mathematical Structures for Computer Science Chapter 6
Can you draw this picture without lifting up your pen/pencil?
Graph Theory.
Lecture 15: Graph Theory II
EMIS 8374 Shortest Path Problems: Introduction Updated 9 February 2008
Mathematical Structures for Computer Science Chapter 6
5 The Mathematics of Getting Around
Euler and Hamilton Paths
A Survey of Mathematics with Applications
Presentation transcript:

Graph Algorithms Mathematical Structures for Computer Science Chapter 6 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesGraph Algorithms

Section 6.2Euler Path and Hamiltonian Circuit1 Euler Path DEFINITION: EULER PATH An Euler path in a graph G is a path that uses each arc of G exactly once. We want to find if an Euler path exists in graph G. Whether an Euler path exists in a given graph hinges on the degrees of its nodes. A node is even if its degree is even and odd if its degree is odd. THEOREM ON ODD NODES IN A GRAPH The number of odd nodes in any graph is even.

Section 6.2Euler Path and Hamiltonian Circuit2 Euler Path THEOREM ON EULER PATHS An Euler path exists in a connected graph if and only if there are either no odd nodes or two odd nodes. For the case of no odd nodes, the path can begin at any node and will end there; for the case of two odd nodes, the path must begin at one odd node and end at the other. The theorem on Euler paths is actually an algorithm to determine if an Euler path exists on an arbitrary connected graph. We make the simplifying assumption that the graph has no loops. If G has loops, we remove them and call the graph H. If H has an Euler path, then so does G, and vice versa.

Section 6.2Euler Path and Hamiltonian Circuit3 Euler Path Algorithm In the Euler Path algorithm, the input is a connected graph represented by an n  n adjacency matrix A. The algorithm counts the number of nodes adjacent to each node and determines whether this is an odd or an even number. If there are too many odd numbers, an Euler path does not exist. The variable total keeps track of the number of odd nodes found in the graph. The degree of any particular node, degree, is found by adding the numbers in that node’s row of the adjacency matrix. The function odd results in a value “true” if and only if the argument is an odd integer.

Section 6.2Euler Path and Hamiltonian Circuit4 Euler Path Algorithm ALGORITHM EulerPath EulerPath (n  n matrix A) //Determines whether an Euler path exists in a connected graph with //no loops and adjacency matrix A total = 0 i = 1 while total  2 and i  n do degree = 0 for j = 1 to n do degree = degree + A[i, j ] //find degree of node i (*) end for if odd(degree) then total = total + 1 //another odd degree node found end if i = i + 1 end while if total > 2 then write (“No Euler path exists”) Else write (“Euler path exists”) end if end EulerPath

Section 6.2Euler Path and Hamiltonian Circuit5 Euler Path Algorithm Example Given the following adjacency matrix: When the algorithm first enters the while loop, total is 0 and i is 1, then degree is 0. Within the for loop, the values of row 1 of the adjacency matrix are added in turn to degree, resulting in a value for degree of 3. The odd function applied to degree returns the value “true,” so the value of total is increased from 0 to 1; one node of odd degree has been found.

Section 6.2Euler Path and Hamiltonian Circuit6 Euler Path Algorithm Example Then i is incremented to 2. Neither the bounds on total nor the bounds on the array size have been exceeded, so the while loop executes again for row 2. degree is found to be odd, so the value of total is changed to 2. When the while loop is executed for row 3 of the array, the value of degree is even (4), so total does not change, and the while loop is executed again with i = 4. Row 4 again produces an odd value for degree, so total is raised to 3. This terminates the while loop. There is no Euler path because the number of odd nodes exceeds 2.

Section 6.2Euler Path and Hamiltonian Circuit7 Euler Path Analysis In the worst case, the while loop in the algorithm is executed n times, once for each row. Within the while loop, the for loop is executed n times, once for each column. EulerPath is therefore an Θ(n 2 ) algorithm in the worst case.

Section 6.2Euler Path and Hamiltonian Circuit8 Hamiltonian Circuit Problem A Hamiltonian circuit is a cycle using every node of the graph. A Hamiltonian circuit requires that each and every node of the graph be visited once and only once (except for the start node, which is also the end node) There can be unused arcs but no arc can be used more than once. No efficient algorithm has ever been found to determine if a Hamiltonian circuit exists.