Week 10 - Wednesday CS221.

Slides:



Advertisements
Similar presentations
CSE 211 Discrete Mathematics
Advertisements

Naveen Garg, CSE, IIT Delhi
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
The 7 Bridges of Konigsberg A puzzle in need of solving.
Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Learning Objectives: Know how to use graphs as models and how to determine.
BY: MIKE BASHAM, Math in Scheduling. The Bridges of Konigsberg.
The Seven Bridges Of Konigsberg.
Chapter 26 of CLSR Bipartite Matching By Dr. M. Sakalli, Sources: Levitin and many other CSE, Marmara Univ. May/2009.
Lecture 4 CSE 331 Sep 9, Blog posts for lectures Starts from today See Sep 8 post on the blog.
1 Bipartite Matching Polytope, Stable Matching Polytope x1 x2 x3 Lecture 10: Feb 15.
By Dr. C. B. Alphonce (Room305 Mathematics Building) MT 147: DISCRETE MATHEMATICS (3 Units) CORE for B. SC. In COMPUTER SCIENCE.
Graphs and Euler cycles Let Maths take you Further…
Eulerian Graphs CSE 331 Section 2 James Daly. Reminders Project 3 is out Covers graphs Due Friday.
The Bridge Obsession Problem By Vamshi Krishna Vedam.
Week 11 - Friday.  What did we talk about last time?  Exam 2 post mortem  Cycle detection  Connectivity.
Chapter 10: Iterative Improvement Simplex Method The Design and Analysis of Algorithms.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Section 2.1 “Matching in bipartite graphs” in Graph Theory Handout for reading seminar.
Stable Matchings a.k.a. the Stable Marriage Problem
Week 11 - Monday.  What did we talk about last time?  Binomial theorem and Pascal's triangle  Conditional probability  Bayes’ theorem.
All Pair Shortest Path IOI/ACM ICPC Training June 2004.
One day a guy approached us with a puzzle he has been pondering on for approximately seven years. He called this the ‘Walls and Lines Puzzle’.
Bipartite Matching. Unweighted Bipartite Matching.
Aim: What is an Euler Path and Circuit?
Week 12 - Wednesday.  What did we talk about last time?  Matching  Stable marriage  Started Euler paths.
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.
Lecture 52 Section 11.2 Wed, Apr 26, 2006
Lecture 11: 9.4 Connectivity Paths in Undirected & Directed Graphs Graph Isomorphisms Counting Paths between Vertices 9.5 Euler and Hamilton Paths Euler.
Graph Algorithms Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]
M Clements Formal Network Theory. Introduction Practical problem – The Seven Bridges of Königsberg Network graphs Nodes & edges Degrees Rules/ axioms.
Indian Institute of Technology Kharagpur PALLAB DASGUPTA Graph Theory: Matchings and Factors Pallab Dasgupta, Professor, Dept. of Computer Sc. and Engineering,
1 Euler and Hamilton paths Jorge A. Cobb The University of Texas at Dallas.
Week 10 - Wednesday.  What did we talk about last time?  Counting practice  Pigeonhole principle.
Dating Advice from Mathematics
Week 6 - Monday.  What did we talk about last time?  Artificial intelligence  Lab 5.
Week 7 - Monday CS 113.
IOI/ACM ICPC Training 4 June 2005.
Matching Boys Girls A B C D E
Cybernetica AS & Tartu University
Stable Matching.
Lower bound for the Stable Marriage Problem
Stable Marriage Problem
Chapter 10 Iterative Improvement
Graph Theory An Introduction.
Week 6 - Wednesday CS 113.
Graph theory. Graph theory Leonard Euler (“Oiler”)
Bipartite Matching Lecture 8: Oct 7.
School of Computing Clemson University Fall, 2012
Euler Paths and Circuits
Eulerian tours Miles Jones MTThF 8:30-9:50am CSE 4140 August 15, 2016.
Week 15 – Friday CS221.
Week 11 - Monday CS221.
Maximum Flow - Best algorithms
CSE 421: Introduction to Algorithms
Special Graphs: Modeling and Algorithms
Various Graph Algorithms
GRAPH-THEORY AND APPLICATIONS
Graph Algorithm.
Euler Paths and Circuits
Euler Circuits and Paths
S. Raskhodnikova; based on slides by K. Wayne
Genome Assembly.
CSE 421: Introduction to Algorithms
Konigsberg- in days past.
Algorithms (2IL15) – Lecture 7
Bipartite Matching By Dr. M
Piyush Kumar (Lecture 3: Stable Marriage)
Graph Theory Relations, graphs
Graph Theory Proof In Class Exercise.
Presentation transcript:

Week 10 - Wednesday CS221

