2/3 comms
git-svn-id: http://cregut.svn.enseeiht.fr/2020/1sn/pim/projets/GH-05@207228 e13453a9-b01f-0410-a051-f404c4f0c485
This commit is contained in:
parent
da91ba9da2
commit
08944a8856
|
@ -67,7 +67,8 @@ procedure pageRank is
|
|||
file: Ada.Text_IO.File_Type;
|
||||
|
||||
N: Positive;
|
||||
pi, pi_last, H, S, G: T_Google;
|
||||
pi, pi_last: T_Google; -- même T_Google que G ? psk vecteur /= matrice
|
||||
G: T_Google;
|
||||
row, col: Natural;
|
||||
|
||||
begin
|
||||
|
@ -94,18 +95,18 @@ begin
|
|||
while not end_of_File(file) loop
|
||||
get(file, row);
|
||||
get(file, col);
|
||||
insert(H, row, col, 1.0);
|
||||
insert(G, row, col, 1.0);
|
||||
end loop;
|
||||
|
||||
-- on crée S
|
||||
-- horrible, voir si simplifiable
|
||||
for row in H loop
|
||||
for row in G.matrix loop
|
||||
p = row_sum(row);
|
||||
for j in row loop
|
||||
if p = 0 then
|
||||
row(j) := 1/N;
|
||||
else
|
||||
if row(j) /= 0 then
|
||||
if row(j) /= 0 then -- TODO: changer T_Element générique en PRECISION
|
||||
row(j) := 1/p;
|
||||
end if;
|
||||
end if;
|
||||
|
@ -113,14 +114,14 @@ begin
|
|||
end loop;
|
||||
|
||||
-- on crée G
|
||||
G := S*alpha + ones(N, N)*(1-alpha)/N;
|
||||
G := G*alpha + ones(N, N)*(1-alpha)/N;
|
||||
|
||||
-- on applique l'algorithme itératif
|
||||
loop
|
||||
pi_last := pi;
|
||||
pi := pi * G;
|
||||
ite := ite + 1;
|
||||
exit when (ite >= ite_max) or (pi(1)(1) - pi_last(1)(1) < epsilon);
|
||||
exit when (ite >= ite_max) or (pi(1)(1) - pi_last(1)(1) < epsilon); -- changer (1)(1) ?
|
||||
end loop;
|
||||
|
||||
-- write_to_files(filename, ...); -- TODO
|
||||
|
|
Loading…
Reference in a new issue