V
- the graph vertex typeE
- the graph edge typepublic class CSVExporter<V,E> extends Object implements GraphExporter<V,E>
The exporter supports three 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 exporter can be adjusted using the
setParameter
method. See
CSVFormat
for a description of the formats.
The default output 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 escaped using the new separator. See Delimiter- separated values for more information.
CSVFormat
Modifier and Type | Field and Description |
---|---|
protected ComponentNameProvider<E> |
edgeIDProvider
Provides an identifier for an edge.
|
protected ComponentNameProvider<V> |
vertexIDProvider
Provides an identifier for a vertex.
|
Constructor and Description |
---|
CSVExporter()
Creates a new CSVExporter with
CSVFormat.ADJACENCY_LIST format and integer name
provider for the vertices. |
CSVExporter(ComponentNameProvider<V> vertexIDProvider,
CSVFormat format,
char delimiter)
Constructs a new CSVExporter with the given ID providers and format.
|
CSVExporter(CSVFormat format)
Creates a new CSVExporter with integer name providers for the vertices.
|
CSVExporter(CSVFormat format,
char delimiter)
Creates a new CSVExporter with integer name providers for the vertices.
|
Modifier and Type | Method and Description |
---|---|
void |
exportGraph(Graph<V,E> g,
Writer writer)
Exports a graph
|
char |
getDelimiter()
Get the delimiter (comma, semicolon, pipe, etc).
|
ComponentNameProvider<E> |
getEdgeIDProvider()
Get the edge id provider
|
CSVFormat |
getFormat()
Get the format of the exporter
|
ComponentNameProvider<V> |
getVertexIDProvider()
Get the vertex id provider
|
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 |
setEdgeIDProvider(ComponentNameProvider<E> edgeIDProvider)
Set the edge id provider.
|
void |
setFormat(CSVFormat format)
Set the format of the exporter
|
void |
setParameter(CSVFormat.Parameter p,
boolean value)
Set the value of a parameter of the exporter
|
void |
setVertexIDProvider(ComponentNameProvider<V> vertexIDProvider)
Set the vertex id provider
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exportGraph, exportGraph
protected ComponentNameProvider<V> vertexIDProvider
protected ComponentNameProvider<E> edgeIDProvider
public CSVExporter()
CSVFormat.ADJACENCY_LIST
format and integer name
provider for the vertices.public CSVExporter(CSVFormat format)
format
- the format to usepublic CSVExporter(CSVFormat format, char delimiter)
format
- the format to usedelimiter
- delimiter to usepublic CSVExporter(ComponentNameProvider<V> vertexIDProvider, CSVFormat format, char delimiter)
vertexIDProvider
- for generating vertex IDs. Must not be null.format
- the format to usedelimiter
- delimiter to usepublic void exportGraph(Graph<V,E> g, Writer writer)
exportGraph
in interface GraphExporter<V,E>
g
- the graphwriter
- the writerpublic 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 CSVFormat getFormat()
public void setFormat(CSVFormat format)
format
- the format to usepublic char getDelimiter()
public void setDelimiter(char delimiter)
delimiter
- the delimiter to usepublic ComponentNameProvider<V> getVertexIDProvider()
public void setVertexIDProvider(ComponentNameProvider<V> vertexIDProvider)
vertexIDProvider
- the new vertex id provider. Must not be null.public ComponentNameProvider<E> getEdgeIDProvider()
public void setEdgeIDProvider(ComponentNameProvider<E> edgeIDProvider)
edgeIDProvider
- the new edge id provider. Must not be null.Copyright © 2019. All rights reserved.