Mercurial > hg > Members > nobuyasu > TPPageRank
view src/sample/SimpleGraph.java @ 2:1744340f8be6 draft
add some java files
author | one |
---|---|
date | Wed, 05 Sep 2012 11:56:21 +0900 |
parents | 08f01b5c4d4a |
children |
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 SimpleGraph { public static void main(String[] args) { /* Graph graph = new 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")); testIteratingGraph(); */ Graph graph = TinkerGraphFactory.createTinkerGraph(); 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); } } public static void testIteratingGraph() { Graph graph = TinkerGraphFactory.createTinkerGraph(); System.out.println("Vertices of " + graph); for (Vertex vertex : graph.getVertices() ){ System.out.println(vertex); } System.out.println("Edges of " + graph); for (Edge edge : graph.getEdges()) { System.out.println(edge); } } }