avg_neighbor_corr#
- graph_tool.correlations.avg_neighbor_corr(g, deg_source, deg_target, bins=[0, 1], weight=None)[source]#
Obtain the average neighbor-neighbor correlation for the given graph.
- Parameters:
- g
Graph
Graph to be used.
- deg_sourcestring or
VertexPropertyMap
degree type (“in”, “out” or “total”) or vertex property map for the source vertex.
- deg_targetstring or
VertexPropertyMap
degree type (“in”, “out” or “total”) or vertex property map for the target vertex.
- binslist (optional, default: [0, 1])
Bins to be used for the source degrees. If the list has size 2, it is used as the constant width of an automatically generated bin range, starting from the first value.
- weightedge property map (optional, default: None)
Weight (multiplicative factor) to be used on each edge.
- g
- Returns:
- bin_avg
numpy.ndarray
Array with the deg_target average for the get_source bins.
- bin_dev
numpy.ndarray
Array with the standard deviation of the deg_target average for the get_source bins.
- bins
numpy.ndarray
Source degree bins,
- bin_avg
See also
assortativity
assortativity coefficient
scalar_assortativity
scalar assortativity coefficient
corr_hist
vertex-vertex correlation histogram
combined_corr_hist
combined single-vertex correlation histogram
avg_neighbor_corr
average nearest-neighbor correlation
avg_combined_corr
average combined single-vertex correlation
Notes
The average correlation is the average, for every vertex with degree (or scalar property) ‘source_deg’, the of the ‘target_deg’ degree (or scalar property) of its neighbors.
Parallel implementation.
If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.
Examples
>>> def sample_k(max): ... accept = False ... while not accept: ... k = np.random.randint(1,max+1) ... accept = np.random.random() < 1.0 / k ... return k ... >>> g = gt.random_graph(10000, lambda: sample_k(40), ... model="probabilistic-configuration", ... edge_probs=lambda i, j: (sin(i / pi) * sin(j / pi) + 1) / 2, ... directed=False, n_iter=100) >>> h = gt.avg_neighbor_corr(g, "out", "out") >>> clf() >>> xlabel("Source out-degree") Text(...) >>> ylabel("Target out-degree") Text(...) >>> errorbar(h[2][:-1], h[0], yerr=h[1], fmt="o") <...> >>> savefig("avg_corr.svg")