Created
July 15, 2022 03:26
-
-
Save JaosnHsieh/9dadebc5fb29b41f4f39e483a1f7d23e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://ianrogers.uk/google-page-rank/ | |
//PR(A) = (1-d) + d (PR(T1)/C(T1) + … +z PR(Tn)/C(Tn))* | |
const alpha = 0.85; | |
//forward links | |
// a -> b | |
// b -> a, c | |
// c -> b | |
//backward links ( what's pointing to me?) | |
// a -> b | |
// b -> a,c | |
// c ->a | |
const ca = 1; | |
const cb = 2; | |
const cc = 1; | |
//init | |
let pa = 0; | |
let pb = 0; | |
let pc = 0; | |
const norm = 1 - alpha; | |
const loop = 40; | |
for (let i = 1; i <= loop; ++i) { | |
pa = norm + alpha * (pb / cb); | |
pb = norm + alpha * (pa / ca + pc / cc); | |
pc = norm + alpha * (pb / cb); | |
console.log('pa', pa); | |
console.log('pb', pb); | |
console.log('pc', pc); | |
const average = (pa + pb + pc) / 3; | |
console.log('average', average); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment