average_degree_connectivity#
- average_degree_connectivity(G, source='in+out', target='in+out', nodes=None, weight=None)[source]#
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 [1], for a node
i
, as\[k_{nn,i}^{w} = \frac{1}{s_i} \sum_{j \in N(i)} w_{ij} k_j\]where
s_i
is the weighted degree of nodei
,w_{ij}
is the weight of the edge that linksi
andj
, andN(i)
are the neighbors of nodei
.- Parameters:
- GNetworkX graph
- sourceâinâ|âoutâ|âin+outâ (default:âin+outâ)
Directed graphs only. Use âinâ- or âoutâ-degree for source node.
- targetâinâ|âoutâ|âin+outâ (default:âin+outâ
Directed graphs only. Use âinâ- or âoutâ-degree for target node.
- nodeslist or iterable (optional)
Compute neighbor connectivity for these nodes. The default is all nodes.
- weightstring or None, optional (default=None)
The edge attribute that holds the numerical value used as a weight. If None, then each edge has weight 1.
- Returns:
- ddict
A dictionary keyed by degree k with the value of average connectivity.
- Raises:
- NetworkXError
If either
source
ortarget
are not one of âinâ, âoutâ, or âin+outâ. If eithersource
ortarget
is passed for an undirected graph.
See also
References
[1]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.edges[1, 2]["weight"] = 3 >>> nx.average_degree_connectivity(G) {1: 2.0, 2: 1.5} >>> nx.average_degree_connectivity(G, weight="weight") {1: 2.0, 2: 1.75}