# HG changeset patch # User one # Date 1347066288 -32400 # Node ID fcf2a7b4b867d1b32f3e8a1147b5cc3004c151f5 # Parent 4ed8a8a5ef92d2eef7e23a578d694ffb1023ac01 modify loop method diff -r 4ed8a8a5ef92 -r fcf2a7b4b867 src/pagerank/LinkToVertex.java --- 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); + } } diff -r 4ed8a8a5ef92 -r fcf2a7b4b867 src/pagerank/TPReadWikiLink.java --- 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(); } }