SlideShare a Scribd company logo
© 2014 IBM Corporation
Bipartite Matching and Optical
Clouds - what?
Kostas Katrinis
Guest Lecture – CS2012 Programming Techniques
Trinity College Dublin
April 14, 2014
© 2014 IBM Corporation2
Outline
• Scope & Background
• Motivation & Challenges
• Hybrid Network Architecture
• MEMS Optical Switch Operation Brief
• Bipartite Graphs
• Matchings
• Make the connection!
• Hungarian Algorithm
Part I - Introduction
Part II – Modeling
Part III – Theory &
Algorithm
© 2014 IBM Corporation3
Scope Part I - Background
• Target Markets
– (Cloud) Datacenters - Θ(10K) Servers
– HPC Clusters (82% in Nov'12 Top-500)
• Target Systems:
– Data Network Fabric
© 2014 IBM Corporation4
DC Traffic Trends
• 76% of the traffic is
intra-datacenter *
• Total DC traffic CAGR
33% to 2015 *
• Traffic percentage exiting the rack
is high (up to 90%) **
– ...and we expect it to increase (scale-out workloads)
* Cisco Global Cloud Index: Forecast and Methodology, 2011–2016
** Benson et al., “Network Traffic Characteristics of Data Centers in the Wild”, IMC'10
Part I - Background
© 2014 IBM Corporation5
Design Trade-offs (Performance)
Performance
Cost
Highly
oversubcr.
High
Bisection
Trade-off
• We need high-capacity between any two points in the DC
• and at various scales (incremental deployment)
• ... we need $$$
Part I - Background
© 2014 IBM Corporation6
Motivating Example
Item Item List Price (USD)** Qty Total List Price (USD)
BNT G8264 (64-port switch) 30,000 5,120 153,600,000
BNT SFP+ SR Transceiver 665 262,164 174,325,760
MM Fiber Cable 28 131,072 3,670,016
Estimated List Prices
**Source: ibm.com
Fabric Price
331M USD
≈ Compute Price
(@5K/server)
• Full-bisection fat-tree @ 65k servers
• Building block: 64-port Ethernet switches (ala VL2*)
• Denser switches will not help you (e.g. 288-port Mellanox
Vantage)
Greenberg et al., “VL2: A Scalable and Flexible Data Center Network”, SIGCOMM 2009
Part I - Background
© 2014 IBM Corporation7
Motivating Example (cont.)
Total Price
331m USD
AND.....
#Cables to route
131,000
Can you count the birds in this nest?
Part I - Background
© 2014 IBM Corporation8
Paradigm Shift - Switch Light
Tiltable Mirrors implemented via MEMS (Micro-Electrical Mechanical Systems)
+ High-radix (320 ports you can buy, 1024 feasible)
+ No transceivers
+ Decreasing $/port
+ 50x less Watts/port vs. electronics
+ Can switch up to ~1Tbps
+ Protocol Agnostic
Electronic Switch (Ethernet) Optical MEMS switch
Price/Port (USD) 1100 (includes TxRx cost) 350
Bandwidth/Port 10Gbps “Rate-free”
Power/Port (W) 10 0.2
Requires TxRxs Yes No
x3
x∞
x50
Part I - Background
© 2014 IBM Corporation9
Hybrid Fabric Architecture Part I - Architecture
© 2014 IBM Corporation10
Dublin Prototype - Photos
Single-mode fiber
links, 25m length,
10GBASE-LR
96x96-Port 3D-MEMS Switch
Shamrock
Server Rack,
Chelsio T4 NIC
cards
G8264 TOR Switch
Redirect traffic from over-subscribed electrical
network to optical circuits.
 Packet forwarding removes bandwidth limitation of
over-subscribed electrical network.
Max.
Latency <13
ns
Part I - Architecture
© 2014 IBM Corporation11
High-level Functionality
• Bijective TE:
– Mice are routed via the 1G electronic fabric
– Elephants are routed via the 10G optical fabric
Optical Fabric is reconfigurable
– Centralized control optimizes topology against traffic pattern and
demand volume
Part I - Architecture
© 2014 IBM Corporation12
Optical MEMS Switch Part II – MEMS Switch
• Focus on the “Optical MEMS Switch”
• NxN ports (N inputs to connect to N outputs)
• Each input port is dynamically “crossconnected” to at most one output port
based on the rack pair we need to connect (decide every X seconds)
• E.g. Crossconnect port-13 to port-45 to connect rack-2 with rack-5 above
© 2014 IBM Corporation13
Bipartite Graphs
Definition (Bipartite Graphs)
G=(V,E) is bipartite if we can partition its vertex set V to two disjoing sets X
and Y, s.t. there are no edges between X and Y. We say that (X,Y) is a
bipartion of G.
Note: During this lecture, we will constrain our focus for the sake of
understanding to undirected graphs. Applying the concepts to directed graphs
as food for thought.
Part II – Bipartite
© 2014 IBM Corporation14
Matchings
Definition (Matching)
A matching M of a graph G=(V,E) is a set of edges of G such that no two
edges in M share a common vertex.
• If a vertex u is matched by M, then we say that u is saturated by M.
Otherwise, a vertex u is unsaturated by M
Example: In M1, v2 is saturated, whereas v1 is unsaturated
Part II – Matchings
© 2014 IBM Corporation15
Maximum Matchings
• Greediness strikes back: we want a matching to have as many edges as
possible
Definition (Maximum Matching)
A matching M of a graph G=(V,E) is a maximum matching if no matching in G
has more edges.
Example: M2 is a maximum matching (|G|=8 and |M2|=4). Since |M1|=3, M1 is
not maximum.
Part II – Matchings
© 2014 IBM Corporation16
Technology ↔ Theory: Connection Part II – Model
© 2014 IBM Corporation17
Maximum Matching – Optical Switch
• Remember that our Greediness keeps striking back, can't get rid of it!
• If we find a maximum matching (maximum number of edges), then we
have maximized the number of crossconnections in our optical switch
• .... thus we have maximized throughput (aggregate bandwidth that
crosses the optical switch)
Part II – Model
© 2014 IBM Corporation18
Maximum Matching in Bipartite Graphs
• So this is what we need (see title above) to maximize utilization of our
optical switch. We need an algorithm to find a maximum matching on a
bipartite graph. But how? Some theory first (and more definitions)
Definition (Alternating and Augmenting Paths)
Let G=(V,E) have a matching M. An alternating path P with respect to M is
any path whose edges are alternately in M and not in M (E-M). If the start and
end vertices of P are not saturated by M, then P is an augmenting path.
Example: P= (v1,v2,v3,v4,v5) is an alternating path
P'= (v1,v2,v3,v4,v5,v6) is an augmenting path
Part III – T&A
© 2014 IBM Corporation19
Matching expansion
Definition (Symmetric Difference)
Let E and E' be two edge sets. Then we define as the symmetric difference
M=E ◘ E' of the two sets the operation M = (E-E') U (E'-E) = (E U E') – (E ∩ E')
• Let G and M a matching (see below). P = (v1,v2,v3,v4,v5,v6) is an
augmentic path. E(P) are the edges of P.
• |M|=3
• Define M' = M ◘ E(P)
• Observe: |M'|=4 … wow! We obtained a larger matching M' starting from a
non-maximum one (M)
Part III – T&A
© 2014 IBM Corporation20
Expansion Lemma
Lemma –1 (Matching Expansion)
Let G have a matching M and let P be an augmenting path with respect to M.
Then M' = M ◘ E(P) is a matching with one more edge than M – or equivalently
– |M'|=|M|+1.
Proof
M' contains all the edges of M, plus all the edges in E(P) that are not in M.
Thus M' is per construction a matching of G.
Let u and v be the start and end vertices of P. Then u and v are unsaturated in
M, because P is an augmenting path. Because of the symmetric difference
operator, u and v are now saturated in M'. The rest of the edges of M that were
not in E(P) are still in M'. Thus, |M'|=|M|+1
Part III – T&A
© 2014 IBM Corporation21
Berge's Theorem
Theorem-1 (Berge's Theorem)
A matching M in G is maximum if and only if G has no augmenting path with
respect to M.
Proof
Left as an exercise (aka we don't have the time budget in class :-)). Reference
Textbook has a rigorous, easy-to-follow proof
• Theorems and lemmas are tools to an end. Let's use them!
• Back to our goal: We need an algorithm to find a maximum matching on
a bipartite graph
• Strategy:
1) Start with an arbitrary (even empty) matching M. If M is not maximum, there
will be an unsaturated vertex u.
2) Follow alternating paths from u until we identify another unsaturated vertex
v. Then the u-v path P is an augmentic path.
3) Set M'=M ◘ E(P). By the expansion Lemma, M' is a larger matching.
4) Repeat
Part III – T&A
© 2014 IBM Corporation22
Hungarian Algorithm - Preliminaries
Data Structures
• Integer Match[n]; // n is the number of vertices or n=|V| of G=(V,E)
– i.e. Match[u]=v if the matching matches vertex u to vertex v for all u in V
• Default: Match[u]=0 if u is unsaturated (not matched) by the matching
• For Breadth-First-Search (BFS) we use
Integer PrevPt[n]
– i.e. PrevPt[u]=v indicates that v is a parent of u in the BFS tree
• Alternating Paths: we use a combination of Match and PrevPt data
structures to store alternating paths. Example: P = (u, v2, v6, v3, v8)
• List S in X of vertices that are reachable
from a vertex u in X using alternate paths
• List NS in Y of vertices that are reachable
from a vertex u in X using alternate paths
Part III – T&A
PrevPt(v3)
PrevPt(v2)
Match(v6)
Match(v8)
© 2014 IBM Corporation23
Algorithm-1 (Augment subroutine)
Augment (y)
// Input: y is the end vertex of the augmenting path
// Output: augments the edges along the augmenting path “in place”
repeat
w = PrevPt[y]
Match[y] = w
u = Match[w]
Match[w]=y
y=u
until y=0 //reached root of BFS tree ie start vertex of augm. 
          //path
