Class UnionArcLabelledImmutableGraph
- All Implemented Interfaces:
it.unimi.dsi.lang.FlyweightPrototype<ImmutableGraph>
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class it.unimi.dsi.webgraph.ImmutableGraph
ImmutableGraph.LoadMethod -
Field Summary
Fields inherited from class it.unimi.dsi.webgraph.labelling.ArcLabelledImmutableGraph
UNDERLYINGGRAPH_PROPERTY_KEY, UNDERLYINGGRAPH_SUFFIXFields inherited from class it.unimi.dsi.webgraph.ImmutableGraph
GRAPHCLASS_PROPERTY_KEY, NUMBER_OF_THREADS_PROPERTY, PROPERTIES_EXTENSION -
Constructor Summary
ConstructorsConstructorDescriptionUnionArcLabelledImmutableGraph(ArcLabelledImmutableGraph g0, ArcLabelledImmutableGraph g1, LabelMergeStrategy labelMergeStrategy) Creates the union of two given graphs. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Returns a flyweight copy of this immutable graph.booleanWhether the node iterators returned by this graph supportNodeIterator.copy(int).Label[]labelArray(int x) Returns a reference to an array containing the labels of the arcs going out of a given node in the same order as the order in which the corresponding successors are returned byArcLabelledImmutableGraph.successors(int).nodeIterator(int from) Returns a node iterator for scanning the graph sequentially, starting from the given node.intnumNodes()Returns the number of nodes of this graph.intoutdegree(int x) Returns the outdegree of a node.Returns a prototype of the labels used by this graph.booleanChecks whether this graph provides random access to successor lists.int[]successorArray(int x) Returns a reference to an array containing the successors of a given node.successors(int x) Returns a lazy iterator over the successors of a given node.Methods inherited from class it.unimi.dsi.webgraph.labelling.ArcLabelledImmutableGraph
equals, load, load, loadOffline, loadOffline, loadOnce, loadSequential, loadSequential, nodeIterator, toStringMethods inherited from class it.unimi.dsi.webgraph.ImmutableGraph
basename, hashCode, load, loadMapped, loadMapped, numArcs, outdegrees, splitNodeIterators, store, store
-
Constructor Details
-
UnionArcLabelledImmutableGraph
public UnionArcLabelledImmutableGraph(ArcLabelledImmutableGraph g0, ArcLabelledImmutableGraph g1, LabelMergeStrategy labelMergeStrategy) Creates the union of two given graphs.- Parameters:
g0- the first graph.g1- the second graph.labelMergeStrategy- the strategy used to merge labels when the same arc is present in both graphs.
-
-
Method Details
-
copy
Description copied from class:ImmutableGraphReturns a flyweight copy of this immutable graph.- Specified by:
copyin interfaceit.unimi.dsi.lang.FlyweightPrototype<ImmutableGraph>- Specified by:
copyin classArcLabelledImmutableGraph- Returns:
- a flyweight copy of this immutable graph.
- See Also:
-
nodeIterator
Description copied from class:ArcLabelledImmutableGraphReturns a node iterator for scanning the graph sequentially, starting from the given node.- Overrides:
nodeIteratorin classArcLabelledImmutableGraph- Parameters:
from- the node from which the iterator will iterate.- Returns:
- an
ArcLabelledNodeIteratorfor accessing nodes, successors and their labels sequentially. - See Also:
-
numNodes
public int numNodes()Description copied from class:ImmutableGraphReturns the number of nodes of this graph.Albeit this method is not optional, it is allowed that this method throws an
UnsupportedOperationExceptionif this graph has never been entirely traversed using anode iterator. This apparently bizarre behaviour is necessary to support implementations asArcListASCIIGraph, which do not know the actual number of nodes until a traversal has been completed.- Specified by:
numNodesin classImmutableGraph- Returns:
- the number of nodes.
-
randomAccess
public boolean randomAccess()Description copied from class:ImmutableGraphChecks whether this graph provides random access to successor lists.- Specified by:
randomAccessin classImmutableGraph- Returns:
- true if this graph provides random access to successor lists.
-
hasCopiableIterators
public boolean hasCopiableIterators()Description copied from class:ImmutableGraphWhether the node iterators returned by this graph supportNodeIterator.copy(int).- Overrides:
hasCopiableIteratorsin classImmutableGraph- Returns:
- true if this graph provides copiable iterators.
-
successorArray
public int[] successorArray(int x) Description copied from class:ImmutableGraphReturns a reference to an array containing the successors of a given node.The returned array may contain more entries than the outdegree of
x. However, only those with indices from 0 (inclusive) to the outdegree ofx(exclusive) contain valid data.- Overrides:
successorArrayin classImmutableGraph- Parameters:
x- a node.- Returns:
- an array whose first elements are the successors of the node; the array must not be modified by the caller.
-
outdegree
public int outdegree(int x) Description copied from class:ImmutableGraphReturns the outdegree of a node.- Specified by:
outdegreein classImmutableGraph- Parameters:
x- a node.- Returns:
- the outdegree of the given node.
-
labelArray
Description copied from class:ArcLabelledImmutableGraphReturns a reference to an array containing the labels of the arcs going out of a given node in the same order as the order in which the corresponding successors are returned byArcLabelledImmutableGraph.successors(int).The returned array may contain more entries than the outdegree of
x. However, only those with indices from 0 (inclusive) to the outdegree ofx(exclusive) contain valid data.- Overrides:
labelArrayin classArcLabelledImmutableGraph- Returns:
- an array whose first elements are the labels of the arcs going out of
x; the array must not be modified by the caller.
-
successors
Description copied from class:ImmutableGraphReturns a lazy iterator over the successors of a given node. The iteration terminates when -1 is returned.- Specified by:
successorsin classArcLabelledImmutableGraph- Parameters:
x- a node.- Returns:
- a lazy iterator over the successors of the node.
-
prototype
Description copied from class:ArcLabelledImmutableGraphReturns a prototype of the labels used by this graph. The prototype can be used to produce new copies, but must not be modified by the caller.- Specified by:
prototypein classArcLabelledImmutableGraph- Returns:
- a prototype for the labels of this graph.
-