def symmetric_rcm(A):
    """Symmetric Reverse Cutthill-McKee.

    Parameters
    ----------
    A : sparse matrix
        Sparse matrix

    Returns
    -------
    B : sparse matrix
        Permuted matrix with reordering

    Notes
    -----
    Get a pseudo-peripheral node, then call BFS

    Examples
    --------
    >>> from pyamg import gallery
    >>> from pyamg.graph import symmetric_rcm
    >>> n = 200
    >>> density = 1.0/n
    >>> A = gallery.sprand(n, n, density, format='csr')
    >>> S = A + A.T
    >>> # try the visualizations
    >>> import matplotlib.pyplot as plt
    >>> plt.figure()
    >>> plt.subplot(121)
    >>> plt.spy(S,marker='.')
    >>> plt.subplot(122)
    >>> plt.spy(symmetric_rcm(S),marker='.')

    See Also
    --------
    pseudo_peripheral_node

    """
    n = A.shape[0]

    root, order, level = pseudo_peripheral_node(A)

    Perm = sparse.identity(n, format='csr')
    p = level.argsort()
    Perm = Perm[p, :]

    return Perm * A * Perm.T
def symmetric_rcm ( A ) : n = A . shape [ 0 ] root , order , level = pseudo_peripheral_node ( A ) Perm = sparse . identity ( n , format = 'csr' ) p = level . argsort ( ) Perm = Perm [ p , : ] return Perm * A * Perm . T
Symmetric Reverse Cutthill-McKee.

    Parameters
    ----------
    A : sparse matrix
        Sparse matrix

    Returns
    -------
    B : sparse matrix
        Permuted matrix with reordering

    Notes
    -----
    Get a pseudo-peripheral node, then call BFS

    Examples
    --------
    >>> from pyamg import gallery
    >>> from pyamg.graph import symmetric_rcm
    >>> n = 200
    >>> density = 1.0/n
    >>> A = gallery.sprand(n, n, density, format='csr')
    >>> S = A + A.T
    >>> # try the visualizations
    >>> import matplotlib.pyplot as plt
    >>> plt.figure()
    >>> plt.subplot(121)
    >>> plt.spy(S,marker='.')
    >>> plt.subplot(122)
    >>> plt.spy(symmetric_rcm(S),marker='.')

    See Also
    --------
    pseudo_peripheral_node