def _apply_prediction(G, func, ebunch=None):
    """
    Applies the given function to each edge in the specified iterable of edges.

    Parameters
    ----------
    G : graph
        A NetworkX graph.
    func : function
        A function on two inputs, each of which is a node in the graph. Can return anything,
        but it should return a value representing a prediction of the likelihood of a "link" joining the two nodes.
    ebunch : iterable, optional
        An iterable of pairs of nodes. If not specified, all edges in the graph G will be used.

    Returns
    -------
    sim : list
        A list of values in the same order as ebunch representing the similarity of each pair of nodes.
    """
    if ebunch is None:
        ebunch = list(G.edges)
    return list(map(lambda e: func(e[0], e[1]), ebunch))
