27 /// \include descriptor_map_demo.cc |
27 /// \include descriptor_map_demo.cc |
28 |
28 |
29 #include <lemon/list_graph.h> |
29 #include <lemon/list_graph.h> |
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/xy.h> |
32 #include <lemon/dim2.h> |
33 #include <lemon/graph_to_eps.h> |
33 #include <lemon/graph_to_eps.h> |
34 |
34 |
35 #include <iostream> |
35 #include <iostream> |
36 |
36 |
37 #include <cstdlib> |
37 #include <cstdlib> |
38 #include <cmath> |
38 #include <cmath> |
39 #include <ctime> |
39 #include <ctime> |
40 |
40 |
41 using namespace lemon; |
41 using namespace lemon; |
42 |
42 |
43 // Special xy<double> map type |
43 // Special dim2::Point<double> map type |
44 // |
44 // |
45 // It gives back a position for each node. The position of the nodes |
45 // It gives back a position for each node. The position of the nodes |
46 // are on the circle with the given center and radius. |
46 // are on the circle with the given center and radius. |
47 // |
47 // |
48 // Because we use the descriptor map it will hold the proprty |
48 // Because we use the descriptor map it will hold the proprty |
49 // described above even if a node added or deleted. |
49 // described above even if a node added or deleted. |
50 template <typename Graph> |
50 template <typename Graph> |
51 class CircleMap { |
51 class CircleMap { |
52 public: |
52 public: |
53 |
53 |
54 typedef xy<double> Value; |
54 typedef dim2::Point<double> Value; |
55 typedef typename Graph::Node Key; |
55 typedef typename Graph::Node Key; |
56 |
56 |
57 CircleMap(const Graph& _graph, |
57 CircleMap(const Graph& _graph, |
58 const Value& _center = Value(0.0, 0.0), |
58 const Value& _center = Value(0.0, 0.0), |
59 double _radius = 1.0) |
59 double _radius = 1.0) |
116 std::cout << std::endl; |
116 std::cout << std::endl; |
117 std::cout << "Postscript file: descriptor_map_demo.eps" << std::endl; |
117 std::cout << "Postscript file: descriptor_map_demo.eps" << std::endl; |
118 |
118 |
119 // Make postscript from the graph. |
119 // Make postscript from the graph. |
120 |
120 |
121 CircleMap<Graph> coords(graph, xy<double>(0.0, 0.0), 10.0); |
121 CircleMap<Graph> coords(graph, dim2::Point<double>(0.0, 0.0), 10.0); |
122 |
122 |
123 graphToEps(graph,"descriptor_map_demo.eps").scaleToA4(). |
123 graphToEps(graph,"descriptor_map_demo.eps").scaleToA4(). |
124 title("Generated graph"). |
124 title("Generated graph"). |
125 copyright("(C) 2006 LEMON Project"). |
125 copyright("(C) 2006 LEMON Project"). |
126 coords(coords). |
126 coords(coords). |