Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First task, communicate from Graphstream to Gephi through GSON protocol
- Loading branch information
Showing
4 changed files
with
492 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,7 @@ | |
# eclipse # | ||
.project | ||
.classpath | ||
.settings | ||
.settings | ||
|
||
bin/ | ||
target/ |
34 changes: 34 additions & 0 deletions
34
src-test/org/graphstream/stream/gephi/test/TestJSONSink.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
}; | ||
} |
Oops, something went wrong.