Reputation: 40982
I have some hard time to understand this graph quantity: networkx.algorithms.assortativity.average_degree_connectivity
average_neighbor_degree
returns a node id and its average_neighbor_degree:
d – A dictionary keyed by node with average neighbors degree value.
However, I can't understand what average_degree_connectivity
is? It returns:
d – A dictionary keyed by degree k with the value of average connectivity.
For example, for three graphs the average_degree_connectivity
vs. average neighbors degree value.
look as follows. What does average neighbors degree value.
mean?
average_degree_connectivity
represent?average_neighbor_degree
related to average_degree_connectivity
?Upvotes: 1
Views: 2753
Reputation: 1029
It makes sense to answer your questions the other way round:
v
be a vertex with m
neighbors. The average_neighbor_degree
of v
is simply the sum of its neighbors' degrees divided by m
.For the average_degree_connectivity
, this is the important part of the definition:
... is the average nearest neighbor degree of nodes with degree k
So for all the different degrees that occur in the graph, it gives the average of the average_neighbor_degree
of all nodes with the same degree. It is a measure of how connected nodes with certain degrees are.
That are many averages, I hope this snippet clarifies question 2:
import networkx as nx
from collections import defaultdict
G = nx.karate_club_graph()
avg_neigh_degrees = nx.algorithms.assortativity.average_neighbor_degree(G)
deg_to_avg_neighbor_degrees = defaultdict(list)
for node, degree in nx.degree(G):
deg_to_avg_neighbor_degrees[degree].append(avg_neigh_degrees[node])
# this is the same as nx.algorithms.assortativity.average_degree_connectivity(G)
avg_degree_connectivity = {degree: sum(vals)/len(vals) for degree, vals in
deg_to_avg_neighbor_degrees.items()}
Upvotes: 3