David Stotts Computer Science Department UNC Chapel Hill.

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.
Graph-02.
Hamiltonian Cycles and paths Bin Zhou. Definitions Hamiltonian cycle (HC): is a cycle which passes once and exactly once through every vertex of G (G.
1 Lecture 5 (part 2) Graphs II Euler and Hamiltonian Path / Circuit Reading: Epp Chp 11.2, 11.3.
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.
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.
IEOR266 © Classification of MCNF problems.
Euler and Hamilton Paths
Chapter 11 Graphs and Trees This handout: Terminology of Graphs Eulerian Cycles.
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.
GRAPH Learning Outcomes Students should be able to:
Take a Tour with Euler Elementary Graph Theory – Euler Circuits and Hamiltonian Circuits Amro Mosaad – Middlesex County Academy.
Graph Theory Topics to be covered:
5.1  Routing Problems: planning and design of delivery routes.  Euler Circuit Problems: Type of routing problem also known as transversability problem.
Euler and Hamilton Paths
Hamiltonian Graphs By: Matt Connor Fall 2013.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
CS 200 Algorithms and Data Structures
Lecture 14: Graph Theory I Discrete Mathematical Structures: Theory and Applications.
Introduction to Graph Theory
Associated Matrices of Vertex Edge Graphs Euler Paths and Circuits Block Days April 30, May 1 and May
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.
Lecture 52 Section 11.2 Wed, Apr 26, 2006
Section 13  Questions  Graphs. Graphs  A graph representation: –Adjacency matrix. Pros:? Cons:? –Neighbor lists. Pros:? Cons:?
Chapter 6: Graphs 6.1 Euler Circuits
David Stotts Computer Science Department UNC Chapel Hill.
Euler and Hamiltonian Graphs
Graphs Rosen, Chapter 8. NOT ONE OF THESE! One of these!
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
1 CSE 326: Data Structures: Graphs Lecture 23: Wednesday, March 5 th, 2003.
CS Lecture 22 Graph Theory. Can I draw the above figure in one continuous trace with no line being drawn twice?
Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The.
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Graphs Chapter 20.
EECS 203 Lecture 19 Graphs.
Euler and Hamiltonian Graphs
Data Structures Graphs - Terminology
Graphs Hubert Chan (Chapter 9) [O1 Abstract Concepts]
Routing Through Networks - 1
Euler and Hamiltonian Graphs
Graphs Rosen, Chapter 8.
Graph theory Definitions Trees, cycles, directed graphs.
Konigsberg’s Seven Bridges
Discrete Structures – CNS2300
Hamiltonian Cycles and paths
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
EECS 203 Lecture 20 More Graphs.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Graphs: As a mathematics branch
Discrete Maths 9. Graphs Objective
Introduction to Graph Theory Euler and Hamilton Paths and Circuits
Graph Theory.
Lecture 15: Graph Theory II
Graphs Chapter 13.
Discrete Math II Howon Kim
A path that uses every vertex of the graph exactly once.
Konigsberg- in days past.
Graph Theory What is a graph?.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Euler and Hamilton Paths
Euler and Hamiltonian Graphs
Euler circuit Theorem 1 If a graph G has an Eulerian path, then it must have exactly two odd vertices. Theorem 2 If a graph G has an Eulerian circuit,
Applied Combinatorics, 4th Ed. Alan Tucker
Warm Up – 3/19 - Wednesday Give the vertex set. Give the edge set.
Chapter 10 Graphs and Trees
5 The Mathematics of Getting Around
Presentation transcript:

David Stotts Computer Science Department UNC Chapel Hill

Graph Theory and Algorithms (part 4)

 Created an abstraction of this problem and laid the groundwork for graph theory (and also topology)  Represented land masses as vertices  Represented bridges as connecting lines (edges) Euler’s original description

We model the city with an undirected graph, because we can walk across the bridge in either direction

Can a person execute a walk that crosses each bridge once and only once? You can start anywhere and end up anywhere Informal: Put a pen on a vertex. Can you trace the diagram without picking up the pen, or redrawing an edge?

Euler Path (EP): A path in the graph that passes through every edge once Euler Circuit (EC): An EP that begins and ends on the same vertex Degree of a vertex v: #edges involving v The question: “ does G have any EP or EC ? ” To answer: ◦ first compute the degree of every vertex in G

Given connected undirected G=(V,E) Theorem 1: EC If G has any odd vertices then it has no EC. If G has all even vertices then there is at least one EC. Theorem 2: EP If G has more than 2 odd vertices, then it has no EP. If G has exactly 2 odd vertices, then it has at least one EP, which must start at one odd vertex and end at the other. Theorem 3: General The sum of the degrees of all vertices in G is even ( exactly twice |E| ). The number of odd vertices is even.

#odd v implication >=1 EC (no EP that is not EC) 1 impossible (th.3) 2 no EC, >=1 EP every EP must start on one odd and end on the other >2 no EC, no EP

odd no EC at least 1 EP they start, end here odd at least 1 EC odd no EP (so no EC)

Memory aid:  G has an EC iff #odd vertices = 0  G has an EP iff #odd vertices = 2 (EP means that is not EC) There is an algorithm to find EC in a graph that is worst case O( |E|+|V| )

Given undirected unweighted G=(V,E) 1) Start with empty tmp stack, empty EC stack If 0 odd nodes pick any as cn, the curr node else if 2 odd nodes pick one odd as cn, the curr node else no EP/EC: end 2) If cn has no neighbors: push cn to EC stack cn = pop tmp stack Else // cn has neighbors push cn to tmp stack pick any neighbor nb of cn remove edge (cn,nb) make nb the new cn 3) Repeat step 2 until cn has no neighbors and tmp stack is empty

