corr_hist

Contents

corr_hist#

graph_tool.correlations.corr_hist(g, deg_source, deg_target, bins=[[0, 1], [0, 1]], weight=None, float_count=True)[source]#

Obtain the correlation histogram for the given graph.

Parameters:
gGraph

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 of lists (optional, default: [[0, 1], [0, 1]])

A list of bin edges to be used for the source and target degrees. If any list has size 2, it is used to create an automatically generated bin range starting from the first value, and with constant bin width given by the second value.

weightedge property map (optional, default: None)

Weight (multiplicative factor) to be used on each edge.

float_countbool (optional, default: True)

If True, the bin counts are converted float variables, which is useful for normalization, and other processing. It False, the bin counts will be unsigned integers.

Returns:
bin_countsnumpy.ndarray

Two-dimensional array with the bin counts.

source_binsnumpy.ndarray

Source degree bins

target_binsnumpy.ndarray

Target degree bins

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 correlation histogram counts, for every vertex with degree (or scalar property) ‘source_deg’, the number of out-neighbors with degree (or scalar property) ‘target_deg’.

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.corr_hist(g, "out", "out")
>>> clf()
>>> xlabel("Source out-degree")
Text(...)
>>> ylabel("Target out-degree")
Text(...)
>>> imshow(h[0].T, interpolation="nearest", origin="lower")
<...>
>>> colorbar()
<...>
>>> savefig("corr.svg")
../_images/corr.svg

Out/out-degree correlation histogram.#