graph_tool.correlations.scalar_assortativity#

graph_tool.correlations.scalar_assortativity(g, deg, eweight=None)[source]#

Obtain the scalar assortativity coefficient for the given graph.

Parameters:
gGraph

Graph to be used.

degstring or VertexPropertyMap

Degree type (“in”, “out” or “total”) or vertex property map, which specifies the vertex scalar values.

eweightEdgePropertyMap (optional, default: None)

If given, this will specify the edge weights, otherwise a constant value of one will be used.

Returns:
scalar assortativity coefficienttuple of two floats

The scalar assortativity coefficient, and its variance.

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 scalar assortativity coefficient [newman-mixing-2003] tells in a concise fashion how vertices of different types are preferentially connected amongst themselves, and is defined by

\[r = \frac{\sum_{xy} xy(e_{xy} - a_x b_y)}{\sigma_a\sigma_b}\]

where \(a_x=\sum_ye_{xy}\) and \(b_y=\sum_xe_{xy}\), and \(e_{xy}\) is the fraction of edges from a vertex of type x to a vertex of type y.

The variance is obtained with the jackknife method.

If enabled during compilation, this algorithm runs in parallel.

References

[newman-mixing-2003]

M. E. J. Newman, “Mixing patterns in networks”, Phys. Rev. E 67, 026126 (2003), DOI: 10.1103/PhysRevE.67.026126 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["pgp-strong-2009"]
>>> g = gt.GraphView(g, directed=False)
>>> gt.scalar_assortativity(g, "out")
(0.026384932418..., 0.001213444270...)