1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| void visiter(Graphe G,int sommet)
{
if (G.nb_traites<G.n)
{
int i;
printf("sommet explore ................: %d\n",sommet);
G.tabSomm[sommet].marque=1; //marquage du sommet explore
for (i=0;i<G.n;i++)
{
if ((G.matrice[sommet][i]==1)&&(G.tabSomm[i].marque==0)) // Si on a trouve un voisin non marque..
{
G.nb_traites++;
printf("Successeur trouve : %d\n",i);
Empiler(&G,sommet);
visiter(G,i);
}
}
printf("Pas de Successeur trouve\n");
Depiler(&G,&sommet); //si tous les voisins sont marques on retourne au sommet pere
visiter(G,sommet);
}
else
{
exit(0); //tous les sommets on ete explores : exit
}
} |
Partager