0
2
0
... | ... |
@@ -21,49 +21,49 @@ |
21 | 21 |
/// \brief Demo of the graph grawing function \ref graphToEps() |
22 | 22 |
/// |
23 | 23 |
/// This demo program shows examples how to use the function \ref |
24 | 24 |
/// graphToEps(). It takes no input but simply creates six |
25 | 25 |
/// <tt>.eps</tt> files demonstrating the capability of \ref |
26 | 26 |
/// graphToEps(), and showing how to draw directed/graphs, |
27 | 27 |
/// how to handle parallel egdes, how to change the properties (like |
28 | 28 |
/// color, shape, size, title etc.) of nodes and arcs individually |
29 | 29 |
/// using appropriate \ref maps-page "graph maps". |
30 | 30 |
/// |
31 | 31 |
/// \include graph_to_eps_demo.cc |
32 | 32 |
|
33 | 33 |
#include <lemon/math.h> |
34 | 34 |
|
35 | 35 |
#include<lemon/graph_to_eps.h> |
36 | 36 |
#include<lemon/list_graph.h> |
37 | 37 |
#include<lemon/graph_utils.h> |
38 | 38 |
|
39 | 39 |
using namespace std; |
40 | 40 |
using namespace lemon; |
41 | 41 |
|
42 | 42 |
int main() |
43 | 43 |
{ |
44 | 44 |
Palette palette; |
45 |
Palette paletteW( |
|
45 |
Palette paletteW(true); |
|
46 | 46 |
|
47 | 47 |
ListDigraph g; |
48 | 48 |
typedef ListDigraph::Node Node; |
49 | 49 |
typedef ListDigraph::NodeIt NodeIt; |
50 | 50 |
typedef ListDigraph::Arc Arc; |
51 | 51 |
typedef dim2::Point<int> Point; |
52 | 52 |
|
53 | 53 |
Node n1=g.addNode(); |
54 | 54 |
Node n2=g.addNode(); |
55 | 55 |
Node n3=g.addNode(); |
56 | 56 |
Node n4=g.addNode(); |
57 | 57 |
Node n5=g.addNode(); |
58 | 58 |
|
59 | 59 |
ListDigraph::NodeMap<Point> coords(g); |
60 | 60 |
ListDigraph::NodeMap<double> sizes(g); |
61 | 61 |
ListDigraph::NodeMap<int> colors(g); |
62 | 62 |
ListDigraph::NodeMap<int> shapes(g); |
63 | 63 |
ListDigraph::ArcMap<int> ecolors(g); |
64 | 64 |
ListDigraph::ArcMap<int> widths(g); |
65 | 65 |
|
66 | 66 |
coords[n1]=Point(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0; |
67 | 67 |
coords[n2]=Point(50,70); sizes[n2]=2; colors[n2]=2; shapes[n2]=2; |
68 | 68 |
coords[n3]=Point(70,70); sizes[n3]=1; colors[n3]=3; shapes[n3]=0; |
69 | 69 |
coords[n4]=Point(70,50); sizes[n4]=2; colors[n4]=4; shapes[n4]=1; |
... | ... |
@@ -98,49 +98,49 @@ |
98 | 98 |
|
99 | 99 |
///This map assigns one of the predefined \ref Color "Color"s to |
100 | 100 |
///each <tt>int</tt>. It is possible to change the colors as well as |
101 | 101 |
///their number. The integer range is cyclically mapped to the |
102 | 102 |
///provided set of colors. |
103 | 103 |
/// |
104 | 104 |
///This is a true \ref concepts::ReferenceMap "reference map", so |
105 | 105 |
///you can also change the actual colors. |
106 | 106 |
|
107 | 107 |
class Palette : public MapBase<int,Color> |
108 | 108 |
{ |
109 | 109 |
std::vector<Color> colors; |
110 | 110 |
public: |
111 | 111 |
///Constructor |
112 | 112 |
|
113 | 113 |
///Constructor |
114 | 114 |
///\param num the number of the allocated colors. If it is \c -1, |
115 | 115 |
///the default color configuration is set up (26 color plus the |
116 | 116 |
///white). If \c num is less then 26/27 then the default color |
117 | 117 |
///list is cut. Otherwise the color list is filled repeatedly with |
118 | 118 |
///the default color list. (The colors can be changed later on.) |
119 | 119 |
///\param have_white indicates whether white is amongst the |
120 | 120 |
///provided color (\c true) or not (\c false). If it is true, |
121 | 121 |
///white will be assigned to \c 0. |
122 |
Palette(int num=-1 |
|
122 |
Palette(bool have_white=false,int num=-1) |
|
123 | 123 |
{ |
124 | 124 |
if (num==0) return; |
125 | 125 |
do { |
126 | 126 |
if(have_white) colors.push_back(Color(1,1,1)); |
127 | 127 |
|
128 | 128 |
colors.push_back(Color(0,0,0)); |
129 | 129 |
colors.push_back(Color(1,0,0)); |
130 | 130 |
colors.push_back(Color(0,1,0)); |
131 | 131 |
colors.push_back(Color(0,0,1)); |
132 | 132 |
colors.push_back(Color(1,1,0)); |
133 | 133 |
colors.push_back(Color(1,0,1)); |
134 | 134 |
colors.push_back(Color(0,1,1)); |
135 | 135 |
|
136 | 136 |
colors.push_back(Color(.5,0,0)); |
137 | 137 |
colors.push_back(Color(0,.5,0)); |
138 | 138 |
colors.push_back(Color(0,0,.5)); |
139 | 139 |
colors.push_back(Color(.5,.5,0)); |
140 | 140 |
colors.push_back(Color(.5,0,.5)); |
141 | 141 |
colors.push_back(Color(0,.5,.5)); |
142 | 142 |
|
143 | 143 |
colors.push_back(Color(.5,.5,.5)); |
144 | 144 |
colors.push_back(Color(1,.5,.5)); |
145 | 145 |
colors.push_back(Color(.5,1,.5)); |
146 | 146 |
colors.push_back(Color(.5,.5,1)); |
0 comments (0 inline)