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

Similar documents
Graph Theory CS/Math231 Discrete Mathematics Spring2015

Introduction to Graphs

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

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

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 7

v V Question: How many edges are there in a graph with 10 vertices each of degree 6?

11.2 Eulerian Trails

Introduction III. Graphs. Motivations I. Introduction IV

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

Elements of Graph Theory

8.2 Paths and Cycles

Chapter 11: Graphs and Trees. March 23, 2008

Lecture 3: Graphs and flows

Lecture 5: Graphs. Graphs! Euler Definitions: model. Fact! Euler Again!! Planar graphs. Euler Again!!!!

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

Chapter 2 Graphs. 2.1 Definition of Graphs

Lecture 5: Graphs. Rajat Mittal. IIT Kanpur

March 20/2003 Jayakanth Srinivasan,

CHAPTER 10 GRAPHS AND TREES. Alessandro Artale UniBZ - artale/z

Hamilton paths & circuits. Gray codes. Hamilton Circuits. Planar Graphs. Hamilton circuits. 10 Nov 2015

Logic: The Big Picture. Axiomatizing Arithmetic. Tautologies and Valid Arguments. Graphs and Trees

Foundations of Discrete Mathematics

Eulerian Paths and Cycles

Math 776 Graph Theory Lecture Note 1 Basic concepts

An Introduction to Graph Theory

Discrete Mathematics and Probability Theory Spring 2015 Vazirani Note 5

Ma/CS 6a Class 8: Eulerian Cycles

An undirected graph is a tree if and only of there is a unique simple path between any 2 of its vertices.

Eulerian Tours and Fleury s Algorithm

7.1 Introduction. A (free) tree T is A simple graph such that for every pair of vertices v and w there is a unique path from v to w

Characterization of Graphs with Eulerian Circuits

Number Theory and Graph Theory

11.4 Bipartite Multigraphs

CS 441 Discrete Mathematics for CS Lecture 26. Graphs. CS 441 Discrete mathematics for CS. Final exam

Sarah Will Math 490 December 2, 2009

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

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph

Graph Algorithms Using Depth First Search

Graph and Digraph Glossary

Graph Theory. Part of Texas Counties.

Math 778S Spectral Graph Theory Handout #2: Basic graph theory

Dieter Jungnickel (2008), Graphs, Networks and Algorithms, 3rd edition, which is available online via SpringerLink.

Graphs and Genetics. Outline. Computational Biology IST. Ana Teresa Freitas 2015/2016. Slides source: AED (MEEC/IST); Jones and Pevzner (book)

Today s Outline. CSE 326: Data Structures. Topic #15: Cool Graphs n Pretty Pictures. A Great Mathematician. The Bridges of Königsberg

γ(ɛ) (a, b) (a, d) (d, a) (a, b) (c, d) (d, d) (e, e) (e, a) (e, e) (a) Draw a picture of G.

EECS 203 Lecture 20. More Graphs

Notes slides from before lecture. CSE 21, Winter 2017, Section A00. Lecture 9 Notes. Class URL:

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?

Chapter 9. Graph Theory

Varying Applications (examples)

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.

Euler and Hamilton paths. Jorge A. Cobb The University of Texas at Dallas

Eulerian tours. Russell Impagliazzo and Miles Jones Thanks to Janine Tiefenbruck. April 20, 2016

Introduction to Computers and Programming. Concept Question

CS70 - Lecture 6. Graphs: Coloring; Special Graphs. 1. Review of L5 2. Planar Five Color Theorem 3. Special Graphs:

Algorithms. Graphs. Algorithms

Discrete mathematics II. - Graphs

Basic Combinatorics. Math 40210, Section 01 Fall Homework 4 Solutions

Majority and Friendship Paradoxes

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

Math.3336: Discrete Mathematics. Chapter 10 Graph Theory

Graphs: Definitions Trails, Paths, and Circuits Matrix Representations Isomorphisms. 11. Graphs and Trees 1. Aaron Tan. 30 October 3 November 2017

CHAPTER 10 GRAPHS AND TREES. Copyright Cengage Learning. All rights reserved.

12/5/17. trees. CS 220: Discrete Structures and their Applications. Trees Chapter 11 in zybooks. rooted trees. rooted trees

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

CSE 21 Spring 2016 Homework 5. Instructions

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

