generalized_degree

generalized_degree#

graph_tool.clustering.generalized_degree(g, prop=None)[git][source]#

Return the generalized degree of the vertices.

Parameters:
gGraph

Graph to be used. If it is directed, it is treated as undirected.

propVertexPropertyMap (optional, default: None)

Vertex property map of type vector<int64_t> where results will be stored.

Returns:
propVertexPropertyMap

Vertex property map of type vector<int64_t>, where prop[v][t] is the number of edges of vertex v that belong to exactly t triangles.

See also

local_clustering

Local clustering coefficient

edge_clustering

Edge clustering coefficient

Notes

The generalized degree [zlatic-networks-2012] of vertex \(v\) is the vector \((k^{(0)}_v, k^{(1)}_v, \dots)\), where \(k^{(t)}_v\) is the number of edges \((v,u)\) whose endpoints have \(t\) common neighbors, i.e. which belong to \(t\) triangles. Its sum is the number of neighbors of \(v\), and the number of triangles that contain \(v\) is \(\sum_t t k^{(t)}_v / 2\). The vector of every vertex ends at the largest \(t\) among its edges, so that it is empty for isolated vertices. Parallel edges and self-loops are ignored.

The algorithm runs in time \(O(\sum_v\sum_{u\in N_v}k_u)\).

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.

References

[zlatic-networks-2012]

Vinko Zlatić, Diego Garlaschelli and Guido Caldarelli, “Networks with arbitrary edge multiplicities”, EPL 97, 28005 (2012), DOI: 10.1209/0295-5075/97/28005 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["karate"]
>>> gdeg = gt.generalized_degree(g)
>>> print(list(gdeg[0]))
[2, 5, 4, 2, 0, 2, 0, 1]