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 [R116], for a node , as:
where is the weighted degree of node , is the weight of the edge that links and , and are the neighbors of node .
Parameters : | G : NetworkX graph source : “in”|”out”|”in+out” (default:”in+out”)
target : “in”|”out”|”in+out” (default:”in+out”
nodes: list or iterable (optional) :
weight : string or None, optional (default=None)
|
---|---|
Returns : | d: dict :
|
See also
neighbors_average_degree
Notes
This algorithm is sometimes called “k nearest neighbors’.
References
[R116] | (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, weight='weight')
{1: 2.0, 2: 1.75}