python-igraph manual

For using igraph from Python

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

Class VertexCover

source code

object --+    
         |    
     Cover --+
             |
            VertexCover
Known Subclasses:

The cover of the vertex set of a graph.

This class extends Cover by linking it to a specific Graph object. It also provides some handy methods like getting the subgraph corresponding to a cluster and such.


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 VertexCover that references the Graph.

Instance Methods [hide private]
 
__init__(self, graph, clusters=None)
Creates a cover object for a given graph.
source code
 
crossing(self)
Returns a boolean vector where element i is True iff edge i lies between clusters, False otherwise.
source code
 
subgraph(self, idx)
Get the subgraph belonging to a given cluster.
source code
 
subgraphs(self)
Gets all the subgraphs belonging to each of the clusters.
source code
 
__plot__(self, context, bbox, palette, *args, **kwds)
Plots the cover to the given Cairo context in the given bounding box.
source code

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]
  graph
Returns the graph belonging to this object

Inherited from Cover: membership, n

Inherited from object: __class__

Method Details [hide private]

__init__(self, graph, clusters=None)
(Constructor)

source code 

Creates a cover object for a given graph.

Parameters:
  • graph - the graph that will be associated to the cover
  • clusters - the list of clusters. If None, it is assumed that there is only a single cluster that covers the whole graph.
Overrides: object.__init__

subgraph(self, idx)

source code 

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 cover was constructed.

subgraphs(self)

source code 

Gets all the subgraphs belonging to each of the clusters.

Returns:
a list containing copies of the subgraphs

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

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

source code 

Plots the cover to the given Cairo context in the given bounding box.

This is done by calling Graph.__plot__() with the same arguments, but drawing nice colored blobs around the vertex groups.

This method understands all the positional and keyword arguments that are understood by Graph.__plot__(), only the differences will be highlighted here:

  • mark_groups: whether to highlight the vertex clusters by colored polygons. Besides the values accepted by Graph.__plot__ (i.e., a dict mapping colors to vertex indices, a list containing lists of vertex indices, or False), the following are also accepted:
    • True: all the clusters will be highlighted, the colors matching the corresponding color indices from the current palette (see the palette keyword argument of Graph.__plot__.
    • A dict mapping cluster indices or tuples of vertex indices to color names. The given clusters or vertex groups will be highlighted by the given colors.
    • A list of cluster indices. This is equivalent to passing a dict mapping numeric color indices from the current palette to cluster indices; therefore, the cluster referred to by element i of the list will be highlighted by color i from the palette.

    The value of the plotting.mark_groups configuration key is also taken into account here; if that configuration key is True and mark_groups is not given explicitly, it will automatically be set to True.

    In place of lists of vertex indices, you may also use VertexSeq instances.

    In place of color names, you may also use color indices into the current palette. None as a color name will mean that the corresponding group is ignored.

  • palette: the palette used to resolve numeric color indices to RGBA values. By default, this is an instance of ClusterColoringPalette.

See Also: Graph.__plot__() for more supported keyword arguments.


Property Details [hide private]

graph

Returns the graph belonging to this object

Get Method:
unreachable.graph(self) - Returns the graph belonging to this object

   Home       Trees       Indices       Help