[Lemon-commits] Alpar Juttner: Port graph_to_eps() and Color fro...
Lemon HG
hg at lemon.cs.elte.hu
Thu Apr 17 18:22:46 CEST 2008
details: http://lemon.cs.elte.hu/hg/lemon/rev/7cd965d2257f
changeset: 128:7cd965d2257f
user: Alpar Juttner <alpar [at] cs.elte.hu>
date: Thu Apr 03 11:10:49 2008 +0100
description:
Port graph_to_eps() and Color from svn -r3482.
diffstat:
10 files changed, 1817 insertions(+), 2 deletions(-)
.hgignore | 1
demo/Makefile.am | 5
demo/arg_parser_demo.cc | 3
demo/graph_to_eps_demo.cc | 208 ++++++++
lemon/Makefile.am | 4
lemon/arg_parser.cc | 1
lemon/bits/bezier.h | 176 ++++++
lemon/color.cc | 44 +
lemon/color.h | 207 +++++++
lemon/graph_to_eps.h | 1170 +++++++++++++++++++++++++++++++++++++++++++++
diffs (truncated from 1916 to 300 lines):
diff -r 7b44eea654d0 -r 7cd965d2257f .hgignore
--- a/.hgignore Tue Apr 01 16:25:51 2008 +0100
+++ b/.hgignore Thu Apr 03 11:10:49 2008 +0100
@@ -24,6 +24,7 @@
.dirstamp
.libs/*
.deps/*
+demo/*.eps
syntax: regexp
(.*/)?\#[^/]*\#$
diff -r 7b44eea654d0 -r 7cd965d2257f demo/Makefile.am
--- a/demo/Makefile.am Tue Apr 01 16:25:51 2008 +0100
+++ b/demo/Makefile.am Thu Apr 03 11:10:49 2008 +0100
@@ -4,9 +4,12 @@
if WANT_DEMO
noinst_PROGRAMS += \
- demo/arg_parser_demo
+ demo/arg_parser_demo \
+ demo/graph_to_eps_demo
endif WANT_DEMO
demo_arg_parser_demo_SOURCES = demo/arg_parser_demo.cc
+demo_graph_to_eps_demo_SOURCES = demo/graph_to_eps_demo.cc
+
diff -r 7b44eea654d0 -r 7cd965d2257f demo/arg_parser_demo.cc
--- a/demo/arg_parser_demo.cc Tue Apr 01 16:25:51 2008 +0100
+++ b/demo/arg_parser_demo.cc Thu Apr 03 11:10:49 2008 +0100
@@ -37,6 +37,7 @@
bool g1,g2,g3;
ap.refOption("n", "An integer input.", i, true)
.refOption("val", "A double input.", d)
+ .doubleOption("val2", "A double input.", d)
.synonym("vals","val")
.refOption("name", "A string input.", s)
.refOption("f", "A switch.", b)
@@ -45,7 +46,7 @@
.refOption("grb","Choice B",g2)
.refOption("grc","Choice C",g3)
.optionGroup("gr","gra")
- .optionGroup("gr","grb")
+ .optionGroup("gr","grbkk")
.optionGroup("gr","grc")
.mandatoryGroup("gr")
.onlyOneGroup("gr")
diff -r 7b44eea654d0 -r 7cd965d2257f demo/graph_to_eps_demo.cc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/demo/graph_to_eps_demo.cc Thu Apr 03 11:10:49 2008 +0100
@@ -0,0 +1,208 @@
+/* -*- C++ -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2003-2008
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+/// \ingroup demos
+/// \file
+/// \brief Demo of the graph grawing 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,
+/// 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>
+
+using namespace std;
+using namespace lemon;
+
+int main()
+{
+ Palette palette;
+ Palette paletteW(-1,true);
+
+ ListDigraph g;
+ typedef ListDigraph::Node Node;
+ typedef ListDigraph::NodeIt NodeIt;
+ typedef ListDigraph::Arc Arc;
+ typedef dim2::Point<int> Point;
+
+ Node n1=g.addNode();
+ Node n2=g.addNode();
+ Node n3=g.addNode();
+ Node n4=g.addNode();
+ Node n5=g.addNode();
+
+ ListDigraph::NodeMap<Point> coords(g);
+ ListDigraph::NodeMap<double> sizes(g);
+ ListDigraph::NodeMap<int> colors(g);
+ ListDigraph::NodeMap<int> shapes(g);
+ ListDigraph::ArcMap<int> ecolors(g);
+ ListDigraph::ArcMap<int> widths(g);
+
+ coords[n1]=Point(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0;
+ coords[n2]=Point(50,70); sizes[n2]=2; colors[n2]=2; shapes[n2]=2;
+ coords[n3]=Point(70,70); sizes[n3]=1; colors[n3]=3; shapes[n3]=0;
+ 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;
+
+ 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;
+
+ 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).
+ 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).
+ 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)).
+ 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).
+ 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)).
+ 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;
+
+ 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").
+ absoluteNodeSizes().absoluteArcWidths().
+ nodeShapes(shapes).
+ coords(coords).
+ nodeScale(2).nodeSizes(sizes).
+ nodeColors(composeMap(palette,colors)).
+ arcColors(composeMap(palette,ecolors)).
+ 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).
+ 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)).
+ 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().
+ 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)).
+ arcWidthScale(.3).arcWidths(widths).
+ nodeTexts(id).nodeTextSize(3).
+ enableParallel().parArcDist(1).
+ drawArrows().arrowWidth(1).arrowLength(1).
+ run();
+
+ ListDigraph h;
+ ListDigraph::NodeMap<int> hcolors(h);
+ ListDigraph::NodeMap<Point> hcoords(h);
+
+ 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);
+ hcolors[n]=i;
+ }
+
+ cout << "Create 'graph_to_eps_demo_out_colors.eps'" << endl;
+ graphToEps(h,"graph_to_eps_demo_out_colors.eps").
+ //scale(60).
+ title("Sample .eps figure (Palette demo)").
+ copyright("(C) 2003-2007 LEMON Project").
+ coords(hcoords).
+ absoluteNodeSizes().absoluteArcWidths().
+ nodeScale(45).
+ distantColorNodeTexts().
+ // distantBWNodeTexts().
+ nodeTexts(hcolors).nodeTextSize(.6).
+ nodeColors(composeMap(paletteW,hcolors)).
+ run();
+}
diff -r 7b44eea654d0 -r 7cd965d2257f lemon/Makefile.am
--- a/lemon/Makefile.am Tue Apr 01 16:25:51 2008 +0100
+++ b/lemon/Makefile.am Thu Apr 03 11:10:49 2008 +0100
@@ -9,6 +9,7 @@
lemon_libemon_la_SOURCES = \
lemon/arg_parser.cc \
lemon/base.cc \
+ lemon/color.cc \
lemon/random.cc
@@ -20,10 +21,12 @@
lemon/assert.h \
lemon/bfs.h \
lemon/bin_heap.h \
+ lemon/color.h \
lemon/dfs.h \
lemon/dijkstra.h \
lemon/dim2.h \
lemon/error.h \
+ lemon/graph_to_eps.h \
lemon/graph_utils.h \
lemon/kruskal.h \
lemon/list_graph.h \
@@ -39,6 +42,7 @@
lemon/bits/alteration_notifier.h \
lemon/bits/array_map.h \
lemon/bits/base_extender.h \
+ lemon/bits/bezier.h \
lemon/bits/default_map.h \
lemon/bits/graph_extender.h \
lemon/bits/invalid.h \
diff -r 7b44eea654d0 -r 7cd965d2257f lemon/arg_parser.cc
--- a/lemon/arg_parser.cc Tue Apr 01 16:25:51 2008 +0100
+++ b/lemon/arg_parser.cc Thu Apr 03 11:10:49 2008 +0100
@@ -194,6 +194,7 @@
{
Opts::iterator i = _opts.find(opt);
LEMON_ASSERT(i!=_opts.end(), "Unknown option: '"+opt+"'");
+ if(i==_opts.end()) std::cout << "JAJJJJJJJJ\n";
More information about the Lemon-commits
mailing list