- java.lang.Object
-
- org.jgrapht.nio.BaseExporter<V,E>
-
- org.jgrapht.nio.csv.CSVExporter<V,E>
-
- Type Parameters:
V
- the graph vertex typeE
- the graph edge type
- All Implemented Interfaces:
GraphExporter<V,E>
public class CSVExporter<V,E> extends BaseExporter<V,E> implements GraphExporter<V,E>
Exports a graph into a CSV Format or any other Delimiter-separated value format.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 thesetParameter
method. SeeCSVFormat
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.
- Author:
- Dimitrios Michail
- See Also:
CSVFormat
-
-
Field Summary
-
Fields inherited from class org.jgrapht.nio.BaseExporter
edgeAttributeProvider, edgeIdProvider, graphAttributeProvider, graphIdProvider, vertexAttributeProvider, vertexIdProvider
-
-
Constructor Summary
Constructors Constructor Description CSVExporter()
Creates a new CSVExporter withCSVFormat.ADJACENCY_LIST
format and integer name provider for the vertices.CSVExporter(java.util.function.Function<V,java.lang.String> 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 id providers for the vertices.CSVExporter(CSVFormat format, char delimiter)
Creates a new CSVExporter with integer id providers for the vertices.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
exportGraph(Graph<V,E> g, java.io.Writer writer)
Exports a graphchar
getDelimiter()
Get the delimiter (comma, semicolon, pipe, etc).CSVFormat
getFormat()
Get the format of the exporterboolean
isParameter(CSVFormat.Parameter p)
Return if a particular parameter of the exporter is enabledvoid
setDelimiter(char delimiter)
Set the delimiter (comma, semicolon, pipe, etc).void
setFormat(CSVFormat format)
Set the format of the exportervoid
setParameter(CSVFormat.Parameter p, boolean value)
Set the value of a parameter of the exporter-
Methods inherited from class org.jgrapht.nio.BaseExporter
getEdgeAttribute, getEdgeAttributeProvider, getEdgeAttributes, getEdgeId, getEdgeIdProvider, getGraphAttribute, getGraphAttributeProvider, getGraphId, getGraphIdProvider, getVertexAttribute, getVertexAttributeProvider, getVertexAttributes, getVertexId, getVertexIdProvider, setEdgeAttributeProvider, setEdgeIdProvider, setGraphAttributeProvider, setGraphIdProvider, setVertexAttributeProvider, setVertexIdProvider
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgrapht.nio.GraphExporter
exportGraph, exportGraph
-
-
-
-
Constructor Detail
-
CSVExporter
public CSVExporter()
Creates a new CSVExporter withCSVFormat.ADJACENCY_LIST
format and integer name provider for the vertices.
-
CSVExporter
public CSVExporter(CSVFormat format)
Creates a new CSVExporter with integer id providers for the vertices.- Parameters:
format
- the format to use
-
CSVExporter
public CSVExporter(CSVFormat format, char delimiter)
Creates a new CSVExporter with integer id providers for the vertices.- Parameters:
format
- the format to usedelimiter
- delimiter to use
-
CSVExporter
public CSVExporter(java.util.function.Function<V,java.lang.String> vertexIdProvider, CSVFormat format, char delimiter)
Constructs a new CSVExporter with the given ID providers and format.- Parameters:
vertexIdProvider
- for generating vertex IDs. Must not be null.format
- the format to usedelimiter
- delimiter to use
-
-
Method Detail
-
exportGraph
public void exportGraph(Graph<V,E> g, java.io.Writer writer)
Exports a graph- Specified by:
exportGraph
in interfaceGraphExporter<V,E>
- Parameters:
g
- the graphwriter
- the writer
-
isParameter
public boolean isParameter(CSVFormat.Parameter p)
Return if a particular parameter of the exporter is enabled- Parameters:
p
- the parameter- Returns:
true
if the parameter is set,false
otherwise
-
setParameter
public void setParameter(CSVFormat.Parameter p, boolean value)
Set the value of a parameter of the exporter- Parameters:
p
- the parametervalue
- the value to set
-
getFormat
public CSVFormat getFormat()
Get the format of the exporter- Returns:
- the format of the exporter
-
setFormat
public void setFormat(CSVFormat format)
Set the format of the exporter- Parameters:
format
- the format to use
-
getDelimiter
public char getDelimiter()
Get the delimiter (comma, semicolon, pipe, etc).- Returns:
- the delimiter
-
setDelimiter
public void setDelimiter(char delimiter)
Set the delimiter (comma, semicolon, pipe, etc).- Parameters:
delimiter
- the delimiter to use
-
-