Index: demo/graph_to_eps_demo.cc
===================================================================
--- demo/graph_to_eps_demo.cc (revision 132)
+++ demo/graph_to_eps_demo.cc (revision 206)
@@ -19,10 +19,10 @@
/// \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
/// .eps 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
@@ -31,9 +31,8 @@
/// \include graph_to_eps_demo.cc
-#include
-
-#include
#include
#include
+#include
+#include
using namespace std;
@@ -45,4 +44,5 @@
Palette paletteW(true);
+ // Create a small digraph
ListDigraph g;
typedef ListDigraph::Node Node;
@@ -61,5 +61,5 @@
ListDigraph::NodeMap colors(g);
ListDigraph::NodeMap shapes(g);
- ListDigraph::ArcMap ecolors(g);
+ ListDigraph::ArcMap acolors(g);
ListDigraph::ArcMap widths(g);
@@ -70,66 +70,63 @@
coords[n5]=Point(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2;
- Arc e;
-
- 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;
+ Arc a;
+
+ 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 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").
- run();
-
- cout << "Create 'graph_to_eps_demo_out.eps'" << endl;
- graphToEps(g,"graph_to_eps_demo_out.eps").
- //scale(10).
+ copyright("(C) 2003-2008 LEMON Project").
+ run();
+
+ 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").
- absoluteNodeSizes().absoluteArcWidths().
- nodeScale(2).nodeSizes(sizes).
- nodeShapes(shapes).
- nodeColors(composeMap(palette,colors)).
- arcColors(composeMap(palette,ecolors)).
+ copyright("(C) 2003-2008 LEMON Project").
+ absoluteNodeSizes().absoluteArcWidths().
+ nodeScale(2).nodeSizes(sizes).
+ nodeShapes(shapes).
+ nodeColors(composeMap(palette,colors)).
+ 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").
- absoluteNodeSizes().absoluteArcWidths().
- nodeColors(composeMap(palette,colors)).
- coords(coords).
- nodeScale(2).nodeSizes(sizes).
- nodeShapes(shapes).
- arcColors(composeMap(palette,ecolors)).
+ copyright("(C) 2003-2008 LEMON Project").
+ absoluteNodeSizes().absoluteArcWidths().
+ nodeColors(composeMap(palette,colors)).
+ coords(coords).
+ nodeScale(2).nodeSizes(sizes).
+ nodeShapes(shapes).
+ arcColors(composeMap(palette,acolors)).
arcWidthScale(.4).arcWidths(widths).
nodeTexts(id).nodeTextSize(3).
- drawArrows().arrowWidth(1).arrowLength(1).
- run();
-
- e=g.addArc(n1,n4); ecolors[e]=2; widths[e]=1;
- e=g.addArc(n4,n1); ecolors[e]=1; widths[e]=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;
+ drawArrows().arrowWidth(2).arrowLength(2).
+ run();
+
+ a=g.addArc(n1,n4); acolors[a]=2; widths[a]=1;
+ a=g.addArc(n4,n1); acolors[a]=1; widths[a]=2;
+
+ 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;
@@ -137,27 +134,26 @@
//scale(10).
title("Sample .eps figure (parallel arcs)").
- copyright("(C) 2003-2007 LEMON Project").
- absoluteNodeSizes().absoluteArcWidths().
- nodeShapes(shapes).
- coords(coords).
- nodeScale(2).nodeSizes(sizes).
- nodeColors(composeMap(palette,colors)).
- arcColors(composeMap(palette,ecolors)).
+ copyright("(C) 2003-2008 LEMON Project").
+ absoluteNodeSizes().absoluteArcWidths().
+ nodeShapes(shapes).
+ coords(coords).
+ nodeScale(2).nodeSizes(sizes).
+ nodeColors(composeMap(palette,colors)).
+ 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").
- absoluteNodeSizes().absoluteArcWidths().
- nodeScale(2).nodeSizes(sizes).
- coords(coords).
- nodeShapes(shapes).
- nodeColors(composeMap(palette,colors)).
- arcColors(composeMap(palette,ecolors)).
+ copyright("(C) 2003-2008 LEMON Project").
+ absoluteNodeSizes().absoluteArcWidths().
+ nodeScale(2).nodeSizes(sizes).
+ coords(coords).
+ nodeShapes(shapes).
+ nodeColors(composeMap(palette,colors)).
+ arcColors(composeMap(palette,acolors)).
arcWidthScale(.3).arcWidths(widths).
nodeTexts(id).nodeTextSize(3).
@@ -166,14 +162,15 @@
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").
- absoluteNodeSizes().absoluteArcWidths().
- nodeScale(2).nodeSizes(sizes).
- coords(coords).
- nodeShapes(shapes).
- nodeColors(composeMap(palette,colors)).
- arcColors(composeMap(palette,ecolors)).
+ copyright("(C) 2003-2008 LEMON Project").
+ scaleToA4().
+ absoluteNodeSizes().absoluteArcWidths().
+ nodeScale(2).nodeSizes(sizes).
+ coords(coords).
+ nodeShapes(shapes).
+ nodeColors(composeMap(palette,colors)).
+ arcColors(composeMap(palette,acolors)).
arcWidthScale(.3).arcWidths(widths).
nodeTexts(id).nodeTextSize(3).
@@ -182,4 +179,5 @@
run();
+ // Create an .eps file showing the colors of a default Palette
ListDigraph h;
ListDigraph::NodeMap hcolors(h);
@@ -189,20 +187,21 @@
for(int i=0;i