- java.lang.Object
-
- org.jgrapht.nio.BaseExporter<V,E>
-
- org.jgrapht.nio.matrix.MatrixExporter<V,E>
-
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
GraphExporter<V,E>
public class MatrixExporter<V,E> extends BaseExporter<V,E> implements GraphExporter<V,E>
Exports a graph to a plain text matrix format, which can be processed by matrix manipulation software, such as MTJ or MATLAB.The exporter supports three different formats, see
MatrixExporter.Format.- Author:
- Charles Fry, Dimitrios Michail
- See Also:
MatrixExporter.Format
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMatrixExporter.FormatFormats supported by theMatrixExporterexporter.
-
Field Summary
-
Fields inherited from class org.jgrapht.nio.BaseExporter
edgeAttributeProvider, edgeIdProvider, graphAttributeProvider, graphIdProvider, vertexAttributeProvider, vertexIdProvider
-
-
Constructor Summary
Constructors Constructor Description MatrixExporter()Creates a new MatrixExporter with integer name provider for the vertex identifiers andMatrixExporter.Format.SPARSE_ADJACENCY_MATRIXas the default format.MatrixExporter(MatrixExporter.Format format)Creates a new MatrixExporter with integer name provider for the vertex identifiers.MatrixExporter(MatrixExporter.Format format, Function<V,String> vertexIdProvider)Creates a new MatrixExporter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexportGraph(Graph<V,E> g, Writer writer)Export a graph using the givenWriter.MatrixExporter.FormatgetFormat()Get the format that the exporter is using.voidsetFormat(MatrixExporter.Format format)Set the output format 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
-
MatrixExporter
public MatrixExporter()
Creates a new MatrixExporter with integer name provider for the vertex identifiers andMatrixExporter.Format.SPARSE_ADJACENCY_MATRIXas the default format.
-
MatrixExporter
public MatrixExporter(MatrixExporter.Format format)
Creates a new MatrixExporter with integer name provider for the vertex identifiers.- Parameters:
format- format to use
-
MatrixExporter
public MatrixExporter(MatrixExporter.Format format, Function<V,String> vertexIdProvider)
Creates a new MatrixExporter.- Parameters:
format- format to usevertexIdProvider- for generating vertex identifiers. Must not be null.
-
-
Method Detail
-
getFormat
public MatrixExporter.Format getFormat()
Get the format that the exporter is using.- Returns:
- the output format
-
setFormat
public void setFormat(MatrixExporter.Format format)
Set the output format of the exporter- Parameters:
format- the format to use
-
exportGraph
public void exportGraph(Graph<V,E> g, Writer writer) throws ExportException
Description copied from interface:GraphExporterExport a graph using the givenWriter.It is the callers responsibility to ensure the
Writeris closed after this method returned.- Specified by:
exportGraphin interfaceGraphExporter<V,E>- Parameters:
g- the graph to exportwriter- the output writer- Throws:
ExportException- in case any error occurs
-
-