Part III – T&AHungarian Algorithm - Augmenting
© 2014 IBM Corporation24
Part III – T&AHungarian Algorithm – Augm. Example
y
w
v
u
augment(y)
rep.1
w = PrevPt[y]
Match[y] = w
v = Match[w]
Match[w]=y
y=v
rep.2
w = PrevPt[y]
Match[y] = w
v = Match[w]
Match[w]=y
y=v
Augmenting Path
© 2014 IBM Corporation25
Algorithm-2 (Maximum Matching of Graph G with bipartition (X,Y) and n vert.)
for i=1 to n do Match[i]=0 //init
for each u in X do {
  S.append(u);
  for i=1 to n do PrevPt[i]=0; //BFS rooted at u
   k=1;
   repeat
x = S[k];
for each y adjacent to x do {
         if y not in NS {
           NS.append(y);
           PrevPt[y]=x;
           if y is unsaturated {
             // found augmented path!!!
             augment(y);
             go to 1; // we saturated u
           } else S.append(Match[y]); // continue building the BFS tree
         }
     }
     k = k+1;
    until k > S.size(); // BFS rooted at u is now built out, no saturation :­(
    Remove S and NS from the graph
} 
Part III – T&AHungarian Algorithm
© 2014 IBM Corporation26
Part III – T&AHungarian Algorithm – Example (1)
© 2014 IBM Corporation27
Part III – T&AHungarian Algorithm – Example (2)
© 2014 IBM Corporation28
Food for Thought and Further Reading
Kocay and Kreher,
“Graphs, Algorithms,
and Optimization
(Discrete
Mathematics and Its
Applications)”,
Chapman and
Hall/CRC
How about faster algorithms?
Hints:
● Hopcroft-Karp Algorithm
● Edmond's Algorithm
How about weighted demand
(instead of edges with
implied unit demands)?
Intellectually appealing:
● Prove that Algorithm 2 finds indeed a maximum matching
●
Prove that the Hungarian Algorithm is O(n3
)
© 2014 IBM Corporation29
THANK YOU!
Q&A

