Class IntegerListImmutableGraph
- All Implemented Interfaces:
FlyweightPrototype<ImmutableGraph>
ImmutableGraph
.
This class is a simple example that should help in understanding how to interface WebGraph with external data. We have a graph contained in a file and represented by a list of binary 32-bit integers as follows: first we have the number of nodes, then the number of successors of node 0, then the list in increasing order of successors of node 0, then the number of successors of node 1, then the list in increasing order of successors of node 1, and so on.
If we want to transform this graph into, say, a BVGraph
,
we must create a class that exposes the file as an ImmutableGraph
and than save it using BVGraph.store(ImmutableGraph,CharSequence)
or by calling
the main method of BVGraph
.
A complete implementation is not necessary, as BVGraph
uses
just nodeIterator()
. Since we are just interesting in importing data, we do not
implement efficient random access methods, and the only loading method we implement is loadOffline(CharSequence)
.
-
Nested Class Summary
Nested classes/interfaces inherited from class it.unimi.dsi.big.webgraph.ImmutableGraph
ImmutableGraph.LoadMethod
-
Field Summary
Fields inherited from class it.unimi.dsi.big.webgraph.ImmutableGraph
GRAPHCLASS_PROPERTY_KEY, NUMBER_OF_THREADS_PROPERTY, PROPERTIES_EXTENSION
-
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableGraph
load
(CharSequence basename) static ImmutableGraph
load
(CharSequence basename, ProgressLogger pl) static ImmutableGraph
loadOffline
(CharSequence basename) static ImmutableGraph
loadOffline
(CharSequence basename, ProgressLogger pl) static ImmutableGraph
loadSequential
(CharSequence basename) Deprecated.static ImmutableGraph
loadSequential
(CharSequence basename, ProgressLogger pl) Deprecated.Returns a node iterator for scanning the graph sequentially, starting from the first node.long
numNodes()
Returns the number of nodes of this graph.Methods inherited from class it.unimi.dsi.big.webgraph.ImmutableSequentialGraph
copy, nodeIterator, outdegree, randomAccess, successorBigArray
Methods inherited from class it.unimi.dsi.big.webgraph.ImmutableGraph
basename, equals, hasCopiableIterators, hashCode, intNumNodes, load, loadMapped, loadMapped, loadOnce, numArcs, outdegrees, splitNodeIterators, store, store, successors, toString, wrap, wrap
-
Method Details
-
numNodes
public long 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.
-
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.
-
load
-
load
-
loadSequential
Deprecated. -
loadSequential
Deprecated. -
loadOffline
public static ImmutableGraph loadOffline(CharSequence basename, ProgressLogger pl) throws IOException - Throws:
IOException
-
loadOffline
- Throws:
IOException
-