Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pagerank;
- /**
- *
- * @author hallgato
- */
- public class PageRank {
- /*
- * linkek
- */
- double[][] L = {
- {0.0, 0.0, 1.0 / 3.0, 0.0},
- {1.0, 1.0 / 2.0, 1.0 / 3.0, 1.0},
- {0.0, 1.0 / 2.0, 0.0, 0.0},
- {0.0, 0.0, 1.0 / 3.0, 0.0}
- };
- /*
- * PageRank
- */
- double pr[] = {0.0, 0.0, 0.0, 0.0};
- double prv[] = {1.0 / 4.0, 1.0 / 4.0, 1.0 / 4.0, 1.0 / 4.0};
- public void kiir() {
- int i, j;
- for (i = 0; i < this.pr.length; i++)
- {
- System.out.println(this.pr[i]);
- }
- }
- public double tavolsag(double[] pr, double prv[])
- {
- int i;
- double osszeg = 0;
- for (i = 0; i< this.pr.length; i++)
- {
- osszeg += (this.prv[i] - this.pr[i]) * (this.prv[i] - this.pr[i]);
- }
- return Math.sqrt(osszeg);
- }
- public void szamol(double[][]L, double[] pr, double prv[])
- {
- int i;
- int j;
- for (;;)
- {
- for (i = 0; i < 4; i++)
- {
- this.pr[i] = 0.0;
- for (j = 0; j < 4; j++)
- {
- this.pr[i] += (this.L[i][j] * this.prv[j]);
- }
- }
- if (this.tavolsag (this.pr, this.prv) < 0.00000001) { break; }
- for (i=0; i<4; i++)
- {
- this.prv[i] = this.pr[i];
- }
- }
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args)
- {
- PageRank prank = new PageRank();
- prank.szamol(prank.L, prank.pr, prank.prv);
- prank.kiir();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement