Changeset 206:4e22275a2b52 in lemon-1.2 for demo
- Timestamp:
- 07/13/08 17:34:27 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
demo/graph_to_eps_demo.cc
r132 r206 19 19 /// \ingroup demos 20 20 /// \file 21 /// \brief Demo of the graph grawing function \ref graphToEps()21 /// \brief Demo of the graph drawing 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 /// graphToEps(), and showing how to draw directed /graphs,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 … … 31 31 /// \include graph_to_eps_demo.cc 32 32 33 #include <lemon/math.h>34 35 #include<lemon/graph_to_eps.h>36 33 #include<lemon/list_graph.h> 37 34 #include<lemon/graph_utils.h> 35 #include<lemon/graph_to_eps.h> 36 #include<lemon/math.h> 38 37 39 38 using namespace std; … … 45 44 Palette paletteW(true); 46 45 46 // Create a small digraph 47 47 ListDigraph g; 48 48 typedef ListDigraph::Node Node; … … 61 61 ListDigraph::NodeMap<int> colors(g); 62 62 ListDigraph::NodeMap<int> shapes(g); 63 ListDigraph::ArcMap<int> ecolors(g);63 ListDigraph::ArcMap<int> acolors(g); 64 64 ListDigraph::ArcMap<int> widths(g); 65 65 … … 70 70 coords[n5]=Point(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2; 71 71 72 Arc e;73 74 e=g.addArc(n1,n2); ecolors[e]=0; widths[e]=1;75 e=g.addArc(n2,n3); ecolors[e]=0; widths[e]=1;76 e=g.addArc(n3,n5); ecolors[e]=0; widths[e]=3;77 e=g.addArc(n5,n4); ecolors[e]=0; widths[e]=1;78 e=g.addArc(n4,n1); ecolors[e]=0; widths[e]=1;79 e=g.addArc(n2,n4); ecolors[e]=1; widths[e]=2;80 e=g.addArc(n3,n4); ecolors[e]=2; widths[e]=1;72 Arc a; 73 74 a=g.addArc(n1,n2); acolors[a]=0; widths[a]=1; 75 a=g.addArc(n2,n3); acolors[a]=0; widths[a]=1; 76 a=g.addArc(n3,n5); acolors[a]=0; widths[a]=3; 77 a=g.addArc(n5,n4); acolors[a]=0; widths[a]=1; 78 a=g.addArc(n4,n1); acolors[a]=0; widths[a]=1; 79 a=g.addArc(n2,n4); acolors[a]=1; widths[a]=2; 80 a=g.addArc(n3,n4); acolors[a]=2; widths[a]=1; 81 81 82 82 IdMap<ListDigraph,Node> id(g); 83 83 84 cout << "Create 'graph_to_eps_demo_out_pure.eps'" << endl;85 graphToEps(g,"graph_to_eps_demo_out_pure.eps").86 //scale(10).84 // Create five .eps files showing the digraph with different options 85 cout << "Create 'graph_to_eps_demo_out_1_pure.eps'" << endl; 86 graphToEps(g,"graph_to_eps_demo_out_1_pure.eps"). 87 87 coords(coords). 88 88 title("Sample .eps figure"). 89 copyright("(C) 2003-2007 LEMON Project"). 90 run(); 91 92 cout << "Create 'graph_to_eps_demo_out.eps'" << endl; 93 graphToEps(g,"graph_to_eps_demo_out.eps"). 94 //scale(10). 89 copyright("(C) 2003-2008 LEMON Project"). 90 run(); 91 92 cout << "Create 'graph_to_eps_demo_out_2.eps'" << endl; 93 graphToEps(g,"graph_to_eps_demo_out_2.eps"). 95 94 coords(coords). 96 95 title("Sample .eps figure"). 97 copyright("(C) 2003-200 7LEMON Project").98 absoluteNodeSizes().absoluteArcWidths(). 99 nodeScale(2).nodeSizes(sizes). 100 nodeShapes(shapes). 101 nodeColors(composeMap(palette,colors)). 102 arcColors(composeMap(palette, ecolors)).96 copyright("(C) 2003-2008 LEMON Project"). 97 absoluteNodeSizes().absoluteArcWidths(). 98 nodeScale(2).nodeSizes(sizes). 99 nodeShapes(shapes). 100 nodeColors(composeMap(palette,colors)). 101 arcColors(composeMap(palette,acolors)). 103 102 arcWidthScale(.4).arcWidths(widths). 104 103 nodeTexts(id).nodeTextSize(3). 105 104 run(); 106 105 107 108 cout << "Create 'graph_to_eps_demo_out_arr.eps'" << endl; 109 graphToEps(g,"graph_to_eps_demo_out_arr.eps"). 110 //scale(10). 106 cout << "Create 'graph_to_eps_demo_out_3_arr.eps'" << endl; 107 graphToEps(g,"graph_to_eps_demo_out_3_arr.eps"). 111 108 title("Sample .eps figure (with arrowheads)"). 112 copyright("(C) 2003-200 7LEMON Project").113 absoluteNodeSizes().absoluteArcWidths(). 114 nodeColors(composeMap(palette,colors)). 115 coords(coords). 116 nodeScale(2).nodeSizes(sizes). 117 nodeShapes(shapes). 118 arcColors(composeMap(palette, ecolors)).109 copyright("(C) 2003-2008 LEMON Project"). 110 absoluteNodeSizes().absoluteArcWidths(). 111 nodeColors(composeMap(palette,colors)). 112 coords(coords). 113 nodeScale(2).nodeSizes(sizes). 114 nodeShapes(shapes). 115 arcColors(composeMap(palette,acolors)). 119 116 arcWidthScale(.4).arcWidths(widths). 120 117 nodeTexts(id).nodeTextSize(3). 121 drawArrows().arrowWidth( 1).arrowLength(1).122 run(); 123 124 e=g.addArc(n1,n4); ecolors[e]=2; widths[e]=1;125 e=g.addArc(n4,n1); ecolors[e]=1; widths[e]=2;126 127 e=g.addArc(n1,n2); ecolors[e]=1; widths[e]=1;128 e=g.addArc(n1,n2); ecolors[e]=2; widths[e]=1;129 e=g.addArc(n1,n2); ecolors[e]=3; widths[e]=1;130 e=g.addArc(n1,n2); ecolors[e]=4; widths[e]=1;131 e=g.addArc(n1,n2); ecolors[e]=5; widths[e]=1;132 e=g.addArc(n1,n2); ecolors[e]=6; widths[e]=1;133 e=g.addArc(n1,n2); ecolors[e]=7; widths[e]=1;118 drawArrows().arrowWidth(2).arrowLength(2). 119 run(); 120 121 a=g.addArc(n1,n4); acolors[a]=2; widths[a]=1; 122 a=g.addArc(n4,n1); acolors[a]=1; widths[a]=2; 123 124 a=g.addArc(n1,n2); acolors[a]=1; widths[a]=1; 125 a=g.addArc(n1,n2); acolors[a]=2; widths[a]=1; 126 a=g.addArc(n1,n2); acolors[a]=3; widths[a]=1; 127 a=g.addArc(n1,n2); acolors[a]=4; widths[a]=1; 128 a=g.addArc(n1,n2); acolors[a]=5; widths[a]=1; 129 a=g.addArc(n1,n2); acolors[a]=6; widths[a]=1; 130 a=g.addArc(n1,n2); acolors[a]=7; widths[a]=1; 134 131 135 132 cout << "Create 'graph_to_eps_demo_out_par.eps'" << endl; … … 137 134 //scale(10). 138 135 title("Sample .eps figure (parallel arcs)"). 139 copyright("(C) 2003-200 7LEMON Project").140 absoluteNodeSizes().absoluteArcWidths(). 141 nodeShapes(shapes). 142 coords(coords). 143 nodeScale(2).nodeSizes(sizes). 144 nodeColors(composeMap(palette,colors)). 145 arcColors(composeMap(palette, ecolors)).136 copyright("(C) 2003-2008 LEMON Project"). 137 absoluteNodeSizes().absoluteArcWidths(). 138 nodeShapes(shapes). 139 coords(coords). 140 nodeScale(2).nodeSizes(sizes). 141 nodeColors(composeMap(palette,colors)). 142 arcColors(composeMap(palette,acolors)). 146 143 arcWidthScale(.4).arcWidths(widths). 147 144 nodeTexts(id).nodeTextSize(3). 148 145 enableParallel().parArcDist(1.5). 149 146 run(); 150 151 cout << "Create 'graph_to_eps_demo_out_par_arr.eps'" << endl; 152 graphToEps(g,"graph_to_eps_demo_out_par_arr.eps"). 153 //scale(10). 147 148 cout << "Create 'graph_to_eps_demo_out_4_par_arr.eps'" << endl; 149 graphToEps(g,"graph_to_eps_demo_out_4_par_arr.eps"). 154 150 title("Sample .eps figure (parallel arcs and arrowheads)"). 155 copyright("(C) 2003-200 7LEMON Project").156 absoluteNodeSizes().absoluteArcWidths(). 157 nodeScale(2).nodeSizes(sizes). 158 coords(coords). 159 nodeShapes(shapes). 160 nodeColors(composeMap(palette,colors)). 161 arcColors(composeMap(palette, ecolors)).151 copyright("(C) 2003-2008 LEMON Project"). 152 absoluteNodeSizes().absoluteArcWidths(). 153 nodeScale(2).nodeSizes(sizes). 154 coords(coords). 155 nodeShapes(shapes). 156 nodeColors(composeMap(palette,colors)). 157 arcColors(composeMap(palette,acolors)). 162 158 arcWidthScale(.3).arcWidths(widths). 163 159 nodeTexts(id).nodeTextSize(3). … … 166 162 run(); 167 163 168 cout << "Create 'graph_to_eps_demo_out_ a4.eps'" << endl;169 graphToEps(g,"graph_to_eps_demo_out_ a4.eps").scaleToA4().164 cout << "Create 'graph_to_eps_demo_out_5_par_arr_a4.eps'" << endl; 165 graphToEps(g,"graph_to_eps_demo_out_5_par_arr_a4.eps"). 170 166 title("Sample .eps figure (fits to A4)"). 171 copyright("(C) 2003-2007 LEMON Project"). 172 absoluteNodeSizes().absoluteArcWidths(). 173 nodeScale(2).nodeSizes(sizes). 174 coords(coords). 175 nodeShapes(shapes). 176 nodeColors(composeMap(palette,colors)). 177 arcColors(composeMap(palette,ecolors)). 167 copyright("(C) 2003-2008 LEMON Project"). 168 scaleToA4(). 169 absoluteNodeSizes().absoluteArcWidths(). 170 nodeScale(2).nodeSizes(sizes). 171 coords(coords). 172 nodeShapes(shapes). 173 nodeColors(composeMap(palette,colors)). 174 arcColors(composeMap(palette,acolors)). 178 175 arcWidthScale(.3).arcWidths(widths). 179 176 nodeTexts(id).nodeTextSize(3). … … 182 179 run(); 183 180 181 // Create an .eps file showing the colors of a default Palette 184 182 ListDigraph h; 185 183 ListDigraph::NodeMap<int> hcolors(h); … … 189 187 for(int i=0;i<int(paletteW.size());i++) { 190 188 Node n=h.addNode(); 191 hcoords[n]=Point( i%cols,i/cols);189 hcoords[n]=Point(1+i%cols,1+i/cols); 192 190 hcolors[n]=i; 193 191 } 194 192 195 cout << "Create 'graph_to_eps_demo_out_ colors.eps'" << endl;196 graphToEps(h,"graph_to_eps_demo_out_ colors.eps").197 //scale(60).193 cout << "Create 'graph_to_eps_demo_out_6_colors.eps'" << endl; 194 graphToEps(h,"graph_to_eps_demo_out_6_colors.eps"). 195 scale(60). 198 196 title("Sample .eps figure (Palette demo)"). 199 copyright("(C) 2003-200 7LEMON Project").197 copyright("(C) 2003-2008 LEMON Project"). 200 198 coords(hcoords). 201 199 absoluteNodeSizes().absoluteArcWidths(). 202 200 nodeScale(.45). 203 201 distantColorNodeTexts(). 204 // distantBWNodeTexts().205 202 nodeTexts(hcolors).nodeTextSize(.6). 206 203 nodeColors(composeMap(paletteW,hcolors)). 207 204 run(); 205 206 return 0; 208 207 }
Note: See TracChangeset
for help on using the changeset viewer.