Page RankTime
limit:3000/1500 MS (java/others) Memory limit:100000/100000 K (java/others)
Total submission (s): 280 Accepted Submission (s): 75
Problem Descriptionevaluation and rank of Web pages are a hot topic for many internet companies and researchers. PageRank is a link analysis tool and it assigns a numerical weighting to each element of a hyperlinked set of documents, s Uch as the world Wide Web, with the purpose of "measuring" its relative importance within the set. The algorithm is applied to any collection of entities with reciprocal quotations and references. The numerical weight that it assigns to any given element E was referred to as the PageRank of E and denoted by. Other factors like Author Rank can contribute to the importance of an entity.
For simplicity, in this problem PageRank vector q are defined as Q = Gq, Where, S is the Destination-by-source stochastic Matrix, you are all one matrix, n are the number of nodes andαis the weight between 0 and 1 (here we use 0.85).
For the example in the right, we have:
Denote the current PageRank vector and the next PageRank vectors by Qcur and Qnext respectively. The process is to compute the iterative powering for finding the first eigenvector.
The computation ends until for some smallε (10-10).
Inputthe input contains many test cases.
For each case, there is multiple lines. The first line contains an integer N (n<=3000), which represents the number of pages. Then a n*n zero-one matrix follows. The element Eij (0 <= I, j < N) on the matrix represents whether the I-th page have a hyper link to the j-th page.
Outputoutput one line with the eigenvector. The numbers should is separated by a space and is correctly rounded to the decimal places.
Sample Input
40111001100010100
Sample Output
0.15 1.49 0.83 1.53
SOURCE2014 Shanghai National Invitational Competition--re-title (thanks to Shanghai University for its topics)
Recommendhujie | we has carefully selected several similar problems for you: & nbsp;5379 5378 5377 5376 5375 simulation,,, add function no OVA used. AC Code
problem:5097 (Page Rank) Judge status:acceptedrunid:14492913 language:c++ Author:lwj1994code Render Status:rendered by hdoj C + + Code Render Version 0.01 beta#include<stdio.h> #include <string.h> #include < Math.h> #define EPS 1e-10char map[3030];d ouble ans[3030][3030];d ouble q[2][3030];int n;void muti (double a[][3030], Double num) {int i,j; for (i=0;i<n;i++) {for (j=0;j<n;j++) A[i][j]*=num; }}void Add (double a[][3030],double b[][3030]) {int i,j; for (i=0;i<n;i++) {for (j=0;j<n;j++) a[i][j]+=b[i][j]; }}int Jud () {double ans=0; int i; for (i=0;i<n;i++) {ans+= (Q[0][i]-q[1][i]) * (Q[0][i]-q[1][i]); }//ans=sqrt (ANS); if (fabs (ANS) <eps) return 1; return 0;} int main () {//int n; while (scanf ("%d", &n)!=eof) {int i,j; Double a=0.85; memset (ans,0,sizeof (ans)); for (i=0;i<n;i++) {int sum=0; scanf ("%s", &map); for (j=0;j<n;j++) {if (map[j]== ' 1 ') sum++; U[i][j]=1; } for (j=0;j<n;j++) {if (map[j]== ' 1 ') ans[j][i]=1.0/sum; }} muti (Ans,a); Muti (u,1.0/n* (0.15)); printf ("\ n"); Add (Ans,u); for (i=0;i<n;i++) for (j=0;j<n;j++) ans[i][j]+= (0.15/n); int p=0; for (i=0;i<n;i++) {q[p][i]=1; q[p^1][i]=0; }//mmuti (q[p],ans,q[p^1]); P^=1; while (!jud ()) {//q[p^1]=mmuti (Q[p],ans); for (i=0;i<n;i++) {q[p^1][i]=0; for (j=0;j<n;j++) q[p^1][i]+=q[p][j]*ans[i][j]; } p^=1; } printf ("%.2lf", q[p][0]); for (i=1;i<n;i++) {printf("%.2lf", Q[p][i]); } printf ("\ n"); }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Hdoj topic 5097 Page Rank (Matrix operation, simulation)