-1

I'm trying to use PageRank and Hits algorithm on a DirectedSparseGraph I have build from a Wikipedia Dump. The graph is huge obviously and its nodes are String, while its Edge are Integer. The problem is that when I run this code:

PageRank<String,Integer> pageRank = new PageRank<String,Integer>(w, alpha);
pageRank.initialize();  
pageRank.setTolerance(0.000001);
pageRank.setMaxIterations(200);
pageRank.evaluate();

HITS<String, Integer> hits = new HITS<String, Integer>(w,alpha);
hits.initialize();
hits.setTolerance(0.000001);
hits.setMaxIterations(200);
hits.evaluate();
for(String s: w.getVertices()){
    writer.write(s + "\th:" + hits.getVertexScore(s).hub + "\ta:" + hits.getVertexScore(s).authority + "\tpagerank:" + pageRank.getVertexScore(s));
    writer.newLine();
}

the results I'm writing on the file txt are always the same for each Node. Maybe I am making a mistake with parameters I pass the methods. I don't know.

CodePi
  • 13
  • 4

1 Answers1

0

How big is the graph? How many iterations are actually being performed?

If the values are simply 1/n (where n is the number of vertices) then what's probably happening here is that it's exiting immediately (which you can check).

The other obvious possibility is that you made a mistake in constructing the graph and made it symmetric, so the scores would all be identical. You should be able to check this pretty easily, too.

Joshua O'Madadhain
  • 2,704
  • 1
  • 14
  • 18
  • Why does it exit immediately in the first case? – CodePi Aug 14 '13 at 15:18
  • The graph contains 34308 nodes. It performs 200 iterations for PageRank and 200 for Hits after the execution. The results for each node are near to 1/n but not exactly 1/n. – CodePi Aug 14 '13 at 15:44
  • It could be exiting immediately if the tolerance for change is high enough. – Joshua O'Madadhain Aug 15 '13 at 15:49
  • Your comment contradicts your original post: it states that the values are near-but-not-exactly 1/n, whereas the original post states that the values are the same for all nodes. Which is it? – Joshua O'Madadhain Aug 15 '13 at 15:50
  • In my first post I said values are the same for all nodes, right! I have not said values are all 1/n. Now the values are near to 1/n and are all the same. – CodePi Aug 18 '13 at 13:46
  • If the values don't sum to 1 (which I infer from the conjunction of "all the same" and "not 1/n") then you've probably done something wrong with the edge weights; another option is that the graph has no edges. Another thing to look at: does it matter how many iterations you use, or do you always get the same result? – Joshua O'Madadhain Aug 21 '13 at 04:40
  • The number of iterations doesn't change the result. Only alpha value changes it. I have checked the results and in every case they are all 2.837379368947091E-5 except 20 or 30 nodes. Theese nodes have 6.213860817994128E-5 as value. – CodePi Aug 21 '13 at 08:33
  • If the number of iterations doesn't change the result, then I'd suggest changing the threshold to something smaller, as I suggested earlier. Your threshold is not much smaller than the values you currently have; the deltas are probably smaller than the deltas. Try reducing it to 1E-7 or 1E-8 and see what happens. – Joshua O'Madadhain Aug 22 '13 at 04:59
  • I've tried to change treshold but nothing change. The only way to change some value is to change alpha value. – CodePi Aug 23 '13 at 12:19
  • Is also possible that those are indeed the right answers. If they correlate well with degree, it could just be that simple. Do you have some a priori reason to believe that the answers your getting are wrong? – Joshua O'Madadhain Aug 25 '13 at 07:39
  • I think that when I've created my Graph using JUNG, maybe I have done a mistake, even if when I print the Graph it seems all right. I mean that maybe the graph is not well prepared to begin the pagerank. Anyway I thank you for the time you are spending helping me. – CodePi Aug 25 '13 at 09:49
  • Problem solved! I have right values now : ) When I build the graph many Edges weren't been added becouse of a control I made. Thank you for your help Joshua : D – CodePi Aug 25 '13 at 11:15
  • I'm glad that you figured it out. I was wondering whether you had some missing edges but it seemed unlikely that you could have added some, but not all, so I hadn't gotten to that suggestion yet. :) – Joshua O'Madadhain Aug 26 '13 at 05:48
  • Don't worry, Thank you for your help anyway : ) – CodePi Aug 26 '13 at 19:33