text
stringlengths
0
234
begin
-- Initialiser le vecteur à 0
vecteur.Initialiser(noeuds_occurence,1,N);
for i in 1..N loop
vecteur.Enregistrer_coefficient(noeuds_occurence,1,i,T_precision(0));
end loop;
-- Si un noeud apparait une fois on incrémente l'occurence de ce noeud
while not end_of_File(fichier_net) loop
Get(fichier_net,entier);
ancien_coefficient := vecteur.Get_coefficient(noeuds_occurence,1,entier+1);
vecteur.Enregistrer_coefficient(noeuds_occurence,1,(entier+1),ancien_coefficient + T_precision(1));
Get(fichier_net,useless);
end loop;
end Creer_vect_occurence;
------------------------------------------------------------------------------------------------------------------------------------IMPLANTATION NAIVE
-- Nom : pagerank_t
-- Semantique : Produire le vecteur PI défini dans le sujet avec des matrices pleines
-- Paramètres :
-- Nom_fichier_net : in Unbounded_String; -- fichier .net
-- alpha : in T_precision; -- coefficient de pondération
-- N : in Integer; -- nombre de noeuds
-- iter_max : in Integer; -- nombre d'iteration
-- PI : out vecteur.T_Google_Naive; -- cf sujet
-- Pre : True;
-- Post : trop complexe pour être exprimée;
-- Tests
-- voir exemple_sujet
-- Exception : Aucune (à part un storage error si le fichier.net est grand, pensez à changer la stack size)
procedure pagerank_t (alpha : in T_precision;
Nom_fichier_net : in Unbounded_String;
N : out Integer;
iter_max : in Integer;
PI : out vecteur.T_Google_Naive ) is
package matrice_pleine is new Google_Naive(nombre_max_ligne => taille_tableau ,
nombre_max_colonne => taille_tableau,
T_Element => T_precision);
--procedure Affichage_vecteur is new Matrice_Pleine.Affichage (Afficher=>Afficher_element);
--procedure Affichage_matrice_pleine is new matrice_pleine.Affichage (Afficher=>Afficher_element);
-- Nom : Creer_H
-- Semantique : Construire la matrice_pleine H définie dans le sujet
-- Paramètres :
-- Nom_fichier_net : in Unbounded_String; -- nom du fichier.net
-- H : out matrice_pleine.T_Google_Naive; -- cf sujet
-- N : in Integer; -- nombre de noeuds
-- Pre : True;
-- Post : trop complexe pour être exprimée;
-- Tests
-- voir exemple_sujet
-- Exception : Aucune
procedure Creer_H(Nom_fichier_net : in Unbounded_String;
H : out matrice_pleine.T_Google_Naive;
N : out Integer) is
entier : Integer; -- coefficient sur la première colonne d'un fichier .net
fichier_net : Ada.Text_IO.File_Type;
noeuds_occurence : vecteur.T_Google_Naive; -- vecteur avec l'occurence de chaque noeud -
coeff_i : Integer; -- numéro de ligne
coeff_j : Integer; -- numéro de colonne
begin
-- Ouvrir le fichier
begin
open(fichier_net, In_File, To_String(Nom_fichier_net));
exception
when ADA.IO_EXCEPTIONS.NAME_ERROR => raise recup.File_Absent_Error;
Function Definition: --procedure Affichage_matrice_creuse is new matrice_creuse.Affichage (Afficher=>Afficher_element);
Function Body: -- Nom : Creer_H
-- Semantique : Construire la matrice_creuse H définie dans le sujet
-- Paramètres :
-- Nom_fichier : in Unbounded_String; -- nom du fichier .net
-- H : out matrice_creuse.T_Google_Creuse;
-- N : in Integer; -- nombre de noeuds
-- Pre : True;
-- Post : trop complexe pour être exprimée;
-- Tests
-- voir exemple_sujet
-- Exception : Aucune
procedure Creer_H(Nom_fichier_net : in Unbounded_String;
H : out matrice_creuse.T_Google_Creuse;
N : out Integer) is
entier : Integer; -- coefficient sur la première colonne d'un fichier .net