Mercurial > hg > Members > nobuyasu > TPPageRank
changeset 11:8e3bb1843beb draft
add pipes.jar and GremlinSample.java
author | one |
---|---|
date | Wed, 05 Sep 2012 19:12:20 +0900 |
parents | c7a7c53702dd |
children | 7e38484474f4 |
files | .classpath lib/pipes-2.2.0-SNAPSHOT-javadoc.jar lib/pipes-2.2.0-SNAPSHOT-sources.jar lib/pipes-2.2.0-SNAPSHOT.jar src/pagerank/TPReadWikiLink.java src/sample/GremlinSample.java |
diffstat | 6 files changed, 56 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/.classpath Wed Sep 05 18:52:37 2012 +0900 +++ b/.classpath Wed Sep 05 19:12:20 2012 +0900 @@ -7,5 +7,7 @@ </attributes> </classpathentry> <classpathentry kind="lib" path="lib/blueprints-core-2.2.0-SNAPSHOT.jar"/> + <classpathentry kind="lib" path="lib/gremlin-java-2.2.0-SNAPSHOT.jar"/> + <classpathentry kind="lib" path="lib/pipes-2.2.0-SNAPSHOT.jar"/> <classpathentry kind="output" path="build/classes"/> </classpath>
--- a/src/pagerank/TPReadWikiLink.java Wed Sep 05 18:52:37 2012 +0900 +++ b/src/pagerank/TPReadWikiLink.java Wed Sep 05 19:12:20 2012 +0900 @@ -36,20 +36,23 @@ LinkToVertex ltv = new LinkToVertex(graph); // ltv.initPageRankAllVertex(); +/* final long AllVertexNumber = ltv.searchAllVertices(); HashMap<String, WikiPage> wikiHash = ltv.getWikiPageHash(); System.out.println("AllVertexNumber = "+AllVertexNumber); - +*/ /* String nodeIds[] = {"80", "290", "21", "164"}; writeComputeTransition(ltv, nodeIds, 50); */ - +/* FileOutputStream fos = new FileOutputStream(new File("./resources/wikiPageRank.log")); descendingOrder(wikiHash, fos); +*/ - + + FileOutputStream out = new FileOutputStream(new File(fileDB)); GraphMLWriter.outputGraph(graph, out); out.close();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/sample/GremlinSample.java Wed Sep 05 19:12:20 2012 +0900 @@ -0,0 +1,48 @@ +package sample; + +import java.io.File; +import java.io.FileInputStream; + +import pagerank.LinkToVertex; + +import com.tinkerpop.blueprints.Graph; +import com.tinkerpop.blueprints.Vertex; +import com.tinkerpop.blueprints.impls.tg.TinkerGraph; +import com.tinkerpop.blueprints.util.io.graphml.GraphMLReader; +import com.tinkerpop.gremlin.java.GremlinPipeline; +import com.tinkerpop.pipes.util.iterators.SingleIterator; + +public class GremlinSample { + + public static void main(String[] args) { + + final String fileDB = "./resources/tinkerpopDB"; + + + try { + Graph graph = new TinkerGraph(); + FileInputStream in = new FileInputStream(new File(fileDB)); + GraphMLReader.inputGraph(graph, in); + in.close(); + LinkToVertex ltv = new LinkToVertex(graph); + + String id = "21"; + GremlinPipeline pipe = new GremlinPipeline(); + pipe.start(graph.getVertex(id)).out("HasLink").property("pageTitle"); + pipe.setStarts(new SingleIterator<Vertex>(graph.getVertex(id))); + for (Object title : pipe) { + System.out.println((String)title); + } + + + } catch (NumberFormatException e){ + System.out.println("Program exit"); + } catch (Exception e) { + e.printStackTrace(); + } finally { + + } + + } + +}