from networkx import get_edge_attributes


def uninformative_prediction(G, required_links):
    """
    Function to predict links in an uninformative manner, i.e., the majority
    parity. So, if there are more positive links that negative links, then a
    positive link is predicted and vice-versa

    Args:
        G : Graph to consider as training data
        required_links : List of tuples (a, b) where (a, b) denotes the outgoing
                         edge from `a` to `b`.

    Returns:
        List of {+1, -1} based on the properties of the graph
    """
    edges_weights = list(get_edge_attributes(G, 'weight').values())
    edges_parity = [1 if w > 0 else -1 for w in edges_weights]
    if sum(edges_parity) > 0:
        return [1 for _ in required_links]
    else:
        return [-1 for _ in required_links]