networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
common_neighbor_centrality(G, ebunch=None, alpha=0.8)

Compute the Common Neighbor and Centrality based Parameterized Algorithm(CCPA) score of all node pairs in ebunch.

CCPA score of u and :None:None:`v` is defined as

$$\alpha \cdot (|\Gamma (u){\cap }^{}\Gamma (v)|)+(1-\alpha )\cdot \frac{N}{{d}_{uv}}$$

where $\Gamma(u)$ denotes the set of neighbors of $u$, $\Gamma(v)$ denotes the set of neighbors of $v$, $\alpha$ is parameter varies between [0,1], $N$ denotes total number of nodes in the Graph and ${d}_{uv}$ denotes shortest distance between $u$ and $v$.

This algorithm is based on two vital properties of nodes, namely the number of common neighbors and their centrality. Common neighbor refers to the common nodes between two nodes. Centrality refers to the prestige that a node enjoys in a network.

.. seealso:: 
    :func:`common_neighbors`

Parameters

G : graph

NetworkX undirected graph.

ebunch : iterable of node pairs, optional (default = None)

Preferential attachment score will be computed for each pair of nodes given in the iterable. The pairs must be given as 2-tuples (u, v) where u and v are nodes in the graph. If ebunch is None then all non-existent edges in the graph will be used. Default value: None.

alpha : Parameter defined for participation of Common Neighbor

and Centrality Algorithm share. Values for alpha should normally be between 0 and 1. Default value set to 0.8 because author found better performance at 0.8 for all the dataset. Default value: 0.8

Returns

piter : iterator

An iterator of 3-tuples in the form (u, v, p) where (u, v) is a pair of nodes and p is their Common Neighbor and Centrality based Parameterized Algorithm(CCPA) score.

Return the CCPA score for each pair of nodes.

Examples

>>> G = nx.complete_graph(5)
... preds = nx.common_neighbor_centrality(G, [(0, 1), (2, 3)])
... for u, v, p in preds:
...  print(f"({u}, {v}) -> {p}") (0, 1) -> 3.4000000000000004 (2, 3) -> 3.4000000000000004
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.link_prediction.common_neighbor_centrality

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/algorithms/link_prediction.py#208
type: <class 'function'>
Commit: