Class SimpleGEXFEventDrivenImporter

java.lang.Object
org.jgrapht.nio.BaseEventDrivenImporter<String,Triple<String,String,Double>>
org.jgrapht.nio.gexf.SimpleGEXFEventDrivenImporter
All Implemented Interfaces:
EventDrivenImporter<String,Triple<String,String,Double>>

public class SimpleGEXFEventDrivenImporter extends BaseEventDrivenImporter<String,Triple<String,String,Double>> implements EventDrivenImporter<String,Triple<String,String,Double>>
Imports a graph from a GEXF data source. The importer does not construct a graph but calls the provided consumers with the appropriate arguments. Vertices are returned simply by their vertex id and edges are returns as triples (source, target, weight) where weight maybe null.

The importer notifies lazily and completely out-of-order for any additional vertex, edge or graph attributes in the input file. Users can register consumers for vertex, edge and graph attributes after construction of the importer. Finally, default attribute values and any nested elements are completely ignored.

This is a simple implementation with supports only a limited set of features of the GEXF specification, oriented towards parsing speed.

For a description of the format see https://gephi.org/gexf/format/index.html or the GEXF Primer.

Below is small example of a graph in GEXF format.

 
 <?xml version="1.0" encoding="UTF-8"?>
 <gexf xmlns="http://www.gexf.net/1.2draft"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd"
       version="1.2">
   <graph defaultedgetype="undirected">
     <nodes>
       <node id="n0" label="node 0"/>
       <node id="n1" label="node 1"/>
       <node id="n2" label="node 2"/>
       <node id="n3" label="node 3"/>
       <node id="n4" label="node 4"/>
       <node id="n5" label="node 5"/>
     </nodes>
     <edges>
       <edge id="e0" source="n0" target="n2" weight="1.0"/>
       <edge id="e1" source="n0" target="n1" weight="1.0"/>
       <edge id="e2" source="n1" target="n3" weight="2.0"/>
       <edge id="e3" source="n3" target="n2"/>
       <edge id="e4" source="n2" target="n4"/>
       <edge id="e5" source="n3" target="n5"/>
       <edge id="e6" source="n5" target="n4" weight="1.1"/>
     </edges>
   </graph>
 </gexf>
 
 

The importer by default validates the input using the 1.2draft GEXF Schema. The user can (not recommended) disable the validation by calling setSchemaValidation(boolean). Older schemas are not supported.

Author:
Dimitrios Michail
  • Constructor Details

    • SimpleGEXFEventDrivenImporter

      public SimpleGEXFEventDrivenImporter()
      Constructs a new importer.
  • Method Details

    • isSchemaValidation

      public boolean isSchemaValidation()
      Whether the importer validates the input
      Returns:
      true if the importer validates the input
    • setSchemaValidation

      public void setSchemaValidation(boolean schemaValidation)
      Set whether the importer should validate the input
      Parameters:
      schemaValidation - value for schema validation
    • importInput

      public void importInput(Reader input)
      Description copied from interface: EventDrivenImporter
      Import a graph
      Specified by:
      importInput in interface EventDrivenImporter<String,Triple<String,String,Double>>
      Parameters:
      input - the input reader