demo/descriptor_map_demo.cc
changeset 1555 48769ac7ec32
parent 1553 434f9add42cd
child 1556 caf0f91e16a7
equal deleted inserted replaced
0:14b8a923c487 1:8b22d2089cb9
       
     1 /* -*- C++ -*-
       
     2  * demo/descriptor_map_demo.cc - Part of LEMON, a generic C++ optimization library
       
     3  *
       
     4  * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
       
     5  * (Egervary Research Group on Combinatorial Optimization, EGRES).
       
     6  *
       
     7  * Permission to use, modify and distribute this software is granted
       
     8  * provided that this copyright notice appears in all copies. For
       
     9  * precise terms see the accompanying LICENSE file.
       
    10  *
       
    11  * This software is provided "AS IS" with no warranty of any kind,
       
    12  * express or implied, and with no claim as to its suitability for any
       
    13  * purpose.
       
    14  *
       
    15  */
       
    16 
     1 #include <lemon/list_graph.h>
    17 #include <lemon/list_graph.h>
     2 #include <lemon/graph_utils.h>
    18 #include <lemon/graph_utils.h>
       
    19 #include <lemon/graph_writer.h>
     3 #include <lemon/xy.h>
    20 #include <lemon/xy.h>
       
    21 #include <lemon/graph_to_eps.h>
     4 
    22 
     5 #include <lemon/graph_to_eps.h>
    23 #include <iostream>
     6 
    24 
     7 #include <cstdlib>
    25 #include <cstdlib>
     8 #include <cmath>
    26 #include <cmath>
     9 #include <ctime>
    27 #include <ctime>
    10 
    28 
    48   typedef ListGraph Graph;
    66   typedef ListGraph Graph;
    49   typedef Graph::Node Node;
    67   typedef Graph::Node Node;
    50   typedef Graph::Edge Edge;
    68   typedef Graph::Edge Edge;
    51   
    69   
    52   // Generating a graph
    70   // Generating a graph
    53   
    71 
       
    72   std::cout << "Generating graph: " << std::endl;
       
    73 
    54   Graph graph;
    74   Graph graph;
    55   
    75   
    56   const int NODE = 16;
    76   const int NODE = 16;
    57   for (int i = 0; i < NODE; ++i) {
    77   for (int i = 0; i < NODE; ++i) {
    58     graph.addNode();
    78     graph.addNode();
    76     int ti = (int)(std::rand() / (RAND_MAX + 1.0) * NODE);
    96     int ti = (int)(std::rand() / (RAND_MAX + 1.0) * NODE);
    77       
    97       
    78     graph.addEdge(nodeInv[si], nodeInv[ti]);
    98     graph.addEdge(nodeInv[si], nodeInv[ti]);
    79   }
    99   }
    80 
   100 
       
   101   GraphWriter<Graph>(std::cout, graph).run();
       
   102 
       
   103   std::cout << std::endl;
       
   104   std::cout << "Postscript file: descriptor_map_demo.eps" << std::endl;
       
   105 
    81   // Make postscript from the graph.
   106   // Make postscript from the graph.
    82     
   107     
    83   CircleMap<Graph> coords(graph, xy<double>(0.0, 0.0), 10.0);
   108   CircleMap<Graph> coords(graph, xy<double>(0.0, 0.0), 10.0);
    84     
   109     
    85   graphToEps(graph,"descriptor_map_demo.eps").scaleToA4().
   110   graphToEps(graph,"descriptor_map_demo.eps").scaleToA4().