volume

Contents

volume#

graph_tool.structure.volume(g, S, weight=None)[git][source]#

Return the volume of a set of vertices.

Parameters:
gGraph

Graph to be used.

Siterable of int or VertexPropertyMap

Set of vertices, as a sequence of vertices or a Boolean vertex property map.

weightEdgePropertyMap (optional, default: None)

Edge weights. If not given, every edge has weight one.

Returns:
volfloat

The volume of S.

See also

cut_size

Size of the cut between two sets of vertices

conductance

Cut 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