Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open)

Similar documents
Eulerian Cycle (2A) Young Won Lim 4/26/18

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

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

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

Eulerian Cycle (2A) Young Won Lim 5/25/18

Eulerian Cycle (2A) Young Won Lim 5/11/18

Planar Graph (7A) Young Won Lim 5/21/18

Planar Graph (7A) Young Won Lim 6/20/18

Introduction to Graphs

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

Varying Applications (examples)

EECS 203 Lecture 20. More Graphs

Introduction III. Graphs. Motivations I. Introduction IV

Ma/CS 6a Class 8: Eulerian Cycles

Graph Theory. Part of Texas Counties.

6.2. Paths and Cycles

PATH FINDING AND GRAPH TRAVERSAL

Minimum Spanning Tree (5A) Young Won Lim 5/11/18

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

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur

Graphs. The ultimate data structure. graphs 1

4. (a) Draw the Petersen graph. (b) Use Kuratowski s teorem to prove that the Petersen graph is non-planar.

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

Module 2: NETWORKS AND DECISION MATHEMATICS

Understand graph terminology Implement graphs using

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

Fundamental Properties of Graphs

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

Further Mathematics 2016 Module 2: NETWORKS AND DECISION MATHEMATICS Chapter 9 Undirected Graphs and Networks

Week 11: Eulerian and Hamiltonian graphs; Trees. 15 and 17 November, 2017

Elements of Graph Theory

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7

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

Konigsberg Bridge Problem

Chapter 14 Section 3 - Slide 1

Sarah Will Math 490 December 2, 2009

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

Introduction to Graphs

Chapter 2 Graphs. 2.1 Definition of Graphs

Worksheet for the Final Exam - Part I. Graphs

Lecture 2: Routing algorithms

Math 776 Graph Theory Lecture Note 1 Basic concepts

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

Binary Search Tree (3A) Young Won Lim 6/2/18

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

Algorithms Overview (1A) Young Won Lim 3/29/18

Precept 4: Traveling Salesman Problem, Hierarchical Clustering. Qian Zhu 2/23/2011

Algorithms. Graphs. Algorithms

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

Binary Search Tree (2A) Young Won Lim 5/17/18

Chapter 9 Graph Algorithms

CSC Intro to Intelligent Robotics, Spring Graphs

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

Graphs II: Trailblazing

An Introduction to Graph Theory

5.1 Min-Max Theorem for General Matching

Undirected Network Summary

Material handling and Transportation in Logistics. Paolo Detti Dipartimento di Ingegneria dell Informazione e Scienze Matematiche Università di Siena

Questions? You are given the complete graph of Facebook. What questions would you ask? (What questions could we hope to answer?)

IE 102 Spring Routing Through Networks - 1

WUCT121. Discrete Mathematics. Graphs

Network Topology and Graph

INTRODUCTION TO GRAPH THEORY. 1. Definitions

Description of The Algorithm

CSE 101. Algorithm Design and Analysis Miles Jones Office 4208 CSE Building Lecture 5: SCC/BFS

Worksheet 28: Wednesday November 18 Euler and Topology

Graphs and Puzzles. Eulerian and Hamiltonian Tours.

Graphs. The ultimate data structure. graphs 1

Number Theory and Graph Theory

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies

Simple graph Complete graph K 7. Non- connected graph

Let G = (V, E) be a graph. If u, v V, then u is adjacent to v if {u, v} E. We also use the notation u v to denote that u is adjacent to v.

22 Elementary Graph Algorithms. There are two standard ways to represent a

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?

1 Digraphs. Definition 1

1. For the graph shown below and the given vertex sequences (i-iv),

Classic Graph Theory Problems

Characterization of Graphs with Eulerian Circuits

Section 3.4 Basic Results of Graph Theory

Assignment 4 Solutions of graph problems

Chapter 2: Graph Theory

Binary Search Tree (3A) Young Won Lim 6/4/18

MST & Shortest Path -Prim s -Djikstra s

CS350: Data Structures Dijkstra s Shortest Path Alg.

Chapter 9 Graph Algorithms

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

Binary Search Tree (3A) Young Won Lim 6/6/18

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

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.

Functions (4A) Young Won Lim 5/8/17

Algorithms (7A) Young Won Lim 4/18/17

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

Chapter 3: Paths and Cycles

Junior Circle Meeting 3 Circuits and Paths. April 18, 2010

Algorithms after Dijkstra and Kruskal for Big Data. User Manual

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

Introduction to Optimization

