4.1.11.5. graph/Union

class mod.UnionGraph

An adaptor for a multiset of Graphs to present them as their disjoint union.

It functions as an iterable of the adapted graphs, and it implements the protocols.LabelledGraph protocol.

__init__()
__init__(graphs)

Construct a graph representing the disjoint union of graphs. Thus, if no graphs are given the empty graph is constructed.

Parameters

graphs (list[Graph]) – the list of graphs to adapt.

__str__()
Return type

str

__len__()
Returns

the number of adapted graphs.

Return type

int

__iter__()
Returns

the range of graphs adapted by this object.

__getitem__(i)
Returns

the ith adapted graph.

Return type

Graph

Raises

LogicError if i is out of range.

class Vertex

Implements the protocols.LabelledGraph.Vertex protocol. Additionally, the id is in the range \([0, numVertices[\).

A non-null vertex represents a specific Graph.Vertex. As the same Graph can be part of a UnionGraph multiple times, a vertex also has a graph index to determine which instance of a Graph in the UnionGraph the vertex refers to.

graphIndex

(Read-only) The index of the graph in the owning UnionGraph this vertex is from. The index is thus in the range \([0, len(graph)[\).

We can obtain the underlying Graph this vertex, self, is from both directly via the vertex attribute as self.vertex.graph, or via the graph index as self.graph[self.graphIndex].

Type

int

Raises

LogicError if it is a null vertex.

vertex

(Read-only) The underlying Graph.Vertex this vertex represents.

We can obtain the underlying Graph this vertex, self, is from both directly via the vertex attribute as self.vertex.graph, or via the graph index as self.graph[self.graphIndex].

Type

Graph.Vertex

Raises

LogicError if it is a null vertex.

class Edge

Implements the protocols.LabelledGraph.Vertex protocol.

A non-null edge represents a specific Graph.Edge. As the same Graph can be part of a UnionGraph multiple times, an edge also has a graph index to determine which instance of a Graph in the UnionGraph the edge refers to.

graphIndex

(Read-only) The index of the graph in the owning UnionGraph this edge is from. The index is thus in the range \([0, len(graph)[\).

We can obtain the underlying Graph this edge, self, is from both directly via the edge attribute as self.edge.graph, or via the graph index as self.graph[self.graphIndex].

Type

int

Raises

LogicError if it is a null edge.

edge

(Read-only) The underlying Graph.Edge this edge represents.

We can obtain the underlying Graph this edge, self, is from both directly via the edge attribute as self.edge.graph, or via the graph index as self.graph[self.graphIndex].

Type

Graph.Edge

Raises

LogicError if it is a null edge.

class VertexRange

Implements the protocols.Graph.VertexRange protocol, in addition to the following functionality.

__getitem__(i)
Returns

the ith vertex of the graph.

Return type

UnionGraph.Vertex

class EdgeRange

Implements the protocols.Graph.EdgeRange protocol.

class IncidentEdgeRange

Implements the protocols.Graph.IncidentEdgeRange protocol.

class mod.VertexMapUnionGraphUnionGraph

Implements the protocols.VertexMap protocol.