Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.62 KB | None | 0 0
  1. int* genererAcpmPrimm(graphe_t* graphe,int sommet){
  2.  
  3.     sommet_t** tableau_sommets = creerTabSommet(graphe->nbSommets);
  4.  
  5.     int* tableauPoidMin = malloc((graphe->nbSommets-1)*sizeof(int));
  6.  
  7.     tableauPoidMin[0] = tableau_sommets[sommet]->valeur;
  8.  
  9.     int pivot = tableau_sommets[sommet]->valeur;
  10.  
  11.     for (int i = 0; i < graphe->nbSommets; ++i)
  12.     {
  13.         if (tableau_sommets[i]!=tableau_sommets[sommet])
  14.         {
  15.             tableau_sommets[i]->distance_origine = INT_MAX;
  16.             printf("%d",tableau_sommets[i]->distance_origine);
  17.         }
  18.  
  19.     }
  20.     printf("\n");
  21.  
  22.      for (int i = 0; i < graphe->nbSommets; ++i)
  23.      {
  24.         for (int z = 0; z < graphe->nbSommets; ++z)
  25.         {
  26.             if (tableau_sommets[z]!=tableau_sommets[sommet] && estVoisin(graphe,pivot,tableau_sommets[z]->valeur)) // && tableau_sommets[z] voisin de pivot
  27.             {
  28.                 printf("dans le il %d fois \n",z );
  29.  
  30.                 int trouve=0;
  31.                 int i = 0;
  32.  
  33.                 while(!trouve && i < graphe->nbSommets-1) // boucle pour savoir si la valeur est contenu dans le tableauFinale
  34.                 {
  35.                     if (tableau_sommets[z]->valeur == tableauPoidMin[i])
  36.                     {
  37.                         trouve=1;
  38.                     }
  39.                     i++;
  40.                 }
  41.                 if (trouve && poid(graphe,pivot,tableau_sommets[z]->valeur) < tableau_sommets[z]->distance_origine )
  42.                 {
  43.                     tableau_sommets[z]->pere = pivot;
  44.                     tableau_sommets[z]->distance_origine = poid(graphe,pivot,tableau_sommets[z]->valeur);
  45.  
  46.                     int * tab_voisins = voisins(graphe,tableau_sommets[z]->valeur);
  47.                     pivot = tab_voisins[0];
  48.  
  49.                     if (i < graphe->nbSommets-2)
  50.                     {
  51.                         tableauPoidMin[i+1] = pivot;
  52.                         tableauPoidMin[i+2] = tableau_sommets[pivot]->pere;
  53.                     }
  54.                 }
  55.             }
  56.         }
  57.  
  58.  
  59.      }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement