Commit bdf07e79 authored by Valentin MEUNIER's avatar Valentin MEUNIER
Browse files

pour tibo le sympasticot

parent 55f282d0
#ifndef _gard_graph_aretes_tab_
#define _gard_graph_aretes_tab_
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include <time.h>
#include "partition.h"
#include "graph_aretes_tab.h"
#include "tas.h"
#endif
......@@ -44,7 +44,7 @@ int ** tableau_ligne(graph_t * graph,int nb_aretes)
return tab;
}
graph_t * kruskal(graph_t * graph,int noeuds, int nb_aretes,int * cours)
graph_t * kruskal(graph_t * graph,int noeuds, int nb_aretes,int * cours,double p)
{
int c1;
int c2;
......@@ -59,7 +59,7 @@ graph_t * kruskal(graph_t * graph,int noeuds, int nb_aretes,int * cours)
c1=recuperer_classe(graph->liste[i].un,partA);
c2=recuperer_classe(graph->liste[i].deux, partA);
// printf("%d %d\n",c1,c2);
if (c1!=c2)
if (c1!=c2 || p<(double)rand()/(double)RAND_MAX)
{
A->liste[*cours]=graph->liste[i];
fusion(A->liste[*cours].un,A->liste[*cours].deux,partA);
......
......@@ -7,7 +7,7 @@
#define N 30
#define P 52
graph_t * kruskal(graph_t * graph,int noeuds, int nb_aretes,int * cours);
graph_t * kruskal(graph_t * graph,int noeuds, int nb_aretes,int * cours,double p);
graph_t * Fisher(graph_t * graph, int nb_aretes);
......
......@@ -66,8 +66,11 @@ int min(int a, int b)
}
int main ()
int main (int argc, char** argv)
{
double p;
if (argc==2) p=atof(argv[1]);
else p=1;
if (SDL_Init(SDL_INIT_VIDEO) == -1)
{
fprintf(stderr, "Erreur d'initialisation de la SDL : %s\n", SDL_GetError());
......@@ -95,10 +98,7 @@ int main ()
graph_t * graph=creer_graph(noeuds,nb_aretes);
generation(graph);
graph=Fisher(graph,nb_aretes);
//printf("%d \n", nb_aretes);
graph=kruskal(graph,noeuds,nb_aretes,&cours);
//printf("cours %d\n",cours);
// affiche_graph_couple(graph,noeuds,cours);
graph=kruskal(graph,noeuds,nb_aretes,&cours,p);
tab=tableau_ligne(graph,cours);
SDL_Event event;
......
......@@ -11,6 +11,6 @@
void end_sdl(char ok,char const* msg,SDL_Window* window, SDL_Renderer* renderer);
void afficheEcranIntelligement(SDL_Renderer*,int**,int);
int min(int , int);
int main();
int main(int ,char**);
#endif
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