Package igraph :: Module clustering :: Class Clustering
[hide private]
[frames] | no frames]

Class Clustering

object --+
         |
        Clustering
Known Subclasses:

Class representing a clustering of an arbitrary ordered set.

This is now used as a base for VertexClustering, but it might be useful for other purposes as well.

Members of an individual cluster can be accessed by the [] operator:

>>> cl = Clustering([0,0,0,0,1,1,1,2,2,2,2])
>>> cl[0]
[0, 1, 2, 3]

The membership vector can be accessed by the membership property:

>>> cl.membership
[0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]

The number of clusters can be retrieved by the len function:

>>> len(cl)
3
Instance Methods [hide private]
 
__getitem__(self, idx)
Returns the members of the specified cluster.
 
__init__(self, membership, params={})
Constructor.
 
__len__(self)
Returns the number of clusters.
 
_get_membership(self)
 
size(self, idx)
Returns the size of a given cluster.
 
size_histogram(self, bin_width=1)
Returns the histogram of cluster sizes.
 
sizes(self, *args)
Returns the size of given clusters.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]
  membership
The membership vector (read only)

Inherited from object: __class__

Method Details [hide private]

__getitem__(self, idx)
(Indexing operator)

 

Returns the members of the specified cluster.

Parameters:
  • idx - the index of the cluster
Returns:
the members of the specified cluster as a list
Raises:
  • IndexError - if the index is out of bounds

__init__(self, membership, params={})
(Constructor)

 

Constructor.

Parameters:
  • membership - the membership list -- that is, the cluster index in which each element of the set belongs to.
  • params - additional parameters to be stored in this object's dictionary.
Overrides: object.__init__

__len__(self)
(Length operator)

 

Returns the number of clusters.

Returns:
the number of clusters

size(self, idx)

 

Returns the size of a given cluster.

Parameters:
  • idx - the cluster in which we are interested.

size_histogram(self, bin_width=1)

 

Returns the histogram of cluster sizes.

Parameters:
  • bin_width - the bin width of the histogram
Returns:
a Histogram object

sizes(self, *args)

 

Returns the size of given clusters.

Parameters:
  • idxs - the cluster indices in which we are interested. If None, defaults to all clusters

Property Details [hide private]

membership

The membership vector (read only)

Get Method:
_get_membership(self)