src/benchmark/graph-bench.cc
changeset 730 af375858f17c
parent 711 b6c56353832c
child 921 818510fa3d99
equal deleted inserted replaced
2:1c2c4edb0ed3 3:7f3940f21ea0
     1 #include<math.h>
     1 #include<math.h>
     2 #include<hugo/list_graph.h>
     2 #include<hugo/list_graph.h>
     3 #include<hugo/time_measure.h>
       
     4 #include<iostream>
       
     5 
     3 
     6 #include"bench_tools.h"
     4 #include"bench_tools.h"
     7 
     5 
     8 using namespace hugo;
     6 using namespace hugo;
     9 
     7 
    26   for(int i=0;i<n;i++) nodes[i]=G.addNode();
    24   for(int i=0;i<n;i++) nodes[i]=G.addNode();
    27   
    25   
    28   //Edge equ[rat];
    26   //Edge equ[rat];
    29   std::vector<Edge> equ(rat);
    27   std::vector<Edge> equ(rat);
    30   
    28   
    31   unsigned long long int count;
    29   long long int count;
    32   
    30   
    33   for(count=0;count<rat;count++) {
    31   for(count=0;count<rat;count++) {
    34     equ[count%rat]=G.addEdge(nodes[(count*p)%n],nodes[(count*p/n)%n]);
    32     equ[count%rat]=G.addEdge(nodes[(count*p)%n],nodes[(count*p/n)%n]);
    35   }
    33   }
    36   for(;(count%rat)||((count*p)%n)||((count*p/n)%n);count++) {
    34   for(;(count%rat)||((count*p)%n)||((count*p/n)%n);count++) {
    37     //    if(!(count%1000000)) fprintf(stderr,"%d\r",count);
    35     //    if(!(count%1000000)) fprintf(stderr,"%d\r",count);
    38     if(count%rat) G.erase(equ[count%rat]);
    36     if(count%rat) G.erase(equ[count%rat]);
    39     equ[count%rat]=G.addEdge(nodes[(count*p)%n],nodes[(count*p/n)%n]);
    37     equ[count%rat]=G.addEdge(nodes[(count*p)%n],nodes[(count*p/n)%n]);
    40   }
    38   }
    41   std::cout << "Added " << count
    39 //   std::cout << "Added " << count
    42 	    << " ( " << n << "^2 * " << rat << " ) edges\n";
    40 // 	    << " ( " << n << "^2 * " << rat << " ) edges\n";
       
    41 
       
    42 
    43   //  for(int i=0;1;i++) ;
    43   //  for(int i=0;1;i++) ;
    44 }
    44 }
    45 
    45 
    46 int main()
    46 int main()
    47 {
    47 {
    48   std::cout << "START: n="  << nextPrim(1000) << " rat="
       
    49 	    << nextPrim(300) << " p=" << nextPrim(100) << '\n';
       
    50   hugo::Timer T;
    48   hugo::Timer T;
    51   makeFullGraph<ListGraph>(nextPrim(1000),nextPrim(300),nextPrim(100));
    49   makeFullGraph<ListGraph>(nextPrim(1000),nextPrim(300),nextPrim(100));
    52   std::cout << T  << '\n';
    50   
    53   std::cout << "START: n="  << nextPrim(1000) << " rat="
    51   PrintTime("BIG",T);
    54 	    << nextPrim(300) << " p=" << nextPrim(100) << '\n';
       
    55   T.reset();
    52   T.reset();
    56   makeFullGraph<ListGraph>(nextPrim(100),nextPrim(30000),nextPrim(150));
    53   makeFullGraph<ListGraph>(nextPrim(100),nextPrim(30000),nextPrim(150));
    57   std::cout << T  << '\n';
    54 
       
    55   PrintTime("SMALL",T);
    58 }
    56 }