#include #include #define R 10 // rayon long int fact(n) { if (n==1) return 1; else return (n*fact(n-1)); } int max_trace(int nbloci)// only for 2 gives max of comb possible... { int i,j; int n=0; for (i=1;in) n=j; } return n; } void svg_header(FILE *f,int w, int h,char *s) { fprintf(f,"\n"); fprintf(f,"\n",w,h); fprintf(f,"%s\n",s); } void read (FILE *f) { char *ligne,*ptr, *sep=" ,\t"; int nbl=0; char **pheno; float *fitness; fscanf(f,"%[^\n]\n",ligne); ptr = strtok(ligne, sep); while ( ptr != NULL ) { nbl++; nba=atoi(ptr); //je dis quil ont tous le meme nbr dalles... ptr = strtok(NULL, sep); } nbp=pow(nba,nbl); pheno=(char *)malloc(sizeof(char *) *nbp ); for (i=0;i>nbp;i++) pheno[i]=malloc(sizeof(char)*nbl); for (i=0;i",x+(i*2*R)+1,y,R,colors[(int)pheno[i]]); } fprintf(f,"%f\n",x+((nbloci*R)/2.0),y+R+12,f); } /*draws a set of genotype with same nubr of mut*/ } void drawLand(struct landscape land,FILE *f) { int c,*g; FILE *f; int x,y; int width,height,middle; int width_geno=R*land.nlocus; int height_geno=R*5; int margin_left=10; int margin_up=10; width=width_geno*land.nlocus*2; height=R*land.nlocus*land.nlocus*4; middleY=height/2.0; void svg_header(f,width, height,"what a beautifull view") for (i=0;i=0) draw_geno(f,x, y,g, land.fitness[i],land.nlocus) } fprintf(f,"\n"); } int main(int argc,char **argv) { char *file, type; FILE *f; struct landscape land; if (argc!=3) printf("Usage %s [G|g] \n",argv[0]); type =*argv[1]; if (type !='g' && type !='G') printf("Usage %s [G|g] \n",argv[0]); land= ReadFile (argv[2]); sprintf(file_out,"%s.svg",argv[2]); f=fopen(file_out,"w"); if (type=='g') drawLand(land,f) else drawGraph(land,f); exit(0); }