comparison src/pagerank/LinkToVertex.java @ 14:86567db31710 draft

fix
author one
date Sat, 08 Sep 2012 04:50:50 +0900
parents 0ef7268bbbac
children e1d758d08e9c
comparison
equal deleted inserted replaced
13:0ef7268bbbac 14:86567db31710
235 235
236 public double computePageRankUsingPipes(Object id) { 236 public double computePageRankUsingPipes(Object id) {
237 double sum = 0.0; 237 double sum = 0.0;
238 double pageRank = 0.0; 238 double pageRank = 0.0;
239 Vertex v = graph.getVertex(id); 239 Vertex v = graph.getVertex(id);
240 WikiPage wiki = wikiPageHash.get(v.getProperty(PAGE_TITLE));
241 240
242 GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); 241 GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>();
243 pipe.start(graph.getVertex(id)).in("HasLink"); 242 pipe.start(graph.getVertex(id)).in("HasLink");
244 for (Vertex inVer : pipe) { 243 for (Vertex inVer : pipe) {
245 Object inVerId = inVer.getId(); 244 Object inVerId = inVer.getId();
248 long linkNum = inPipe.count(); 247 long linkNum = inPipe.count();
249 double pr = (Double) inVer.getProperty(PAGE_RANK); 248 double pr = (Double) inVer.getProperty(PAGE_RANK);
250 sum += (double) pr / linkNum; 249 sum += (double) pr / linkNum;
251 } 250 }
252 pageRank = (double) 1 - weight + (double) sum * weight; 251 pageRank = (double) 1 - weight + (double) sum * weight;
253 wiki.setRank(pageRank);
254 v.setProperty(PAGE_RANK, pageRank); 252 v.setProperty(PAGE_RANK, pageRank);
255 return pageRank; 253 return pageRank;
256 } 254 }
257 255
258 public void printVertexInfo(int nodeId) { 256 public void printVertexInfo(int nodeId) {