group_degree#
- graph_tool.centrality.group_degree(g, group, mode='out')[git][source]#
Calculate the degree centrality of a group of vertices.
- Parameters:
- g
Graph Graph to be used.
- grouplist or
numpy.ndarray Vertices of the group.
- mode
str(optional, default:"out") For directed graphs, the neighbors that are counted:
"out","in", or"total"(both). It is ignored for undirected graphs.
- g
- Returns:
- GD
float The group degree centrality.
- GD
See also
group_betweennessGroup betweenness centrality
group_closenessGroup closeness centrality
Notes
The group degree [everett-centrality-1999] of a group \(C\) is the fraction of the vertices outside the group that are neighbors of at least one vertex of the group,
\[C_D(C) = \frac{|N(C)\setminus C|}{n - |C|},\]where \(N(C)\) is the set of the out-neighbors of the vertices of \(C\) (their in-neighbors, or both, according to
mode, for directed graphs), and the value is zero if the group contains all vertices. It takes time \(O(V + E)\).References
[everett-centrality-1999]M. G. Everett and S. P. Borgatti, “The centrality of groups and classes”, The Journal of Mathematical Sociology 23, 181-201 (1999), DOI: 10.1080/0022250X.1999.9990219 [sci-hub, @tor]
Examples
>>> g = gt.collection.data["karate"] >>> print(gt.group_degree(g, [0, 33])) 0.90625