def bfs_matching(A):
    '\n    Returns an array of row permutations that removes nonzero elements\n    from the diagonal of a nonsingular square CSC sparse matrix.  Such\n    a permutation is always possible provided that the matrix is \n    nonsingular.\n    \n    This function looks at the structure of the matrix only.\n    \n    Parameters\n    ----------\n    A : csc_matrix\n        Input matrix\n    \n    Returns\n    -------\n    perm : array\n        Array of row permutations.\n    \n    Notes\n    -----\n    This function relies on a maximum cardinality bipartite matching algorithm\n    based on a breadth-first search (BFS) of the underlying graph[1]_.\n    \n    References\n    ----------\n    .. [1] I. S. Duff, K. Kaya, and B. Ucar, "Design, Implementation, and \n    Analysis of Maximum Transversal Algorithms", ACM Trans. Math. Softw.\n    38, no. 2, (2011).\n    \n    '
    nrows = A.shape[0]
    if (A.shape[0] != A.shape[1]):
        raise ValueError('bfs_matching requires a square matrix.')
    if (A.__class__.__name__ == 'Qobj'):
        A = A.data.tocsc()
    elif (not sp.isspmatrix_csc(A)):
        A = sp.csc_matrix(A)
        warn('bfs_matching requires CSC matrix format.', sp.SparseEfficiencyWarning)
    perm = _bfs_matching(A.indices, A.indptr, nrows)
    if np.any((perm == (- 1))):
        raise Exception('Possibly singular input matrix.')
    return perm
Returns an array of row permutations that removes nonzero elements
from the diagonal of a nonsingular square CSC sparse matrix.  Such
a permutation is always possible provided that the matrix is 
nonsingular.

This function looks at the structure of the matrix only.

Parameters
----------
A : csc_matrix
    Input matrix

Returns
-------
perm : array
    Array of row permutations.

Notes
-----
This function relies on a maximum cardinality bipartite matching algorithm
based on a breadth-first search (BFS) of the underlying graph[1]_.

References
----------
.. [1] I. S. Duff, K. Kaya, and B. Ucar, "Design, Implementation, and 
Analysis of Maximum Transversal Algorithms", ACM Trans. Math. Softw.
38, no. 2, (2011).
def bfs_matching(A):
    '\n    Returns an array of row permutations that removes nonzero elements\n    from the diagonal of a nonsingular square CSC sparse matrix.  Such\n    a permutation is always possible provided that the matrix is \n    nonsingular.\n    \n    This function looks at the structure of the matrix only.\n    \n    Parameters\n    ----------\n    A : csc_matrix\n        Input matrix\n    \n    Returns\n    -------\n    perm : array\n        Array of row permutations.\n    \n    Notes\n    -----\n    This function relies on a maximum cardinality bipartite matching algorithm\n    based on a breadth-first search (BFS) of the underlying graph[1]_.\n    \n    References\n    ----------\n    .. [1] I. S. Duff, K. Kaya, and B. Ucar, "Design, Implementation, and \n    Analysis of Maximum Transversal Algorithms", ACM Trans. Math. Softw.\n    38, no. 2, (2011).\n    \n    '
    nrows = A.shape[0]
    if (A.shape[0] != A.shape[1]):
        raise ValueError('bfs_matching requires a square matrix.')
    if (A.__class__.__name__ == 'Qobj'):
        A = A.data.tocsc()
    elif (not sp.isspmatrix_csc(A)):
        A = sp.csc_matrix(A)
        warn('bfs_matching requires CSC matrix format.', sp.SparseEfficiencyWarning)
    perm = _bfs_matching(A.indices, A.indptr, nrows)
    if np.any((perm == (- 1))):
        raise Exception('Possibly singular input matrix.')
    return perm