Graphe A
laroui
Messages postés
1
Date d'inscription
Statut
Membre
Dernière intervention
-
DarkenNights Messages postés 137 Date d'inscription Statut Membre Dernière intervention -
DarkenNights Messages postés 137 Date d'inscription Statut Membre Dernière intervention -
ce code n'a marche pas et je n'outrouve pas l'erreure ou exacte svt aidez moi
typedef struct strelem
{
struct strelem *s1;
int v;
struct strelsm *s2;
} Strelem,*Elem, *Graphe;
//---------------------------------------------------------------------------
typedef struct strelsm
{
int v;
struct strelsm *s2;
} Strelsm,*Elem, *Graphe;
//----------------------------------------------------------------------------
typedef struct maillon
{
int val;
struct maillon *suiv;
} Maillon, *Ens;
//-----------------------------------------------------------------------------
Ens Ensvide(void)
{
Ens e=NULL;
return e;
}
//-----------------------------------------------------------------------------
#define faux 0;
#define vrai 1;
typedef int Booleen;
//------------------------------------------------------------------------------
Booleen appartient(int a, Ens e)
{
{if (e==NULL) return faux;
if (e->val==a) return vrai;
return apprtient (a,e->suiv);
}
//------------------------------------------------------------------------------
Booleen EstVide (Ens e)
{
if (e==NULL) return vrai;
return faux;
}
//-----------------------------------------------------------------------------
int cardianl (Ens e)
{
int i=0;
while (e!=NULL)
{ i++;
e=e->suiv;
}
return i;
}
//--------------------------------------------------------------------------------
Ens inserer(int a, Ens e)
{
Ens m;
if (appartient (a,e)) return e;
m=(maillon*)malloc (sizeof (Maillon))
m->val=a;
m->suiv=e;
return m;
}
//----------------------------------------------------------------------------------
Ens supprimer (int a , Ens e)
{
Ens save;
if (!appartient (a,e)) return e;
if (e->val==a) {
save=e;
e=e->suiv;
free(save);
return (e)
}
e->suiv=supprier(a,e);
return e;
}
//-------------------------------------------------------------------------------------
typedef struct eltens
{
int n;
struct eltens *suiv;
}maillonEns, *Ens;
//-----------------------------------------------------------------------------------
typedef struct eltgraphe
{ int v;
struct eltgraphe *S1;
Ens s2;
} maillongraphe, *Graphe;
//--------------------------------------------------------------------------------
Graphe graphnouv (void)
{ return (Graphe)NULL;
}
Booleen exs(Graphe g, int x)
{
if vide(g)) return faux;
if (g->v==x) return vrai;
return exs(d->S1,x);
}
//------------------------------------------------------------------------------------
Booleen exa(Graphe g, int x, int y)
{
Graphe aux=g;
if (!exs(g,x)|| !exs(g,y)) return faux;
while (aux->v !=x)
aux=aux->Ss;
return (appartient (aux->S1, y);
}
//--------------------------------------------------------------------------------------
int de( Graphe g , int x)
{ Graphe aux =g;
if (!exs(g,x)) return 0;
while (aux->v !=x)
aux= aux ->S1;
return cardinal (aux->Ss);
}
//-------------------------------------------------------------------------------------
int di (Graphe g, int x)
{
Graphe aux=g;
int cpt=0;
while (aux ! NULL)
{if apparient(aux->S1,x) cpt++;
aux->S1;
}
return cpt;
}
//------------------------------------------------------------------------------------------
Graphe adjs(Graphe g, int x)
{
Graphe m;
if (exs (g,x) return g;
m=(maillongraphe *)malloc(sizeof (maillonGraphe))
if( m==NULL)
{
printf ("plus de place memoie");
exit (0);
}
m->v=x;
if (vide(g))
{
m->S1=NULL;
m->S2=ensnouv();
return m;
}
if //-------
{
m->S1=g;
m->S2=ensnouv;
return m
}
g->S1=adjs(g->S1, x);
return g;
}
//-------------------------------------------------------------------------------------------------
Graphe adja (Graphe g, int x, int y)
{
Graphe aux=g;
if(!exs (g,x) || !exs (g,y)) return g;
while (aux->v!=x)
aux=aux->S1;
aux->S2=inserer(aux->S2,y);
return g;
}
//-----------------------------------------------------------------------------------------------------
Graphe sups(Graphe g , int x)
{
if (!exs(g,x)) return g;
if (de(g,x)!=0 || di(g,x)!=0)
{
printf ("sommet relie à un arc");
return g;
}
if vide (g) return g;
if (g->v==x) return g->S1;
g->S1=sups(g->S1,x);
return g;
}
//-----------------------------------------------------------------------------------------------
Graphe supa(graphe g int x, int y)
{
Graphe aux=g;
if (!exa(g,x,y) return g;
while (!vide (aux))
{
if (aux->v==x)
{
aux->S2=supelement(aux->S2,y);
break;
aux=aux->S1;
}
return g
}
}
//--------------------------------------------------------------------------------------------------
//ensemble des successeur
Ens esuc(Graphe g, int x)
{
while (g->v!=x)
g=g->S1;
return g->S2;
}
//--------------------------------------------------------------------------------------------------------
// ensemble des sommets
Ens eg(Graphe g)
{
Ens e=ensnouv();
while (!vide(g))
{
e=inserer (e, g->v);
g=g->S1
}
return e;
}
//----------------------------------------------------------------------------------------------------------
Ens parcprof(Graphe g, int x)
{
Ens e,l;
e=ensnouv();
l=ensnouv();
e=inserer(e,x)
return parcprof(g,e,l);
}
//--------------------------------------------------------------------------------------------------------------
Ens parcfrofe(Graphe g, ens e, Ens l)
{
int z; Ens l1;
if (vide(e)) return l;
z=choix (e);
if (appartient(z,l)) l1=l;
else l1=parcprofe(g,esuc(g,z), inserer(z,l));
return parcprofe(g,supprimer(e,z),l1)
}
//------------------------------------------------------------------------------------------------------
boolleen chemin(Graphe g, int x, int y)
{
Ens e1,e2;
e1=esuc(g,x)
e2=parcprofe(g,e1,ensnouv());
return (appartient (e2,y));
}
//----------------------------------------------------------------------------------------------------------
typedef struct strelem
{
struct strelem *s1;
int v;
struct strelsm *s2;
} Strelem,*Elem, *Graphe;
//---------------------------------------------------------------------------
typedef struct strelsm
{
int v;
struct strelsm *s2;
} Strelsm,*Elem, *Graphe;
//----------------------------------------------------------------------------
typedef struct maillon
{
int val;
struct maillon *suiv;
} Maillon, *Ens;
//-----------------------------------------------------------------------------
Ens Ensvide(void)
{
Ens e=NULL;
return e;
}
//-----------------------------------------------------------------------------
#define faux 0;
#define vrai 1;
typedef int Booleen;
//------------------------------------------------------------------------------
Booleen appartient(int a, Ens e)
{
{if (e==NULL) return faux;
if (e->val==a) return vrai;
return apprtient (a,e->suiv);
}
//------------------------------------------------------------------------------
Booleen EstVide (Ens e)
{
if (e==NULL) return vrai;
return faux;
}
//-----------------------------------------------------------------------------
int cardianl (Ens e)
{
int i=0;
while (e!=NULL)
{ i++;
e=e->suiv;
}
return i;
}
//--------------------------------------------------------------------------------
Ens inserer(int a, Ens e)
{
Ens m;
if (appartient (a,e)) return e;
m=(maillon*)malloc (sizeof (Maillon))
m->val=a;
m->suiv=e;
return m;
}
//----------------------------------------------------------------------------------
Ens supprimer (int a , Ens e)
{
Ens save;
if (!appartient (a,e)) return e;
if (e->val==a) {
save=e;
e=e->suiv;
free(save);
return (e)
}
e->suiv=supprier(a,e);
return e;
}
//-------------------------------------------------------------------------------------
typedef struct eltens
{
int n;
struct eltens *suiv;
}maillonEns, *Ens;
//-----------------------------------------------------------------------------------
typedef struct eltgraphe
{ int v;
struct eltgraphe *S1;
Ens s2;
} maillongraphe, *Graphe;
//--------------------------------------------------------------------------------
Graphe graphnouv (void)
{ return (Graphe)NULL;
}
Booleen exs(Graphe g, int x)
{
if vide(g)) return faux;
if (g->v==x) return vrai;
return exs(d->S1,x);
}
//------------------------------------------------------------------------------------
Booleen exa(Graphe g, int x, int y)
{
Graphe aux=g;
if (!exs(g,x)|| !exs(g,y)) return faux;
while (aux->v !=x)
aux=aux->Ss;
return (appartient (aux->S1, y);
}
//--------------------------------------------------------------------------------------
int de( Graphe g , int x)
{ Graphe aux =g;
if (!exs(g,x)) return 0;
while (aux->v !=x)
aux= aux ->S1;
return cardinal (aux->Ss);
}
//-------------------------------------------------------------------------------------
int di (Graphe g, int x)
{
Graphe aux=g;
int cpt=0;
while (aux ! NULL)
{if apparient(aux->S1,x) cpt++;
aux->S1;
}
return cpt;
}
//------------------------------------------------------------------------------------------
Graphe adjs(Graphe g, int x)
{
Graphe m;
if (exs (g,x) return g;
m=(maillongraphe *)malloc(sizeof (maillonGraphe))
if( m==NULL)
{
printf ("plus de place memoie");
exit (0);
}
m->v=x;
if (vide(g))
{
m->S1=NULL;
m->S2=ensnouv();
return m;
}
if //-------
{
m->S1=g;
m->S2=ensnouv;
return m
}
g->S1=adjs(g->S1, x);
return g;
}
//-------------------------------------------------------------------------------------------------
Graphe adja (Graphe g, int x, int y)
{
Graphe aux=g;
if(!exs (g,x) || !exs (g,y)) return g;
while (aux->v!=x)
aux=aux->S1;
aux->S2=inserer(aux->S2,y);
return g;
}
//-----------------------------------------------------------------------------------------------------
Graphe sups(Graphe g , int x)
{
if (!exs(g,x)) return g;
if (de(g,x)!=0 || di(g,x)!=0)
{
printf ("sommet relie à un arc");
return g;
}
if vide (g) return g;
if (g->v==x) return g->S1;
g->S1=sups(g->S1,x);
return g;
}
//-----------------------------------------------------------------------------------------------
Graphe supa(graphe g int x, int y)
{
Graphe aux=g;
if (!exa(g,x,y) return g;
while (!vide (aux))
{
if (aux->v==x)
{
aux->S2=supelement(aux->S2,y);
break;
aux=aux->S1;
}
return g
}
}
//--------------------------------------------------------------------------------------------------
//ensemble des successeur
Ens esuc(Graphe g, int x)
{
while (g->v!=x)
g=g->S1;
return g->S2;
}
//--------------------------------------------------------------------------------------------------------
// ensemble des sommets
Ens eg(Graphe g)
{
Ens e=ensnouv();
while (!vide(g))
{
e=inserer (e, g->v);
g=g->S1
}
return e;
}
//----------------------------------------------------------------------------------------------------------
Ens parcprof(Graphe g, int x)
{
Ens e,l;
e=ensnouv();
l=ensnouv();
e=inserer(e,x)
return parcprof(g,e,l);
}
//--------------------------------------------------------------------------------------------------------------
Ens parcfrofe(Graphe g, ens e, Ens l)
{
int z; Ens l1;
if (vide(e)) return l;
z=choix (e);
if (appartient(z,l)) l1=l;
else l1=parcprofe(g,esuc(g,z), inserer(z,l));
return parcprofe(g,supprimer(e,z),l1)
}
//------------------------------------------------------------------------------------------------------
boolleen chemin(Graphe g, int x, int y)
{
Ens e1,e2;
e1=esuc(g,x)
e2=parcprofe(g,e1,ensnouv());
return (appartient (e2,y));
}
//----------------------------------------------------------------------------------------------------------
A voir également:
- Graphe A
- Graphe easy - Télécharger - Études & Formations
- Comment faire un graphe sur excel - Guide
- Logiciel graphe - Télécharger - Études & Formations
- Graphe camembert - Guide
- Excel: Réaliser un graphe de cause à effet - Forum Excel