comparison src/pagerank/TPReadWikiLink.java @ 16:4ed8a8a5ef92 draft

commit
author one
date Sat, 08 Sep 2012 09:56:03 +0900
parents e1d758d08e9c
children fcf2a7b4b867
comparison
equal deleted inserted replaced
15:e1d758d08e9c 16:4ed8a8a5ef92
25 25
26 public static void main(String[] args) { 26 public static void main(String[] args) {
27 27
28 // final String fileDB = "./resources/tinkerpopDB"; 28 // final String fileDB = "./resources/tinkerpopDB";
29 29
30 final long PAGENUM = 22; 30 // final long PAGENUM = 200000;
31 final long PAGENUM = 242014;
31 final String fileDB = "./resources/tinkerGraph"+Long.toString(PAGENUM); 32 final String fileDB = "./resources/tinkerGraph"+Long.toString(PAGENUM);
32 final String pageRankLog = "./resources/wikiPageRank"+Long.toString(PAGENUM)+".log"; 33 final String pageRankLog = "./resources/wikiPageRank"+Long.toString(PAGENUM)+".log";
33 34
34 try { 35 try {
35 Graph graph = new TinkerGraph(); 36 Graph graph = new TinkerGraph();
36 FileInputStream in = new FileInputStream(new File(fileDB)); 37 FileInputStream in = new FileInputStream(new File(fileDB));
37 GraphMLReader.inputGraph(graph, in); 38 GraphMLReader.inputGraph(graph, in);
38 in.close(); 39 in.close();
39 LinkToVertex ltv = new LinkToVertex(graph); 40 LinkToVertex ltv = new LinkToVertex(graph);
40 41
41 ltv.initPageRankAllVertex(); 42 // ltv.initPageRankAllVertex();
42 43
43 final long AllVertexNumber = ltv.searchAllVertices(); 44 final long AllVertexNumber = ltv.searchAllVertices();
44 HashMap<String, WikiPage> wikiHash = ltv.getWikiPageHash(); 45 HashMap<String, WikiPage> wikiHash = ltv.getWikiPageHash();
45 System.out.println("AllVertexNumber = "+AllVertexNumber); 46 System.out.println("AllVertexNumber = "+AllVertexNumber);
46 47
47 48
48 Object vertexIds[] = {80, 79, 20, 28}; 49 Object vertexIds[] = {79, 20, 575, 80};
50 writeComputeTransition(ltv, vertexIds, 10, PAGENUM);
51
49 52
50 53 /*
51 long start = java.lang.System.currentTimeMillis(); 54 for (int i=0; i<10; i++) {
52 writeComputeTransition(ltv, vertexIds, 11, PAGENUM);
53 long end = java.lang.System.currentTimeMillis();
54 long time = end - start;
55 System.out.println(time);
56
57 /*
58 for (int i=0; i<10; i++ ) {
59 long start = java.lang.System.currentTimeMillis(); 55 long start = java.lang.System.currentTimeMillis();
60 for (int j=0; j<10; j++){ 56 for (int j=0; j<10; j++){
61 for (Vertex v : graph.getVertices()) { 57 for (Vertex v : graph.getVertices()) {
62 ltv.computePageRankUsingPipes(v.getId()); 58 ltv.computePageRankUsingPipes(v.getId());
63 } 59 }
64 } 60 }
65 long end = java.lang.System.currentTimeMillis(); 61 long end = java.lang.System.currentTimeMillis();
66 long time = end - start; 62 long time = end - start;
67 System.out.println(time); 63 System.out.println(time);
68 } 64 }
69 */ 65 */
70 66
71 67
72 FileOutputStream fos = new FileOutputStream(new File(pageRankLog)); 68 FileOutputStream fos = new FileOutputStream(new File(pageRankLog));
73 descendingOrder(graph, ltv, fos); 69 descendingOrder(graph, ltv, fos);
74 /* 70 /*
110 106
111 Vertex v = ltv.getVertexById(id); 107 Vertex v = ltv.getVertexById(id);
112 fos.write( ("# Vertex ID "+id+" "+ ltv.getPageTitle(v)+"\n").getBytes()); 108 fos.write( ("# Vertex ID "+id+" "+ ltv.getPageTitle(v)+"\n").getBytes());
113 fosList.add(fos); 109 fosList.add(fos);
114 } 110 }
111
112
115 113
116 for (int i=0; i<count; i++) { 114 for (int i=0; i<count; i++) {
115 for (int index=0; index< vertexIds.length; index++){
116 FileOutputStream fos = fosList.get(index);
117 printPageRankLog(fos, ltv, vertexIds[index], i);
118 }
117 for (Vertex v : ltv.getAllVertices() ) { 119 for (Vertex v : ltv.getAllVertices() ) {
118 // ltv.computePageRank(v); 120 // ltv.computePageRank(v);
119 ltv.computePageRankUsingPipes(v.getId()); 121 ltv.computePageRankUsingPipes(v.getId());
120 } 122 }
121 123
122 for (int index=0; index< vertexIds.length; index++){
123 FileOutputStream fos = fosList.get(index);
124 printPageRankLog(fos, ltv, vertexIds[index], i);
125 }
126 } 124 }
125 for (int index=0; index< vertexIds.length; index++){
126 FileOutputStream fos = fosList.get(index);
127 printPageRankLog(fos, ltv, vertexIds[index], count);
128 }
129
127 for (FileOutputStream fos: fosList) { 130 for (FileOutputStream fos: fosList) {
128 fos.close(); 131 fos.close();
129 } 132 }
130 133
131 } 134 }