org.matalon.pagerankhits.util
Class AlgorithmComparator

java.lang.Object
  extended byorg.matalon.pagerankhits.util.AlgorithmComparator

public class AlgorithmComparator
extends java.lang.Object

This class is responsible for comparing the results of all 3 relevant algorithms: Google's PageRank, Kleinberg's HITS and our modification to Kleinberg's HITS.

Author:
Yonatan Matalon

Constructor Summary
AlgorithmComparator()
           
 
Method Summary
static int[] comparePositions(java.lang.Integer[] pagePositions1, java.lang.Integer[] pagePositions2, int totalNoOfPages)
          Compares the given page positions (as returned by org.matalon.pagerankhits.util.AlgorithmComparator#compareResults(resultsNo, compare2Algorithm)).
static java.lang.Object[] compareResults(int resultsNo, java.lang.String compare2Algorithm)
          This method returns the top resultsNo URLs, as computed by the given algorithm.
static java.lang.Integer[] getDefaultUrlPositions(int length)
           
static java.lang.String[] getSubArray(java.lang.String[] array, int beginIndex, int endIndex)
           
static java.lang.Integer[] getUrlPositions(java.lang.String[] urlsSubset, java.lang.String[] urlsSet)
          Finds all urlsSubset's URLs inside urlsSet and returns their positions.
static java.lang.String[] getUrlResults(java.lang.String algorithm)
          Returns all the URLs, ordered by their importance according to the given algorithm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlgorithmComparator

public AlgorithmComparator()
Method Detail

compareResults

public static final java.lang.Object[] compareResults(int resultsNo,
                                                      java.lang.String compare2Algorithm)
This method returns the top resultsNo URLs, as computed by the given algorithm. In addition, it returns the position of each page, as computed by all 3 algorithms: Google's PageRank, Kleinberg's HITS and our modification to Kleinberg's HITS. The position is set according to the rank of the page; the page with the highest rank gets the position 1, the page with the second highest rank gets the position 2 and so on. Assumption: The results of PageRank algorithm are saved in GeneralSettings.FILE_PAGERANK_RESULT_OBJECT, the results of HITS algorithm are saved in GeneralSettings.FILE_HITS_RESULT_OBJECT and the results of our modified HITS algorithm are saved in GeneralSettings.FILE_HITS_MODIFIED_RESULT_OBJECT.

Parameters:
resultsNo -
compare2Algorithm -
Returns:
Returns the total number of pages, which the algorithms have crawled over, and 4 arrays: 1 for the top resultsNo URLs (according to the given algorithm), and 3 for the positions of these URLs according to PageRank, HITS and our modified HITS, respectively. Technically, this method returns Object[5] = { Integer[1]: The total number of pages, String[resultsNo]: The URLs of the top resultsNo pages, Integer[resultsNo]: The positions of the top resultsNo pages according to PageRank algorithm, Integer[resultsNo]: The positions of the top resultsNo pages according to HITS algorithm, Integer[resultsNo]: The positions of the top resultsNo pages according to our modified HITS algorithm }

getUrlResults

public static final java.lang.String[] getUrlResults(java.lang.String algorithm)
Returns all the URLs, ordered by their importance according to the given algorithm. The URLs are taken from the results file of the given algorithm. Assumption: The results of PageRank algorithm are saved in GeneralSettings.FILE_PAGERANK_RESULT_OBJECT, the results of HITS algorithm are saved in GeneralSettings.FILE_HITS_RESULT_OBJECT and the results of our modified HITS algorithm are saved in GeneralSettings.FILE_HITS_MODIFIED_RESULT_OBJECT.

Parameters:
algorithm -
Returns:
Returns the URLs found inside the results file, ordered by their importance according to the given algorithm.

getDefaultUrlPositions

public static final java.lang.Integer[] getDefaultUrlPositions(int length)
Parameters:
length -
Returns:
Returns an array in length length where array[i] = new Integer(i+1).

getUrlPositions

public static final java.lang.Integer[] getUrlPositions(java.lang.String[] urlsSubset,
                                                        java.lang.String[] urlsSet)
Finds all urlsSubset's URLs inside urlsSet and returns their positions. Assumption: urlsSubset is a subset of urlsSet.

Parameters:
urlsSubset -
urlsSet -
Returns:
Returns the positions of urlsSubset's URLs inside urlsSet.

comparePositions

public static final int[] comparePositions(java.lang.Integer[] pagePositions1,
                                           java.lang.Integer[] pagePositions2,
                                           int totalNoOfPages)
Compares the given page positions (as returned by org.matalon.pagerankhits.util.AlgorithmComparator#compareResults(resultsNo, compare2Algorithm)). Assumption: pagePositions1 and pagePositions2 have the same length.

Parameters:
pagePositions1 -
pagePositions2 -
totalNoOfPages -
Returns:
Returns the result of the comparison. Technically, this method returns int[4] = { , , , }

getSubArray

public static final java.lang.String[] getSubArray(java.lang.String[] array,
                                                   int beginIndex,
                                                   int endIndex)
Parameters:
array -
beginIndex -
endIndex -
Returns:
Returns part of the given array, starting at index beginIndex and ending at endIndex (inclusive).