void profondeur (pArbre A,int * T, int p){ if (A==NULL){} else if ((A->ag==NULL)||(A->ad==NULL)){ T[(unsigned char) A->cle]=p;} else { profondeur(A->ad,T,(p+1)); profondeur(A->ag,T,(p+1));} }
int main(int argc, char **argv) { if (argc != 2) help(); profondeur(argv[1]); return (0); }
void lancementSimple(char* chemin, char* name) { int T[N]; int nb_occurence[N]; int i; int f,d; extentionDossierCalcul(chemin,&f,&d); char* format = malloc(sizeof(char)*(f+1)); char* dossier = malloc(sizeof(char)*(d+1)); extentionDossierCreation(chemin,format,dossier,&f,&d); char fichierCode[strlen(dossier)+strlen(name)+4]; char fichierRetour[strlen(dossier)+strlen(name)+1+strlen(format)]; strcpy(fichierCode,dossier); strcat(fichierCode,name); strcat(fichierCode,".txt"); strcpy(fichierRetour,dossier); strcat(fichierRetour,name); strcat(fichierRetour,"."); strcat(fichierRetour,format); pArbre res = huffman(chemin,nb_occurence); for (i=0;i<N;i++){ T[i]=0; } profondeur(res,T,0); unsigned char nb_symbole=255; for (i=0;i<N;i++){ if (T[i]!=0){ nb_symbole++;}} //calcul de la taille int taille=0; for (i=0;i<N;i++){ taille= taille + nb_occurence[i]*T[i]; } pArbre A=construction_arbre_canonique(T); FILE *F1= ouvertureFichierLecture(chemin); FILE *F2 = ouvertureFichierEcriture (fichierCode); //ecriture du nombre de symbole putByte(F2,nb_symbole); codage(F1,F2,A,taille); fermetureFichier(F1); fermetureFichier(F2); }
static void profondeur (GrapheMat* graphe, int numSommet) { int nMax = graphe->nMax; graphe->marque [numSommet] = vrai; printf ("%s\n", graphe->nomS [numSommet]); for (int i=0; i<graphe->n; i++) { if ( (graphe->element [numSommet*nMax+i] == vrai) && !graphe->marque [i] ) { profondeur (graphe, i); } } }
void parcoursProfond (GrapheMat* graphe) { razMarque (graphe); for (int i=0; i<graphe->n; i++) { if (!graphe->marque [i]) profondeur (graphe, i); } }