Compute the average degree connectivity of graph.
The average degree connectivity is the average nearest neighbor degree of nodes with degree k. For weighted graphs, an analogous measure can be computed using the weighted average neighbors degree defined in [R145], for a node , as:
where is the weighted degree of node , and , and are the neighbors of node .
Parameters : | G : NetworkX graph nodes: list or iterable (optional) :
weighted: bool (default=False) :
|
---|---|
Returns : | d: dict :
|
See also
neighbors_average_degree
Notes
This algorithm is sometimes called “k nearest neighbors’.
References
[R145] | (1, 2) A. Barrat, M. Barthélemy, R. Pastor-Satorras, and A. Vespignani, “The architecture of complex weighted networks”. PNAS 101 (11): 3747–3752 (2004). |
Examples
>>> G=nx.path_graph(4)
>>> G.edge[1][2]['weight'] = 3
>>> nx.k_nearest_neighbors(G)
{1: 2.0, 2: 1.5}
>>> nx.k_nearest_neighbors(G, weighted=True)
{1: 2.0, 2: 1.75}