annotate src/sample/GremlinSample.java @ 13:0ef7268bbbac draft

create descendiangOrder(Graph,FileOutputStream) method.
author one
date Sat, 08 Sep 2012 04:12:19 +0900
parents 8e3bb1843beb
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
1 package sample;
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
2
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
3 import java.io.File;
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
4 import java.io.FileInputStream;
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
5
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
6 import pagerank.LinkToVertex;
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
7
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
8 import com.tinkerpop.blueprints.Graph;
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
9 import com.tinkerpop.blueprints.Vertex;
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
10 import com.tinkerpop.blueprints.impls.tg.TinkerGraph;
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
11 import com.tinkerpop.blueprints.util.io.graphml.GraphMLReader;
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
12 import com.tinkerpop.gremlin.java.GremlinPipeline;
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
13 import com.tinkerpop.pipes.util.iterators.SingleIterator;
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
14
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
15 public class GremlinSample {
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
16
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
17 public static void main(String[] args) {
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
18
13
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
19 // final String fileDB = "./resources/tinkerpopDB";
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
20 final String fileDB = "./resources/tinkerGraph100";
11
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
21
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
22 try {
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
23 Graph graph = new TinkerGraph();
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
24 FileInputStream in = new FileInputStream(new File(fileDB));
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
25 GraphMLReader.inputGraph(graph, in);
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
26 in.close();
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
27 LinkToVertex ltv = new LinkToVertex(graph);
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
28
13
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
29 final long AllVertexNumber = ltv.searchAllVertices();
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
30 System.out.println("AllVertexNumber = "+ AllVertexNumber);
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
31
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
32 for (Vertex o : graph.getVertices()) {
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
33 System.out.println(o);
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
34 }
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
35 /*
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
36 GremlinPipeline pipe = new GremlinPipeline();
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
37 pipe.start(graph.getVertex(1));
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
38 */
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
39
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
40 /*
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
41 String id = "85956";
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
42 GremlinPipeline pipe = new GremlinPipeline();
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
43 pipe.start(graph.getVertex(id)).out("HasLink");//.property("pageTitle");
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
44 pipe.property("pageTitle");
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
45 // pipe.start(graph.getVertex(id)).out("HasLink");
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
46 // pipe.setStarts(new SingleIterator<Vertex>(graph.getVertex(id)));
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
47
11
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
48 for (Object title : pipe) {
13
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
49 System.out.println(title);
11
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
50 }
13
0ef7268bbbac create descendiangOrder(Graph,FileOutputStream) method.
one
parents: 11
diff changeset
51 */
11
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
52 } catch (NumberFormatException e){
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
53 System.out.println("Program exit");
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
54 } catch (Exception e) {
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
55 e.printStackTrace();
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
56 } finally {
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
57
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
58 }
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
59
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
60 }
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
61
8e3bb1843beb add pipes.jar and GremlinSample.java
one
parents:
diff changeset
62 }