prominent_group#
- graph_tool.centrality.prominent_group(g, k, weight=None, exclude=None, norm=True, endpoints=False, greedy=False)[git][source]#
Find the group of vertices with the largest group betweenness centrality.
- Parameters:
- g
Graph Graph to be used.
- k
int Size of the group.
- weight
EdgePropertyMap(optional, default:None) Edge lengths. If not supplied, every edge has unit length.
- excludelist or
numpy.ndarray(optional, default:None) Vertices that cannot belong to the group.
- norm
bool(optional, default:True) Whether or not the returned value should be normalized.
- endpoints
bool(optional, default:False) If
True, the returned value includes the pairs in which one of the vertices belongs to the group.- greedy
bool(optional, default:False) If
True, the vertices are added greedily, in the order of largest increase of the group betweenness, instead of searching for the largest value.
- g
- Returns:
- GBC
float The group betweenness of the group, as computed by
group_betweenness().- group
numpy.ndarray The vertices of the group.
- GBC
See also
group_betweennessGroup betweenness centrality
voterankSelection of influential spreaders
Notes
The group of \(k\) vertices with the largest group betweenness (see
group_betweenness()), including the pairs in which one vertex belongs to the group, is found with the depth-first branch and bound search of [puzis-fast-2007], in which the group betweenness is updated successively as vertices are added to the group. This requires the distances, numbers of shortest paths, and path betweenness of all pairs of candidates, which are computed in time \(O(VE + VC^2)\), where \(C\) is the number of candidates, and memory \(O(VC)\), and every step of the search takes time \(O(C^2)\). The number of steps of the exact search can grow exponentially with \(k\), but the bounds prune most of them in practice; withgreedy == Truethere are only \(k\) steps.For disconnected graphs, the group with the largest value that includes the pairs with an endpoint in the group is not necessarily the one with the largest value that excludes them.
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
[puzis-fast-2007]Rami Puzis, Yuval Elovici, and Shlomi Dolev, “Fast algorithm for successive computation of group betweenness centrality”, Physical Review E 76, 056709 (2007), DOI: 10.1103/PhysRevE.76.056709 [sci-hub, @tor]
Examples
>>> g = gt.collection.data["karate"] >>> print(gt.prominent_group(g, 3)) (0.814372759..., array([ 0, 33, 32], dtype=uint64))
The group can be highlighted in a drawing of the network:
>>> gbc, group = gt.prominent_group(g, 3) >>> vcolor = g.new_vp("string", val="#cccccc") >>> for v in group: ... vcolor[v] = "#f28c8e" >>> gt.graph_draw(g, g.vp.pos, vertex_fill_color=vcolor, ... output="prominent_group-karate.pdf") <...>
Group of three vertices with the largest group betweenness in Zachary’s karate club network, in red.#