V - the graph vertex typeE - the graph edge typepublic class CSVImporter<V,E> extends Object implements GraphImporter<V,E>
 The importer supports various different formats which can be adjusted using the
 setFormat method. The supported formats are the same CSV formats
 used by Gephi . For some
 of the formats, the behavior of the importer can be adjusted using the
 setParameter method. See
 CSVFormat for a description of the formats.
 
The importer respects rfc4180. The caller can also adjust the separator to something like semicolon or pipe instead of comma. In such a case, all fields are unescaped using the new separator. See Delimiter- separated values for more information.
 This importer does not distinguish between CSVFormat.EDGE_LIST and
 CSVFormat.ADJACENCY_LIST. In both cases it assumes the format is
 CSVFormat.ADJACENCY_LIST.
 
CSVFormat| Modifier and Type | Field and Description | 
|---|---|
protected EdgeProvider<V,E> | 
edgeProvider
Constructs new edges 
 | 
protected ComponentUpdater<Graph<V,E>> | 
graphUpdater
Updates graph properties 
 | 
protected VertexProvider<V> | 
vertexProvider
Constructs new vertices 
 | 
protected ComponentUpdater<V> | 
vertexUpdater
Updates already constructed vertices 
 | 
| Constructor and Description | 
|---|
CSVImporter(VertexProvider<V> vertexProvider,
           EdgeProvider<V,E> edgeProvider)
Constructs a new importer using the  
CSVFormat.ADJACENCY_LIST format as default. | 
CSVImporter(VertexProvider<V> vertexProvider,
           EdgeProvider<V,E> edgeProvider,
           CSVFormat format)
Constructs a new importer. 
 | 
CSVImporter(VertexProvider<V> vertexProvider,
           EdgeProvider<V,E> edgeProvider,
           CSVFormat format,
           char delimiter)
Constructs a new importer. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
char | 
getDelimiter()
Get the delimiter (comma, semicolon, pipe, etc). 
 | 
EdgeProvider<V,E> | 
getEdgeProvider()
Get the edge provider 
 | 
CSVFormat | 
getFormat()
Get the format that the importer is using. 
 | 
ComponentUpdater<Graph<V,E>> | 
getGraphUpdater()
Get the graph updater. 
 | 
VertexProvider<V> | 
getVertexProvider()
Get the vertex provider 
 | 
ComponentUpdater<V> | 
getVertexUpdater()
Get the vertex updater 
 | 
void | 
importGraph(Graph<V,E> graph,
           Reader input)
Import a graph. 
 | 
boolean | 
isParameter(CSVFormat.Parameter p)
Return if a particular parameter of the exporter is enabled 
 | 
void | 
setDelimiter(char delimiter)
Set the delimiter (comma, semicolon, pipe, etc). 
 | 
void | 
setEdgeProvider(EdgeProvider<V,E> edgeProvider)
Set the edge provider. 
 | 
void | 
setFormat(CSVFormat format)
Set the format of the importer 
 | 
void | 
setGraphUpdater(ComponentUpdater<Graph<V,E>> graphUpdater)
Set the graph updater. 
 | 
void | 
setParameter(CSVFormat.Parameter p,
            boolean value)
Set the value of a parameter of the exporter 
 | 
void | 
setVertexProvider(VertexProvider<V> vertexProvider)
Set the vertex provider 
 | 
void | 
setVertexUpdater(ComponentUpdater<V> vertexUpdater)
Set the vertex updater. 
 | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitimportGraph, importGraphprotected VertexProvider<V> vertexProvider
protected EdgeProvider<V,E> edgeProvider
protected ComponentUpdater<V> vertexUpdater
protected ComponentUpdater<Graph<V,E>> graphUpdater
public CSVImporter(VertexProvider<V> vertexProvider, EdgeProvider<V,E> edgeProvider)
CSVFormat.ADJACENCY_LIST format as default.vertexProvider - provider for the generation of vertices. Must not be null.edgeProvider - provider for the generation of edges. Must not be null.public CSVImporter(VertexProvider<V> vertexProvider, EdgeProvider<V,E> edgeProvider, CSVFormat format)
vertexProvider - provider for the generation of vertices. Must not be null.edgeProvider - provider for the generation of edges. Must not be null.format - format to use out of the supported onespublic CSVImporter(VertexProvider<V> vertexProvider, EdgeProvider<V,E> edgeProvider, CSVFormat format, char delimiter)
vertexProvider - provider for the generation of vertices. Must not be null.edgeProvider - provider for the generation of edges. Must not be null.format - format to use out of the supported onesdelimiter - delimiter to use (comma, semicolon, pipe, etc.)public CSVFormat getFormat()
public void setFormat(CSVFormat format)
format - the format to usepublic char getDelimiter()
public void setDelimiter(char delimiter)
delimiter - the delimiter to usepublic boolean isParameter(CSVFormat.Parameter p)
p - the parametertrue if the parameter is set, false otherwisepublic void setParameter(CSVFormat.Parameter p, boolean value)
p - the parametervalue - the value to setpublic void importGraph(Graph<V,E> graph, Reader input) throws ImportException
The provided graph must be able to support the features of the graph that is read. For example if the input contains self-loops then the graph provided must also support self-loops. The same for multiple edges.
If the provided graph is a weighted graph, the importer also reads edge weights.
importGraph in interface GraphImporter<V,E>graph - the graphinput - the input readerImportException - in case an error occurs, such as I/O or parse errorpublic VertexProvider<V> getVertexProvider()
public void setVertexProvider(VertexProvider<V> vertexProvider)
vertexProvider - the new vertex provider. Must not be null.public EdgeProvider<V,E> getEdgeProvider()
public void setEdgeProvider(EdgeProvider<V,E> edgeProvider)
edgeProvider - the new edge provider. Must not be null.public ComponentUpdater<V> getVertexUpdater()
public void setVertexUpdater(ComponentUpdater<V> vertexUpdater)
vertexUpdater - the new vertex updater. Must not be null.public ComponentUpdater<Graph<V,E>> getGraphUpdater()
public void setGraphUpdater(ComponentUpdater<Graph<V,E>> graphUpdater)
graphUpdater - the new graph updater. Must not be null.Copyright © 2018. All rights reserved.