Eulerian Tours and Fleury s Algorithm

Topic 10 Part 2 [474 marks]

(Re)Introduction to Graphs and Some Algorithms

Transcription:

Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open) circuit : vertices my repeat, edges cannot repeat (closed) path : vertices cannot repeat, edges cannot repeat (open) cycle : vertices cannot repeat, edges cannot repeat (closed)

Copyright (c) 2015 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". 1) Undirected Graphs Vertex, Vertices 2) Directed Graphs Edge, Edges Please send corrections (or suggestions) to youngwlim@hotmail.com. This document was produced by using LibreOffice and Octave.

Euler Cycle visits every edge exactly once a necessary condition for the existence of Eulerian cycles is that all vertices in the graph have an even degree that connected graphs with all vertices of even degree have an Eulerian circuit. https://en.wikipedia.org/wiki/eulerian_path Graph (5A) 3

Euler Cycle degree 3 4 4 5 3 4 4 3 4 2 All odd degree vertices All even degree vertices https://en.wikipedia.org/wiki/eulerian_path Graph (5A) 4

Euler Cycle F B H E D C I J G ABCDEFGHIJK A K Eulerian Cycle Cycle: Vs = Vt start, terminal Path : Vs ----> Vt Vs!= Vt en.wikipedia.org Graph (5A) 5

Eulerian Cycles of Undirected Graphs An undirected graph has an Eulerian cycle if and only if every vertex has even degree, and all of its vertices with nonzero degree belong to a single connected component. 4 4 4 4 An undirected graph can be decomposed into edge-disjoint cycles if and only if all of its vertices have even degree. So, a graph has an Eulerian cycle if and only if it can be decomposed into edge-disjoint cycles and its nonzero-degree vertices belong to a single connected component. 4 2 https://en.wikipedia.org/wiki/eulerian_path Graph (5A) 6

Edge Disjoint Cycle Decomposition F B H E C I G D J A K Graph (5A) 7

Eulerian Paths of Undirected Graphs An undirected graph has an Eulerian path if and only if exactly zero or two vertices have odd degree, and all of its vertices with nonzero degree belong to a single connected component. E. C. https://en.wikipedia.org/wiki/eulerian_path Graph (5A) 8

Eulerian Cycles of Directed Graphs A directed graph has an Eulerian cycle if and only if every vertex has equal in degree and out degree, and all of its vertices with nonzero degree belong to a single strongly connected component. Equivalently, a directed graph has an Eulerian cycle if and only if it can be decomposed into edge-disjoint directed cycles and all of its vertices with nonzero degree belong to a single strongly connected component. https://en.wikipedia.org/wiki/eulerian_path Graph (5A) 9

Eulerian Paths of Directed Graphs A directed graph has an Eulerian path if and only if at most one vertex has (out-degree) (in-degree) = 1, at most one vertex has (in-degree) (out-degree) = 1, every other vertex has equal in-degree and out-degree, and all of its vertices with nonzero degree belong to a single connected component of the underlying undirected graph. https://en.wikipedia.org/wiki/eulerian_path Graph (5A) 10

Seven Bridges of Königsberg The problem was to devise a walk through the city that would cross each of those bridges once and only once. Euler Cycles (X) Euler Path (X) Euler Cycle Euler Path All even degree vertices = 0 odd degree vertices Only 0 or 2 odd degree vertices https://en.wikipedia.org/wiki/seven_bridges_of_k%c3%b6nigsberg Graph (5A) 11

Seven Bridges of Königsberg 7Bridges Problem 3 8Bridges Problem 3 A B C A B C 5 D 3 5 D 4 E F G E F G H 3 E Cycle (X) E Path (X) All - Odd Deg - Vertices 4 Eulerian Path AEHGFDCB https://en.wikipedia.org/wiki/seven_bridges_of_k%c3%b6nigsberg Graph (5A) 12

Seven Bridges of Königsberg 9 Bridges Problem 10 Bridges Problem 4 4 A B C A B C 5 I D 4 6 I D 4 E F G E J F G H H 5 6 Eulerian Path EHGFDCBAI Eulerian Cycle AEHGFDCBAJI https://en.wikipedia.org/wiki/seven_bridges_of_k%c3%b6nigsberg Graph (5A) 13

Euler Cycle Base Cases n = 0 edge n = 1 edge all even degree vertices n = 2 edge an Euler cycle Johnsonbough, Discrete Mathematics Graph (5A) 16

