Class IntegerTriplesArcLabelledImmutableGraph
- All Implemented Interfaces:
FlyweightPrototype<ImmutableGraph>
public class IntegerTriplesArcLabelledImmutableGraph extends ArcLabelledImmutableSequentialGraph
ArcLabelledImmutableGraph
. The triples are
interpreted as labelled arcs: the first element is the source, the second element is the target,
and the third element must be a nonnegative integer that will be saved using a GammaCodedIntLabel
.
This class is mainly a useful example of how to expose of your data via an ArcLabelledImmutableGraph
, and
it is also used to build test cases, but it is not efficient or particularly refined.
A main method reads from standard input a list of TAB-separated triples and writes the corresponding graph
using BVGraph
and BitStreamArcLabelledImmutableGraph
.
-
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_SUFFIX
Fields inherited from class it.unimi.dsi.webgraph.ImmutableGraph
GRAPHCLASS_PROPERTY_KEY, NUMBER_OF_THREADS_PROPERTY, PROPERTIES_EXTENSION
-
Constructor Summary
Constructors Constructor Description IntegerTriplesArcLabelledImmutableGraph(int[][] triple)
Creates a new arc-labelled immutable graph using a specified list of triples. -
Method Summary
Modifier and Type Method Description boolean
hasCopiableIterators()
Whether the node iterators returned by this graph supportNodeIterator.copy(int)
.static void
main(String[] arg)
ArcLabelledNodeIterator
nodeIterator()
Returns a node iterator for scanning the graph sequentially, starting from the first node.ArcLabelledNodeIterator
nodeIterator(int from)
Throws anUnsupportedOperationException
.int
numNodes()
Returns the number of nodes of this graph.Label
prototype()
Returns a prototype of the labels used by this graph.ArcLabelledNodeIterator.LabelledArcIterator
successors(int from)
Throws anUnsupportedOperationException
.Methods inherited from class it.unimi.dsi.webgraph.labelling.ArcLabelledImmutableSequentialGraph
copy, labelArray, outdegree, randomAccess, successorArray
Methods inherited from class it.unimi.dsi.webgraph.labelling.ArcLabelledImmutableGraph
equals, load, load, loadOffline, loadOffline, loadOnce, loadSequential, loadSequential, toString
Methods inherited from class it.unimi.dsi.webgraph.ImmutableGraph
basename, hashCode, load, loadMapped, loadMapped, numArcs, outdegrees, splitNodeIterators, store, store
-
Constructor Details
-
IntegerTriplesArcLabelledImmutableGraph
public IntegerTriplesArcLabelledImmutableGraph(int[][] triple)Creates a new arc-labelled immutable graph using a specified list of triples.Note that it is impossible to specify isolated nodes with indices larger than the largest node with positive indegree or outdegree, as the number of nodes is computed by maximising over all indices in
triple
.- Parameters:
triple
- a list of triples specifying labelled arcs (see the class documentation); order is not relevant, but multiple arcs are not allowed.
-
-
Method Details
-
prototype
Description copied from class:ArcLabelledImmutableGraph
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.- Specified by:
prototype
in classArcLabelledImmutableGraph
- Returns:
- a prototype for the labels of this graph.
-
numNodes
public int numNodes()Description copied from class:ImmutableGraph
Returns the number of nodes of this graph.Albeit this method is not optional, it is allowed that this method throws an
UnsupportedOperationException
if 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:
numNodes
in classImmutableGraph
- Returns:
- the number of nodes.
-
hasCopiableIterators
public boolean hasCopiableIterators()Description copied from class:ImmutableGraph
Whether the node iterators returned by this graph supportNodeIterator.copy(int)
.- Overrides:
hasCopiableIterators
in classImmutableGraph
- Returns:
- true if this graph provides copiable iterators.
-
nodeIterator
Description copied from class:ArcLabelledImmutableSequentialGraph
Throws anUnsupportedOperationException
.- Overrides:
nodeIterator
in classArcLabelledImmutableSequentialGraph
- 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()
-
successors
Description copied from class:ArcLabelledImmutableSequentialGraph
Throws anUnsupportedOperationException
.- Overrides:
successors
in classArcLabelledImmutableSequentialGraph
- Parameters:
from
- a node.- Returns:
- a lazy iterator over the successors of the node.
-
nodeIterator
Description copied from class:ImmutableGraph
Returns a node iterator for scanning the graph sequentially, starting from the first node.- Overrides:
nodeIterator
in classArcLabelledImmutableGraph
- Returns:
- a
NodeIterator
for accessing nodes and successors sequentially.
-
main
- Throws:
JSAPException
IOException
-