Class ArcListASCIIGraph

All Implemented Interfaces:
FlyweightPrototype<ImmutableGraph>
Direct Known Subclasses:
ShiftedByOneArcListASCIIGraph

public class ArcListASCIIGraph
extends ImmutableSequentialGraph
An ImmutableGraph that corresponds to graphs stored in a human-readable ASCII format were each line contains an arc.

The file format is very simple: each line contains an arc specified as two nodes separated by whitespace (but we suggest exactly one TAB character). Sources must be in increasing order, but targets can be in any order. The constructor provides an additional parameter, called shift, which will be added to all node indices. The default is 0, but for lists that number nodes starting from 1 it can be set to -1. Actually, the class ShiftedByOneArcListASCIIGraph can be used in place of this class for setting the shift to -1 without specifying additional parameters.

Contrarily to other classes, the load methods of this class do not always return instances of this class. In particular, loadOnce(InputStream) will return an instance of this class for read-once access. The instance will not provide offline or random access, but read-once access will be backed by the original input stream and only the successors of a single node will be loaded in core memory at any time.

The load(CharSequence) method, on the other hand, will return an instance of ArrayListMutableGraph built by copying an offline instance of this class.

Using ArcListASCIIGraph to convert your data

A simple (albeit rather inefficient) way to import data into WebGraph is using ASCII graphs specified by arc lists. Suppose you create the following file, named example.arcs:

  0 1
  1 2
  2 1
  
Then, the command
  java it.unimi.dsi.webgraph.BVGraph -g ArcListASCIIGraph example.arcs bvexample
  
will produce a compressed graph in BVGraph format with basename bvexample. Even more convenient, and extremely more efficient, is the loadOnce(InputStream) method, which reads from an input stream an arc-list ASCII graph and exposes it for a single traversal. It can be used, for instance, with the main method of BVGraph to generate somehow an arc-list ASCII graph and store it in compressed form on the fly. The previous example could be then rewritten as
  java it.unimi.dsi.webgraph.BVGraph -1 -g ArcListASCIIGraph dummy bvexample <example.arcs