Euler Cycle F B H E D C I J G ABCDEFGHIJK A K en.wikipedia.org Graph (5A) 19

References [1] http://en.wikipedia.org/ [2]

Hamiltonian Cycle (3A)

Copyright (c) 2015 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections (or suggestions) to youngwlim@hotmail.com. This document was produced by using LibreOffice and Octave.

Hamiltonian Cycles A Hamiltonian path is a path in an undirected or directed graph that visits each vertex exactly once. A Hamiltonian cycle is a Hamiltonian path that is a cycle. the Hamiltonian path problem is NP-complete. https://en.wikipedia.org/wiki/hamiltonian_path Hamiltonian Cycles (3A) 3

Hamiltonian Cycles https://en.wikipedia.org/wiki/hamiltonian_path Hamiltonian Cycles (3A) 4

Hamiltonian Cycles https://en.wikipedia.org/wiki/hamiltonian_path Hamiltonian Cycles (3A) 5

Complete Graphs and Cycle Graphs https://en.wikipedia.org/wiki/complete_graph https://en.wikipedia.org/wiki/cycle_graph Hamiltonian Cycles (3A) 6

Complete Graphs https://en.wikipedia.org/wiki/complete_graph Hamiltonian Cycles (3A) 7

Tournament Graphs https://en.wikipedia.org/wiki/tournament_(graph_theory Hamiltonian Cycles (3A) 8

Platonic Solid Graphs https://en.wikipedia.org/wiki/platonic_solid Hamiltonian Cycles (3A) 9

Hamiltonian Cycles Properties (1) Any Hamiltonian cycle can be converted to a Hamiltonian path by removing one of its edges, but a Hamiltonian path can be extended to Hamiltonian cycle only if its endpoints are adjacent. All Hamiltonian graphs are biconnected, but a biconnected graph need not be Hamiltonian Hamiltonian Graphs Biconnected Graphs https://en.wikipedia.org/wiki/hamiltonian_path Hamiltonian Cycles (3A) 10

Hamiltonian Cycles Properties (2) An Eulerian graph G : a connected graph in which every vertex has even degree An Eulerian graph G necessarily has an Euler path, a closed walk passing through each edge of G exactly once. This Eulerian path corresponds to a Hamiltonian cycle in the line graph L(G), so the line graph of every Eulerian graph is Hamiltonian. Line graphs may have other Hamiltonian cycles that do not correspond to Euler paths. The line graph L(G) of every Hamiltonian graph G is itself Hamiltonian, regardless of whether the graph G is Eulerian. https://en.wikipedia.org/wiki/hamiltonian_path Hamiltonian Cycles (3A) 13

Line Graphs In the mathematical discipline of graph theory, the line graph of an undirected graph G is another graph L(G) that represents the adjacencies between edges of G. Given a graph G, its line graph L(G) is a graph such that each vertex of L(G) represents an edge of G; and two vertices of L(G) are adjacent if and only if their corresponding edges share a common endpoint ("are incident") in G. That is, it is the intersection graph of the edges of G, representing each edge by the set of its two endpoints. https://en.wikipedia.org/wiki/line_graph Hamiltonian Cycles (3A) 14

Line Graphs Examples https://en.wikipedia.org/wiki/line_graph Hamiltonian Cycles (3A) 15

References [1] http://en.wikipedia.org/ [2]

Shortest Path Problem (4A)

Copyright (c) 2015 2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections (or suggestions) to youngwlim@hotmail.com. This document was produced by using LibreOffice and Octave.

Shortest Path Problem the shortest path problem is the problem of finding a path between two vertices (or nodes) in a graph such that the sum of the weights of its constituent edges is minimized. https://en.wikipedia.org/wiki/shortest_path_problem Shortest Path Problem (4A) 3

Types of Shortest Path Problems The single-pair shortest path problem: to find shortest paths from a source vertex v to a destination vertex w in a graph The single-source shortest path problem: to find shortest paths from a source vertex v to all other vertices in the graph. The single-destination shortest path problem: to find shortest paths from all vertices in the directed graph to a single destination vertex v. This can be reduced to the single-source shortest path problem by reversing the arcs in the directed graph. The all-pairs shortest path problem: to find shortest paths between every pair of vertices v, v' in the graph. https://en.wikipedia.org/wiki/shortest_path_problem Shortest Path Problem (4A) 4

Dijkstra s Algorithm Example Summary U={1,2,3,4,5,6,7,8} U={2,3,4,5,6,7,8} U={3,4,5,6,7,8} https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif U={4,5,6,7,8} Shortest Path Problem (4A) 5

