public class FileSourceNCol extends FileSourceBase
The ncol graph format is a simple format where each line describes an edge by giving two node names and an optional third parameters giving the edge weight. The nodes are created implicitly.
Also, the format does not specify any direction for edges. By default all edges are undirected. It is specified in the format that you will never have directed edges and that the lines:
node1Name node2Name
and
node2Name node1Name
Cannot both appear at the same time in a file.
This format only contains edges. To ensure the "add node" events are sent before an edge referencing two nodes is created via an "add edge" event, this reader has a hash set of already encountered nodes. The hash set allows to issue "add node" events only when a node is encountered for the first time.
This hash set consumes memory, but is the only way to ensure "add node" events are correctly issued. If this input is directly connected to a graph, as graphs can create non-existing nodes automatically, you can disable the hash set of nodes using the constructorFileSourceNCol(boolean), and giving "false" for the first
argument.
The usual file name extension for this format is ".ncol".SourceBase.ElementType| Constructor and Description |
|---|
FileSourceNCol()
New reader for the "ncol" format.
|
FileSourceNCol(boolean declareNodes)
New reader for the "ncol" format.
|
| Modifier and Type | Method and Description |
|---|---|
void |
begin(InputStream stream)
Begin reading the file stopping as soon as possible.
|
void |
begin(Reader reader)
Begin reading the file stopping as soon as possible.
|
void |
begin(String filename)
Begin reading the file stopping as soon as possible.
|
void |
begin(URL url)
Begin reading the file stopping as soon as possible.
|
void |
end()
Finish the reading process (even if
FileSource.nextEvents() or
FileSource.nextStep() did not returned false). |
boolean |
nextEvents()
Try to process one graph event, or as few as possible, if more must be
read at once.
|
boolean |
nextStep()
Try to process all the events occurring during one time step.
|
addAttributeClass, readAll, readAll, readAll, readAlladdAttributeSink, addElementSink, addSink, attributeSinks, clearAttributeSinks, clearElementSinks, clearSinks, elementSinks, removeAttributeSink, removeElementSink, removeSink, sendAttributeChangedEvent, sendAttributeChangedEvent, sendEdgeAdded, sendEdgeAdded, sendEdgeAttributeAdded, sendEdgeAttributeAdded, sendEdgeAttributeChanged, sendEdgeAttributeChanged, sendEdgeAttributeRemoved, sendEdgeAttributeRemoved, sendEdgeRemoved, sendEdgeRemoved, sendGraphAttributeAdded, sendGraphAttributeAdded, sendGraphAttributeChanged, sendGraphAttributeChanged, sendGraphAttributeRemoved, sendGraphAttributeRemoved, sendGraphCleared, sendGraphCleared, sendNodeAdded, sendNodeAdded, sendNodeAttributeAdded, sendNodeAttributeAdded, sendNodeAttributeChanged, sendNodeAttributeChanged, sendNodeAttributeRemoved, sendNodeAttributeRemoved, sendNodeRemoved, sendNodeRemoved, sendStepBegins, sendStepBeginsequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddAttributeSink, addElementSink, addSink, clearAttributeSinks, clearElementSinks, clearSinks, removeAttributeSink, removeElementSink, removeSinkpublic FileSourceNCol()
public FileSourceNCol(boolean declareNodes)
declareNodes - If true (default=true) this reader outputs nodeAdded events.public boolean nextEvents()
throws IOException
FileSourceFileSource.begin(InputStream) or FileSource.begin(String) before. This method
return true while there are still events to read.nextEvents in interface FileSourcenextEvents in class FileSourceBaseIOException - If an I/O error occurs while reading.public void begin(String filename) throws IOException
FileSourceFileSource.nextEvents() or
FileSource.nextStep(). Once begin() has been called, you must finish the
reading process using FileSource.end(). You cannot call begin() twice
without having called FileSource.end() in between.begin in interface FileSourcebegin in class FileSourceBasefilename - Name of the file to read.IOException - If an I/O error occurs while reading.public void begin(URL url) throws IOException
FileSourceFileSource.nextEvents() or
FileSource.nextStep(). Once begin() has been called, you must finish the
reading process using FileSource.end(). You cannot call begin() twice
without having called FileSource.end() in between.begin in interface FileSourcebegin in class FileSourceBaseurl - The URL of the file to read.IOException - If an I/O error occurs while reading.public void begin(InputStream stream) throws IOException
FileSourceFileSource.nextEvents() or
FileSource.nextStep(). Once begin() has been called, you must finish the
reading process using FileSource.end(). You cannot call begin() twice
without having called FileSource.end() in between.begin in interface FileSourcebegin in class FileSourceBasestream - The input stream to use for reading.IOException - If an I/O error occurs while reading.public void begin(Reader reader) throws IOException
FileSourceFileSource.nextEvents() or
FileSource.nextStep(). Once begin() has been called, you must finish the
reading process using FileSource.end(). You cannot call begin() twice
without having called FileSource.end() in between.begin in interface FileSourcebegin in class FileSourceBasereader - The file reader to use.IOException - If an I/O error occurs while reading.public boolean nextStep()
throws IOException
FileSourceIOException - If an I/O error occurs while reading.public void end()
throws IOException
FileSourceFileSource.nextEvents() or
FileSource.nextStep() did not returned false). You must call this method
after reading.end in interface FileSourceend in class FileSourceBaseIOException - If an I/O error occurs while closing the file.Copyright © 2015. All rights reserved.