#NEWLINE# @ not_implemented_for ( 'directed' ) #NEWLINE# @ not_implemented_for ( 'multigraph' ) #NEWLINE# def preferential_attachment( G , ebunch = None ) : #NEWLINE# #INDENT# "Compute the preferential attachment score of all node pairs in ebunch.\n\n    Preferential attachment score of `u` and `v` is defined as\n\n    .. math::\n\n        |\\Gamma(u)| |\\Gamma(v)|\n\n    where :math:`\\Gamma(u)` denotes the set of neighbors of `u`.\n\n    Parameters\n    ----------\n    G : graph\n        NetworkX undirected graph.\n\n    ebunch : iterable of node pairs, optional (default = None)\n        Preferential attachment score will be computed for each pair of\n        nodes given in the iterable. The pairs must be given as\n        2-tuples (u, v) where u and v are nodes in the graph. If ebunch\n        is None then all non-existent edges in the graph will be used.\n        Default value: None.\n\n    Returns\n    -------\n    piter : iterator\n        An iterator of 3-tuples in the form (u, v, p) where (u, v) is a\n        pair of nodes and p is their preferential attachment score.\n\n    Examples\n    --------\n    >>> import networkx as nx\n    >>> G = nx.complete_graph(5)\n    >>> preds = nx.preferential_attachment(G, [(0, 1), (2, 3)])\n    >>> for u, v, p in preds:\n    ...     '(%d, %d) -> %d' % (u, v, p)\n    ...\n    '(0, 1) -> 16'\n    '(2, 3) -> 16'\n\n    References\n    ----------\n    .. [1] D. Liben-Nowell, J. Kleinberg.\n           The Link Prediction Problem for Social Networks (2004).\n           http://www.cs.cornell.edu/home/kleinber/link-pred.pdf\n    " #NEWLINE# def predict( u , v ) : #NEWLINE# #INDENT# return ( G . degree ( u ) * G . degree ( v ) ) #NEWLINE# #UNINDENT# return _apply_prediction ( G , predict , G )