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