A cut of a given graph.
This is a simple class used to represent cuts returned by Graph.mincut() , Graph.all_st_cuts() and other functions that calculate cuts.
A cut is a special vertex clustering with only two clusters. Besides the usual VertexClustering methods, it also has the following attributes:
- value - the value (capacity) of the cut. It is equal to the number of edges if there are no capacities on the edges.
- partition - vertex IDs in the parts created after removing edges in the cut
- cut - edge IDs in the cut
- es - an edge selector restricted to the edges in the cut.
You can use indexing on this object to obtain lists of vertex IDs for both sides of the partition.
This class is usually not instantiated directly, everything is taken care of by the functions that return cuts.
Examples:
>>> from igraph import Graph >>> g = Graph.Ring(20) >>> mc = g.mincut() >>> print(mc.value) 2.0 >>> print(min(len(x) for x in mc)) 1 >>> mc.es["color"] = "red"
__init__
Initializes the cut.
__repr__
Undocumented
__str__
Undocumented
cut
Returns the edge IDs in the cut
es
Returns an edge selector restricted to the cut
partition
Returns the vertex IDs partitioned according to the cut
value
Returns the sum of edge capacities in the cut
_cut
Undocumented
_partition
Undocumented
_value
Undocumented
Inherited from VertexClustering :
FromAttribute
Creates a vertex clustering based on the value of a vertex attribute.
__plot__
Plots the clustering to the given Cairo context or matplotlib Axes.
as_cover
Returns a VertexCover that contains the same clusters as this clustering.
cluster_graph
Returns a graph where each cluster is contracted into a single vertex.
crossing
Returns a boolean vector where element i is True iff edge i lies between clusters, False otherwise.
giant
Returns the largest cluster of the clustered graph.
recalculate_modularity
Recalculates the stored modularity value.
subgraph
Get the subgraph belonging to a given cluster.
subgraphs
Gets all the subgraphs belonging to each of the clusters.
graph
Returns the graph belonging to this object
modularity
Returns the modularity score
_formatted_cluster_iterator
Iterates over the clusters and formats them into a string to be presented in the summary.
_recalculate_modularity_safe
Recalculates the stored modularity value and swallows all exceptions raised by the modularity function (if any).
_default_palette
Undocumented
_graph
Undocumented
_modularity
Undocumented
_modularity_dirty
Undocumented
_modularity_params
Undocumented
Inherited from Clustering (via VertexClustering ):
__getitem__
Returns the members of the specified cluster.
__iter__
Iterates over the clusters in this clustering.
__len__
Returns the number of clusters.
compare_to
Compares this clustering to another one using some similarity or distance metric.
size
Returns the size of a given cluster.
size_histogram
Returns the histogram of cluster sizes.
sizes
Returns the size of given clusters.
summary
Returns the summary of the clustering.
membership
Returns the membership vector.
n
Returns the number of elements covered by this clustering.
_len
Undocumented
_membership
Undocumented
igraph.VertexClustering.__init__ igraph.Flow Initializes the cut.
This should not be called directly, everything is taken care of by the functions that return cuts.
igraph.Flow Undocumented
Returns the edge IDs in the cut
Returns an edge selector restricted to the cut
Returns the vertex IDs partitioned according to the cut
Returns the sum of edge capacities in the cut
Undocumented
Undocumented
Undocumented