Class ArcLabelledImmutableGraph
- java.lang.Object
-
- it.unimi.dsi.big.webgraph.ImmutableGraph
-
- it.unimi.dsi.big.webgraph.labelling.ArcLabelledImmutableGraph
-
- All Implemented Interfaces:
it.unimi.dsi.lang.FlyweightPrototype<ImmutableGraph>
- Direct Known Subclasses:
ArcLabelledImmutableSequentialGraph
,ArcRelabelledImmutableGraph
,BitStreamArcLabelledImmutableGraph
,UnionArcLabelledImmutableGraph
public abstract class ArcLabelledImmutableGraph extends ImmutableGraph
An abstract implementation of a graph labelled on its arcs.The main purpose of this class is that of override covariantly the return type of
nodeIterator()
andnodeIterator(long)
so that it is anArcLabelledNodeIterator
, and the return type of all static load methods and ofcopy()
so that it is anArcLabelledImmutableGraph
(the methods themselves just delegate to the corresponding method inImmutableGraph
).The only additional instance methods are
labelBigArray(long)
andprototype()
.Saving labels
A subclass of this class may implement
store(ArcLabelledImmutableGraph, CharSequence, CharSequence, ProgressLogger)
;store(ArcLabelledImmutableGraph, CharSequence, CharSequence)
.
These methods must save the labels of the given arc-labelled graph using the first given character sequence as a basename, and a suitable property file using the second given basename. Note that the graph will not be saved—use the
store()
method of anImmutableGraph
implementation for that purpose.For istance, assuming
g
is an arc-labelled graph the idiomatic way of storing it on disk usingBVGraph
for the underlying graph andBitStreamArcLabelledImmutableGraph
for the labels isBVGraph.store(g, "foo"); BitStreamArcLabelledImmutableGraph.store(g, "bar", "foo");
Underlying graphs
Often, implementations of this class will just wrap an underlying graph (i.e., an instance of
ImmutableGraph
). In that case, we suggest that if the implementation uses property files the basename of the underlying graph is specified using the property keyUNDERLYINGGRAPH_PROPERTY_KEY
. If the basename must be generated starting from the arc-labelled graph basename, we suggest to just add at the end the stringUNDERLYINGGRAPH_SUFFIX
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class it.unimi.dsi.big.webgraph.ImmutableGraph
ImmutableGraph.LoadMethod
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
UNDERLYINGGRAPH_PROPERTY_KEY
The standard property key for the underlying graph.static java.lang.String
UNDERLYINGGRAPH_SUFFIX
The standard suffix added to basenames in order to give a basename to the underlying graph, when needed.-
Fields inherited from class it.unimi.dsi.big.webgraph.ImmutableGraph
GRAPHCLASS_PROPERTY_KEY, NUMBER_OF_THREADS_PROPERTY, PROPERTIES_EXTENSION
-
-
Constructor Summary
Constructors Constructor Description ArcLabelledImmutableGraph()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract ArcLabelledImmutableGraph
copy()
Returns a flyweight copy of this immutable graph.boolean
equals(java.lang.Object x)
Compare this immutable graph to another object.Label[][]
labelBigArray(long 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 bysuccessors(long)
.static ArcLabelledImmutableGraph
load(java.lang.CharSequence basename)
static ArcLabelledImmutableGraph
load(java.lang.CharSequence basename, it.unimi.dsi.logging.ProgressLogger pl)
static ArcLabelledImmutableGraph
loadOffline(java.lang.CharSequence basename)
static ArcLabelledImmutableGraph
loadOffline(java.lang.CharSequence basename, it.unimi.dsi.logging.ProgressLogger pl)
static ArcLabelledImmutableGraph
loadOnce(java.io.InputStream is)
static ArcLabelledImmutableGraph
loadSequential(java.lang.CharSequence basename)
Deprecated.static ArcLabelledImmutableGraph
loadSequential(java.lang.CharSequence basename, it.unimi.dsi.logging.ProgressLogger pl)
Deprecated.ArcLabelledNodeIterator
nodeIterator()
Returns a node iterator for scanning the graph sequentially, starting from the first node.ArcLabelledNodeIterator
nodeIterator(long from)
Returns a node iterator for scanning the graph sequentially, starting from the given node.abstract Label
prototype()
Returns a prototype of the labels used by this graph.abstract ArcLabelledNodeIterator.LabelledArcIterator
successors(long x)
Returns a lazy iterator over the successors of a given node.java.lang.String
toString()
-
Methods inherited from class it.unimi.dsi.big.webgraph.ImmutableGraph
basename, hasCopiableIterators, hashCode, intNumNodes, load, loadMapped, loadMapped, numArcs, numNodes, outdegree, outdegrees, randomAccess, splitNodeIterators, store, store, successorBigArray, wrap, wrap
-
-
-
-
Field Detail
-
UNDERLYINGGRAPH_PROPERTY_KEY
public static final java.lang.String UNDERLYINGGRAPH_PROPERTY_KEY
The standard property key for the underlying graph. All implementations decorating with labels an underlying graph are strongly encouraged to use this property name to specify the basename of the underlying graph.- See Also:
- Constant Field Values
-
UNDERLYINGGRAPH_SUFFIX
public static final java.lang.String UNDERLYINGGRAPH_SUFFIX
The standard suffix added to basenames in order to give a basename to the underlying graph, when needed.- See Also:
- Constant Field Values
-
-
Method Detail
-
copy
public abstract ArcLabelledImmutableGraph copy()
Description copied from class:ImmutableGraph
Returns a flyweight copy of this immutable graph.- Specified by:
copy
in interfaceit.unimi.dsi.lang.FlyweightPrototype<ImmutableGraph>
- Specified by:
copy
in classImmutableGraph
- Returns:
- a flyweight copy of this immutable graph.
- See Also:
FlyweightPrototype
-
nodeIterator
public ArcLabelledNodeIterator nodeIterator()
Description copied from class:ImmutableGraph
Returns a node iterator for scanning the graph sequentially, starting from the first node.- Overrides:
nodeIterator
in classImmutableGraph
- Returns:
- a
NodeIterator
for accessing nodes and successors sequentially.
-
nodeIterator
public ArcLabelledNodeIterator nodeIterator(long from)
Returns a node iterator for scanning the graph sequentially, starting from the given node.- Overrides:
nodeIterator
in classImmutableGraph
- Parameters:
from
- the node from which the iterator will iterate.- Returns:
- an
ArcLabelledNodeIterator
for accessing nodes, successors and their labels sequentially. - See Also:
ImmutableGraph.nodeIterator()
- Implementation Specification:
- This implementation strengthens that provided in
ImmutableGraph
, but calls the labelled random-access methodsuccessors(long)
.
-
successors
public abstract ArcLabelledNodeIterator.LabelledArcIterator successors(long x)
Description copied from class:ImmutableGraph
Returns a lazy iterator over the successors of a given node. The iteration terminates when -1 is returned.- Overrides:
successors
in classImmutableGraph
- Parameters:
x
- a node.- Returns:
- a lazy iterator over the successors of the node.
-
prototype
public abstract Label prototype()
Returns 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.- Returns:
- a prototype for the labels of this graph.
-
labelBigArray
public Label[][] labelBigArray(long 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 bysuccessors(long)
.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.- 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. - Implementation Specification:
- This implementation just unwrap the iterator returned by
successors(long)
and writes in a newly allocated array copies of the labels returned byArcLabelledNodeIterator.LabelledArcIterator.label()
.
-
loadSequential
@Deprecated public static ArcLabelledImmutableGraph loadSequential(java.lang.CharSequence basename) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
loadSequential
@Deprecated public static ArcLabelledImmutableGraph loadSequential(java.lang.CharSequence basename, it.unimi.dsi.logging.ProgressLogger pl) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
loadOffline
public static ArcLabelledImmutableGraph loadOffline(java.lang.CharSequence basename) throws java.io.IOException
- Throws:
java.io.IOException
-
loadOffline
public static ArcLabelledImmutableGraph loadOffline(java.lang.CharSequence basename, it.unimi.dsi.logging.ProgressLogger pl) throws java.io.IOException
- Throws:
java.io.IOException
-
load
public static ArcLabelledImmutableGraph load(java.lang.CharSequence basename) throws java.io.IOException
- Throws:
java.io.IOException
-
load
public static ArcLabelledImmutableGraph load(java.lang.CharSequence basename, it.unimi.dsi.logging.ProgressLogger pl) throws java.io.IOException
- Throws:
java.io.IOException
-
loadOnce
public static ArcLabelledImmutableGraph loadOnce(java.io.InputStream is) throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classImmutableGraph
-
equals
public boolean equals(java.lang.Object x)
Description copied from class:ImmutableGraph
Compare this immutable graph to another object.- Overrides:
equals
in classImmutableGraph
- Returns:
- true iff the given object is an immutable graph of the same size, and
the successor list of every node of this graph is equal to the successor list of the corresponding node of
o
.
-
-