|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectit.unimi.dsi.webgraph.ImmutableGraph
it.unimi.dsi.webgraph.ImmutableSequentialGraph
it.unimi.dsi.webgraph.ASCIIGraph
public class ASCIIGraph
An ImmutableGraph
that corresponds to graphs stored in a human-readable
ASCII format where each line contains the list of successors of a given node.
The file format is as follows: the graph is stored in a file named basename.graph-txt. The first line contains the number of nodes, n. Then, n lines follow, the i-th line containing the successors of node i in increasing order (nodes are numbered from 0 to n−1). Successors are separated by a single space.
Contrarily to other classes, the load methods of this class do not always return instances of this class.
In particular, loadOffline(CharSequence)
and loadOnce(InputStream)
will return an instance of this class for
offline access. The instance will not provide random access, but sequential access will be backed by
the original text file and only one array of successor 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.
ASCIIGraph
to convert your dataA simple (albeit rather inefficient) way to import data into WebGraph is using ASCII graphs. Suppose you create the following file, named example.graph-txt:
2 1 0 1Then, the command
java it.unimi.dsi.webgraph.BVGraph -g ASCIIGraph example bvexamplewill produce a compressed graph in
BVGraph
format
with basename bvexample. Even more convenient is the loadOnce(InputStream)
method, which reads from an input stream an 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 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 ASCIIGraph dummy bvexample <example.graph-txt
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 |
Constructor Summary | |
---|---|
protected |
ASCIIGraph(CharSequence graphFile)
|
|
ASCIIGraph(InputStream is)
Creates a read-once ASCII graph. |
Method Summary | |
---|---|
static ImmutableGraph |
load(CharSequence basename)
|
static ImmutableGraph |
load(CharSequence basename,
ProgressLogger unused)
|
static ASCIIGraph |
loadOffline(CharSequence basename)
|
static ASCIIGraph |
loadOffline(CharSequence basename,
ProgressLogger unused)
|
static ASCIIGraph |
loadOnce(InputStream is)
|
static ImmutableGraph |
loadSequential(CharSequence basename)
|
static ASCIIGraph |
loadSequential(CharSequence basename,
ProgressLogger unused)
|
static void |
main(String[] args)
|
NodeIterator |
nodeIterator(int from)
Returns a node iterator for scanning the graph sequentially, starting from the given node. |
int |
numNodes()
Returns the number of nodes of this graph. |
static void |
store(ImmutableGraph graph,
CharSequence basename)
|
static void |
store(ImmutableGraph graph,
CharSequence basename,
ProgressLogger unused)
|
static void |
store(ImmutableGraph graph,
int shift,
CharSequence basename)
|
Methods inherited from class it.unimi.dsi.webgraph.ImmutableSequentialGraph |
---|
copy, outdegree, randomAccess, successorArray |
Methods inherited from class it.unimi.dsi.webgraph.ImmutableGraph |
---|
basename, equals, hashCode, load, loadMapped, loadMapped, nodeIterator, numArcs, outdegrees, store, store, successors, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected ASCIIGraph(CharSequence graphFile) throws NumberFormatException, IOException
NumberFormatException
IOException
public ASCIIGraph(InputStream is) throws NumberFormatException, IOException
nodeIterator(int)
.
is
- an input stream containing an ASCII graph.
NumberFormatException
IOException
Method Detail |
---|
public int numNodes()
ImmutableGraph
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.
numNodes
in class ImmutableGraph
public NodeIterator nodeIterator(int from)
ImmutableGraph
This implementation just calls the random-access methods (ImmutableGraph.successors(int)
and
ImmutableGraph.outdegree(int)
). More specific implementations may choose to maintain some extra state
to make the enumeration more efficient.
nodeIterator
in class ImmutableSequentialGraph
from
- the node from which the iterator will iterate.
NodeIterator
for accessing nodes and successors sequentially.public static ImmutableGraph loadSequential(CharSequence basename) throws IOException
IOException
public static ASCIIGraph loadSequential(CharSequence basename, ProgressLogger unused) throws IOException
IOException
public static ASCIIGraph loadOffline(CharSequence basename) throws IOException
IOException
public static ASCIIGraph loadOffline(CharSequence basename, ProgressLogger unused) throws IOException
IOException
public static ASCIIGraph loadOnce(InputStream is) throws IOException
IOException
public static ImmutableGraph load(CharSequence basename) throws IOException
IOException
public static ImmutableGraph load(CharSequence basename, ProgressLogger unused) throws IOException
IOException
public static void store(ImmutableGraph graph, CharSequence basename, ProgressLogger unused) throws IOException
IOException
public static void store(ImmutableGraph graph, CharSequence basename) throws IOException
IOException
public static void store(ImmutableGraph graph, int shift, CharSequence basename) throws IOException
IOException
public static void main(String[] args) throws IllegalArgumentException, SecurityException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, IOException, JSAPException, ClassNotFoundException, InstantiationException
IllegalArgumentException
SecurityException
IllegalAccessException
InvocationTargetException
NoSuchMethodException
IOException
JSAPException
ClassNotFoundException
InstantiationException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |