Skip to content

Commit

Permalink
First task, communicate from Graphstream to Gephi through GSON protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
wumalbert committed Jun 16, 2012
1 parent 7f8b335 commit 0ec6602
Show file tree
Hide file tree
Showing 4 changed files with 492 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -8,4 +8,7 @@
# eclipse #
.project
.classpath
.settings
.settings

bin/
target/
34 changes: 34 additions & 0 deletions src-test/org/graphstream/stream/gephi/test/TestJSONSink.java
@@ -0,0 +1,34 @@
package org.graphstream.stream.gephi.test;

import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.SingleGraph;
import org.graphstream.stream.gephi.JSONSink;

public class TestJSONSink {
public static void main(String args[]) {
Graph graph = new SingleGraph("Tutorial 1");

JSONSink jsonSink = new JSONSink("localhost", 8080, "workspace0");
graph.addSink(jsonSink);

//graph.display();

graph.addNode("A");
graph.addNode("B");
graph.addNode("C");
sleep();
graph.addEdge("AB", "A", "B");
graph.addEdge("BC", "B", "C");
graph.addEdge("CA", "C", "A");
sleep();


graph.clear();
}

protected static void sleep() {
try {
Thread.sleep(1000);
} catch (Exception e) {}
}
}
48 changes: 48 additions & 0 deletions src/org/graphstream/stream/gephi/JSONEventConstants.java
@@ -0,0 +1,48 @@
/**
*
*/
package org.graphstream.stream.gephi;

/**
* @author wumalbert
*
*/
public class JSONEventConstants {

public enum Types {
AN("an"),
CN("cn"),
DN("dn"),
AE("ae"),
CE("ce"),
DE("de"),
CG("cg");

private String value;

private Types(String value) {
this.value = value;
}

public String value() {
return value;
}
}

public enum Fields {
ID("id"),
T("t"), //timestamp
SOURCE("source"),
TARGET("target"),
DIRECTED("directed");
private String value;

private Fields(String value) {
this.value = value;
}

public String value() {
return value;
}
};
}

0 comments on commit 0ec6602

Please sign in to comment.