Today. Types of graphs. Complete Graphs. Trees. Hypercubes.

CS70: Discrete Math and Probability. Fan Ye June 23, 2016

Chapter 5: Euler Paths and Circuits The Mathematics of Getting Around

MATH 113 Section 9.2: Topology

Trees : Part 1. Section 4.1. Theory and Terminology. A Tree? A Tree? Theory and Terminology. Theory and Terminology

MC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points

Lecture 1: An Introduction to Graph Theory

Lecture 8: The Traveling Salesman Problem

Introduction to Graph Theory

DEFINITION OF GRAPH GRAPH THEORY GRAPHS ACCORDING TO THEIR VERTICES AND EDGES EXAMPLE GRAPHS ACCORDING TO THEIR VERTICES AND EDGES

PATH FINDING AND GRAPH TRAVERSAL

Chapter 10: Trees. A tree is a connected simple undirected graph with no simple circuits.

Discrete mathematics

INTRODUCTION TO GRAPH THEORY. 1. Definitions

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

#30: Graph theory May 25, 2009

Section Summary. Introduction to Trees Rooted Trees Trees as Models Properties of Trees

Introduction to Graphs

Analysis of Algorithms

We will show that the height of a RB tree on n vertices is approximately 2*log n. In class I presented a simple structural proof of this claim:

Eulerian Tours and Fleury s Algorithm

Understand graph terminology Implement graphs using

MATH 682 Notes Combinatorics and Graph Theory II. One interesting class of graphs rather akin to trees and acyclic graphs is the bipartite graph:

Ma/CS 6b Class 2: Matchings

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

Graphs. Reading Assignment. Mandatory: Chapter 3 Sections 3.1 & 3.2. Peeking into Computer Science. Jalal Kawash 2010

1 Digraphs. Definition 1

Lecture 3: Recap. Administrivia. Graph theory: Historical Motivation. COMP9020 Lecture 4 Session 2, 2017 Graphs and Trees

Chapter 5: Euler Paths and Circuits The Mathematics of Getting Around

4 Basics of Trees. Petr Hliněný, FI MU Brno 1 FI: MA010: Trees and Forests

CS473-Algorithms I. Lecture 13-A. Graphs. Cevdet Aykanat - Bilkent University Computer Engineering Department

6.2. Paths and Cycles

Chapter Summary. Introduction to Trees Applications of Trees Tree Traversal Spanning Trees Minimum Spanning Trees

Transcription:

15-251 Great Ideas in Theoretical Computer Science Lecture 12: Graphs I: The Basics February 22nd, 2018 Crossing bridges Königsberg (Prussia) Now Kaliningrad (Russia) Is there a way to walk through the city that would cross each bridge exactly once? Leonhard Euler (1735) This is not possible! Crossing bridges Except for the start and end vertices:

Crossing bridges 3 5 3 Every vertex is incident to an odd number of edges. So this graph does not have an Eulerian tour. 3 Crossing bridges What if it is the case that exactly 0 or 2 nodes are incident to an odd number of edges? Does that imply the graph must have an Eulerian tour? Why graphs? Why now?

Some examples where graphs appear Computer Science Life Lesson If your problem has a graph,. If not, try to make it have a graph. What is a graph? (A hundred) definitions and basic properties

Types of Graphs v 3 v 4 v 3 v 4 v 3 v 4 Simple Undirected Graph Directed Graph Multigraph Formal Definition: (undirected) graph A graph G is a tuple (V,E), where Example: V = {,,v 3,v 4,v 5,v 6 } E = {{, }, {,v 4 }, {,v 3 }, {v 3,v 4 }, {v 5,v 6 }} Formal Definition: (undirected) graph Example: V = {,,v 3,v 4,v 5,v 6 } E = {{, }, {,v 4 }, {,v 3 }, {v 3,v 4 }, {v 5,v 6 }} v 4 v 5 Graphs can be drawn: v 3 v 6

