it.unimi.dsi.webgraph.examples
Class IntegerListImmutableGraph

java.lang.Object
  extended by it.unimi.dsi.webgraph.ImmutableGraph
      extended by it.unimi.dsi.webgraph.ImmutableSequentialGraph
          extended by it.unimi.dsi.webgraph.examples.IntegerListImmutableGraph
All Implemented Interfaces:
FlyweightPrototype<ImmutableGraph>

public class IntegerListImmutableGraph
extends ImmutableSequentialGraph

Exposes a graph in a simple binary format as an (offline-only) 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, PROPERTIES_EXTENSION
 
Method Summary
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)
           
static ImmutableGraph loadSequential(CharSequence basename, ProgressLogger pl)
           
 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, hashCode, load, loadMapped, loadMapped, loadOnce, numArcs, outdegrees, store, store, successors, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

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 a node iterator. This apparently bizarre behaviour is necessary to support implementations as ArcListASCIIGraph, which do not know the actual number of nodes until a traversal has been completed.

Specified by:
numNodes in class ImmutableGraph
Returns:
the number of nodes.

nodeIterator

public NodeIterator nodeIterator()
Description copied from class: ImmutableGraph
Returns a node iterator for scanning the graph sequentially, starting from the first node.

Overrides:
nodeIterator in class ImmutableGraph
Returns:
a NodeIterator for accessing nodes and successors sequentially.

load

public static ImmutableGraph load(CharSequence basename,
                                  ProgressLogger pl)

load

public static ImmutableGraph load(CharSequence basename)

loadSequential

public static ImmutableGraph loadSequential(CharSequence basename,
                                            ProgressLogger pl)

loadSequential

public static ImmutableGraph loadSequential(CharSequence basename)

loadOffline

public static ImmutableGraph loadOffline(CharSequence basename,
                                         ProgressLogger pl)
                                  throws IOException
Throws:
IOException

loadOffline

public static ImmutableGraph loadOffline(CharSequence basename)
                                  throws IOException
Throws:
IOException