Class UnionArcLabelledImmutableGraph

All Implemented Interfaces:
FlyweightPrototype<ImmutableGraph>

public class UnionArcLabelledImmutableGraph
extends ArcLabelledImmutableGraph
An arc-labelled immutable graph representing the union of two given such graphs. Here by “union” we mean that an arc will belong to the union iff it belongs to at least one of the two graphs (the number of nodes of the union is taken to be the maximum among the number of nodes of each graph). Labels are assumed to have the same prototype in both graphs, and are treated as follows: if an arc is present in but one graph, its label in the resulting graph is going to be the label of the arc in the graph where it comes from; if an arc is present in both graphs, the labels are combined using a provided LabelMergeStrategy.

Remarks about the implementation

Due to the lack of multiple inheritance, we could not extend both UnionImmutableGraph and ArcLabelledImmutableGraph, hence we forcedly decided to extend the latter. The possibility of using delegation on the former was also discarded because the code for reading and merging labels is so tightly coupled with the rest that it would have been essentially useless (and even dangerous) to delegate the iteration methods. As a result, some of the code of this class is actually almost a duplicate of the code of UnionImmutableGraph.