Formal Definition: (undirected) graph Example: V = {,,v 3,v 4,v 5,v 6 } E = {{, }, {,v 4 }, {,v 3 }, {v 3,v 4 }, {v 5,v 6 }} Matrix representation (adjacency matrix): v 3 v 4 v 0 5 v 6 1 0 1 0 1 0 0 1 0 1 0 0 0 v 3 0 1 0 1 0 0 v 4 B1 0 1 0 0 0 C v 5 @ 0 0 0 0 0 1A v 6 0 0 0 0 1 0 v 3 v 4 v 5 v 6 IMPORTANT Notation n = m = Almost always: number of vertices in the graph, V number of edges, E 1st Challenge Is it possible to have a party with 251 people in which everyone knows exactly 5 other people in the party? Is it possible to have a graph with 251 vertices in which each vertex is adjacent to exactly 5 other vertices?

Terminology: Neighbor Suppose e = {u, v} 2 E is an edge. We say: u and v are of e u u v and v are. u and v are on e is a is a of v of u Terminology: Neighborhood For V, the neighborhood of v is defined as v 5 v 3 v 4 Terminology: Degree For V, the degree of v is defined as v 5 v 3 v 4 A graph is called d-regular if

1st Theorem Theorem: Let G =(V,E) be a graph. Then X deg(v) =2m. v2v Proof: v 5 v 3 v 4 Poll Is it possible to have a graph with 251 vertices in which each vertex is adjacent to exactly 5 other vertices? Yes No Beats me 2nd Challenge We have n computers that we want to connect. We can put a link between any two computers, but the links are expensive. What is the least number of links we can use? What is the least number of edges needed to connect n vertices?

Walks and Paths A walk in a graph G = (V, E) is a c b d e Walks and Paths A path in a graph G = (V, E) is Fact: There is a path from u to v iff there is a walk from u to v a c b (a, c, d, a, d, e) shortcut repeated vertices d e (a, c, d, e) Circuits and Cycles A circuit in a graph G = (V, E) is a b c e d

Circuits and Cycles A cycle in a graph G = (V, E) is a b e c d A graph with no cycles is called. A graph is connected if Connected Graphs a i b c d e j h g f This 10-vertex graph is not connected. It has 4 connected components: {a, i, j}, {b, h}, {c}, {d, e, f, g} A graph is connected iff Back to the challenge What is the least number of edges needed to connect n vertices? n = 1 n = 2 n = 3 n = 4

Back to the challenge What is the least number of edges needed to connect n vertices? Poll Are n-1 edges always necassary to connect n vertices? Yes No No opinion Theorem: Let Then m n 1. Furthermore, 2nd Theorem G =(V,E) m = n 1 () G Proof: Imagine the following process: be a connected graph. is acyclic. - remove all the edges of G. - add them back one by one (in an arbitrary order). n isolated vertices n CCs G 1 CC CC = connected component

2nd Theorem Proof (continued): Consider a step of adding an edge back. 2 possibilities: C 1 C 2 C 3 Proof (continued): 2nd Theorem Trees Some examples with 5 vertices Definition: An n-vertex tree is any graph with at least 2 of the following 3 properties:

Trees 4 6 3 2 5 1 8 9 10 11 12 7 Leaf: Internal node: Rooted tree: Trees 1 vertex 1 is the root 2 9 3 4 5 10 11 12 6 7 8 For rooted trees, we use family tree terminology: - parent - child - sibling - ancestor - descendant etc Binary tree: - rooted tree - each node has at most 2 children. Back to Köningsberg s Bridges

Eulerian circuit Eulerian Circuit Problem Input: a graph G = (V, E) Output: Yes if there is a circuit visiting each edge exactly once. No otherwise. Eulerian circuit Eulerian Circuit Problem Input: a graph G = (V, E) Output: Yes if there is a circuit visiting each edge exactly once. No otherwise. Euler claimed (but did not provide a proof): A connected graph has an Eulerian circuit iff deg(v) is even for all v. Efficient algorithm: - Check that the graph is connected. - Check that every vertex has even degree. proved by Hierholzer Hamiltonian cycle Hamiltonian Cycle Problem Input: a graph G = (V, E) Output: Yes if there is a cycle visiting each vertex exactly once. No otherwise.

- Try all cycles Hamiltonian cycle Hamiltonian Cycle Problem Input: a graph G = (V, E) Output: Yes if there is a cycle visiting each vertex exactly once. No otherwise. Brute-Force Algorithm: O(n!) Dynamic Programming Algorithm: O(2 n ) Clever Algebraic Brute-Force: O(1.657 n ) Anything better?