-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPage_rank_student_Solution_Apr24'2018.sas
108 lines (84 loc) · 1.77 KB
/
Page_rank_student_Solution_Apr24'2018.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*PageRank Soluion*/
data Arcs;
infile datalines;
input Node $ A B C D ;
datalines;
A 0 1 1 0
B 1 0 0 1
C 1 0 0 1
D 1 1 0 0
;
run;
/*get the transition matrix*/
proc sql;
create table matrix_1 as
select a/sum(a) as x1
,b/sum(b) as x2
,c/sum(c) as x3
,d/sum(d) as x4
from Arcs
;
quit;
/*Since there are 7 nodes, the initial vector v0 has 7 components, each 1/7*/
data rank_p;
x1=1/4;
x2=1/4;
x3=1/4;
x4=1/4;
output;
run;
proc iml;
use matrix_1;
read all var { x1 x2 x3 x4 } into M;
print M;
use rank_p;
read all var { x1 x2 x3 x4 } into rank_p1;
rank_p = t(rank_p1);
print rank_p;
rank_p2=M * rank_p;
print rank_p2;
rank_p50 = (M**50)*rank_p;
print rank_p50;
quit;
/*PageRank Soluion*/
data Arcs;
infile datalines;
input Node $ A B C D ;
datalines;
A 0 1 0 0
B 1 0 0 1
C 1 0 0 1
D 1 1 0 0
;
run;
/*get the transition matrix*/
proc sql;
create table matrix_1 as
select a/sum(a) as x1
,b/sum(b) as x2
,c/1 as x3
,d/sum(d) as x4
from Arcs
;
quit;
/*Since there are 7 nodes, the initial vector v0 has 7 components, each 1/7*/
data rank_p;
x1=1/4;
x2=1/4;
x3=1/4;
x4=1/4;
output;
run;
proc iml;
use matrix_1;
read all var { x1 x2 x3 x4 } into M;
print M;
use rank_p;
read all var { x1 x2 x3 x4 } into rank_p1;
rank_p = t(rank_p1);
print rank_p;
rank_p2=M * rank_p;
print rank_p2;
rank_p50 = (M**50)*rank_p;
print rank_p50;
quit;