Last time What did we talk about last time? Dijkstra's shortest path algorithm Bellman-Ford shortest path algorithm Bipartite graphs Matching

Questions?

Project 3

Assignment 5

Matching

Bipartite graphs A bipartite graph is one whose nodes can be divided into two disjoint sets X and Y There can be edges between set X and set Y There are no edges inside set X or set Y A graph is bipartite if and only if it contains no odd cycles

Bipartite graph X A B C D E F Y A B C D E F

Maximum matching A perfect matching is when every node in set X and every node in set Y is matched It is not always possible to have a perfect matching We can still try to find a maximum matching in which as many nodes are matched up as possible

Matching algorithm Come up with a legal, maximal matching Take an augmenting path that starts at an unmatched node in X and ends at an unmatched node in Y If there is such a path, switch all the edges along the path from being in the matching to being out and vice versa If there is another augmenting path, go back to Step 2

X Y Match the graph Anna Becky Caitlin Daisy Erin Fiona A B C D E F A Adam Ben Carlos Dan Evan Fred

Is this graph bipartite?

Let’s make a maximal matching

Maximum matching! (one of them)

Stable Marriage

Imagine n men and n women All 2n people want to get married Each woman has ranked all n men in order of preference Each man has ranked all n women in order of preference We want to match them up so that the marriages are stable

Stability Consider two marriages: Anna and Bob Caitlin and Dan This pair of marriages is unstable if Anna likes Dan more than Bob and Dan likes Anna more than Caitlin or Caitlin likes Bob more than Dan and Bob likes Caitlin more than Anna We want to arrange all n marriages such that none are unstable

Gale-Shapley algorithm n rounds In each round, every unengaged man proposes to the woman he likes best (who he hasn’t proposed to already) An unengaged woman must accept the proposal from the one of her suitors she likes best If a woman is already engaged, she accepts the best suitor only if she likes him better than her fiance

Lessons from Stable Marriage It’s a graph problem where we never look at a graph The algorithm is guaranteed to terminate A woman can’t refuse to get engaged If a man gets dumped, he will eventually propose to everyone The algorithm is guaranteed to find stable marriages Unfortunately, it’s male-optimal and female-pessimal The lesson: Women should propose to men

Euler Paths and Tours

Königsberg Used to be Königsberg, Prussia Now called Kaliningrad, Russia On the Pregel River, including two large islands

Seven Bridges of Königsberg In 1736, the islands were connected by seven bridges In modern times, there are only five

The Challenge After a lazy Sunday and a bit of drinking, the citizens would challenge each other to walk around the city and try to find a path which crossed each bridge exactly once

Can you find a solution? Can you find such a solution? Start anywhere and find a path which crosses each bridge exactly once

Euler’s Solution What did Euler find? The same thing you did: nothing But, he also proved it was impossible Here’s how: Center Island North Shore East South Shore Remarkable for having his name mispronounced and getting a number named after himself, also knew something about civil engineering.

Graph theoretical view By simplifying the problem into a graph, the important features are clear To arrive as many times as you leave, the degrees of each node must be even (except for the starting and ending points) Center Island North Shore East South Shore

Eulerian Path Algorithm There is actually an way to find such a path on a graph where one exists: Start with a node of odd degree if there is one Every time we move across an edge, delete it If you have a choice, always pick an edge whose deletion will not disconnect the graph At the end of the algorithm, you will either have an Eulerian path or an Eulerian cycle, depending on the graph

The Two Princes and the Bishop We can label the nodes to make a more interesting problem Now each piece of land is associated with the Blue Prince, the Red Prince, the Bishop, or the Tavern

The Blue Prince: 8th Bridge The Blue Prince wants to build an 8th bridge so that he can walk starting at his castle, cross every bridge once, and end at the Tavern to brag

The Blue Prince: Solution Put the bridge from the Bishop’s land to the Red Prince’s land

The Red Prince: 9th Bridge Furious, the Red Prince wants to build his own bridge so that only he can start at his own castle, cross all the bridges once and then end at the Tavern

The Red Prince: Solution Put the bridge from the Red Prince’s land to the Blue Prince’s land

The Bishop: 10th Bridge Upset by this pettiness, the Bishop decides to build a 10th bridge which allows all citizens to cross all bridges and return to their starting point

The Bishop: Solution Put the bridge from the Center Island to the Red Prince’s land, making all pieces of land have even degree

Euler Practice

Is there an Euler tour? 2 1 3 4 9 5 7 8 6

What about here? 1 5 2 4 3

Quiz

Upcoming

Next time… B-trees Network flow

Reminders Keep working on Project 3 Work on Assignment 5 Read sections 6.2 and 6.4