Question: [ 3 0 points ] assignPageRanks and computeRanks The method computeRanks is a helper method for assignPageRanks. We specifically ask you to implement it so
points assignPageRanks and computeRanks
The method computeRanks is a helper method for assignPageRanks. We specifically ask you to implement it so that our grader will be able to assign partial marks to your implementation. The purpose of assignPageRanks is to assign a rank to each vertex in
the web graph. It will only be called after crawlAndIndex has been executed. Here are the principles we will be using to assign a rank to a web page:
Good web pages are cited by many other pages. If we think about it in terms of the webgraph, this means that we should prefer web pages ie vertices with a large indegree.
Web pages that link to a large number of other pages are less valuable. In terms of webgraph, this means that we will value less web pages ie vertices with a large outdegree.
A link from a web page is more valuable if the web page is itself a good one. In graph terms, higher the rank of a web page ie vertex more valuable an inedge from it would be
Note that the rank of a page depends solely on the structure of the graph we have created while crawling. To represent the ideas just described, let
the be the page rank of a vertex
the out be the outdegree of a vertex
dots, be all the vertices in the graph that have an out edge going into
Then, the following equation determines the page rank of a vertex :
dots
The constant is called the damping factor and it is added for technical reasons to account for the probability that an imaginary surfer who is randomly clicking on links will eventually stop clicking. For this project, we will be using a damping factor of As you may notice, is defined as a function of If is the total number of vertices in the graph dots, then we have a system of linear equations in variables. The unknown values, ie our variables, are the To determine their values, we should solve the system of linear equations described above. To do so we could use linear algebra, but the implementation of gaussian elimination runs in To improve the efficiency, we can instead use an iterative algorithm that approximate the result. The idea is the following:
Start by initializing to for all
Repeat the following until convergence:
compute for all i using the formula above.
This single step is what the helper method computeRanks should be doing. The method takes as input an ArrayList
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
