V
- the graph vertex typeE
- the graph edge typepublic class JSONExporter<V,E> extends Object implements GraphExporter<V,E>
The output is one object which contains:
nodes
whose value is an array of nodes.
edges
whose value is an array of edges.
creator
and version
for metadata.
Each node contains an identifier and possibly other attributes provided using a
ComponentAttributeProvider
. Similarly each edge contains the source and target vertices,
a possible identifier using ComponentNameProvider
and possible other attributes using a
ComponentAttributeProvider
. All these can be adjusted using the appropriate constructor
call, see
JSONExporter(ComponentNameProvider, ComponentAttributeProvider, ComponentNameProvider, ComponentAttributeProvider)
.
The default constructor constructs integer identifiers using an
IntegerComponentNameProvider
for both vertices and edges and does not output any custom
attributes using EmptyComponentAttributeProvider
.
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 |
---|
JSONExporter()
Creates a new exporter with integer name provider for the vertex identifiers.
|
JSONExporter(ComponentNameProvider<V> vertexIDProvider)
Creates a new exporter.
|
JSONExporter(ComponentNameProvider<V> vertexIDProvider,
ComponentAttributeProvider<V> vertexAttributeProvider,
ComponentNameProvider<E> edgeIDProvider,
ComponentAttributeProvider<E> edgeAttributeProvider)
Constructs a new exporter
|
Modifier and Type | Method and Description |
---|---|
void |
exportGraph(Graph<V,E> g,
Writer writer)
Export a graph
|
ComponentNameProvider<E> |
getEdgeIDProvider()
Get the edge id provider
|
ComponentNameProvider<V> |
getVertexIDProvider()
Get the vertex id provider
|
void |
setEdgeIDProvider(ComponentNameProvider<E> edgeIDProvider)
Set the edge id provider.
|
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 JSONExporter()
public JSONExporter(ComponentNameProvider<V> vertexIDProvider)
vertexIDProvider
- for generating vertex identifiers. Must not be null.public JSONExporter(ComponentNameProvider<V> vertexIDProvider, ComponentAttributeProvider<V> vertexAttributeProvider, ComponentNameProvider<E> edgeIDProvider, ComponentAttributeProvider<E> edgeAttributeProvider)
vertexIDProvider
- for generating vertex identifiers. Must not be null.vertexAttributeProvider
- for generating vertex attributes. If null, no additional
attributes will be exported.edgeIDProvider
- for generating edge identifiers. Must not be null.edgeAttributeProvider
- for generating edge attributes. If null, no additional
attributes will be exported.public void exportGraph(Graph<V,E> g, Writer writer) throws ExportException
GraphExporter
exportGraph
in interface GraphExporter<V,E>
g
- the graph to exportwriter
- the output writerExportException
- in case any error occurspublic 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.