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:
- g
Graph Graph to be used.
- Siterable of
intorVertexPropertyMap First set of vertices, as a sequence of vertices or a Boolean vertex property map.
- Titerable of
intorVertexPropertyMap(optional, default:None) Second set of vertices. If not given, the complement of
Sis used.- weight
EdgePropertyMap(optional, default:None) Edge weights. If not given, every edge has weight one.
- g
- Returns:
- cut
float The total weight of the edges between
SandT.
- cut
See also
volumeTotal degree of a set of vertices
conductanceCut size normalized by the smaller volume
normalized_cut_sizeCut size normalized by both volumes
edge_boundaryEdges of the cut
graph_tool.flow.minimum_cutMinimum 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(), andmixing_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