Dijkstra s Algorithm Example (1) U={1,2,3,4,5,6} C= 1 N={2,3,4} https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 6

Dijkstra s Algorithm Example (2) U={1,2,3,4,5,6} C= 1 N={2,3,4} U={2,3,4,5,6} C= 2 (min=7) N={3,4} https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 7

Dijkstra s Algorithm Example (3) https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif U={3,4,5,6} C= 3 (min=9) N={4,6} Shortest Path Problem (4A) 8

Dijkstra s Algorithm Example (4) https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 9

Dijkstra s Algorithm Example (5) U={4,5,6} C= 6 (min=11) N={5} U={4,5} C= 5 (min=20) N={4} https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 10

Hamiltonian Cycles https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 11

new C U={a,b,c,d,e,f,g,z} C=a (min=0) N={b,f}

U={a,b,c,d,e,f,g,z} C=a (min=0) N={b,f}

new C U={f,b,c,d,e,g,z} C=f (min=1) N={d,g}

U={f,b,c,d,e,g,z} C=f (min=1) N={d,g}

new C U={b,c,d,e,g,z} C=b (min=2) N={c,d,e}

U={b,c,d,e,g,z} C=b (min=2) N={c,d,e}

new C U={c,d,e,g,z} C=c (min=4) N={e,z}

U={c,d,e,g,z} C=c (min=4) N={e,z}

new C U={d,e,g,z} C=d (min=4) N={e}

U={d,e,g,z} C=d (min=4) N={e}

new C U={e,g,z} C=z (min=5) N={g}

U={e,g} C=z (min=5) N={g}

new C U={e,g} C=e (min=6) N={g}

U={e,g} C=e (min=6) N={g}

U={e,g} C=e (min=6) N={g}

U={e,g} C=e (min=6) N={g}

Dijkstra s Algorithm Let the node at which we are starting be called the initial node. Let the distance of node Y be the distance from the initial node to Y. Dijkstra's algorithm will assign some initial distance values and will try to improve them step by step. 1. Mark all nodes unvisited. Create a set of all the unvisited nodes called the unvisited set. 2. Assign to every node a tentative distance value: set it to zero for our initial node and to infinity for all other nodes. Set the initial node as current. https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 12

Dijkstra s Algorithm 3. For the current node, consider all of its unvisited neighbors and calculate their tentative distances through the current node. Compare the newly calculated tentative distance to the current assigned value and assign the smaller one. For example, if the current node A is marked with a distance of 6, and the edge connecting it with a neighbor B has length 2, then the distance to B through A will be 6 + 2 = 8. If B was previously marked with a distance greater than 8 then change it to 8. Otherwise, keep the current value. 8 6 2 B A https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 13

Dijkstra s Algorithm 4. When we are done considering all of the neighbors of the current node, mark the current node as visited and remove it from the unvisited set. A visited node will never be checked again. 5. Move to the next unvisited node with the smallest tentative distances and repeat the above steps which check neighbors and mark visited. https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 14

Dijkstra s Algorithm 6. If the destination node has been marked visited (when planning a route between two specific nodes) or if the smallest tentative distance among the nodes in the unvisited set is infinity (when planning a complete traversal; occurs when there is no connection between the initial node and remaining unvisited nodes), then stop. The algorithm has finished. 7. Otherwise, select the unvisited node that is marked with the smallest tentative distance, set it as the new "current node", and go back to step 3. https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 15

Dijkstra s Algorithm 1 function Dijkstra(Graph, source): 2 3 create vertex set Q 4 5 for each vertex v in Graph: // Initialization 6 dist[v] INFINITY // Unknown distance from source to v 7 prev[v] UNDEFINED // Previous node in optimal path from source 8 add v to Q // All nodes initially in Q (unvisited nodes) 9 10 dist[source] 0 // Distance from source to source 11 12 while Q is not empty: 13 u vertex in Q with min dist[u] // Node with the least distance 14 // will be selected first 15 remove u from Q 16 17 for each neighbor v of u: // where v is still in Q. 18 alt dist[u] + length(u, v) 19 if alt < dist[v]: // A shorter path to v has been found 20 dist[v] alt 21 prev[v] u 22 23 return dist[], prev[] https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 16

Hamiltonian Cycles https://en.wikipedia.org/wiki/dijkstra%27s_algorithm#/media/file:dijkstra_animation.gif Shortest Path Problem (4A) 17

References [1] http://en.wikipedia.org/ [2]