Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int* genererAcpmPrimm(graphe_t* graphe,int sommet){
- sommet_t** tableau_sommets = creerTabSommet(graphe->nbSommets);
- int* tableauPoidMin = malloc((graphe->nbSommets-1)*sizeof(int));
- tableauPoidMin[0] = tableau_sommets[sommet]->valeur;
- int pivot = tableau_sommets[sommet]->valeur;
- for (int i = 0; i < graphe->nbSommets; ++i)
- {
- if (tableau_sommets[i]!=tableau_sommets[sommet])
- {
- tableau_sommets[i]->distance_origine = INT_MAX;
- printf("%d",tableau_sommets[i]->distance_origine);
- }
- }
- printf("\n");
- for (int i = 0; i < graphe->nbSommets; ++i)
- {
- for (int z = 0; z < graphe->nbSommets; ++z)
- {
- if (tableau_sommets[z]!=tableau_sommets[sommet] && estVoisin(graphe,pivot,tableau_sommets[z]->valeur)) // && tableau_sommets[z] voisin de pivot
- {
- printf("dans le il %d fois \n",z );
- int trouve=0;
- int i = 0;
- while(!trouve && i < graphe->nbSommets-1) // boucle pour savoir si la valeur est contenu dans le tableauFinale
- {
- if (tableau_sommets[z]->valeur == tableauPoidMin[i])
- {
- trouve=1;
- }
- i++;
- }
- if (trouve && poid(graphe,pivot,tableau_sommets[z]->valeur) < tableau_sommets[z]->distance_origine )
- {
- tableau_sommets[z]->pere = pivot;
- tableau_sommets[z]->distance_origine = poid(graphe,pivot,tableau_sommets[z]->valeur);
- int * tab_voisins = voisins(graphe,tableau_sommets[z]->valeur);
- pivot = tab_voisins[0];
- if (i < graphe->nbSommets-2)
- {
- tableauPoidMin[i+1] = pivot;
- tableauPoidMin[i+2] = tableau_sommets[pivot]->pere;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement