def dominant_flip_flopping(W):
    """Determine if a unique walk matrix demonstrates dominant flip-flopping.

    Dominant flip-flopping is defined as:
    For every class C[i], there exists a walk length L[x], such that C[i] has
    more closed walks of length L[x] than all other classes combined.

    Dominant flip-flopping implies all-subset flip-flopping.

    Parameters
    ----------
    W : Numpy Matrix
        Unique walk matrix as returned by `walk_classes`

    Returns
    -------
    boolean
        True if dominant flip-flopping holds for `W`
    """
    # Work with an ndarray representation of W
    w = W.getA()

    # Get the number of rows and columns in W
    num_rows, num_cols = w.shape

    # Generate the column-wise sum of w
    # This amounts to a 1darray where each item
    # is the sum of all walks of a length k for
    # all classes
    sums = w.sum(0)

    # Iterate over all classes
    for cls in range(0, num_rows):

        # Whether this class dominates any k-walk
        is_dominant = False

        # Iterate over all walks
        for walk in range(0, num_cols):

            # Check to see if is dominant
            # Sums includes the number of walks for the class
            # so it must be removed before checking that it
            # dominates the remainder
            if w[cls][walk] > sums[walk] - w[cls][walk]:
                is_dominant = True
                break

        # Return false immediately if this class does
        # not dominate a k-walk
        if not is_dominant:
            return False

    # Return true as default
    return True