List of all classes, functions and methods in python-igraph
Class representing a cover of an arbitrary ordered set.
Covers are similar to clusterings, but each element of the set may belong to more than one cluster in a cover, and elements not belonging to any cluster are also allowed.
Cover instances provide a similar API as
Clustering instances; for instance, iterating over a
Cover will iterate over the clusters just like with a regular
Clustering instance. However, they are not derived from each other or from a common superclass, and there might be functions that exist only in one of them or the other.
Clusters of an individual cover can be accessed by the
>>> cl = Cover([[0,1,2,3], [2,3,4], [0,1,6]]) >>> cl [0, 1, 2, 3]
The membership vector can be accessed by the
membership property. Note that contrary to
Clustering instances, the membership vector will contain lists that contain the cluster indices each item belongs to:
>>> cl.membership [[0, 2], [0, 2], [0, 1], [0, 1], , , ]
The number of clusters can be retrieved by the
>>> len(cl) 3
You can iterate over the cover as if it were a regular list of clusters:
>>> for cluster in cl: ... print(" ".join(str(idx) for idx in cluster)) ... 0 1 2 3 2 3 4 0 1 6
If you need all the clusters at once as lists, you can simply convert the cover to a list:
>>> cluster_list = list(cl) >>> print(cluster_list) [[0, 1, 2, 3], [2, 3, 4], [0, 1, 6]]
>>> clustering = Clustering([0, 0, 0, 0, 1, 1, 1, 2, 2, 2]) >>> cover = Cover(clustering) >>> list(clustering) == list(cover) True
||Returns the cluster with the given index.|
||Iterates over the clusters in this cover.|
||Returns the number of clusters in this cover.|
||Returns a string representation of the cover.|
||Returns the membership vector of this cover.|
||Returns the number of elements in the set covered by this cover.|
||Returns the size of a given cluster.|
||Returns the histogram of cluster sizes.|
||Returns the size of given clusters.|
||Returns the summary of the cover.|
||Iterates over the clusters and formats them into a string to be presented in the summary.|
Constructs a cover with the given clusters.
|Parameters||clusters||the clusters in this cover, as a list or iterable. Each cluster is specified by a list or tuple that contains the IDs of the items in this cluster. IDs start from zero.|
|n||the total number of elements in the set that is covered by this cover. If it is less than the number of unique elements found in all the clusters, we will simply use the number of unique elements, so it is safe to leave this at zero. You only have to specify this parameter if there are some elements that are covered by none of the clusters.|
Returns the membership vector of this cover.
The membership vector of a cover covering n elements is a list of length n, where element i contains the cluster indices of the ith item.
Returns the size of a given cluster.
|Parameters||idx||the cluster in which we are interested.|
Returns the size of given clusters.
The indices are given as positional arguments. If there are no positional arguments, the function will return the sizes of all clusters.
Returns the histogram of cluster sizes.
|Parameters||bin_width||the bin width of the histogram|
Returns the summary of the cover.
The summary includes the number of items and clusters, and also the list of members for each of the clusters if the verbosity is nonzero.
|Parameters||verbosity||determines whether the cluster members should be printed. Zero verbosity prints the number of items and clusters only.|
|Returns||the summary of the cover as a string.|
Iterates over the clusters and formats them into a string to be presented in the summary.