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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| typedef int sommet;
typedef struct chainon
{
sommet st;
struct chainon * suivant ;
} Couple;
typedef Couple * liste;
typedef struct
{
liste a[n_max];
int n;
}graphe;
/*structure contenant toutes les données du parcours*/
typedef struct
{
int flagsMarquage[n_max];
int numeros[n_max];
int numeroActuel;
} Parcours;
void parcours_en_prof(graphe const *pcg)
{
Parcours prc;
sommet x;
/* Initialisation */
for (x=0 ; x<pcg->n ; x++)
{
prc.flagsMarquage[x] =0;
prc.numeros[x] =0;
}
prc.numeroActuel = 1;
for(x=0 ; x < pcg->n ; x++)
{
if(!prc.flagsMarquage[x])
rech_prof(pcg, &prc, x);
}
}
void rech_prof(graphe const *pcg, Parcours *pPrc, sommet x)
{
Couple const *pc;
pPrc->flagsMarquage[x] = 1;
pc=pcg->a[x];
while(p != NULL)
{
if(!marque[pc->st])
rech_prof(pcg, pPrc, pc->st);
pc=pc->suivant;
}
pPrc->numeros[x] = pPrc->numeroActuel;
pPrc->numeroActuel++;
} |
Partager