function [p,q,r,s] = dmperm(A)
%DMPERM Dulmage-Mendelsohn permutation.
%   p = DMPERM(A) returns a row permutation p so that if A is square and
%   has full rank, A(p,:) has nonzero diagonal elements.
%
%   [p,q,r,s] = DMPERM(A) finds a row permutation p and column permutation
%   q so that A(p,q) is in block upper triangular form.
%   The outputs r and s are integer-valued vectors describing the
%   boundaries of the blocks:
%
%     the kth block of A(p,q) has indices (r(k):r(k+1)-1,s(k):s(k+1)-1).  
%
%   When A is square and has full rank, r==s.
%
%   In graph theoretic terms, DMPERM finds a maximum-size matching in the
%   bipartite graph of A, and the diagonal blocks correspond to the strong
%   Hall components of that graph.  The output of DMPERM can also be used
%   to find the connected or strongly connected components of an undirected
%   or directed graph.   
%
%   See also SPRANK.

%   Copyright 1984-2004 The MathWorks, Inc. 
%   $Revision: 5.9.4.1 $  $Date: 2004/06/25 18:52:25 $

if nargout <= 1,
    p = sparsfun('dmperm',A);
elseif nargout == 2,
    [p,q] = sparsfun('dmperm',A);
elseif nargout == 3,
    [p,q,r] = sparsfun('dmperm',A);
else
    [p,q,r,s] = sparsfun('dmperm',A);
end;
