This commit is contained in:
Adrian POURCHOT 2023-03-17 12:43:26 +01:00
parent 0c05731f22
commit b7e9fd77cd
2 changed files with 53 additions and 1 deletions

View File

@ -11,6 +11,59 @@ struct graphe{
typedef struct graphe graphe;
struct file {
int data;
struct file* succ;
};
typedef struct file fifo;
fifo* enqueue(fifo **fi,int v){
fifo *nf=malloc(sizeof(fifo));
nf->data=v;
nf->succ=*fi;
return nf;
}
int dequeue(fifo **fi){
fifo *lect=*fi;
if(lect->succ==NULL){
int res=lect->data;
*fi=NULL;
return res;
}
while(lect->succ->succ!=NULL){
lect=lect->succ;
}
int res=lect->succ->data;
fifo *temp=lect->succ;
lect->succ=NULL;
free(temp);
return res;
}
int empty(fifo *fi){
return fi==NULL;
}
void afficheFile(fifo *fi){
fifo *affichage=malloc(sizeof(fifo));
affichage=fi;
while(affichage->succ!=NULL){
printf("%hu ",affichage->data);
affichage=affichage->succ;
}free(affichage);
}
fifo* fileVoisins(graphe g,int v){
fifo *res=malloc(sizeof(fifo));
int i;
for(i=0;i<g.ordre;i++){
if(g.adj[i][v]==1){
enqueue(&res,g.adj[i][v]);
}
} return res;
}
graphe creergraphe(int ord,int or){
int i;
int j;

View File

@ -2,7 +2,6 @@
#include <stdlib.h>
#include "FichierDef.h"
int main(int argc, char const *argv[]){
graphe Graphe;
int connexe;