Class IntegerListImmutableGraph
- All Implemented Interfaces:
FlyweightPrototype<ImmutableGraph>
public class IntegerListImmutableGraph extends ImmutableSequentialGraph
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.webgraph.ImmutableGraph
ImmutableGraph.LoadMethod
-
Field Summary
Fields inherited from class it.unimi.dsi.webgraph.ImmutableGraph
GRAPHCLASS_PROPERTY_KEY, NUMBER_OF_THREADS_PROPERTY, PROPERTIES_EXTENSION
-
Method Summary
Modifier and Type Method Description static 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.NodeIterator
nodeIterator()
Returns a node iterator for scanning the graph sequentially, starting from the first node.int
numNodes()
Returns the number of nodes of this graph.Methods inherited from class it.unimi.dsi.webgraph.ImmutableSequentialGraph
copy, nodeIterator, outdegree, randomAccess, successorArray
Methods inherited from class it.unimi.dsi.webgraph.ImmutableGraph
basename, equals, hasCopiableIterators, hashCode, load, loadMapped, loadMapped, loadOnce, numArcs, outdegrees, splitNodeIterators, store, store, successors, toString
-
Method Details
-
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.
-
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
-