changeset 17:fcf2a7b4b867 draft default tip

modify loop method
author one
date Sat, 08 Sep 2012 10:04:48 +0900
parents 4ed8a8a5ef92
children
files src/pagerank/LinkToVertex.java src/pagerank/TPReadWikiLink.java
diffstat 2 files changed, 23 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/pagerank/LinkToVertex.java	Sat Sep 08 09:56:03 2012 +0900
+++ b/src/pagerank/LinkToVertex.java	Sat Sep 08 10:04:48 2012 +0900
@@ -253,8 +253,12 @@
 		return pageRank;
 	}
 	
-	public void printVertexInfo(int nodeId) {
-		Vertex v = graph.getVertex(nodeId);
+	public void printVertexInfo(Object id) {
+		Vertex v = graph.getVertex(id);
+		if (v == null) {
+			System.out.println(id+" is null.");
+			return;
+		}
 		printInHasLink(v, 1);
 		printOutHasLink(v, 1);
 
@@ -263,12 +267,15 @@
 		long inHasLink = computeInHasLink(v);
 		long outHasLink = computeOutHasLink(v);
 		
-		System.out.println("id:"+nodeId+" title:"+title+" rank:"+rank);
+		System.out.println("id:"+id+" title:"+title+" rank:"+rank);
 		System.out.println("inHasLink:"+inHasLink+" outHasLink:"+outHasLink);
 		System.out.println();
 	
 	}
 
-
+	public void printVertexInfo(String title) {
+		Object id = getId(title);
+		printVertexInfo(id);
+	}
 
 }
--- a/src/pagerank/TPReadWikiLink.java	Sat Sep 08 09:56:03 2012 +0900
+++ b/src/pagerank/TPReadWikiLink.java	Sat Sep 08 10:04:48 2012 +0900
@@ -46,9 +46,12 @@
 			System.out.println("AllVertexNumber = "+AllVertexNumber);
 
 
-			Object vertexIds[] = {79, 20, 575, 80};
-			writeComputeTransition(ltv, vertexIds, 10, PAGENUM);
+//			Object vertexIds[] = {79, 20, 575, 80};
+//			writeComputeTransition(ltv, vertexIds, 10, PAGENUM);
 
+			loop(ltv);
+
+			
 			
 /*			
 			for (int i=0; i<10; i++) {
@@ -62,17 +65,15 @@
 			long time = end - start;
 			System.out.println(time);
 			}
-*/
-			
 
 			FileOutputStream fos = new FileOutputStream(new File(pageRankLog));
 			descendingOrder(graph, ltv, fos);			
-/*			
+
+
 			FileOutputStream out = new FileOutputStream(new File(fileDB));
 			GraphMLWriter.outputGraph(graph, out);
 			out.close();
 */			
-//			loop(ltv);
 			
 		} catch (NumberFormatException e){
 			System.out.println("Program exit");
@@ -86,13 +87,14 @@
 
 	public static void loop(LinkToVertex ltv) throws IOException {
 		BufferedReader r = new BufferedReader( new InputStreamReader(System.in), 1);
-		System.out.print("\nPlease enter Node Id...>");
+		System.out.print("\nPlease enter Page Title...>");
 		System.out.flush();
 		String s;
 		while ((s = r.readLine()) != null ) {
-			int nodeId = Integer.parseInt(s);
-			ltv.printVertexInfo(nodeId);
-			System.out.print("\nPlease enter Node Id...>");
+			//int nodeId = Integer.parseInt(s);
+			//ltv.printVertexInfo(nodeId);
+			ltv.printVertexInfo(s);
+			System.out.print("\nPlease enter Page Title...>");
 			System.out.flush();
 		}
 	}