More Related Content

PDF
Maximizing a Nonnegative, Monotone, Submodular Function Constrained to Matchings
PDF
Graphical Models In Python | Edureka
PDF
Accurate Learning of Graph Representations with Graph Multiset Pooling
PDF
Weight watcher Bay Area ACM Feb 28, 2022
PDF
This Week in Machine Learning and AI Feb 2019
PDF
Statistical Mechanics Methods for Discovering Knowledge from Production-Scale...
PPTX
Connectivity - Graph Theory in Computer Applications
PDF
ENS Macrh 2022.pdf
Maximizing a Nonnegative, Monotone, Submodular Function Constrained to Matchings
Graphical Models In Python | Edureka
Accurate Learning of Graph Representations with Graph Multiset Pooling
Weight watcher Bay Area ACM Feb 28, 2022
This Week in Machine Learning and AI Feb 2019
Statistical Mechanics Methods for Discovering Knowledge from Production-Scale...
Connectivity - Graph Theory in Computer Applications
ENS Macrh 2022.pdf

What's hot (20)

PDF
Reduced Complexity Transfer Function Computation for Complex Indoor Channels ...
PDF
Stanford ICME Lecture on Why Deep Learning Works
PDF
EmacsRedisplayAlgorithm
PDF
Poster2013
PDF
Why Deep Learning Works: Self Regularization in Deep Neural Networks
PDF
Why Deep Learning Works: Self Regularization in Deep Neural Networks
PPT
Graph Matching
PDF
Why Deep Learning Works: Self Regularization in Deep Neural Networks
PDF
Why Deep Learning Works: Dec 13, 2018 at ICSI, UC Berkeley
PDF
Paper id 37201520
PDF
Lecture15 xing
PDF
Search relevance
PDF
CHI 2014 talk by Antti Oulasvirta: Automated Nonlinear Regression Modeling fo...
PDF
The Power-Bandwidth Tradeoff in MIMO Systems
PDF
F04924352
PPTX
Image processing with matlab
PDF
IRJET- Color Image Compression using Canonic Signed Digit and Block based...
PDF
Georgetown B-school Talk 2021
PDF
Computationally Efficient Multi-Antenna Techniques for Multi-User Two-Way Wire...
PDF
Albert
Reduced Complexity Transfer Function Computation for Complex Indoor Channels ...
Stanford ICME Lecture on Why Deep Learning Works
EmacsRedisplayAlgorithm
Poster2013
Why Deep Learning Works: Self Regularization in Deep Neural Networks
Why Deep Learning Works: Self Regularization in Deep Neural Networks
Graph Matching
Why Deep Learning Works: Self Regularization in Deep Neural Networks
Why Deep Learning Works: Dec 13, 2018 at ICSI, UC Berkeley
Paper id 37201520
Lecture15 xing
Search relevance
CHI 2014 talk by Antti Oulasvirta: Automated Nonlinear Regression Modeling fo...
The Power-Bandwidth Tradeoff in MIMO Systems
F04924352
Image processing with matlab
IRJET- Color Image Compression using Canonic Signed Digit and Block based...
Georgetown B-school Talk 2021
Computationally Efficient Multi-Antenna Techniques for Multi-User Two-Way Wire...
Albert
Ad

