python-igraph API reference

List of all classes, functions and methods in python-igraph

module documentation

Implementation of union, disjoint union and intersection operators.

Function disjoint_union Graph disjoint union.
Function intersection Graph intersection.
Function name_set Converts a list of names to a set of names while checking for duplicates.
Function union Graph union.
def disjoint_union(graphs):

Graph disjoint union.

The disjoint union of two or more graphs is created.

This function keeps the attributes of all graphs. All graph, vertex and edge attributes are copied to the result. If an attribute is present in multiple graphs and would result a name clash, then this attribute is renamed by adding suffixes: _1, _2, etc.

An error is generated if some input graphs are directed and others are undirected.

Parameters
graphslist of graphs. A lazy sequence is not acceptable.
Returns
the disjoint union graph
def intersection(graphs, byname='auto', keep_all_vertices=True):

Graph intersection.

The intersection of two or more graphs is created. The graphs may have identical or overlapping vertex sets. Edges which are included in all graphs will be part of the new graph.

This function keeps the attributes of all graphs. All graph, vertex and edge attributes are copied to the result. If an attribute is present in multiple graphs and would result a name clash, then this attribute is renamed by adding suffixes: _1, _2, etc.

The 'name' vertex attribute is treated specially if the operation is performed based on symbolic vertex names. In this case 'name' must be present in all graphs, and it is not renamed in the result graph.

An error is generated if some input graphs are directed and others are undirected.

Parameters
graphslist of graphs. A lazy sequence is not acceptable.
bynamebool or 'auto' specifying the function behaviour with respect to names vertices (i.e. vertices with the 'name' attribute). If False, ignore vertex names. If True, merge vertices based on names. If 'auto', use True if all graphs have named vertices and False otherwise (in the latter case, a warning is generated too).
keep_all_verticesbool specifying if vertices that are not present in all graphs should be kept in the intersection.
Returns
the intersection graph
Raises
RuntimeErrorif 'byname' is set to True and some graphs are not named or the set of names is not unique in one of the graphs
def name_set(names):

Converts a list of names to a set of names while checking for duplicates.

Parameters
namesthe list of names to convert
Returns
the set of unique names appearing in the list
Raises
RuntimeErrorif the input name list has duplicates
def union(graphs, byname='auto'):

Graph union.

The union of two or more graphs is created. The graphs may have identical or overlapping vertex sets. Edges which are included in at least one graph will be part of the new graph.

This function keeps the attributes of all graphs. All graph, vertex and edge attributes are copied to the result. If an attribute is present in multiple graphs and would result a name clash, then this attribute is renamed by adding suffixes: _1, _2, etc.

The 'name' vertex attribute is treated specially if the operation is performed based on symbolic vertex names. In this case 'name' must be present in all graphs, and it is not renamed in the result graph.

An error is generated if some input graphs are directed and others are undirected.

Parameters
graphslist of graphs. A lazy sequence is not acceptable.
bynamebool or 'auto' specifying the function behaviour with respect to names vertices (i.e. vertices with the 'name' attribute). If False, ignore vertex names. If True, merge vertices based on names. If 'auto', use True if all graphs have named vertices and False otherwise (in the latter case, a warning is generated too).
Returns
the union graph
Raises
RuntimeErrorif 'byname' is set to True and some graphs are not named or the set of names is not unique in one of the graphs