def influence(path, alpha=1):
    """
        given a sequence of edge types (ie up, down), return the influence of the path
        consisting of those edges
        The influence is defined as |E| + alpha * (# of alternating colored edges)
    """
    return len(path) + alpha * sum(
        pair[0] != pair[1] for pair in zip(path[:-1], path[1:])
    )