Viewers also liked (7)

PDF
PDF
Maximum Matching in General Graphs
PPT
Graphs
PDF
Graph Coloring and Its Implementation
PDF
[ACM-ICPC] Bipartite Matching
PPT
Simple algorithm & hopcroft karp for bipartite graph
PPTX
Mems optical switches
Maximum Matching in General Graphs
Graphs
Graph Coloring and Its Implementation
[ACM-ICPC] Bipartite Matching
Simple algorithm & hopcroft karp for bipartite graph
Mems optical switches
Ad

Similar to Teaching Graph Algorithms in the Field - Bipartite Matching in optical datacenters (20)

PDF
Thesis_Draft_Nurkhaidarov
PDF
On the-optimal-number-of-smart-dust-particles
PDF
Analysis of Impact of Graph Theory in Computer Application
PPTX
Matrix Factorization lecture by bowen yang
PDF
Day 5 application of graph ,biconnectivity fdp on ds
PPT
Graphs in Data Structure
PDF
An Alternative Genetic Algorithm to Optimize OSPF Weights
PDF
Applied Graph Theory Applications
PDF
A comparison of efficient algorithms for scheduling parallel data redistribution
PPTX
kruskal and prims algorithm _
PPT
Sigmod11 outsource shortest path
PPTX
Computer Networking Assignment Help
PPTX
Computation Assignment Help
PPTX
Network Design Assignment Help
PDF
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
PDF
Traveling Salesman Problem in Distributed Environment
PDF
Description Of A Graph
PPT
K-BestMatch
PDF
IRJET- Comparison for Max-Flow Min-Cut Algorithms for Optimal Assignment Problem
PDF
Algorithm Finding Maximum Concurrent Multicommodity Linear Flow with Limited ...
Thesis_Draft_Nurkhaidarov
On the-optimal-number-of-smart-dust-particles
Analysis of Impact of Graph Theory in Computer Application
Matrix Factorization lecture by bowen yang
Day 5 application of graph ,biconnectivity fdp on ds
Graphs in Data Structure
An Alternative Genetic Algorithm to Optimize OSPF Weights
Applied Graph Theory Applications
A comparison of efficient algorithms for scheduling parallel data redistribution
kruskal and prims algorithm _
Sigmod11 outsource shortest path
Computer Networking Assignment Help
Computation Assignment Help
Network Design Assignment Help
TRAVELING SALESMAN PROBLEM IN DISTRIBUTED ENVIRONMENT
Traveling Salesman Problem in Distributed Environment
Description Of A Graph
K-BestMatch
IRJET- Comparison for Max-Flow Min-Cut Algorithms for Optimal Assignment Problem
Algorithm Finding Maximum Concurrent Multicommodity Linear Flow with Limited ...

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Cloud computing and distributed systems.
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Approach and Philosophy of On baking technology
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
cuic standard and advanced reporting.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Machine learning based COVID-19 study performance prediction
PDF
Assigned Numbers - 2025 - Bluetooth® Document
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
sap open course for s4hana steps from ECC to s4
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Chapter 3 Spatial Domain Image Processing.pdf
Cloud computing and distributed systems.
NewMind AI Weekly Chronicles - August'25-Week II
20250228 LYD VKU AI Blended-Learning.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Approach and Philosophy of On baking technology
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Electronic commerce courselecture one. Pdf
Review of recent advances in non-invasive hemoglobin estimation
cuic standard and advanced reporting.pdf
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
Machine learning based COVID-19 study performance prediction
Assigned Numbers - 2025 - Bluetooth® Document

Teaching Graph Algorithms in the Field - Bipartite Matching in optical datacenters

  • 1. © 2014 IBM Corporation Bipartite Matching and Optical Clouds - what? Kostas Katrinis Guest Lecture – CS2012 Programming Techniques Trinity College Dublin April 14, 2014
  • 2. © 2014 IBM Corporation2 Outline • Scope & Background • Motivation & Challenges • Hybrid Network Architecture • MEMS Optical Switch Operation Brief • Bipartite Graphs • Matchings • Make the connection! • Hungarian Algorithm Part I - Introduction Part II – Modeling Part III – Theory & Algorithm
  • 3. © 2014 IBM Corporation3 Scope Part I - Background • Target Markets – (Cloud) Datacenters - Θ(10K) Servers – HPC Clusters (82% in Nov'12 Top-500) • Target Systems: – Data Network Fabric
  • 4. © 2014 IBM Corporation4 DC Traffic Trends • 76% of the traffic is intra-datacenter * • Total DC traffic CAGR 33% to 2015 * • Traffic percentage exiting the rack is high (up to 90%) ** – ...and we expect it to increase (scale-out workloads) * Cisco Global Cloud Index: Forecast and Methodology, 2011–2016 ** Benson et al., “Network Traffic Characteristics of Data Centers in the Wild”, IMC'10 Part I - Background
  • 5. © 2014 IBM Corporation5 Design Trade-offs (Performance) Performance Cost Highly oversubcr. High Bisection Trade-off • We need high-capacity between any two points in the DC • and at various scales (incremental deployment) • ... we need $$$ Part I - Background
  • 6. © 2014 IBM Corporation6 Motivating Example Item Item List Price (USD)** Qty Total List Price (USD) BNT G8264 (64-port switch) 30,000 5,120 153,600,000 BNT SFP+ SR Transceiver 665 262,164 174,325,760 MM Fiber Cable 28 131,072 3,670,016 Estimated List Prices **Source: ibm.com Fabric Price 331M USD ≈ Compute Price (@5K/server) • Full-bisection fat-tree @ 65k servers • Building block: 64-port Ethernet switches (ala VL2*) • Denser switches will not help you (e.g. 288-port Mellanox Vantage) Greenberg et al., “VL2: A Scalable and Flexible Data Center Network”, SIGCOMM 2009 Part I - Background
  • 7. © 2014 IBM Corporation7 Motivating Example (cont.) Total Price 331m USD AND..... #Cables to route 131,000 Can you count the birds in this nest? Part I - Background
  • 8. © 2014 IBM Corporation8 Paradigm Shift - Switch Light Tiltable Mirrors implemented via MEMS (Micro-Electrical Mechanical Systems) + High-radix (320 ports you can buy, 1024 feasible) + No transceivers + Decreasing $/port + 50x less Watts/port vs. electronics + Can switch up to ~1Tbps + Protocol Agnostic Electronic Switch (Ethernet) Optical MEMS switch Price/Port (USD) 1100 (includes TxRx cost) 350 Bandwidth/Port 10Gbps “Rate-free” Power/Port (W) 10 0.2 Requires TxRxs Yes No x3 x∞ x50 Part I - Background
  • 9. © 2014 IBM Corporation9 Hybrid Fabric Architecture Part I - Architecture
  • 10. © 2014 IBM Corporation10 Dublin Prototype - Photos Single-mode fiber links, 25m length, 10GBASE-LR 96x96-Port 3D-MEMS Switch Shamrock Server Rack, Chelsio T4 NIC cards G8264 TOR Switch Redirect traffic from over-subscribed electrical network to optical circuits.  Packet forwarding removes bandwidth limitation of over-subscribed electrical network. Max. Latency <13 ns Part I - Architecture
  • 11. © 2014 IBM Corporation11 High-level Functionality • Bijective TE: – Mice are routed via the 1G electronic fabric – Elephants are routed via the 10G optical fabric Optical Fabric is reconfigurable – Centralized control optimizes topology against traffic pattern and demand volume Part I - Architecture
  • 12. © 2014 IBM Corporation12 Optical MEMS Switch Part II – MEMS Switch • Focus on the “Optical MEMS Switch” • NxN ports (N inputs to connect to N outputs) • Each input port is dynamically “crossconnected” to at most one output port based on the rack pair we need to connect (decide every X seconds) • E.g. Crossconnect port-13 to port-45 to connect rack-2 with rack-5 above
  • 13. © 2014 IBM Corporation13 Bipartite Graphs Definition (Bipartite Graphs) G=(V,E) is bipartite if we can partition its vertex set V to two disjoing sets X and Y, s.t. there are no edges between X and Y. We say that (X,Y) is a bipartion of G. Note: During this lecture, we will constrain our focus for the sake of understanding to undirected graphs. Applying the concepts to directed graphs as food for thought. Part II – Bipartite
  • 14. © 2014 IBM Corporation14 Matchings Definition (Matching) A matching M of a graph G=(V,E) is a set of edges of G such that no two edges in M share a common vertex. • If a vertex u is matched by M, then we say that u is saturated by M. Otherwise, a vertex u is unsaturated by M Example: In M1, v2 is saturated, whereas v1 is unsaturated Part II – Matchings
  • 15. © 2014 IBM Corporation15 Maximum Matchings • Greediness strikes back: we want a matching to have as many edges as possible Definition (Maximum Matching) A matching M of a graph G=(V,E) is a maximum matching if no matching in G has more edges. Example: M2 is a maximum matching (|G|=8 and |M2|=4). Since |M1|=3, M1 is not maximum. Part II – Matchings
  • 16. © 2014 IBM Corporation16 Technology ↔ Theory: Connection Part II – Model
  • 17. © 2014 IBM Corporation17 Maximum Matching – Optical Switch • Remember that our Greediness keeps striking back, can't get rid of it! • If we find a maximum matching (maximum number of edges), then we have maximized the number of crossconnections in our optical switch • .... thus we have maximized throughput (aggregate bandwidth that crosses the optical switch) Part II – Model
  • 18. © 2014 IBM Corporation18 Maximum Matching in Bipartite Graphs • So this is what we need (see title above) to maximize utilization of our optical switch. We need an algorithm to find a maximum matching on a bipartite graph. But how? Some theory first (and more definitions) Definition (Alternating and Augmenting Paths) Let G=(V,E) have a matching M. An alternating path P with respect to M is any path whose edges are alternately in M and not in M (E-M). If the start and end vertices of P are not saturated by M, then P is an augmenting path. Example: P= (v1,v2,v3,v4,v5) is an alternating path P'= (v1,v2,v3,v4,v5,v6) is an augmenting path Part III – T&A
  • 19. © 2014 IBM Corporation19 Matching expansion Definition (Symmetric Difference) Let E and E' be two edge sets. Then we define as the symmetric difference M=E ◘ E' of the two sets the operation M = (E-E') U (E'-E) = (E U E') – (E ∩ E') • Let G and M a matching (see below). P = (v1,v2,v3,v4,v5,v6) is an augmentic path. E(P) are the edges of P. • |M|=3 • Define M' = M ◘ E(P) • Observe: |M'|=4 … wow! We obtained a larger matching M' starting from a non-maximum one (M) Part III – T&A
  • 20. © 2014 IBM Corporation20 Expansion Lemma Lemma –1 (Matching Expansion) Let G have a matching M and let P be an augmenting path with respect to M. Then M' = M ◘ E(P) is a matching with one more edge than M – or equivalently – |M'|=|M|+1. Proof M' contains all the edges of M, plus all the edges in E(P) that are not in M. Thus M' is per construction a matching of G. Let u and v be the start and end vertices of P. Then u and v are unsaturated in M, because P is an augmenting path. Because of the symmetric difference operator, u and v are now saturated in M'. The rest of the edges of M that were not in E(P) are still in M'. Thus, |M'|=|M|+1 Part III – T&A
  • 21. © 2014 IBM Corporation21 Berge's Theorem Theorem-1 (Berge's Theorem) A matching M in G is maximum if and only if G has no augmenting path with respect to M. Proof Left as an exercise (aka we don't have the time budget in class :-)). Reference Textbook has a rigorous, easy-to-follow proof • Theorems and lemmas are tools to an end. Let's use them! • Back to our goal: We need an algorithm to find a maximum matching on a bipartite graph • Strategy: 1) Start with an arbitrary (even empty) matching M. If M is not maximum, there will be an unsaturated vertex u. 2) Follow alternating paths from u until we identify another unsaturated vertex v. Then the u-v path P is an augmentic path. 3) Set M'=M ◘ E(P). By the expansion Lemma, M' is a larger matching. 4) Repeat Part III – T&A
  • 22. © 2014 IBM Corporation22 Hungarian Algorithm - Preliminaries Data Structures • Integer Match[n]; // n is the number of vertices or n=|V| of G=(V,E) – i.e. Match[u]=v if the matching matches vertex u to vertex v for all u in V • Default: Match[u]=0 if u is unsaturated (not matched) by the matching • For Breadth-First-Search (BFS) we use Integer PrevPt[n] – i.e. PrevPt[u]=v indicates that v is a parent of u in the BFS tree • Alternating Paths: we use a combination of Match and PrevPt data structures to store alternating paths. Example: P = (u, v2, v6, v3, v8) • List S in X of vertices that are reachable from a vertex u in X using alternate paths • List NS in Y of vertices that are reachable from a vertex u in X using alternate paths Part III – T&A PrevPt(v3) PrevPt(v2) Match(v6) Match(v8)
  • 23. © 2014 IBM Corporation23 Algorithm-1 (Augment subroutine) Augment (y) // Input: y is the end vertex of the augmenting path // Output: augments the edges along the augmenting path “in place” repeat w = PrevPt[y] Match[y] = w u = Match[w] Match[w]=y y=u until y=0 //reached root of BFS tree ie start vertex of augm.            //path Part III – T&AHungarian Algorithm - Augmenting
  • 24. © 2014 IBM Corporation24 Part III – T&AHungarian Algorithm – Augm. Example y w v u augment(y) rep.1 w = PrevPt[y] Match[y] = w v = Match[w] Match[w]=y y=v rep.2 w = PrevPt[y] Match[y] = w v = Match[w] Match[w]=y y=v Augmenting Path
  • 25. © 2014 IBM Corporation25 Algorithm-2 (Maximum Matching of Graph G with bipartition (X,Y) and n vert.) for i=1 to n do Match[i]=0 //init for each u in X do {   S.append(u);   for i=1 to n do PrevPt[i]=0; //BFS rooted at u    k=1;    repeat x = S[k]; for each y adjacent to x do {          if y not in NS {            NS.append(y);            PrevPt[y]=x;            if y is unsaturated {              // found augmented path!!!              augment(y);              go to 1; // we saturated u            } else S.append(Match[y]); // continue building the BFS tree          }      }      k = k+1;     until k > S.size(); // BFS rooted at u is now built out, no saturation :­(     Remove S and NS from the graph }  Part III – T&AHungarian Algorithm
  • 26. © 2014 IBM Corporation26 Part III – T&AHungarian Algorithm – Example (1)
  • 27. © 2014 IBM Corporation27 Part III – T&AHungarian Algorithm – Example (2)
  • 28. © 2014 IBM Corporation28 Food for Thought and Further Reading Kocay and Kreher, “Graphs, Algorithms, and Optimization (Discrete Mathematics and Its Applications)”, Chapman and Hall/CRC How about faster algorithms? Hints: ● Hopcroft-Karp Algorithm ● Edmond's Algorithm How about weighted demand (instead of edges with implied unit demands)? Intellectually appealing: ● Prove that Algorithm 2 finds indeed a maximum matching ● Prove that the Hungarian Algorithm is O(n3 )
  • 29. © 2014 IBM Corporation29 THANK YOU! Q&A