Skip to content
Extraits de code Groupes Projets
Valider c558dfb3 rédigé par Samuh's avatar Samuh
Parcourir les fichiers

question 3 TP4

parent 03b76617
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -142,7 +142,8 @@ void aff_tab(unsigned long *t, int size) ...@@ -142,7 +142,8 @@ void aff_tab(unsigned long *t, int size)
// ----------------------------------------------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------------------------------------------
void simplifie_label(unsigned long *label, unsigned long size) // renvoie le nombre de label et les renommes
unsigned long simplifie_label(unsigned long *label, unsigned long size)
{ {
unsigned long c = 0; unsigned long c = 0;
unsigned long smallest = size; unsigned long smallest = size;
...@@ -168,6 +169,7 @@ void simplifie_label(unsigned long *label, unsigned long size) ...@@ -168,6 +169,7 @@ void simplifie_label(unsigned long *label, unsigned long size)
} }
c++; c++;
} }
return c - 1;
} }
void output_graphe(adjlist *g, unsigned long *label, char *filename) void output_graphe(adjlist *g, unsigned long *label, char *filename)
...@@ -255,7 +257,7 @@ int main(int argc, char **argv) ...@@ -255,7 +257,7 @@ int main(int argc, char **argv)
} }
adjlist *g; adjlist *g;
time_t t1, t2, t3; time_t t1, t2, t3, t4;
// PARSING // PARSING
t1 = time(NULL); t1 = time(NULL);
...@@ -263,8 +265,11 @@ int main(int argc, char **argv) ...@@ -263,8 +265,11 @@ int main(int argc, char **argv)
printf("Reading edgelist from file %s\n", argv[1]); printf("Reading edgelist from file %s\n", argv[1]);
g = al_readedgelist(argv[1]); g = al_readedgelist(argv[1]);
t3 = time(NULL); t3 = time(NULL);
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
printf("- edge list time = %I64dh%I64dm%I64ds\n", (t3 - t1) / 3600, ((t3 - t1) % 3600) / 60, ((t3 - t1) % 60));
#else
printf("- edge list time = %ldh%ldm%lds\n", (t3 - t1) / 3600, ((t3 - t1) % 3600) / 60, ((t3 - t1) % 60)); printf("- edge list time = %ldh%ldm%lds\n", (t3 - t1) / 3600, ((t3 - t1) % 3600) / 60, ((t3 - t1) % 60));
// printf("- edge list time = %I64dh%I64dm%I64ds\n", (t3 - t1) / 3600, ((t3 - t1) % 3600) / 60, ((t3 - t1) % 60)); #endif
printf("Number of nodes: %lu\n", g->n); printf("Number of nodes: %lu\n", g->n);
printf("Number of edges: %lu\n", g->e); printf("Number of edges: %lu\n", g->e);
...@@ -274,18 +279,31 @@ int main(int argc, char **argv) ...@@ -274,18 +279,31 @@ int main(int argc, char **argv)
t2 = time(NULL); t2 = time(NULL);
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
printf("- Overall time = %I64dh%I64dm%I64ds\n", (t2 - t1) / 3600, ((t2 - t1) % 3600) / 60, ((t2 - t1) % 60));
#else
printf("- Overall time = %ldh%ldm%lds\n", (t2 - t1) / 3600, ((t2 - t1) % 3600) / 60, ((t2 - t1) % 60)); printf("- Overall time = %ldh%ldm%lds\n", (t2 - t1) / 3600, ((t2 - t1) % 3600) / 60, ((t2 - t1) % 60));
// printf("- Overall time = %I64dh%I64dm%I64ds\n", (t2 - t1) / 3600, ((t2 - t1) % 3600) / 60, ((t2 - t1) % 60)); #endif
srand(time(NULL)); srand(time(NULL));
unsigned long *res = label_propagation(g); unsigned long *res = label_propagation(g);
simplifie_label(res, g->n); t4 = time(NULL);
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
printf("- label_propagation time = %I64dh%I64dm%I64ds\n", (t4 - t2) / 3600, ((t4 - t2) % 3600) / 60, ((t4 - t2) % 60));
#else
printf("- label_propagation time = %ldh%ldm%lds\n", (t4 - t2) / 3600, ((t4 - t2) % 3600) / 60, ((t4 - t2) % 60));
#endif
unsigned long nb = simplifie_label(res, g->n);
printf("%li label different\n", nb);
output_graphe(g, res, "toto.dot"); output_graphe(g, res, "toto.dot");
printf("run {dot -Tpng -o out.png toto.dot} pour avoir une visualisation de la solution\n"); printf("run {dot -Tpng -o out.png toto.dot} pour avoir une visualisation de la solution\n");
free(res);
free_adjlist(g); free_adjlist(g);
return 0; return 0;
} }
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter