Implementation of union, disjoint union and intersection operators.

Function | `disjoint` |
Graph disjoint union. |

Function | `intersection` |
Graph intersection. |

Function | `name` |
Converts a list of names to a set of names while checking for duplicates. |

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.

Parameters | |

graphs | list of graphs. A lazy sequence is not acceptable. |

Returns | |

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.

Parameters | |

graphs | list of graphs. A lazy sequence is not acceptable. |

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). |

keep | bool specifying if vertices that are not present in all graphs should be kept in the intersection. |

Returns | |

the intersection graph | |

Raises | |

`RuntimeError` | if 'byname' is set to True and some graphs are not named or the set of names is not unique in one of the graphs |

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

Parameters | |

names | the list of names to convert |

Returns | |

the set of unique names appearing in the list | |

Raises | |

`RuntimeError` | if the input name list has duplicates |

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 | |

graphs | list of graphs. A lazy sequence is not acceptable. |

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). |

Returns | |

the union graph | |

Raises | |

`RuntimeError` | if 'byname' is set to True and some graphs are not named or the set of names is not unique in one of the graphs |