git-svn-id: http://cregut.svn.enseeiht.fr/2020/1sn/pim/projets/GH-05@214003 e13453a9-b01f-0410-a051-f404c4f0c485
This commit is contained in:
parent
25f2182ca6
commit
c8a03f9eae
|
@ -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
|
procedure create_Google(mat: in out T_Google; file: in out Ada.Text_IO.File_Type) is
|
||||||
row, col: Natural;
|
row, col: Natural;
|
||||||
offset: Natural;
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
initialize(mat.Rows, 0);
|
initialize(mat.Rows, 0);
|
||||||
initialize(mat.Cols, -1);
|
initialize(mat.Cols, N);
|
||||||
|
|
||||||
for i in 0..N_Links-1 loop
|
for i in 0..N_Links-1 loop
|
||||||
get(file, row);
|
get(file, row);
|
||||||
|
@ -140,18 +139,12 @@ package body Google is
|
||||||
get(file, row);
|
get(file, row);
|
||||||
get(file, col);
|
get(file, col);
|
||||||
|
|
||||||
if row = N then
|
for j in mat.rows(row)..mat.rows(row+1)-1 loop
|
||||||
offset := 0;
|
|
||||||
else
|
|
||||||
offset := mat.rows(row+1) - mat.rows(row);
|
|
||||||
end if;
|
|
||||||
|
|
||||||
for j in 0..offset loop
|
exit when mat.cols(j) = col; -- anti-doublon
|
||||||
|
|
||||||
exit when mat.cols(mat.rows(row)+j) = col; -- anti-doublon
|
if mat.cols(j) >= N then
|
||||||
|
mat.cols(j) := col;
|
||||||
if mat.cols(mat.rows(row)+j) = -1 then
|
|
||||||
mat.cols(mat.rows(row)+j) := col;
|
|
||||||
exit;
|
exit;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
@ -196,7 +189,7 @@ package body Google is
|
||||||
|
|
||||||
for j in mat.rows(i)..mat.rows(i+1)-1 loop
|
for j in mat.rows(i)..mat.rows(i+1)-1 loop
|
||||||
index_col := mat.cols(j);
|
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);
|
new_vec(index_col) := new_vec(index_col) + alpha*vec(i)/T_Reel(nb_col);
|
||||||
end if;
|
end if;
|
||||||
end loop;
|
end loop;
|
||||||
|
|
|
@ -55,11 +55,14 @@ package Google is
|
||||||
package Vector_Rows is
|
package Vector_Rows is
|
||||||
new Vector.Entier(T_Entier => Natural, Capacite => N+1);
|
new Vector.Entier(T_Entier => Natural, Capacite => N+1);
|
||||||
package Vector_Cols is
|
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_Rows;
|
||||||
use Vector_Cols;
|
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
|
-- on définit le type T_Google correspondant à une matrice CSC
|
||||||
type T_Google is record
|
type T_Google is record
|
||||||
rows: Vector_Rows.T_Vecteur;
|
rows: Vector_Rows.T_Vecteur;
|
||||||
|
|
|
@ -19,7 +19,7 @@ procedure pageRank is
|
||||||
INFO_help: Exception;
|
INFO_help: Exception;
|
||||||
|
|
||||||
-- définition du type T_Reel
|
-- 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
|
-- on utilise le module générique Float_IO pour pouvoir afficher T_Reel directement
|
||||||
package Text_T_Reel is
|
package Text_T_Reel is
|
||||||
new Ada.Text_IO.Float_IO(Num => T_Reel);
|
new Ada.Text_IO.Float_IO(Num => T_Reel);
|
||||||
|
@ -172,6 +172,7 @@ begin
|
||||||
skip_line(file);
|
skip_line(file);
|
||||||
|
|
||||||
declare
|
declare
|
||||||
|
|
||||||
-- on peut maintenant créer nos vecteurs
|
-- on peut maintenant créer nos vecteurs
|
||||||
package Vector_Entier is
|
package Vector_Entier is
|
||||||
new Vector.Entier(T_Entier => Natural, Capacite => N);
|
new Vector.Entier(T_Entier => Natural, Capacite => N);
|
||||||
|
|
Loading…
Reference in a new issue