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

Class VertexClustering

object --+    
         |    
Clustering --+
             |
            VertexClustering
Known Subclasses:

The clustering of the vertex set of a graph.

This class extends Clustering by linking it to a specific Graph object and by optionally storing the modularity score of the clustering.


Note: since this class is linked to a Graph, destroying the graph by the del operator does not free the memory occupied by the graph if there exists a VertexClustering that references the Graph.

Instance Methods [hide private]
 
__init__(self, graph, membership=None, modularity=None, params={})
Creates a clustering object for a given graph.
 
_get_graph(self)
 
_get_modularity(self)
 
giant(self)
Returns the giant community of the clustered graph.
 
recalculate_modularity(self)
Recalculates the stored modularity value.
 
subgraph(self, idx)
Get the subgraph belonging to a given cluster.

Inherited from Clustering: __getitem__, __len__, size, size_histogram, sizes

Inherited from Clustering (private): _get_membership

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

Properties [hide private]
  graph
The graph belonging to this object
  modularity
The modularity score
  q
The modularity score

Inherited from Clustering: membership

Inherited from object: __class__

Method Details [hide private]

__init__(self, graph, membership=None, modularity=None, params={})
(Constructor)

 

Creates a clustering object for a given graph.

Parameters:
  • graph - the graph that will be associated to the clustering
  • membership - the membership list. The length of the list must be equal to the number of vertices in the graph. If None, every vertex is assumed to belong to the same cluster.
  • modularity - the modularity score of the clustering. If None, it will be calculated.
  • params - additional parameters to be stored in this object.
Overrides: object.__init__

giant(self)

 

Returns the giant community of the clustered graph.

The giant component a community for which no larger community exists.

Returns:
a copy of the giant community.

Note: there can be multiple giant communities, this method will return the copy of an arbitrary one if there are multiple giant communities.

Precondition: the vertex set of the graph hasn't been modified since the moment the clustering was constructed.

recalculate_modularity(self)

 

Recalculates the stored modularity value.

This method must be called before querying the modularity score of the clustering through the class member modularity or q if the graph has been modified (edges have been added or removed) since the creation of the VertexClustering object.

Returns:
the new modularity score

subgraph(self, idx)

 

Get the subgraph belonging to a given cluster.

Parameters:
  • idx - the cluster index
Returns:
a copy of the subgraph

Precondition: the vertex set of the graph hasn't been modified since the moment the clustering was constructed.


Property Details [hide private]

graph

The graph belonging to this object

Get Method:
_get_graph(self)

modularity

The modularity score

Get Method:
_get_modularity(self)

q

The modularity score

Get Method:
_get_modularity(self)