What is it?
gexf4j is a GEXF File Format Java Library. it's intention is to fully supports GEXF 1.1. it's used to create and write GEXF Files for visualizing graphs using Gephi and any other GEXF-supporting application.
Developer: Javier Campanini (blog)
How to use it?
Using the library in your Java programs is very simple:
- Import the JAR file (or produce your own JAR from the source code).
- Start using it, see the hello world example below.
How to get started?
You have two options:
- Download the latest JAR files from the download page OR
- Download the source, and compile/install using maven2.
That's all, folks!
Features
- Write GEXF Files
- Read GEXF Files
- Data Validation & Integerity
- Helper Functionality for Dynamic Timelines
- Chaining API for concise graph creation (see example below)
Fully supports gexf 1.1:
- Static graph
- Data graphs
- Dynamics
- Hierarchy
- Phylogeny
- Visualization
Hello World example
This is how to create a GEXF file with v0.2alpha:
Gexf gexf = new GexfImpl();
gexf.getMetadata()
.setLastModified(toDate("2009-03-20"))
.setCreator("Gephi.org")
.setDescription("A Web network");
// attributes
AttributeList attrList = new AttributeListImpl(AttributeClass.NODE);
gexf.getGraph().getAttributeLists().add(attrList);
Attribute attUrl = attrList.createAttribute("0", AttributeType.STRING, "url");
Attribute attIndegree = attrList.createAttribute("1", AttributeType.FLOAT, "indegree");
Attribute attFrog = attrList.createAttribute("2", AttributeType.BOOLEAN, "frog")
.setDefaultValue("true");
// nodes
Node gephi = gexf.getGraph().createNode("0");
gephi
.setLabel("Gephi")
.getAttributeValues()
.addValue(attUrl, "http://gephi.org")
.addValue(attIndegree, "1");
Node webatlas = gexf.getGraph().createNode("1");
webatlas
.setLabel("Webatlas")
.getAttributeValues()
.addValue(attUrl, "http://webatlas.fr")
.addValue(attIndegree, "2");
Node rtgi = gexf.getGraph().createNode("2");
rtgi
.setLabel("RTGI")
.getAttributeValues()
.addValue(attUrl, "http://rtgi.fr")
.addValue(attIndegree, "1");
Node blab = gexf.getGraph().createNode("3");
blab
.setLabel("BarabasiLab")
.getAttributeValues()
.addValue(attUrl, "http://barabasilab.com")
.addValue(attIndegree, "1")
.addValue(attFrog, "false");
// edges
gephi.connectTo("0", webatlas);
gephi.connectTo("1";, rtgi);
webatlas.connectTo("2", gephi);
rtgi.connectTo("3", webatlas);
gephi.connectTo("4", blab);
The result will be:
<?xml version="1.0" encoding="UTF-8"?>
<gexf xmlns="http://www.gexf.net/1.1draft" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gexf.net/1.1draft http://www.gexf.net/1.1draft/gexf.xsd" version="1.1">
<meta lastmodifieddate="2009-03-20">
<creator>Gephi.org</creator>
<description>A Web network</description>
</meta>
<graph defaultedgetype="directed">
<attributes class="node">
<attribute id="0" title="url" type="string"/>
<attribute id="1" title="indegree" type="float"/>
<attribute id="2" title="frog" type="boolean">
<default>true</default>
</attribute>
</attributes>
<nodes>
<node id="0" label="Gephi">
<attvalues>
<attvalue for="0" value="http://gephi.org"/>
<attvalue for="1" value="1"/>
</attvalues>
</node>
<node id="1" label="Webatlas">
<attvalues>
<attvalue for="0" value="http://webatlas.fr"/>
<attvalue for="1" value="2"/>
</attvalues>
</node>
<node id="2" label="RTGI">
<attvalues>
<attvalue for="0" value="http://rtgi.fr"/>
<attvalue for="1" value="1"/>
</attvalues>
</node>
<node id="3" label="BarabasiLab">
<attvalues>
<attvalue for="0" value="http://barabasilab.com"/>
<attvalue for="1" value="1"/>
<attvalue for="2" value="false"/>
</attvalues>
</node>
</nodes>
<edges>
<edge id="0" source="0" target="1"/>
<edge id="1" source="0" target="2"/>
<edge id="2" source="1" target="0"/>
<edge id="3" source="2" target="1"/>
<edge id="4" source="0" target="3"/>
</edges>
</graph>
</gexf>
Get started!
Download the latest release now!
-
Download v0.2 (70 KB)
Only sources in GZIP are available for unstable versions.
-
Stay involved
-
It is Open
This project is distributed under Apache License v2.0.
-
Source and Bugs
Gexf4j uses the DCVS Git and the platforme GitHub. The current repository is hosted on GitHub, this means you can get there the most up to date code, but it may be unstable.
Please report bugs in our issue tracker.
-
Useful Links
- gexf file format: official format specifications
- LibGEXF: Official C++ toolkit for GEXF
- gexfExplorer: open source Flash visualizer
- Gephi: graph exploration and manipulation sofware