Commit de882a8f authored by phelma's avatar phelma
Browse files

..

parent 09f5e368
el// Fichier list.c
#include "list.h"
#define NIL NULL
list_t list_arc_new() {
return NIL;
}
int list_vertex_is_empty(listevertex_t l)
{
return l==NULL;
}
int list_arc_is_empty(list_t l)
{
return l==NULL;
}
int vertex_equal(vertex_t ver1 , vertex_t ver2)
{
if((ver1.num==ver2.num)&&(strcpm(ver1.name,ver2.name)==0)
&&(strcpm(ver1.ligne,ver2.ligne)==0)&&(ver1.x==ver2.x)&&(ver1.y==ver2.y)
&&list_equal(ver1.arcs,ver2.arcs)&&(ver1.pcc==ver2.pcc))
return 1;
else
return 0;
}
list_t list_add_arc(list_t l,arc_t arc){
list_t li=NULL;
li=calloc(1,sizeof(*li));
li->val=arc;
li->next=l;
return li;
}
int summit_in_list(vertex_t s, lvertex_t l)
{
lvertex_t p;
for( p=l; !list_vertex_is_empty(p) ; p=p->next )
{
if( vertex_equal(p->val, s) )
{
return 1;
}
}
return 0;
}
lvertex_t liste_min(lvertex_t l)
{
lvertex_t p,q;
int min=(l->val).pcc;
for(p=l; !list_vertex_is_empty(p); p=p->next)
{
if((p->val).pcc<min)
{
min=(l->val).pcc;
q=p;
}
}
return q;
}
lvertex_t liste_add(vertex_t s, lvertex_t l)
{
lvertex_t p = calloc( 1, sizeof( *p ) );
if ( NULL == p )
{
printf( stderr, "impossible d'allouer dynamiquement.\n" );
return l;
}
p->val = s;
p->next = l;
return p;
}
lvertex_t list_move(lvertex_t l)
{
lvertex_t p = l->next;
free( l );
return p;
}
int list_equal(list_t l1 , list_t l2){
if((l1==NULL)&&(l2==NULL)){
return 1;}
if((l1==NULL)||(l2==NULL)){return 0;}
if(l1->val!=l2->val){return 0;}
list_equal(l1->next,l2->next);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment