[Lemon-commits] Alpar Juttner: Merge
Lemon HG
hg at lemon.cs.elte.hu
Sun Jul 13 17:41:43 CEST 2008
details: http://lemon.cs.elte.hu/hg/lemon/rev/574b963d0275
changeset: 207:574b963d0275
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Sun Jul 13 16:35:05 2008 +0100
description:
Merge
diffstat:
3 files changed, 98 insertions(+), 160 deletions(-)
demo/graph_to_eps_demo.cc | 113 ++++++++++++++++++-------------------
lemon/color.h | 11 +--
lemon/graph_to_eps.h | 134 ++++++++++++---------------------------------
diffs (truncated from 667 to 300 lines):
diff -r 436fe75092b7 -r 574b963d0275 demo/graph_to_eps_demo.cc
--- a/demo/graph_to_eps_demo.cc Sat Jul 12 09:45:11 2008 +0100
+++ b/demo/graph_to_eps_demo.cc Sun Jul 13 16:35:05 2008 +0100
@@ -18,23 +18,22 @@
/// \ingroup demos
/// \file
-/// \brief Demo of the graph grawing function \ref graphToEps()
+/// \brief Demo of the graph drawing function \ref graphToEps()
///
/// This demo program shows examples how to use the function \ref
/// graphToEps(). It takes no input but simply creates six
/// <tt>.eps</tt> files demonstrating the capability of \ref
-/// graphToEps(), and showing how to draw directed/graphs,
+/// graphToEps(), and showing how to draw directed graphs,
/// how to handle parallel egdes, how to change the properties (like
/// color, shape, size, title etc.) of nodes and arcs individually
/// using appropriate \ref maps-page "graph maps".
///
/// \include graph_to_eps_demo.cc
-#include <lemon/math.h>
-
-#include<lemon/graph_to_eps.h>
#include<lemon/list_graph.h>
#include<lemon/graph_utils.h>
+#include<lemon/graph_to_eps.h>
+#include<lemon/math.h>
using namespace std;
using namespace lemon;
@@ -44,6 +43,7 @@
Palette palette;
Palette paletteW(true);
+ // Create a small digraph
ListDigraph g;
typedef ListDigraph::Node Node;
typedef ListDigraph::NodeIt NodeIt;
@@ -60,7 +60,7 @@
ListDigraph::NodeMap<double> sizes(g);
ListDigraph::NodeMap<int> colors(g);
ListDigraph::NodeMap<int> shapes(g);
- ListDigraph::ArcMap<int> ecolors(g);
+ ListDigraph::ArcMap<int> acolors(g);
ListDigraph::ArcMap<int> widths(g);
coords[n1]=Point(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0;
@@ -69,118 +69,116 @@
coords[n4]=Point(70,50); sizes[n4]=2; colors[n4]=4; shapes[n4]=1;
coords[n5]=Point(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2;
- Arc e;
+ Arc a;
- e=g.addArc(n1,n2); ecolors[e]=0; widths[e]=1;
- e=g.addArc(n2,n3); ecolors[e]=0; widths[e]=1;
- e=g.addArc(n3,n5); ecolors[e]=0; widths[e]=3;
- e=g.addArc(n5,n4); ecolors[e]=0; widths[e]=1;
- e=g.addArc(n4,n1); ecolors[e]=0; widths[e]=1;
- e=g.addArc(n2,n4); ecolors[e]=1; widths[e]=2;
- e=g.addArc(n3,n4); ecolors[e]=2; widths[e]=1;
+ a=g.addArc(n1,n2); acolors[a]=0; widths[a]=1;
+ a=g.addArc(n2,n3); acolors[a]=0; widths[a]=1;
+ a=g.addArc(n3,n5); acolors[a]=0; widths[a]=3;
+ a=g.addArc(n5,n4); acolors[a]=0; widths[a]=1;
+ a=g.addArc(n4,n1); acolors[a]=0; widths[a]=1;
+ a=g.addArc(n2,n4); acolors[a]=1; widths[a]=2;
+ a=g.addArc(n3,n4); acolors[a]=2; widths[a]=1;
IdMap<ListDigraph,Node> id(g);
- cout << "Create 'graph_to_eps_demo_out_pure.eps'" << endl;
- graphToEps(g,"graph_to_eps_demo_out_pure.eps").
- //scale(10).
+ // Create five .eps files showing the digraph with different options
+ cout << "Create 'graph_to_eps_demo_out_1_pure.eps'" << endl;
+ graphToEps(g,"graph_to_eps_demo_out_1_pure.eps").
coords(coords).
title("Sample .eps figure").
- copyright("(C) 2003-2007 LEMON Project").
+ copyright("(C) 2003-2008 LEMON Project").
run();
- cout << "Create 'graph_to_eps_demo_out.eps'" << endl;
- graphToEps(g,"graph_to_eps_demo_out.eps").
- //scale(10).
+ cout << "Create 'graph_to_eps_demo_out_2.eps'" << endl;
+ graphToEps(g,"graph_to_eps_demo_out_2.eps").
coords(coords).
title("Sample .eps figure").
- copyright("(C) 2003-2007 LEMON Project").
+ copyright("(C) 2003-2008 LEMON Project").
absoluteNodeSizes().absoluteArcWidths().
nodeScale(2).nodeSizes(sizes).
nodeShapes(shapes).
nodeColors(composeMap(palette,colors)).
- arcColors(composeMap(palette,ecolors)).
+ arcColors(composeMap(palette,acolors)).
arcWidthScale(.4).arcWidths(widths).
nodeTexts(id).nodeTextSize(3).
run();
-
- cout << "Create 'graph_to_eps_demo_out_arr.eps'" << endl;
- graphToEps(g,"graph_to_eps_demo_out_arr.eps").
- //scale(10).
+ cout << "Create 'graph_to_eps_demo_out_3_arr.eps'" << endl;
+ graphToEps(g,"graph_to_eps_demo_out_3_arr.eps").
title("Sample .eps figure (with arrowheads)").
- copyright("(C) 2003-2007 LEMON Project").
+ copyright("(C) 2003-2008 LEMON Project").
absoluteNodeSizes().absoluteArcWidths().
nodeColors(composeMap(palette,colors)).
coords(coords).
nodeScale(2).nodeSizes(sizes).
nodeShapes(shapes).
- arcColors(composeMap(palette,ecolors)).
+ arcColors(composeMap(palette,acolors)).
arcWidthScale(.4).arcWidths(widths).
nodeTexts(id).nodeTextSize(3).
- drawArrows().arrowWidth(1).arrowLength(1).
+ drawArrows().arrowWidth(2).arrowLength(2).
run();
- e=g.addArc(n1,n4); ecolors[e]=2; widths[e]=1;
- e=g.addArc(n4,n1); ecolors[e]=1; widths[e]=2;
+ a=g.addArc(n1,n4); acolors[a]=2; widths[a]=1;
+ a=g.addArc(n4,n1); acolors[a]=1; widths[a]=2;
- e=g.addArc(n1,n2); ecolors[e]=1; widths[e]=1;
- e=g.addArc(n1,n2); ecolors[e]=2; widths[e]=1;
- e=g.addArc(n1,n2); ecolors[e]=3; widths[e]=1;
- e=g.addArc(n1,n2); ecolors[e]=4; widths[e]=1;
- e=g.addArc(n1,n2); ecolors[e]=5; widths[e]=1;
- e=g.addArc(n1,n2); ecolors[e]=6; widths[e]=1;
- e=g.addArc(n1,n2); ecolors[e]=7; widths[e]=1;
+ a=g.addArc(n1,n2); acolors[a]=1; widths[a]=1;
+ a=g.addArc(n1,n2); acolors[a]=2; widths[a]=1;
+ a=g.addArc(n1,n2); acolors[a]=3; widths[a]=1;
+ a=g.addArc(n1,n2); acolors[a]=4; widths[a]=1;
+ a=g.addArc(n1,n2); acolors[a]=5; widths[a]=1;
+ a=g.addArc(n1,n2); acolors[a]=6; widths[a]=1;
+ a=g.addArc(n1,n2); acolors[a]=7; widths[a]=1;
cout << "Create 'graph_to_eps_demo_out_par.eps'" << endl;
graphToEps(g,"graph_to_eps_demo_out_par.eps").
//scale(10).
title("Sample .eps figure (parallel arcs)").
- copyright("(C) 2003-2007 LEMON Project").
+ copyright("(C) 2003-2008 LEMON Project").
absoluteNodeSizes().absoluteArcWidths().
nodeShapes(shapes).
coords(coords).
nodeScale(2).nodeSizes(sizes).
nodeColors(composeMap(palette,colors)).
- arcColors(composeMap(palette,ecolors)).
+ arcColors(composeMap(palette,acolors)).
arcWidthScale(.4).arcWidths(widths).
nodeTexts(id).nodeTextSize(3).
enableParallel().parArcDist(1.5).
run();
-
- cout << "Create 'graph_to_eps_demo_out_par_arr.eps'" << endl;
- graphToEps(g,"graph_to_eps_demo_out_par_arr.eps").
- //scale(10).
+
+ cout << "Create 'graph_to_eps_demo_out_4_par_arr.eps'" << endl;
+ graphToEps(g,"graph_to_eps_demo_out_4_par_arr.eps").
title("Sample .eps figure (parallel arcs and arrowheads)").
- copyright("(C) 2003-2007 LEMON Project").
+ copyright("(C) 2003-2008 LEMON Project").
absoluteNodeSizes().absoluteArcWidths().
nodeScale(2).nodeSizes(sizes).
coords(coords).
nodeShapes(shapes).
nodeColors(composeMap(palette,colors)).
- arcColors(composeMap(palette,ecolors)).
+ arcColors(composeMap(palette,acolors)).
arcWidthScale(.3).arcWidths(widths).
nodeTexts(id).nodeTextSize(3).
enableParallel().parArcDist(1).
drawArrows().arrowWidth(1).arrowLength(1).
run();
- cout << "Create 'graph_to_eps_demo_out_a4.eps'" << endl;
- graphToEps(g,"graph_to_eps_demo_out_a4.eps").scaleToA4().
+ cout << "Create 'graph_to_eps_demo_out_5_par_arr_a4.eps'" << endl;
+ graphToEps(g,"graph_to_eps_demo_out_5_par_arr_a4.eps").
title("Sample .eps figure (fits to A4)").
- copyright("(C) 2003-2007 LEMON Project").
+ copyright("(C) 2003-2008 LEMON Project").
+ scaleToA4().
absoluteNodeSizes().absoluteArcWidths().
nodeScale(2).nodeSizes(sizes).
coords(coords).
nodeShapes(shapes).
nodeColors(composeMap(palette,colors)).
- arcColors(composeMap(palette,ecolors)).
+ arcColors(composeMap(palette,acolors)).
arcWidthScale(.3).arcWidths(widths).
nodeTexts(id).nodeTextSize(3).
enableParallel().parArcDist(1).
drawArrows().arrowWidth(1).arrowLength(1).
run();
+ // Create an .eps file showing the colors of a default Palette
ListDigraph h;
ListDigraph::NodeMap<int> hcolors(h);
ListDigraph::NodeMap<Point> hcoords(h);
@@ -188,21 +186,22 @@
int cols=int(sqrt(double(palette.size())));
for(int i=0;i<int(paletteW.size());i++) {
Node n=h.addNode();
- hcoords[n]=Point(i%cols,i/cols);
+ hcoords[n]=Point(1+i%cols,1+i/cols);
hcolors[n]=i;
}
- cout << "Create 'graph_to_eps_demo_out_colors.eps'" << endl;
- graphToEps(h,"graph_to_eps_demo_out_colors.eps").
- //scale(60).
+ cout << "Create 'graph_to_eps_demo_out_6_colors.eps'" << endl;
+ graphToEps(h,"graph_to_eps_demo_out_6_colors.eps").
+ scale(60).
title("Sample .eps figure (Palette demo)").
- copyright("(C) 2003-2007 LEMON Project").
+ copyright("(C) 2003-2008 LEMON Project").
coords(hcoords).
absoluteNodeSizes().absoluteArcWidths().
nodeScale(.45).
distantColorNodeTexts().
- // distantBWNodeTexts().
nodeTexts(hcolors).nodeTextSize(.6).
nodeColors(composeMap(paletteW,hcolors)).
run();
+
+ return 0;
}
diff -r 436fe75092b7 -r 574b963d0275 lemon/color.h
--- a/lemon/color.h Sat Jul 12 09:45:11 2008 +0100
+++ b/lemon/color.h Sun Jul 13 16:35:05 2008 +0100
@@ -108,11 +108,11 @@
public:
///Constructor
- ///Constructor
- ///\param have_white indicates whether white is amongst the
+ ///Constructor.
+ ///\param have_white Indicates whether white is among the
///provided initial colors (\c true) or not (\c false). If it is true,
///white will be assigned to \c 0.
- ///\param num the number of the allocated colors. If it is \c -1,
+ ///\param num The number of the allocated colors. If it is \c -1,
///the default color configuration is set up (26 color plus optionaly the
///white). If \c num is less then 26/27 then the default color
///list is cut. Otherwise the color list is filled repeatedly with
@@ -153,7 +153,6 @@
colors.push_back(Color(0,.5,1));
colors.push_back(Color(.5,0,1));
} while(int(colors.size())<num);
- // colors.push_back(Color(1,1,1));
if(num>=0) colors.resize(num);
}
///\e
@@ -171,13 +170,13 @@
{
colors[i%colors.size()]=c;
}
- ///Add a new color to the end of the color list.
+ ///Adds a new color to the end of the color list.
void add(const Color &c)
{
colors.push_back(c);
}
- ///Sets the number of the exiting colors.
+ ///Sets the number of the existing colors.
void resize(int s) { colors.resize(s);}
///Returns the number of the existing colors.
int size() const { return int(colors.size());}
diff -r 436fe75092b7 -r 574b963d0275 lemon/graph_to_eps.h
--- a/lemon/graph_to_eps.h Sat Jul 12 09:45:11 2008 +0100
+++ b/lemon/graph_to_eps.h Sun Jul 13 16:35:05 2008 +0100
@@ -63,7 +63,7 @@
///Default traits class of \ref GraphToEps
-///Default traits class of \ref GraphToEps
+///Default traits class of \ref GraphToEps.
///
///\c G is the type of the underlying graph.
template<class G>
@@ -140,12 +140,11 @@
///Constructor
///Constructor
- ///\param _g is a reference to the graph to be printed
- ///\param _os is a reference to the output stream.
- ///\param _os is a reference to the output stream.
More information about the Lemon-commits
mailing list