Inventing graphs allowed Euler to begin defining what we now know as topology This is a cube (3D) “stretched” flattened to 2D The graph allows us to study some properties of the cube Every convex polyhedron can be projected into 2D as a connected planar graph

Can a bug crawl along all edges of the cube without crossing any twice? Sounds like EP in 3-space So maybe we can do EP on the flattened graph #odd vertices = no EC (needs 0 odds) no EP (needs exactly 2 odds) compute degree of all vertices No, tough luck for the bug !

Given undirected connected graph G=(V,E) Hamiltonian Path (HP): path in G that contains each vertex once Hamiltonian Circuit (HC): a HP with endpoints that are adjacent HC: 1, 2, 3, 4, 5, 1 HP: 1, 2, 3, 4, 5 HC: 2, 3, 4, 5, 1, 2 HC: 2, 3, 4, 1, 5, HP: 1, 5, 2, 4, 3 HP: 2, 5, 1, 4, 3

HC: none HP: 1, 2, 3, 4, 5 HP: 1, 4, 3, 2, 5 HP: 1, 4, 5, 2, 3 HP: 3, 2, 5, 4, 1 etc

Memory aid: To remember which does edges, and which does vertices… Euler Edge

From puzzlemuseum.com Invented by Sir William Rowan Hamilton in 1857 Sold as a physical board game Put pegs in the holes in number order to define a path that uses each peg exactly once, and ends where it starts

From “Wordplay”, the NYT crossword blog Planar graph, a flattened dodecahedron By Christoph Sommer - Own work, CC BY-SA 3.0, There is a HC for this graph

From We said earlier that any convex polyhedron will project down to a connected planar graph The 5 platonic solids produce graphs that are Hamiltonian, i.e. have an HC

We saw an O(|V|+|E|) algorithm for EP/EC HP/HC is not nearly so easy for some strange reason Dirac 1952 (sufficient condition) A simple graph G (no loops, no multi-edges) with N vertices is Hamiltonian if degree of each vertex is >= N/2. ◦ does NOT say if G is Hamiltonian, then the vertex degrees are >= N/2 Ore 1960 (sufficient condition) A graph G with N vertices is Hamiltonian if for every pair of non-adjacent vertices the sum of their degrees is >=N. Existence proofs, not constructive Same for Euler’s Theorems

No known efficient algorithm for finding HP/HC So EP/EC is linear O(|V|+|E|) worst case But HP/HC is exponential on some data Efficient means polynomial Bubble Sort? O(N^2) we said its horrible, but its polynomial HP/HC exponential is way worse Note: We have not proven that HP/HC is not polynomial… We have not yet found a polynomial time algorithm All known algorithms are exponential time worst case

Note: If we are given a path/circuit, we can easily (in polynomial time) check if it is a HP/HC for a graph See the difference: 1) Does this G have an HC? 2) Given this path P in G, is it a HC? 3) Find a HC for G Y/N decision procedure Checking, verify Constructive

 esman_problem esman_problem  Computes a Hamiltonian Path (or circuit) on a graph  No known efficient (polynomial time) algorithm for solving this  Known algorithms are exponential (non- polynomial) in the size of the graph (#nodes + #edges)