Fundamentals of Informatics Introduction to Algorithms and...
Transcript of Fundamentals of Informatics Introduction to Algorithms and...
Fundamentals of InformaticsIntroduction to Algorithms and Informatics
Lecture 2: Graphs as models
I Prof: David Avis
I Research bldg. No. 7, room404
I www.i-kyoto-u.ca.jp/∼avis
I Check course web page at leastonce a week !
I TA: Yang Cao
How to pass this course smiling!
I Attend the lectures !
I Do all the reading assignments on the lecturesummaries web page
I Do the exercises after each lecture
I 3 reports consisting of exercises from 3-4 lectures
I Report due dates: Wed May 14, Wed June 29, WedJuly 16 in class (or give to Yang Cao)
I Ask questions !
www.i-kyoto-u.ca.jp/∼avis
How to pass this course smiling!
I Attend the lectures !
I Do all the reading assignments on the lecturesummaries web page
I Do the exercises after each lecture
I 3 reports consisting of exercises from 3-4 lectures
I Report due dates: Wed May 14, Wed June 29, WedJuly 16 in class (or give to Yang Cao)
I Ask questions !
www.i-kyoto-u.ca.jp/∼avis
How to pass this course smiling!
I Attend the lectures !
I Do all the reading assignments on the lecturesummaries web page
I Do the exercises after each lecture
I 3 reports consisting of exercises from 3-4 lectures
I Report due dates: Wed May 14, Wed June 29, WedJuly 16 in class (or give to Yang Cao)
I Ask questions !
www.i-kyoto-u.ca.jp/∼avis
How to pass this course smiling!
I Attend the lectures !
I Do all the reading assignments on the lecturesummaries web page
I Do the exercises after each lecture
I 3 reports consisting of exercises from 3-4 lectures
I Report due dates: Wed May 14, Wed June 29, WedJuly 16 in class (or give to Yang Cao)
I Ask questions !
www.i-kyoto-u.ca.jp/∼avis
How to pass this course smiling!
I Attend the lectures !
I Do all the reading assignments on the lecturesummaries web page
I Do the exercises after each lecture
I 3 reports consisting of exercises from 3-4 lectures
I Report due dates: Wed May 14, Wed June 29, WedJuly 16 in class (or give to Yang Cao)
I Ask questions !
www.i-kyoto-u.ca.jp/∼avis
How to pass this course smiling!
I Attend the lectures !
I Do all the reading assignments on the lecturesummaries web page
I Do the exercises after each lecture
I 3 reports consisting of exercises from 3-4 lectures
I Report due dates: Wed May 14, Wed June 29, WedJuly 16 in class (or give to Yang Cao)
I Ask questions !
www.i-kyoto-u.ca.jp/∼avis
How to pass this course smiling!
I Attend the lectures !
I Do all the reading assignments on the lecturesummaries web page
I Do the exercises after each lecture
I 3 reports consisting of exercises from 3-4 lectures
I Report due dates: Wed May 14, Wed June 29, WedJuly 16 in class (or give to Yang Cao)
I Ask questions !
www.i-kyoto-u.ca.jp/∼avis
Kyoto bridge problem
I Is it possible to cross each bridge exactly once?
I If so, can you do so and start and end at the same place?
Kyoto bridge problem
I Is it possible to cross each bridge exactly once?
I If so, can you do so and start and end at the same place?
Kyoto bridge problem
I Is it possible to cross each bridge exactly once?
I If so, can you do so and start and end at the same place?
Konigsberg bridges: 1735 and now
I The problem is to cross each bridge exactly once and end at thestarting point
I This is the Euler circuit problem ...
I ... and can be solved in linear time
I Considered as the birth of graph theory
Konigsberg bridges: 1735 and now
I The problem is to cross each bridge exactly once and end at thestarting point
I This is the Euler circuit problem ...
I ... and can be solved in linear time
I Considered as the birth of graph theory
Konigsberg bridges: 1735 and now
I The problem is to cross each bridge exactly once and end at thestarting point
I This is the Euler circuit problem ...
I ... and can be solved in linear time
I Considered as the birth of graph theory
Konigsberg bridges: 1735 and now
I The problem is to cross each bridge exactly once and end at thestarting point
I This is the Euler circuit problem ...
I ... and can be solved in linear time
I Considered as the birth of graph theory
Konigsberg bridges: 1735 and now
I The problem is to cross each bridge exactly once and end at thestarting point
I This is the Euler circuit problem ...
I ... and can be solved in linear time
I Considered as the birth of graph theory
Euler Circuits: Konigsberg bridge problem (1735)
B
g
e
f
C
c
a b
d
A D
I A graph consists of a set of vertices V and edges E connectingvertices
I Vertices in graph correspond to land, edges to bridges
I Euler’s Theorem: A circuit exists that crosses every bridge if andonly if each vertex in the corresponding graph has even degree
I We can find the circuit in linear time
Euler Circuits: Konigsberg bridge problem (1735)
B
g
e
f
C
c
a b
d
A D
I A graph consists of a set of vertices V and edges E connectingvertices
I Vertices in graph correspond to land, edges to bridges
I Euler’s Theorem: A circuit exists that crosses every bridge if andonly if each vertex in the corresponding graph has even degree
I We can find the circuit in linear time
Euler Circuits: Konigsberg bridge problem (1735)
B
g
e
f
C
c
a b
d
A D
I A graph consists of a set of vertices V and edges E connectingvertices
I Vertices in graph correspond to land, edges to bridges
I Euler’s Theorem: A circuit exists that crosses every bridge if andonly if each vertex in the corresponding graph has even degree
I We can find the circuit in linear time
Euler Circuits: Konigsberg bridge problem (1735)
B
g
e
f
C
c
a b
d
A D
I A graph consists of a set of vertices V and edges E connectingvertices
I Vertices in graph correspond to land, edges to bridges
I Euler’s Theorem: A circuit exists that crosses every bridge if andonly if each vertex in the corresponding graph has even degree
I We can find the circuit in linear time
Extensions: Chinese Postman Problem
I If the graph has exactly two vertices of odd degree we can find apath visiting each edge exactly once
I What if there are more than two vertices of odd degree?
I Find a minimum length path that visits each edge at least once.
I Proposed by Kwan Mei-Ko (1962) solved by Jack Edmonds and EllisJohnson (1973)
I Many applications of this: postal delivery, street cleaning, garbagepickup, snow removal, ...
Extensions: Chinese Postman Problem
I If the graph has exactly two vertices of odd degree we can find apath visiting each edge exactly once
I What if there are more than two vertices of odd degree?
I Find a minimum length path that visits each edge at least once.
I Proposed by Kwan Mei-Ko (1962) solved by Jack Edmonds and EllisJohnson (1973)
I Many applications of this: postal delivery, street cleaning, garbagepickup, snow removal, ...
Extensions: Chinese Postman Problem
I If the graph has exactly two vertices of odd degree we can find apath visiting each edge exactly once
I What if there are more than two vertices of odd degree?
I Find a minimum length path that visits each edge at least once.
I Proposed by Kwan Mei-Ko (1962) solved by Jack Edmonds and EllisJohnson (1973)
I Many applications of this: postal delivery, street cleaning, garbagepickup, snow removal, ...
Extensions: Chinese Postman Problem
I If the graph has exactly two vertices of odd degree we can find apath visiting each edge exactly once
I What if there are more than two vertices of odd degree?
I Find a minimum length path that visits each edge at least once.
I Proposed by Kwan Mei-Ko (1962) solved by Jack Edmonds and EllisJohnson (1973)
I Many applications of this: postal delivery, street cleaning, garbagepickup, snow removal, ...
Extensions: Chinese Postman Problem
I If the graph has exactly two vertices of odd degree we can find apath visiting each edge exactly once
I What if there are more than two vertices of odd degree?
I Find a minimum length path that visits each edge at least once.
I Proposed by Kwan Mei-Ko (1962) solved by Jack Edmonds and EllisJohnson (1973)
I Many applications of this: postal delivery, street cleaning, garbagepickup, snow removal, ...
ExercisesI Let G = (V ,E ) be a connected undirected graph with exactly two
vertices, A and B, of odd degree. Prove that any maximal lengthpath with no repeated edges that starts at A must end at B.Conclude that after this path has been removed from G all vertexdegrees must be even.
I Consider the Montreal map at the top of the next slide. Decidewhether or not there is a path (or circuit) that crosses each bridge.If so, give the path (or circuit). (Consider all lines crossing the wateras bridges)
I Consider the new bridge connecting highway 25 shown in yellowbelow. How does this change the answer to the preceding question?
Montreal bridge problem
Montreal map before 2011