Mercurial > hg > Members > nobuyasu > TPPageRank
view src/sample/CreateTinkerGraph.java @ 1:08f01b5c4d4a draft
add libraries and java files
author | one |
---|---|
date | Tue, 04 Sep 2012 22:47:53 +0900 |
parents | |
children | 1744340f8be6 |
line wrap: on
line source
package sample; import com.tinkerpop.blueprints.Direction; import com.tinkerpop.blueprints.Edge; import com.tinkerpop.blueprints.Graph; import com.tinkerpop.blueprints.Vertex; import com.tinkerpop.blueprints.impls.tg.TinkerGraph; import com.tinkerpop.blueprints.impls.tg.TinkerGraphFactory; public class CreateTinkerGraph { public static void main(String[] args) { createTest(); // readTest(); } public static void outputGraph() { Graph graph = new TinkerGraph("./resources/"); } public static void createTest() { Graph graph = new TinkerGraph("/tmp/tinkergraph"); Vertex a = graph.addVertex(null); Vertex b = graph.addVertex(null); a.setProperty("name", "mariko"); b.setProperty("name", "Peter"); Edge e = graph.addEdge(null, a, b, "knows"); System.out.println(e.getVertex(Direction.OUT).getProperty("name") + "--" + e.getLabel() + "-->" + e.getVertex(Direction.IN).getProperty("name")); } public static void readTest() { Graph graph = new TinkerGraph("/tmp/tinkergraph"); Vertex aa = graph.getVertex("1"); System.out.println("vertex " + aa.getId() + " has name " + aa.getProperty("name")); for(Edge ee : aa.getEdges(Direction.OUT)) { System.out.println(ee); } } }