python-igraph manual

For using igraph from Python

   Home       Trees       Indices       Help   
Package igraph :: Module clustering :: Class CohesiveBlocks
[hide private]

Class CohesiveBlocks

source code

object --+        
         |        
     Cover --+    
             |    
   VertexCover --+
                 |
                CohesiveBlocks

The cohesive block structure of a graph.

Instances of this type are created by Graph.cohesive_blocks(). See the documentation of Graph.cohesive_blocks() for an explanation of what cohesive blocks are.

This class provides a few more methods that make handling of cohesive block structures easier.

Instance Methods [hide private]
 
__init__(self, graph, blocks=None, cohesion=None, parent=None)
Constructs a new cohesive block structure for the given graph.
source code
 
cohesion(self, idx)
Returns the cohesion of the group with the given index.
source code
 
cohesions(self)
Returns the list of cohesion values for each group.
source code
 
hierarchy(self)
Returns a new graph that describes the hierarchical relationships between the groups.
source code
 
max_cohesion(self, idx)
Finds the maximum cohesion score among all the groups that contain the given vertex.
source code
 
max_cohesions(self)
For each vertex in the graph, returns the maximum cohesion score among all the groups that contain the vertex.
source code
 
parent(self, idx)
Returns the parent group index of the group with the given index or None if the given group is the root.
source code
 
parents(self)
Returns the list of parent group indices for each group or None if the given group is the root.
source code
 
__plot__(self, context, bbox, palette, *args, **kwds)
Plots the cohesive block structure to the given Cairo context in the given bounding box.
source code

Inherited from VertexCover: crossing, subgraph, subgraphs

Inherited from Cover: __getitem__, __iter__, __len__, __str__, size, size_histogram, sizes, summary

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from VertexCover: graph

Inherited from Cover: membership, n

Inherited from object: __class__

Method Details [hide private]

__init__(self, graph, blocks=None, cohesion=None, parent=None)
(Constructor)

source code 

Constructs a new cohesive block structure for the given graph.

If any of blocks, cohesion or parent is None, all the arguments will be ignored and Graph.cohesive_blocks() will be called to calculate the cohesive blocks. Otherwise, these three variables should describe the *result* of a cohesive block structure calculation. Chances are that you never have to construct CohesiveBlocks instances directly, just use Graph.cohesive_blocks().

Parameters:
  • graph - the graph itself
  • blocks - a list containing the blocks; each block is described as a list containing vertex IDs.
  • cohesion - the cohesion of each block. The length of this list must be equal to the length of blocks.
  • parent - the parent block of each block. Negative values or None mean that there is no parent block for that block. There should be only one parent block, which covers the entire graph.
Overrides: object.__init__

See Also: Graph.cohesive_blocks()

hierarchy(self)

source code 

Returns a new graph that describes the hierarchical relationships between the groups.

The new graph will be a directed tree; an edge will point from vertex i to vertex j if group i is a superset of group j. In other words, the edges point downwards.

__plot__(self, context, bbox, palette, *args, **kwds)

source code 

Plots the cohesive block structure to the given Cairo context in the given bounding box.

Since a CohesiveBlocks instance is also a VertexCover, keyword arguments accepted by VertexCover.__plot__() are also accepted here. The only difference is that the vertices are colored according to their maximal cohesions by default, and groups are marked by colored blobs except the last group which encapsulates the whole graph.

See the documentation of VertexCover.__plot__() for more details.

Overrides: VertexCover.__plot__

   Home       Trees       Indices       Help