demo/descriptor_map_demo.cc
changeset 2316 c0fae4bbaa5c
parent 2207 75a29ac69c19
child 2386 81b47fc5c444
equal deleted inserted replaced
7:dfaad10e52bd 8:9aae97b0eee3
    30 #include <lemon/graph_utils.h>
    30 #include <lemon/graph_utils.h>
    31 #include <lemon/graph_writer.h>
    31 #include <lemon/graph_writer.h>
    32 #include <lemon/dim2.h>
    32 #include <lemon/dim2.h>
    33 #include <lemon/graph_to_eps.h>
    33 #include <lemon/graph_to_eps.h>
    34 
    34 
       
    35 #include <lemon/random.h>
       
    36 
    35 #include <iostream>
    37 #include <iostream>
    36 
    38 
    37 #include <cstdlib>
       
    38 #include <cmath>
    39 #include <cmath>
    39 #include <ctime>
    40 
    40 
    41 
    41 using namespace lemon;
    42 using namespace lemon;
    42 
    43 
    43 // Special dim2::Point<double> map type 
    44 // Special dim2::Point<double> map type 
    44 //
    45 //
    73   Value center;
    74   Value center;
    74   double radius;
    75   double radius;
    75 };
    76 };
    76 
    77 
    77 int main() {
    78 int main() {
    78   std::srand(std::time(0));
       
    79   typedef ListGraph Graph;
    79   typedef ListGraph Graph;
    80   typedef Graph::Node Node;
    80   typedef Graph::Node Node;
    81   typedef Graph::Edge Edge;
    81   typedef Graph::Edge Edge;
    82   
    82   
    83   // Generating a graph
    83   // Generating a graph
   103   //
   103   //
   104   // The inversemap cannot works without its DescriptorMap because
   104   // The inversemap cannot works without its DescriptorMap because
   105   // it holds reference to it. 
   105   // it holds reference to it. 
   106   const int EDGE = (int)(NODE * std::log(double(NODE)));
   106   const int EDGE = (int)(NODE * std::log(double(NODE)));
   107   for (int i = 0; i < EDGE; ++i) {
   107   for (int i = 0; i < EDGE; ++i) {
   108     int si = (int)(std::rand() / (RAND_MAX + 1.0) * NODE);
   108     int si = rnd[NODE];
   109     int ti = (int)(std::rand() / (RAND_MAX + 1.0) * NODE);
   109     int ti = rnd[NODE];
   110       
   110       
   111     graph.addEdge(nodeInv[si], nodeInv[ti]);
   111     graph.addEdge(nodeInv[si], nodeInv[ti]);
   112   }
   112   }
   113 
   113 
   114   GraphWriter<Graph>(std::cout, graph).run();
   114   GraphWriter<Graph>(std::cout, graph).run();