Lab 10 - JS Functions and Page ranking
- Page Ranking algorithm
- Defining and invoking functions
Downloads folder, download the
Task 1 - Page Ranking for three pages
Open the file
pageRank3.htmlin your editor. Examine the code.
Define a function
computePageRank3()in a file named
pageRank.js. This function reads the values for each of the three pages from the web page, and calculates the new values, after one iteration only, based on the
Brin and Page Algorithm. At the end, it presents the results on the web page.
Add a button on the web page and arrange so that when the button is clicked the
computePageRank3()function is called.
- What happens if you click on the button again and again, for a number of times?
Task 2 - Page Ranking for four pages
- Create a file named
pageRank4.html, that will work similar to the page in the previous task, on this particular graph:
Define your function,
computePageRankOneRound()in the file
pageRank.js. Use your work on the previous task to get guided.
- Test your work by calling the function multiple times, as you click on the
Compute button, until the values converge (do not change any more).
Define one more function, named
computePageRankManyRounds()which takes an integer number,
n, as input. This function will call the
Attach this function to the
Compute button. Experiment to see what number you should pass it as input, so that the final values are computed.
- If time permits, add one more input field to the page, for the user to enter the number of rounds they would like to perform.