Advertisement
Guest User

forcaBruta_TentativaEerro

a guest
Nov 24th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. void ExatoForcaBruta(Grafo* grafo, int* n_agentes, int cor) {
  2.     //implementar
  3.     //calcular tempo, salvar resultado do tempo em um log
  4.     int fim = 1;
  5.  
  6.     int i,j;
  7.     for(i = 0; i < (grafo)->n_vertices; i++){
  8.         //for(j=0; j<grafo->n_vertices; j++) {
  9.  
  10.         if ((grafo)->cores[i] == -1) {
  11.             (grafo)->cores[i] = 1;
  12.  
  13.             for(j=0; j<(grafo)->n_vertices; j++) {
  14.                 if((i!=j) && ((grafo)->arestas[i][j] != -1)){
  15.                     if((grafo)->cores[i] == (grafo)->cores[j]){
  16.                         (grafo)->cores[i] ++;
  17.                         if(cor < (grafo)->cores[i]){
  18.                             cor = (grafo)->cores[i];
  19.                         }
  20.                         j=0;
  21.                     }
  22.                 }
  23.             }
  24.             ExatoForcaBruta(grafo, n_agentes, cor);
  25.             cor = 1;
  26.             //(grafo)->cores[i] = 0;
  27.             for(j=0; j<(grafo)->n_vertices; j++) {
  28.                 if( (grafo)->cores[j] > cor ) {
  29.                     cor = (grafo)->cores[j];
  30.                 }
  31.             }
  32.             fim = 0;
  33.         }
  34.     }
  35.     if( fim ){
  36.         if( (*n_agentes) > cor ){
  37.             (*n_agentes) = cor;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement