Content deleted Content added
→Algorithm: The introduction should correctly describe the algorithm |
→Algorithm: Copied the algorithm from the discussion page |
||
Line 23:
The algorithm is run in phases. Each phase consists of:
* A BFS is run from free U vertices. This BFS stops at
* Find a maximal set of
''Pseudo Code''
for all <math>q\in U \cup V</math>
q.matching= null;
end for
while (true)
// Find all potential beginnings of shortest augmenting paths
B := empty;
for all u:U s.t. (u.matching = null)
insert u in B;
end for
// Find all endings of shortest augmenting paths
F := Find_Augmenting_Path_Endings(B);
if (F is empty)
M:= empty;
for all u:U s.t. (u.matching ≠ null)
insert (u, u.matching) in M; // insert edge
end for
return M;
end if
Augment_Paths(F);
end while
// Perform BFS starting with vertices of B.
// '''Return''': a list of free vertices which potentially
// end the shortest vertex-disjoint augmenting paths.
// '''Side effect''': For any vertex v.layer has the index of
// the BFS layer to reach this vertex (or -1)
// '''B''': potential beginning of augmenting paths
Find_Augmenting_Path_Endings(B):
// F: The set of free endings (the other side of augmenting paths)
F := empty;
for all <math>q\in U \cup V</math>
q.layer:=-1;
end for
// The potential beginnings of augmenting paths are at layer 0.
for all b:B
b.layer:=0;
end for
while (Q is not empty)
Q' := empty;
for all q: Q
for
if (p.matching
insert p in F; // Collect the free vertex, continue BFS
else
end
end for
if (F is not empty)
return F; // Free vertices found, stop at this layer.
end if
Q:= empty;
for all
// By
p.layer:= q.layer+1;
insert p in Q;
end for
end while
return
Augment_Paths(F):
for all <math>q\in U \cup V</math>
q.visited= false;
end for
P:=Get_Augmenting_Path(q);
// Make sure q ends a ''vertex-disjoint'' augmenting path
if (P is not empty)
// Perform <math> M := M\oplus P </math>
odd := true;
for all (t,q):P
if (odd)
// Make (t,q) match (first, third, ... edges)
p.matching := q;
q.matching := t;
odd := false;
else
// t.matching has already been updated by the ''odd'' condition
q.matching := null; // This is not strictly required
odd := true;
end if
end for
end if
end for
// DFS from p, avoiding previously visited vertices.
// Start at the last layer of BFS, and go backwards
// to layer 0.
Get_Augmenting_Path(p):
if (p.visited)
return empty;
end if
p.visited:= true;
if (p.layer = 0) // layer 0 has free vertices.
return (p);
end if
// Consider only edges going one layer backwards.
for all (q,p):E such that p.layer+1=q.layer
P= Get_Augmenting_Path(q);
if (P not empty)
return (q, P); // Prepend q to the path found so far.
end if
end for
// Could not find a vertex-disjoint augmenting path ending with p.
return empty;
== References ==
|