Implementation of union, disjoint union and intersection operators.
Function | disjoint |
Graph disjoint union. |
Function | intersection |
Graph intersection. |
Function | union |
Graph union. |
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.
@param graphs: list of graphs. A lazy sequence is not acceptable. @return: the disjoint union graph
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.
@param graphs: list of graphs. A lazy sequence is not acceptable. @param byname: bool 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).
- @param keep_all_vertices: bool specifying if vertices that are not present
- in all graphs should be kept in the intersection.
@return: the intersection graph
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.
@param graphs: list of graphs. A lazy sequence is not acceptable. @param byname: bool 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).
@return: the union graph