Mercurial > hg > Members > nobuyasu > TPPageRank
changeset 15:e1d758d08e9c draft
modify id in WikiPage.java
author | one |
---|---|
date | Sat, 08 Sep 2012 06:01:00 +0900 |
parents | 86567db31710 |
children | 4ed8a8a5ef92 |
files | src/pagerank/LinkConvertGraph.java src/pagerank/LinkToVertex.java src/pagerank/TPReadWikiLink.java |
diffstat | 3 files changed, 20 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pagerank/LinkConvertGraph.java Sat Sep 08 04:50:50 2012 +0900 +++ b/src/pagerank/LinkConvertGraph.java Sat Sep 08 06:01:00 2012 +0900 @@ -34,7 +34,7 @@ // final String fileDB = "./resources/tinkerpopDB"; - final long PAGENUM = 11; + final long PAGENUM = 22; final String fileDB = "./resources/tinkerGraph"+ Long.toString(PAGENUM); final String logFile = "./resources/wikiLink"+Long.toString(PAGENUM)+".log"; @@ -58,7 +58,7 @@ String pageTitle = map.getKey(); Vertex v;// = graph.addVertex(null); if ( ltv.getId(pageTitle) == null ) { - v = ltv.createVertexWithPageTitle(pageTitle); + v = ltv.createVertexWithPageTitle(pageTitle,countId); ltv.setPageRank(v, (Double)0.0); countId++; // if (PAGENUM <= countId) break; @@ -69,7 +69,7 @@ for (String linkPageTitle : map.getValue()) { Vertex linkV; if ( ltv.getId(linkPageTitle) == null) { - linkV = ltv.createVertexWithPageTitle(linkPageTitle); + linkV = ltv.createVertexWithPageTitle(linkPageTitle,countId); countId++; ltv.setPageRank(linkV, (Double)0.0); } else {
--- a/src/pagerank/LinkToVertex.java Sat Sep 08 04:50:50 2012 +0900 +++ b/src/pagerank/LinkToVertex.java Sat Sep 08 06:01:00 2012 +0900 @@ -94,7 +94,7 @@ return graph.getVertex(id); } - Vertex getVertexById(String id) { + Vertex getVertexById(Object id) { return graph.getVertex(id); } @@ -269,4 +269,6 @@ } + + }
--- a/src/pagerank/TPReadWikiLink.java Sat Sep 08 04:50:50 2012 +0900 +++ b/src/pagerank/TPReadWikiLink.java Sat Sep 08 06:01:00 2012 +0900 @@ -25,10 +25,10 @@ public static void main(String[] args) { - final String fileDB = "./resources/tinkerpopDB"; +// final String fileDB = "./resources/tinkerpopDB"; - final long PAGENUM = 11; -// final String fileDB = "./resources/tinkerGraph"+Long.toString(PAGENUM); + final long PAGENUM = 22; + final String fileDB = "./resources/tinkerGraph"+Long.toString(PAGENUM); final String pageRankLog = "./resources/wikiPageRank"+Long.toString(PAGENUM)+".log"; try { @@ -45,16 +45,16 @@ System.out.println("AllVertexNumber = "+AllVertexNumber); -// String nodeIds[] = {"80", "290", "21", "164", "41972", "103700", "65956", "103700"}; - String nodeIds[] = {"146","148"}; + Object vertexIds[] = {80, 79, 20, 28}; -/* + long start = java.lang.System.currentTimeMillis(); - writeComputeTransition(ltv, nodeIds, 10, PAGENUM); + 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++ ) { long start = java.lang.System.currentTimeMillis(); for (int j=0; j<10; j++){ @@ -66,7 +66,7 @@ long time = end - start; System.out.println(time); } - +*/ FileOutputStream fos = new FileOutputStream(new File(pageRankLog)); @@ -101,9 +101,9 @@ } } - public static void writeComputeTransition(LinkToVertex ltv,final String nodeIds[], int count, long pagenum) throws IOException { + public static void writeComputeTransition(LinkToVertex ltv,final Object[] vertexIds, int count, long pagenum) throws IOException { LinkedList<FileOutputStream> fosList = new LinkedList<FileOutputStream>(); - for (String id: nodeIds) { + for (Object id: vertexIds) { String filename = "./resources/VertexId_"+id+"_num"+Long.toString(pagenum)+".dat"; FileOutputStream fos = null; fos = new FileOutputStream(filename); @@ -119,9 +119,9 @@ ltv.computePageRankUsingPipes(v.getId()); } - for (int index=0; index<nodeIds.length; index++){ + for (int index=0; index< vertexIds.length; index++){ FileOutputStream fos = fosList.get(index); - printPageRankLog(fos, ltv, nodeIds[index], i); + printPageRankLog(fos, ltv, vertexIds[index], i); } } for (FileOutputStream fos: fosList) { @@ -182,7 +182,7 @@ fos.flush(); } - public static void printPageRankLog(FileOutputStream fos, LinkToVertex ltv, String id, int x) throws IOException { + public static void printPageRankLog(FileOutputStream fos, LinkToVertex ltv, Object id, int x) throws IOException { double rank = ltv.getPageRank(ltv.getVertexById(id)); fos.write( (x+" "+ rank+"\n").getBytes() ); fos.flush();