Skip to content

Commit

Permalink
Version 0.3.1
Browse files Browse the repository at this point in the history
- Javadoc have been added
- Bug fix for the not-inclusion of the timeformat attribute in static
graphs
- Smart names for the method parameters
- Two examples about static and dynamic graphs have been added
- README.md udpated
  • Loading branch information
Francesco Ficarola committed May 6, 2012
1 parent 79ea944 commit 97c4d6e
Show file tree
Hide file tree
Showing 370 changed files with 59,985 additions and 2,197 deletions.
8 changes: 8 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/examples/java"/>
<classpathentry kind="lib" path="lib/guava-11.0.2.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gexf4j</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
234 changes: 214 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
gexf4j - The new java library for the latest .gexf file format
gexf4j - A java library for the GEXF file format
=================

Latest Version: [0.3.0-ALPHA](http://github.com/francesco-ficarola/gexf4j)
Latest Version: [0.3.1-ALPHA](http://github.com/francesco-ficarola/gexf4j)

About
------------------
Expand All @@ -18,6 +18,13 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Version 0.3.1 - ALPHA (by Francesco Ficarola)
------------------
The following changes were applied:

* Javadoc was added
* Bug fix for the not-inclusion of the timeformat attribute in static graphs

Version 0.3.0 - ALPHA (by Francesco Ficarola)
------------------
The following changes were applied:
Expand All @@ -42,64 +49,63 @@ The underlying API has changed dramatically. Gexf4j now supports the entire GEXF
* Phylogeny
* Visualization

Also introduced in 0.2 is a chaining API, allowing for a more descriptive interaction with the API. Here's an example:

Node gephi = gexf.getGraph().createNode("0");
gephi
.setLabel("Gephi")
.setStartDate(toDate("2009-03-01"))
.getAttributeValues()
.addValue(attUrl, "http://gephi.org")
.addValue(attIndegree, "1");

Installing
------------------
You have two options:

1. Download the latest JAR files from the download page
1. Download the latest version of the JAR file from the [download page](https://github.com/francesco-ficarola/gexf4j/downloads)
2. Download the source, and compile/install using maven2 (mvn clean && mvn package)

Dependecies
------------------
Gexf4j library needs [com.google.common.base.Preconditions](http://code.google.com/p/guava-libraries/). You can find a version of that library in the lib directory, too.

Sample Code
------------------
The following code creates the same graph located on: http://gexf.net/format/data.html
The following code builds [this static graph](https://github.com/downloads/francesco-ficarola/gexf4j/static_graph_sample.gexf).

Gexf gexf = new GexfImpl();
Calendar date = Calendar.getInstance();

gexf.getMetadata()
.setLastModified(toDate("2009-03-20"))
.setLastModified(date.getTime())
.setCreator("Gephi.org")
.setDescription("A Web network");

Graph graph = gexf.getGraph();
graph.setDefaultEdgeType(EdgeType.UNDIRECTED).setMode(Mode.STATIC);

AttributeList attrList = new AttributeListImpl(AttributeClass.NODE);
gexf.getGraph().getAttributeLists().add(attrList);
graph.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");


Node gephi = gexf.getGraph().createNode("0");
Node gephi = graph.createNode("0");
gephi
.setLabel("Gephi")
.getAttributeValues()
.addValue(attUrl, "http://gephi.org")
.addValue(attIndegree, "1");

Node webatlas = gexf.getGraph().createNode("1");
Node webatlas = graph.createNode("1");
webatlas
.setLabel("Webatlas")
.getAttributeValues()
.addValue(attUrl, "http://webatlas.fr")
.addValue(attIndegree, "2");

Node rtgi = gexf.getGraph().createNode("2");
Node rtgi = graph.createNode("2");
rtgi
.setLabel("RTGI")
.getAttributeValues()
.addValue(attUrl, "http://rtgi.fr")
.addValue(attIndegree, "1");

Node blab = gexf.getGraph().createNode("3");
Node blab = graph.createNode("3");
blab
.setLabel("BarabasiLab")
.getAttributeValues()
Expand All @@ -112,3 +118,191 @@ The following code creates the same graph located on: http://gexf.net/format/dat
webatlas.connectTo("2", gephi);
rtgi.connectTo("3", webatlas);
gephi.connectTo("4", blab);

StaxGraphWriter graphWriter = new StaxGraphWriter();
File f = new File("static_graph_sample.gexf");
FileOutputStream fos;
try {
fos = new FileOutputStream(f, false);
graphWriter.writeToStream(gexf, fos);
System.out.println(f.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}


The following code builds [this dynamic graph](https://github.com/downloads/francesco-ficarola/gexf4j/dynamic_graph_sample.gexf).

Gexf gexf = new GexfImpl();
Calendar date = Calendar.getInstance();

gexf.getMetadata()
.setLastModified(date.getTime())
.setCreator("Gephi.org")
.setDescription("A Web network");


Graph graph = gexf.getGraph();
graph.
setDefaultEdgeType(EdgeType.UNDIRECTED)
.setMode(Mode.DYNAMIC)
.setTimeType(TimeFormat.XSDDATETIME);

AttributeList attrList = new AttributeListImpl(AttributeClass.NODE);
graph.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");


/** Node Gephi */
Node gephi = graph.createNode("0");
gephi
.setLabel("Gephi")
.getAttributeValues()
.addValue(attUrl, "http://gephi.org")
.addValue(attIndegree, "1");

Spell spellGephi = new SpellImpl();
date.set(2012, 3, 28, 16, 10, 0);
date.set(Calendar.MILLISECOND, 0);
spellGephi.setStartValue(date.getTime());
gephi.getSpells().add(spellGephi);


/** Node Webatlas */
Node webatlas = graph.createNode("1");
webatlas
.setLabel("Webatlas")
.getAttributeValues()
.addValue(attUrl, "http://webatlas.fr")
.addValue(attIndegree, "2");

Spell spellWebatlas1 = new SpellImpl();
date.set(Calendar.MINUTE, 15);
spellWebatlas1.setStartValue(date.getTime());
date.set(2012, 3, 28, 18, 57, 2);
spellWebatlas1.setEndValue(date.getTime());
webatlas.getSpells().add(spellWebatlas1);

Spell spellWebatlas2 = new SpellImpl();
date.set(2012, 3, 28, 20, 31, 10);
spellWebatlas2.setStartValue(date.getTime()).setStartIntervalType(IntervalType.OPEN);
date.set(Calendar.MINUTE, 45);
date.set(Calendar.SECOND, 21);
spellWebatlas2.setEndValue(date.getTime());
webatlas.getSpells().add(spellWebatlas2);

Spell spellWebatlas3 = new SpellImpl();
date.set(2012, 3, 28, 21, 0, 0);
spellWebatlas3.setStartValue(date.getTime());
date.set(2012, 4, 11, 10, 49, 27);
spellWebatlas3.setEndValue(date.getTime()).setEndIntervalType(IntervalType.OPEN);
webatlas.getSpells().add(spellWebatlas3);


/** Node RTGI */
Node rtgi = graph.createNode("2");
rtgi
.setLabel("RTGI")
.getAttributeValues()
.addValue(attUrl, "http://rtgi.fr")
.addValue(attIndegree, "1");

Spell spellRtgi = new SpellImpl();
date.set(2012, 3, 27, 6, 0, 0);
spellRtgi.setStartValue(date.getTime());
date.set(2012, 4, 19);
spellRtgi.setEndValue(date.getTime());
rtgi.getSpells().add(spellRtgi);


/** Node BarabasiLab */
Node blab = graph.createNode("3");
blab
.setLabel("BarabasiLab")
.getAttributeValues()
.addValue(attUrl, "http://barabasilab.com")
.addValue(attIndegree, "3")
.addValue(attFrog, "false");


/** Node foobar */
Node foobar = graph.createNode("4");
foobar
.setLabel("FooBar")
.getAttributeValues()
.addValue(attUrl, "http://foo.bar")
.addValue(attIndegree, "1")
.addValue(attFrog, "false");


/** Edge 0 [gephi, webatlas] */
Edge edge0 = gephi.connectTo("0", webatlas);

Spell spellEdge0 = new SpellImpl();
date.set(2012, 3, 28, 16, 15, 36);
spellEdge0.setStartValue(date.getTime());
date.set(2012, 3, 28, 17, 41, 5);
spellEdge0.setEndValue(date.getTime());
edge0.getSpells().add(spellEdge0);


/** Edge 1 [gephi, rtgi] */
Edge edge1 = gephi.connectTo("1", rtgi);

Spell spellEdge1 = new SpellImpl();
date.set(2012, 3, 30, 11, 16, 6);
spellEdge1.setStartValue(date.getTime());
date.set(2012, 4, 3, 11, 52, 6);
spellEdge1.setEndValue(date.getTime());
edge1.getSpells().add(spellEdge1);


/** Edge 2 [rtgi, webatlas] */
Edge edge2 = rtgi.connectTo("2", webatlas);
Spell spellEdge2 = new SpellImpl();
date.set(2012, 4, 1, 11, 0, 0);
spellEdge2.setStartValue(date.getTime()).setStartIntervalType(IntervalType.OPEN);
date.set(2012, 4, 5, 11, 9, 44);
spellEdge2.setEndValue(date.getTime());
edge2.getSpells().add(spellEdge2);


/** Edge 3 [gephi, blab] */
Edge edge3 = gephi.connectTo("3", blab);
Spell spellEdge3 = new SpellImpl();
date.set(2012, 3, 30, 12, 13, 22);
spellEdge3.setStartValue(date.getTime());
date.set(Calendar.MINUTE, 58);
date.set(Calendar.SECOND, 24);
spellEdge3.setEndValue(date.getTime());
edge3.getSpells().add(spellEdge3);


/** Edge 4 [webatlas, blab] */
Edge edge4 = webatlas.connectTo("4", blab);
Spell spellEdge4 = new SpellImpl();
date.set(2012, 3, 30, 21, 2, 37);
spellEdge4.setStartValue(date.getTime());
date.set(Calendar.MINUTE, 13);
spellEdge4.setEndValue(date.getTime());
edge4.getSpells().add(spellEdge4);


/** Edge 5 [foobar, blab] */
foobar.connectTo("5", blab);


StaxGraphWriter graphWriter = new StaxGraphWriter();
File f = new File("dynamic_graph_sample.gexf");
FileOutputStream fos;
try {
fos = new FileOutputStream(f, false);
graphWriter.writeToStream(gexf, fos);
System.out.println(f.getAbsolutePath());
} catch (IOException e) {
e.printStackTrace();
}
Loading

0 comments on commit 97c4d6e

Please sign in to comment.