Mercurial > hg > Members > nobuyasu > TPPageRank
changeset 16:4ed8a8a5ef92 draft
commit
author | one |
---|---|
date | Sat, 08 Sep 2012 09:56:03 +0900 |
parents | e1d758d08e9c |
children | fcf2a7b4b867 |
files | src/pagerank/LinkConvertGraph.java src/pagerank/TPReadWikiLink.java src/pagerank/WikiPage.java |
diffstat | 3 files changed, 29 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pagerank/LinkConvertGraph.java Sat Sep 08 06:01:00 2012 +0900 +++ b/src/pagerank/LinkConvertGraph.java Sat Sep 08 09:56:03 2012 +0900 @@ -34,7 +34,7 @@ // final String fileDB = "./resources/tinkerpopDB"; - final long PAGENUM = 22; + final long PAGENUM = 200000; final String fileDB = "./resources/tinkerGraph"+ Long.toString(PAGENUM); final String logFile = "./resources/wikiLink"+Long.toString(PAGENUM)+".log"; @@ -52,16 +52,17 @@ FileOutputStream fos = new FileOutputStream(logFile); long countId = 0; + for (Map.Entry<String, HashSet<String>> map : hash.entrySet()) { lcg.printLinkLog(map, fos); -// if (PAGENUM <= countId) break; + if (PAGENUM <= countId) break; String pageTitle = map.getKey(); Vertex v;// = graph.addVertex(null); if ( ltv.getId(pageTitle) == null ) { v = ltv.createVertexWithPageTitle(pageTitle,countId); ltv.setPageRank(v, (Double)0.0); countId++; -// if (PAGENUM <= countId) break; + if (PAGENUM <= countId) break; } else { v = ltv.getVertex(pageTitle); } @@ -76,7 +77,7 @@ linkV = ltv.getVertex(linkPageTitle); } ltv.setHasLink(v, linkV); -// if (PAGENUM <= countId) break; + if (PAGENUM <= countId) break; } }
--- a/src/pagerank/TPReadWikiLink.java Sat Sep 08 06:01:00 2012 +0900 +++ b/src/pagerank/TPReadWikiLink.java Sat Sep 08 09:56:03 2012 +0900 @@ -27,7 +27,8 @@ // final String fileDB = "./resources/tinkerpopDB"; - final long PAGENUM = 22; +// final long PAGENUM = 200000; + final long PAGENUM = 242014; final String fileDB = "./resources/tinkerGraph"+Long.toString(PAGENUM); final String pageRankLog = "./resources/wikiPageRank"+Long.toString(PAGENUM)+".log"; @@ -38,24 +39,19 @@ in.close(); LinkToVertex ltv = new LinkToVertex(graph); - ltv.initPageRankAllVertex(); +// ltv.initPageRankAllVertex(); final long AllVertexNumber = ltv.searchAllVertices(); HashMap<String, WikiPage> wikiHash = ltv.getWikiPageHash(); System.out.println("AllVertexNumber = "+AllVertexNumber); - Object vertexIds[] = {80, 79, 20, 28}; - + Object vertexIds[] = {79, 20, 575, 80}; + writeComputeTransition(ltv, vertexIds, 10, PAGENUM); - long start = java.lang.System.currentTimeMillis(); - writeComputeTransition(ltv, vertexIds, 11, PAGENUM); - long end = java.lang.System.currentTimeMillis(); - long time = end - start; - System.out.println(time); - - /* - for (int i=0; i<10; i++ ) { + +/* + for (int i=0; i<10; i++) { long start = java.lang.System.currentTimeMillis(); for (int j=0; j<10; j++){ for (Vertex v : graph.getVertices()) { @@ -66,7 +62,7 @@ long time = end - start; System.out.println(time); } -*/ +*/ FileOutputStream fos = new FileOutputStream(new File(pageRankLog)); @@ -112,18 +108,25 @@ fos.write( ("# Vertex ID "+id+" "+ ltv.getPageTitle(v)+"\n").getBytes()); fosList.add(fos); } + + for (int i=0; i<count; i++) { + for (int index=0; index< vertexIds.length; index++){ + FileOutputStream fos = fosList.get(index); + printPageRankLog(fos, ltv, vertexIds[index], i); + } for (Vertex v : ltv.getAllVertices() ) { // ltv.computePageRank(v); ltv.computePageRankUsingPipes(v.getId()); } - for (int index=0; index< vertexIds.length; index++){ - FileOutputStream fos = fosList.get(index); - printPageRankLog(fos, ltv, vertexIds[index], i); - } } + for (int index=0; index< vertexIds.length; index++){ + FileOutputStream fos = fosList.get(index); + printPageRankLog(fos, ltv, vertexIds[index], count); + } + for (FileOutputStream fos: fosList) { fos.close(); }
--- a/src/pagerank/WikiPage.java Sat Sep 08 06:01:00 2012 +0900 +++ b/src/pagerank/WikiPage.java Sat Sep 08 09:56:03 2012 +0900 @@ -10,7 +10,7 @@ public class WikiPage { private String title; - private long id; + private Object id; private Double rank; private long outHasLink; private long inHasLink; @@ -25,7 +25,7 @@ WikiPage(Vertex v) { this.title = (String) v.getProperty(LinkToVertex.PAGE_TITLE); - this.id = Long.parseLong((String)v.getId()); + this.id = v.getId(); this.rank = (Double)v.getProperty(LinkToVertex.PAGE_RANK); this.outHasLink = 0; this.inHasLink = 0; @@ -43,7 +43,7 @@ return title; } - long getId() { + Object getId() { return id; } @@ -63,7 +63,7 @@ this.title = title; } - void setId(long id) { + void setId(Object id) { this.id = id; }