volume#
- graph_tool.structure.volume(g, S, weight=None)[git][source]#
Return the volume of a set of vertices.
- Parameters:
- g
Graph Graph to be used.
- Siterable of
intorVertexPropertyMap Set of vertices, as a sequence of vertices or a Boolean vertex property map.
- weight
EdgePropertyMap(optional, default:None) Edge weights. If not given, every edge has weight one.
- g
- Returns:
- vol
float The volume of
S.
- vol
See also
cut_sizeSize of the cut between two sets of vertices
conductanceCut size normalized by the smaller volume
Notes
The volume of a set \(S\) of vertices is
\[\mathrm{vol}(S) = \sum_{v\in S}\sum_{e\in\delta(v)} w_e,\]where \(\delta(v)\) is the set of edges incident to \(v\) (its out-edges, for directed graphs), i.e. the sum of the (weighted) degrees of its vertices, or of their out-degrees for directed graphs. The time is \(O(V + E)\).
Examples
>>> g = gt.collection.data["karate"] >>> print(gt.volume(g, [0, 1, 2])) 35.0