def each_class_max(W):
    """Determine if a unique walk matrix demonstrates each class max.

    Each class max is defined as:

    For each class C[i] in W there exists a walk length L[x] such that
    C[i] has larger number of walks of length L[x] than all other classes.

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

    Returns
    -------
    boolean
        True if each-class-max holds, false if not
    """
    # 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

    # Possible classes
    classes = [i for i in range(0, num_rows)]

    # Possible walks
    walks = [i for i in range(0, num_cols)]

    # Check all classes
    for cls in classes:

        # Whether class has a max
        has_max = False

        # Check all walks
        for walk in walks:

            # Find maximum of other classes for same walk
            maximum = max([w[cls2][walk] for cls2 in classes if cls2 != cls])

            # Set has max to true if number of walks is greater
            if w[cls][walk] > maximum:
                has_max = True
                break

        # If not max for some length return false
        if not has_max:
            return False

    # Return true if property is not violated
    return True