This commit is contained in:
lfainsin 2021-01-24 09:26:20 +00:00
parent 25f2182ca6
commit c8a03f9eae
3 changed files with 12 additions and 15 deletions

View file

@ -119,11 +119,10 @@ package body Google is
procedure create_Google(mat: in out T_Google; file: in out Ada.Text_IO.File_Type) is
row, col: Natural;
offset: Natural;
begin
initialize(mat.Rows, 0);
initialize(mat.Cols, -1);
initialize(mat.Cols, N);
for i in 0..N_Links-1 loop
get(file, row);
@ -139,19 +138,13 @@ package body Google is
for i in 0..N_Links-1 loop
get(file, row);
get(file, col);
if row = N then
offset := 0;
else
offset := mat.rows(row+1) - mat.rows(row);
end if;
for j in 0..offset loop
for j in mat.rows(row)..mat.rows(row+1)-1 loop
exit when mat.cols(mat.rows(row)+j) = col; -- anti-doublon
exit when mat.cols(j) = col; -- anti-doublon
if mat.cols(mat.rows(row)+j) = -1 then
mat.cols(mat.rows(row)+j) := col;
if mat.cols(j) >= N then
mat.cols(j) := col;
exit;
end if;
@ -196,7 +189,7 @@ package body Google is
for j in mat.rows(i)..mat.rows(i+1)-1 loop
index_col := mat.cols(j);
if index_col /= -1 then -- anti calcul d'un doublon
if index_col < N then -- anti calcul d'un doublon
new_vec(index_col) := new_vec(index_col) + alpha*vec(i)/T_Reel(nb_col);
end if;
end loop;

View file

@ -55,11 +55,14 @@ package Google is
package Vector_Rows is
new Vector.Entier(T_Entier => Natural, Capacite => N+1);
package Vector_Cols is
new Vector.Entier(T_Entier => Integer, Capacite => N_Links);
new Vector.Entier(T_Entier => Natural, Capacite => N_Links);
use Vector_Rows;
use Vector_Cols;
type T_Rows is array (0..N) of Natural;
type T_Cols is array (0..N_Links-1) of Natural;
-- on définit le type T_Google correspondant à une matrice CSC
type T_Google is record
rows: Vector_Rows.T_Vecteur;

View file

@ -19,7 +19,7 @@ procedure pageRank is
INFO_help: Exception;
-- définition du type T_Reel
Type T_Reel is digits 6;
Type T_Reel is digits 18;
-- on utilise le module générique Float_IO pour pouvoir afficher T_Reel directement
package Text_T_Reel is
new Ada.Text_IO.Float_IO(Num => T_Reel);
@ -172,6 +172,7 @@ begin
skip_line(file);
declare
-- on peut maintenant créer nos vecteurs
package Vector_Entier is
new Vector.Entier(T_Entier => Natural, Capacite => N);