cut_size

Contents

cut_size#

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

Return the size of the cut between two sets of vertices.

Parameters:
gGraph

Graph to be used.

Siterable of int or VertexPropertyMap

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

Titerable of int or VertexPropertyMap (optional, default: None)

Second set of vertices. If not given, the complement of S is used.

weightEdgePropertyMap (optional, default: None)

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

Returns:
cutfloat

The total weight of the edges between S and T.

See also

volume

Total degree of a set of vertices

conductance

Cut size normalized by the smaller volume

normalized_cut_size

Cut size normalized by both volumes

edge_boundary

Edges of the cut

graph_tool.flow.minimum_cut

Minimum cut

Notes

The cut size is

\[c(S, T) = \sum_{\{u,v\}\in E,\, u\in S,\, v\in T} w_{uv},\]

the total weight of the edges with one endpoint in \(S\) and the other in \(T\); for directed graphs, the edges in both directions are counted. This and the other cut and expansion measures (volume(), conductance(), normalized_cut_size(), edge_expansion(), vertex_expansion(), boundary_expansion(), and mixing_expansion()) are described in [gleich-hierarchical-2005], and are computed in time \(O(V + E)\).

References

[gleich-hierarchical-2005]

David Gleich, “Hierarchical directed spectral graph partitioning”, Information Networks (2005), https://www.cs.purdue.edu/homes/dgleich/publications/Gleich%202005%20-%20hierarchical%20directed%20spectral.pdf

Examples

>>> g = gt.collection.data["karate"]
>>> S = np.arange(17)
>>> print(gt.cut_size(g, S))
20.0