Class MatrixExporter<V,​E>

  • Type Parameters:
    V - the graph vertex type
    E - 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
    • Constructor Detail

      • 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 use
        vertexIdProvider - 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: GraphExporter
        Export a graph using the given Writer.

        It is the callers responsibility to ensure the Writer is closed after this method returned.

        Specified by:
        exportGraph in interface GraphExporter<V,​E>
        Parameters:
        g - the graph to export
        writer - the output writer
        Throws:
        ExportException - in case any error occurs