[Lemon-commits] [lemon_svn] alpar: r2933 - in hugo/trunk: . benchmark demo lemon lemon/bits test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 21:51:20 CET 2006
Author: alpar
Date: Thu Sep 7 15:27:16 2006
New Revision: 2933
Added:
hugo/trunk/lemon/dim2.h
- copied, changed from r2932, /hugo/trunk/lemon/xy.h
hugo/trunk/test/dim_test.cc
- copied, changed from r2932, /hugo/trunk/test/xy_test.cc
Removed:
hugo/trunk/lemon/xy.h
hugo/trunk/test/xy_test.cc
Modified:
hugo/trunk/benchmark/swap_bipartite_bench.cc
hugo/trunk/demo/coloring.cc
hugo/trunk/demo/descriptor_map_demo.cc
hugo/trunk/demo/disjoint_paths_demo.cc
hugo/trunk/demo/graph_orientation.cc
hugo/trunk/demo/graph_to_eps_demo.cc
hugo/trunk/demo/grid_ugraph_demo.cc
hugo/trunk/demo/min_route.cc
hugo/trunk/demo/strongly_connected_orientation.cc
hugo/trunk/demo/topology_demo.cc
hugo/trunk/lemon.spec.in
hugo/trunk/lemon/Makefile.am
hugo/trunk/lemon/bits/bezier.h
hugo/trunk/lemon/eps.cc
hugo/trunk/lemon/eps.h
hugo/trunk/lemon/graph_to_eps.h
hugo/trunk/lemon/grid_ugraph.h
hugo/trunk/lemon/hypercube_graph.h
hugo/trunk/lemon/lemon_reader.h
hugo/trunk/lemon/lemon_writer.h
hugo/trunk/lemon/polynomial.h
hugo/trunk/test/Makefile.am
hugo/trunk/test/polynomial_test.cc
Log:
xy -> dim2::Point
Modified: hugo/trunk/benchmark/swap_bipartite_bench.cc
==============================================================================
--- hugo/trunk/benchmark/swap_bipartite_bench.cc (original)
+++ hugo/trunk/benchmark/swap_bipartite_bench.cc Thu Sep 7 15:27:16 2006
@@ -3,12 +3,13 @@
#include <sstream>
#include <lemon/smart_graph.h>
+#include <lemon/list_graph.h>
#include <lemon/bpugraph_adaptor.h>
#include <lemon/bipartite_matching.h>
#include <lemon/graph_utils.h>
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
#include <lemon/graph_to_eps.h>
#include <lemon/time_measure.h>
@@ -17,6 +18,7 @@
using namespace lemon;
typedef SmartBpUGraph Graph;
+typedef ListBpUGraph LGraph;
BPUGRAPH_TYPEDEFS(Graph);
int _urandom_init() {
@@ -41,24 +43,36 @@
int s = 100;
Timer nt(false), st(false);
+ Timer lnt(false), lst(false);
for (int i = 0; i < s; ++i) {
Graph graph;
+ LGraph lgraph;
vector<Node> aNodes;
vector<Node> bNodes;
+ vector<LGraph::Node> laNodes;
+ vector<LGraph::Node> lbNodes;
for (int i = 0; i < n; ++i) {
Node node = graph.addANode();
aNodes.push_back(node);
+ LGraph::Node lnode = lgraph.addANode();
+ laNodes.push_back(lnode);
}
for (int i = 0; i < m; ++i) {
Node node = graph.addBNode();
bNodes.push_back(node);
+ LGraph::Node lnode = lgraph.addBNode();
+ lbNodes.push_back(lnode);
}
for (int i = 0; i < e; ++i) {
- Node aNode = aNodes[urandom(n)];
- Node bNode = bNodes[urandom(m)];
+ int a,b;
+ Node aNode = aNodes[a=urandom(n)];
+ Node bNode = bNodes[b=urandom(m)];
graph.addEdge(aNode, bNode);
+ LGraph::Node laNode = laNodes[a];
+ LGraph::Node lbNode = lbNodes[b];
+ lgraph.addEdge(laNode, lbNode);
}
{
@@ -81,11 +95,32 @@
bpmatch.start();
st.stop();
+ }
+ {
+ MaxBipartiteMatching<LGraph> bpmatch(lgraph);
+
+ lnt.start();
+ bpmatch.init();
+ bpmatch.start();
+ lnt.stop();
+
+ }
+
+ {
+ typedef SwapBpUGraphAdaptor<LGraph> SGraph;
+ SGraph sgraph(lgraph);
+ MaxBipartiteMatching<SGraph> bpmatch(sgraph);
+
+ lst.start();
+ bpmatch.init();
+ bpmatch.start();
+ lst.stop();
+
}
-
- }
+ }
- cout << k * 100 << ' ' << nt.realTime() << ' ' << st.realTime() << endl;
+ cout << k * 100 << ' ' << nt.realTime() << ' ' << st.realTime()
+ << ' ' << lnt.realTime() << ' ' << lst.realTime()<< endl;
}
Modified: hugo/trunk/demo/coloring.cc
==============================================================================
--- hugo/trunk/demo/coloring.cc (original)
+++ hugo/trunk/demo/coloring.cc Thu Sep 7 15:27:16 2006
@@ -55,7 +55,7 @@
Graph graph;
UGraphReader<Graph> reader("coloring.lgf", graph);
- Graph::NodeMap<xy<double> > coords(graph);
+ Graph::NodeMap<dim2::Point<double> > coords(graph);
reader.readNodeMap("coords", coords);
reader.run();
Modified: hugo/trunk/demo/descriptor_map_demo.cc
==============================================================================
--- hugo/trunk/demo/descriptor_map_demo.cc (original)
+++ hugo/trunk/demo/descriptor_map_demo.cc Thu Sep 7 15:27:16 2006
@@ -29,7 +29,7 @@
#include <lemon/list_graph.h>
#include <lemon/graph_utils.h>
#include <lemon/graph_writer.h>
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
#include <lemon/graph_to_eps.h>
#include <iostream>
@@ -40,7 +40,7 @@
using namespace lemon;
-// Special xy<double> map type
+// Special dim2::Point<double> map type
//
// It gives back a position for each node. The position of the nodes
// are on the circle with the given center and radius.
@@ -51,7 +51,7 @@
class CircleMap {
public:
- typedef xy<double> Value;
+ typedef dim2::Point<double> Value;
typedef typename Graph::Node Key;
CircleMap(const Graph& _graph,
@@ -118,7 +118,7 @@
// Make postscript from the graph.
- CircleMap<Graph> coords(graph, xy<double>(0.0, 0.0), 10.0);
+ CircleMap<Graph> coords(graph, dim2::Point<double>(0.0, 0.0), 10.0);
graphToEps(graph,"descriptor_map_demo.eps").scaleToA4().
title("Generated graph").
Modified: hugo/trunk/demo/disjoint_paths_demo.cc
==============================================================================
--- hugo/trunk/demo/disjoint_paths_demo.cc (original)
+++ hugo/trunk/demo/disjoint_paths_demo.cc Thu Sep 7 15:27:16 2006
@@ -52,7 +52,7 @@
Graph graph;
- Graph::NodeMap<xy<double> > coords(graph);
+ Graph::NodeMap<dim2::Point<double> > coords(graph);
Graph::Node source, target;
GraphReader<Graph>("disjoint_paths_demo.lgf", graph).
readNodeMap("coords", coords).
@@ -98,7 +98,9 @@
graphToEps(sgraph, "node_disjoint_paths.eps").
title("node disjoint path").copyright("(C) 2006 LEMON Project").drawArrows().
edgeColors(composeMap(functorMap(color), sflow)).
- coords(SGraph::combinedNodeMap(coords, shiftMap(coords, xy<double>(5, 0)))).
+ coords(SGraph::combinedNodeMap(coords,
+ shiftMap(coords,
+ dim2::Point<double>(5, 0)))).
autoNodeScale().run();
cout << "The paths are written into node_disjoint_paths.eps" << endl;
Modified: hugo/trunk/demo/graph_orientation.cc
==============================================================================
--- hugo/trunk/demo/graph_orientation.cc (original)
+++ hugo/trunk/demo/graph_orientation.cc Thu Sep 7 15:27:16 2006
@@ -19,7 +19,7 @@
#include <lemon/list_graph.h>
#include <lemon/graph_reader.h>
#include <lemon/iterable_maps.h>
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
#include <lemon/graph_to_eps.h>
@@ -45,7 +45,7 @@
ListGraph::NodeMap<int> f(g); //in-deg requirement;
ListGraph::NodeMap<int> label(g);
- ListGraph::NodeMap<xy<double> > coords(g);
+ ListGraph::NodeMap<dim2::Point<double> > coords(g);
try {
GraphReader<ListGraph> reader(argv[1],g);
Modified: hugo/trunk/demo/graph_to_eps_demo.cc
==============================================================================
--- hugo/trunk/demo/graph_to_eps_demo.cc (original)
+++ hugo/trunk/demo/graph_to_eps_demo.cc Thu Sep 7 15:27:16 2006
@@ -48,7 +48,7 @@
typedef ListGraph::Node Node;
typedef ListGraph::NodeIt NodeIt;
typedef ListGraph::Edge Edge;
- typedef xy<int> Xy;
+ typedef dim2::Point<int> Point;
Node n1=g.addNode();
Node n2=g.addNode();
@@ -56,18 +56,18 @@
Node n4=g.addNode();
Node n5=g.addNode();
- ListGraph::NodeMap<Xy> coords(g);
+ ListGraph::NodeMap<Point> coords(g);
ListGraph::NodeMap<double> sizes(g);
ListGraph::NodeMap<int> colors(g);
ListGraph::NodeMap<int> shapes(g);
ListGraph::EdgeMap<int> ecolors(g);
ListGraph::EdgeMap<int> widths(g);
- coords[n1]=Xy(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0;
- coords[n2]=Xy(50,70); sizes[n2]=2; colors[n2]=2; shapes[n2]=2;
- coords[n3]=Xy(70,70); sizes[n3]=1; colors[n3]=3; shapes[n3]=0;
- coords[n4]=Xy(70,50); sizes[n4]=2; colors[n4]=4; shapes[n4]=1;
- coords[n5]=Xy(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2;
+ 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;
Edge e;
@@ -183,12 +183,12 @@
ListGraph h;
ListGraph::NodeMap<int> hcolors(h);
- ListGraph::NodeMap<Xy> hcoords(h);
+ ListGraph::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]=Xy(i%cols,i/cols);
+ hcoords[n]=Point(i%cols,i/cols);
hcolors[n]=i;
}
Modified: hugo/trunk/demo/grid_ugraph_demo.cc
==============================================================================
--- hugo/trunk/demo/grid_ugraph_demo.cc (original)
+++ hugo/trunk/demo/grid_ugraph_demo.cc Thu Sep 7 15:27:16 2006
@@ -20,7 +20,7 @@
#include <lemon/graph_adaptor.h>
#include <lemon/graph_to_eps.h>
#include <lemon/bfs.h>
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
#include <iostream>
#include <fstream>
Modified: hugo/trunk/demo/min_route.cc
==============================================================================
--- hugo/trunk/demo/min_route.cc (original)
+++ hugo/trunk/demo/min_route.cc Thu Sep 7 15:27:16 2006
@@ -22,7 +22,7 @@
#include <lemon/smart_graph.h>
#include <lemon/dijkstra.h>
#include <lemon/maps.h>
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
#include <lemon/graph_reader.h>
#include <lemon/time_measure.h>
@@ -46,7 +46,7 @@
typedef double Value;
typedef typename CoordMap::Key Key;
- PotentialMap(const CoordMap& _coord, const xy<double>& _target)
+ PotentialMap(const CoordMap& _coord, const dim2::Point<double>& _target)
: coord(_coord), target(_target) {}
double operator[](const Key& node) const {
@@ -55,7 +55,7 @@
}
private:
const CoordMap& coord;
- xy<double> target;
+ dim2::Point<double> target;
};
template <typename Graph, typename LengthMap, typename PotentialMap>
@@ -86,7 +86,7 @@
typedef Graph::EdgeIt EdgeIt;
typedef Graph::NodeIt NodeIt;
typedef Graph::EdgeMap<double> LengthMap;
- typedef Graph::NodeMap<xy<double> > CoordMap;
+ typedef Graph::NodeMap<dim2::Point<double> > CoordMap;
SmartGraph graph;
@@ -94,9 +94,9 @@
GraphReader<Graph> reader(is, graph);
CoordMap coord(graph);
- XMap<CoordMap> xcoord = xMap(coord);
+ dim2::XMap<CoordMap> xcoord = xMap(coord);
reader.readNodeMap("coordinates_x", xcoord);
- YMap<CoordMap> ycoord = yMap(coord);
+ dim2::YMap<CoordMap> ycoord = yMap(coord);
reader.readNodeMap("coordinates_y", ycoord);
LengthMap length(graph);
Modified: hugo/trunk/demo/strongly_connected_orientation.cc
==============================================================================
--- hugo/trunk/demo/strongly_connected_orientation.cc (original)
+++ hugo/trunk/demo/strongly_connected_orientation.cc Thu Sep 7 15:27:16 2006
@@ -78,7 +78,7 @@
<< "to be strongly connected" << endl;
UGraph ugraph;
- UGraph::NodeMap<xy<double> > coords(ugraph);
+ UGraph::NodeMap<dim2::Point<double> > coords(ugraph);
UGraphReader<UGraph>("strongly_connected_orientation.lgf", ugraph).
readNodeMap("coords", coords).run();
Modified: hugo/trunk/demo/topology_demo.cc
==============================================================================
--- hugo/trunk/demo/topology_demo.cc (original)
+++ hugo/trunk/demo/topology_demo.cc Thu Sep 7 15:27:16 2006
@@ -20,7 +20,7 @@
#include <lemon/topology.h>
#include <lemon/graph_to_eps.h>
#include <lemon/graph_reader.h>
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
#include <iostream>
@@ -49,7 +49,7 @@
typedef Graph::Node Node;
Graph graph;
- Graph::NodeMap<xy<double> > coords(graph);
+ Graph::NodeMap<dim2::Point<double> > coords(graph);
UGraphReader<Graph>("u_components.lgf", graph).
readNodeMap("coordinates_x", xMap(coords)).
@@ -74,7 +74,7 @@
typedef Graph::Node Node;
Graph graph;
- Graph::NodeMap<xy<double> > coords(graph);
+ Graph::NodeMap<dim2::Point<double> > coords(graph);
GraphReader<Graph>("dir_components.lgf", graph).
readNodeMap("coordinates_x", xMap(coords)).
@@ -104,7 +104,7 @@
typedef Graph::UEdge UEdge;
Graph graph;
- Graph::NodeMap<xy<double> > coords(graph);
+ Graph::NodeMap<dim2::Point<double> > coords(graph);
UGraphReader<Graph>("u_components.lgf", graph).
readNodeMap("coordinates_x", xMap(coords)).
@@ -134,7 +134,7 @@
typedef Graph::UEdge UEdge;
Graph graph;
- Graph::NodeMap<xy<double> > coords(graph);
+ Graph::NodeMap<dim2::Point<double> > coords(graph);
UGraphReader<Graph>("u_components.lgf", graph).
readNodeMap("coordinates_x", xMap(coords)).
@@ -163,7 +163,7 @@
typedef Graph::UEdge UEdge;
Graph graph;
- Graph::NodeMap<xy<double> > coords(graph);
+ Graph::NodeMap<dim2::Point<double> > coords(graph);
UGraphReader<Graph>("partitions.lgf", graph).
readNodeMap("coordinates_x", xMap(coords)).
Modified: hugo/trunk/lemon.spec.in
==============================================================================
--- hugo/trunk/lemon.spec.in (original)
+++ hugo/trunk/lemon.spec.in Thu Sep 7 15:27:16 2006
@@ -7,7 +7,7 @@
Source0: %{name}-%{version}.tar.gz
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-root
-# Requires: glpk
+Requires: glpk
# BuildRequires: glpk-devel
%description
Modified: hugo/trunk/lemon/Makefile.am
==============================================================================
--- hugo/trunk/lemon/Makefile.am (original)
+++ hugo/trunk/lemon/Makefile.am Thu Sep 7 15:27:16 2006
@@ -41,6 +41,7 @@
lemon/dag_shortest_path.h \
lemon/dfs.h \
lemon/dijkstra.h \
+ lemon/dim2.h \
lemon/dimacs.h \
lemon/edge_set.h \
lemon/edmonds_karp.h \
@@ -92,8 +93,7 @@
lemon/tolerance.h \
lemon/topology.h \
lemon/ugraph_adaptor.h \
- lemon/unionfind.h \
- lemon/xy.h
+ lemon/unionfind.h
bits_HEADERS += \
lemon/bits/alteration_notifier.h \
Modified: hugo/trunk/lemon/bits/bezier.h
==============================================================================
--- hugo/trunk/lemon/bits/bezier.h (original)
+++ hugo/trunk/lemon/bits/bezier.h Thu Sep 7 15:27:16 2006
@@ -27,26 +27,27 @@
///
///\author Alpar Juttner
-#include<lemon/xy.h>
+#include<lemon/dim2.h>
namespace lemon {
+ namespace dim2 {
class BezierBase {
public:
- typedef xy<double> xy;
+ typedef Point<double> Point;
protected:
- static xy conv(xy x,xy y,double t) {return (1-t)*x+t*y;}
+ static Point conv(Point x,Point y,double t) {return (1-t)*x+t*y;}
};
class Bezier1 : public BezierBase
{
public:
- xy p1,p2;
+ Point p1,p2;
Bezier1() {}
- Bezier1(xy _p1, xy _p2) :p1(_p1), p2(_p2) {}
+ Bezier1(Point _p1, Point _p2) :p1(_p1), p2(_p2) {}
- xy operator()(double t) const
+ Point operator()(double t) const
{
// return conv(conv(p1,p2,t),conv(p2,p3,t),t);
return conv(p1,p2,t);
@@ -63,59 +64,60 @@
Bezier1 revert() const { return Bezier1(p2,p1);}
Bezier1 operator()(double a,double b) const { return before(b).after(a/b); }
- xy grad() const { return p2-p1; }
- xy norm() const { return rot90(p2-p1); }
- xy grad(double) const { return grad(); }
- xy norm(double t) const { return rot90(grad(t)); }
+ Point grad() const { return p2-p1; }
+ Point norm() const { return rot90(p2-p1); }
+ Point grad(double) const { return grad(); }
+ Point norm(double t) const { return rot90(grad(t)); }
};
class Bezier2 : public BezierBase
{
public:
- xy p1,p2,p3;
+ Point p1,p2,p3;
Bezier2() {}
- Bezier2(xy _p1, xy _p2, xy _p3) :p1(_p1), p2(_p2), p3(_p3) {}
+ Bezier2(Point _p1, Point _p2, Point _p3) :p1(_p1), p2(_p2), p3(_p3) {}
Bezier2(const Bezier1 &b) : p1(b.p1), p2(conv(b.p1,b.p2,.5)), p3(b.p2) {}
- xy operator()(double t) const
+ Point operator()(double t) const
{
// return conv(conv(p1,p2,t),conv(p2,p3,t),t);
return ((1-t)*(1-t))*p1+(2*(1-t)*t)*p2+(t*t)*p3;
}
Bezier2 before(double t) const
{
- xy q(conv(p1,p2,t));
- xy r(conv(p2,p3,t));
+ Point q(conv(p1,p2,t));
+ Point r(conv(p2,p3,t));
return Bezier2(p1,q,conv(q,r,t));
}
Bezier2 after(double t) const
{
- xy q(conv(p1,p2,t));
- xy r(conv(p2,p3,t));
+ Point q(conv(p1,p2,t));
+ Point r(conv(p2,p3,t));
return Bezier2(conv(q,r,t),r,p3);
}
Bezier2 revert() const { return Bezier2(p3,p2,p1);}
Bezier2 operator()(double a,double b) const { return before(b).after(a/b); }
Bezier1 grad() const { return Bezier1(2.0*(p2-p1),2.0*(p3-p2)); }
Bezier1 norm() const { return Bezier1(2.0*rot90(p2-p1),2.0*rot90(p3-p2)); }
- xy grad(double t) const { return grad()(t); }
- xy norm(double t) const { return rot90(grad(t)); }
+ Point grad(double t) const { return grad()(t); }
+ Point norm(double t) const { return rot90(grad(t)); }
};
class Bezier3 : public BezierBase
{
public:
- xy p1,p2,p3,p4;
+ Point p1,p2,p3,p4;
Bezier3() {}
- Bezier3(xy _p1, xy _p2, xy _p3, xy _p4) :p1(_p1), p2(_p2), p3(_p3), p4(_p4) {}
+ Bezier3(Point _p1, Point _p2, Point _p3, Point _p4)
+ : p1(_p1), p2(_p2), p3(_p3), p4(_p4) {}
Bezier3(const Bezier1 &b) : p1(b.p1), p2(conv(b.p1,b.p2,1.0/3.0)),
p3(conv(b.p1,b.p2,2.0/3.0)), p4(b.p2) {}
Bezier3(const Bezier2 &b) : p1(b.p1), p2(conv(b.p1,b.p2,2.0/3.0)),
p3(conv(b.p2,b.p3,1.0/3.0)), p4(b.p3) {}
- xy operator()(double t) const
+ Point operator()(double t) const
{
// return Bezier2(conv(p1,p2,t),conv(p2,p3,t),conv(p3,p4,t))(t);
return ((1-t)*(1-t)*(1-t))*p1+(3*t*(1-t)*(1-t))*p2+
@@ -123,23 +125,23 @@
}
Bezier3 before(double t) const
{
- xy p(conv(p1,p2,t));
- xy q(conv(p2,p3,t));
- xy r(conv(p3,p4,t));
- xy a(conv(p,q,t));
- xy b(conv(q,r,t));
- xy c(conv(a,b,t));
+ Point p(conv(p1,p2,t));
+ Point q(conv(p2,p3,t));
+ Point r(conv(p3,p4,t));
+ Point a(conv(p,q,t));
+ Point b(conv(q,r,t));
+ Point c(conv(a,b,t));
return Bezier3(p1,p,a,c);
}
Bezier3 after(double t) const
{
- xy p(conv(p1,p2,t));
- xy q(conv(p2,p3,t));
- xy r(conv(p3,p4,t));
- xy a(conv(p,q,t));
- xy b(conv(q,r,t));
- xy c(conv(a,b,t));
+ Point p(conv(p1,p2,t));
+ Point q(conv(p2,p3,t));
+ Point r(conv(p3,p4,t));
+ Point a(conv(p,q,t));
+ Point b(conv(q,r,t));
+ Point c(conv(a,b,t));
return Bezier3(c,b,r,p4);
}
Bezier3 revert() const { return Bezier3(p4,p3,p2,p1);}
@@ -148,18 +150,18 @@
Bezier2 norm() const { return Bezier2(3.0*rot90(p2-p1),
3.0*rot90(p3-p2),
3.0*rot90(p4-p3)); }
- xy grad(double t) const { return grad()(t); }
- xy norm(double t) const { return rot90(grad(t)); }
+ Point grad(double t) const { return grad()(t); }
+ Point norm(double t) const { return rot90(grad(t)); }
template<class R,class F,class S,class D>
R recSplit(F &_f,const S &_s,D _d) const
{
- const xy a=(p1+p2)/2;
- const xy b=(p2+p3)/2;
- const xy c=(p3+p4)/2;
- const xy d=(a+b)/2;
- const xy e=(b+c)/2;
- const xy f=(d+e)/2;
+ const Point a=(p1+p2)/2;
+ const Point b=(p2+p3)/2;
+ const Point c=(p3+p4)/2;
+ const Point d=(a+b)/2;
+ const Point e=(b+c)/2;
+ const Point f=(d+e)/2;
R f1=_f(Bezier3(p1,a,d,e),_d);
R f2=_f(Bezier3(e,d,c,p4),_d);
return _s(f1,f2);
@@ -167,6 +169,8 @@
};
-} //END OF NAMESPACE LEMON
+
+} //END OF NAMESPACE dim2
+} //END OF NAMESPACE lemon
#endif // LEMON_BEZIER_H
Copied: hugo/trunk/lemon/dim2.h (from r2932, /hugo/trunk/lemon/xy.h)
==============================================================================
--- /hugo/trunk/lemon/xy.h (original)
+++ hugo/trunk/lemon/dim2.h Thu Sep 7 15:27:16 2006
@@ -16,8 +16,8 @@
*
*/
-#ifndef LEMON_XY_H
-#define LEMON_XY_H
+#ifndef LEMON_DIM2_H
+#define LEMON_DIM2_H
#include <iostream>
#include <lemon/bits/utility.h>
@@ -26,18 +26,26 @@
///\file
///\brief A simple two dimensional vector and a bounding box implementation
///
-/// The class \ref lemon::xy "xy" implements
+/// The class \ref lemon::dim2::Point "dim2::Point" implements
///a two dimensional vector with the usual
/// operations.
///
-/// The class \ref lemon::BoundingBox "BoundingBox" can be used to determine
-/// the rectangular bounding box of a set of \ref lemon::xy "xy"'s.
+/// The class \ref lemon::dim2::BoundingBox "dim2::BoundingBox"
+/// can be used to determine
+/// the rectangular bounding box of a set of
+/// \ref lemon::dim2::Point "dim2::Point"'s.
///
///\author Attila Bernath
namespace lemon {
+ ///Tools for handling two dimensional coordinates
+
+ ///This namespace is a storage of several
+ ///tools for handling two dimensional coordinates
+ namespace dim2 {
+
/// \addtogroup misc
/// @{
@@ -47,16 +55,8 @@
///with the usual vector
/// operators.
///
- ///\note As you might have noticed, this class does not follow the
- ///\ref naming_conv "LEMON Coding Style" (it should be called \c Xy
- ///according to it). There is a stupid Hungarian proverb, "A kivétel
- ///erõsíti a szabályt" ("An exception
- ///reinforces a rule", which is
- ///actually a mistranslation of the Latin proverb "Exceptio probat regulam").
- ///This class is an example for that.
- ///\author Attila Bernath
template<typename T>
- class xy {
+ class Point {
public:
@@ -68,14 +68,14 @@
T y;
///Default constructor
- xy() {}
+ Point() {}
///Construct an instance from coordinates
- xy(T a, T b) : x(a), y(b) { }
+ Point(T a, T b) : x(a), y(b) { }
///Conversion constructor
- template<class TT> xy(const xy<TT> &p) : x(p.x), y(p.y) {}
+ template<class TT> Point(const Point<TT> &p) : x(p.x), y(p.y) {}
///Give back the square of the norm of the vector
T normSquare() const {
@@ -83,105 +83,105 @@
}
///Increment the left hand side by u
- xy<T>& operator +=(const xy<T>& u) {
+ Point<T>& operator +=(const Point<T>& u) {
x += u.x;
y += u.y;
return *this;
}
///Decrement the left hand side by u
- xy<T>& operator -=(const xy<T>& u) {
+ Point<T>& operator -=(const Point<T>& u) {
x -= u.x;
y -= u.y;
return *this;
}
///Multiply the left hand side with a scalar
- xy<T>& operator *=(const T &u) {
+ Point<T>& operator *=(const T &u) {
x *= u;
y *= u;
return *this;
}
///Divide the left hand side by a scalar
- xy<T>& operator /=(const T &u) {
+ Point<T>& operator /=(const T &u) {
x /= u;
y /= u;
return *this;
}
///Return the scalar product of two vectors
- T operator *(const xy<T>& u) const {
+ T operator *(const Point<T>& u) const {
return x*u.x+y*u.y;
}
///Return the sum of two vectors
- xy<T> operator+(const xy<T> &u) const {
- xy<T> b=*this;
+ Point<T> operator+(const Point<T> &u) const {
+ Point<T> b=*this;
return b+=u;
}
///Return the neg of the vectors
- xy<T> operator-() const {
- xy<T> b=*this;
+ Point<T> operator-() const {
+ Point<T> b=*this;
b.x=-b.x; b.y=-b.y;
return b;
}
///Return the difference of two vectors
- xy<T> operator-(const xy<T> &u) const {
- xy<T> b=*this;
+ Point<T> operator-(const Point<T> &u) const {
+ Point<T> b=*this;
return b-=u;
}
///Return a vector multiplied by a scalar
- xy<T> operator*(const T &u) const {
- xy<T> b=*this;
+ Point<T> operator*(const T &u) const {
+ Point<T> b=*this;
return b*=u;
}
///Return a vector divided by a scalar
- xy<T> operator/(const T &u) const {
- xy<T> b=*this;
+ Point<T> operator/(const T &u) const {
+ Point<T> b=*this;
return b/=u;
}
///Test equality
- bool operator==(const xy<T> &u) const {
+ bool operator==(const Point<T> &u) const {
return (x==u.x) && (y==u.y);
}
///Test inequality
- bool operator!=(xy u) const {
+ bool operator!=(Point u) const {
return (x!=u.x) || (y!=u.y);
}
};
- ///Return an xy
+ ///Return an Point
- ///Return an xy
- ///\relates xy
+ ///Return an Point
+ ///\relates Point
template <typename T>
- inline xy<T> make_xy(const T& x, const T& y) {
- return xy<T>(x, y);
+ inline Point<T> make_Point(const T& x, const T& y) {
+ return Point<T>(x, y);
}
///Return a vector multiplied by a scalar
///Return a vector multiplied by a scalar
- ///\relates xy
- template<typename T> xy<T> operator*(const T &u,const xy<T> &x) {
+ ///\relates Point
+ template<typename T> Point<T> operator*(const T &u,const Point<T> &x) {
return x*u;
}
///Read a plainvector from a stream
///Read a plainvector from a stream
- ///\relates xy
+ ///\relates Point
///
template<typename T>
- inline std::istream& operator>>(std::istream &is, xy<T> &z) {
+ inline std::istream& operator>>(std::istream &is, Point<T> &z) {
char c;
if (is >> c) {
if (c != '(') is.putback(c);
@@ -206,10 +206,10 @@
///Write a plainvector to a stream
///Write a plainvector to a stream
- ///\relates xy
+ ///\relates Point
///
template<typename T>
- inline std::ostream& operator<<(std::ostream &os, const xy<T>& z)
+ inline std::ostream& operator<<(std::ostream &os, const Point<T>& z)
{
os << "(" << z.x << ", " << z.y << ")";
return os;
@@ -218,34 +218,34 @@
///Rotate by 90 degrees
///Returns its parameter rotated by 90 degrees in positive direction.
- ///\relates xy
+ ///\relates Point
///
template<typename T>
- inline xy<T> rot90(const xy<T> &z)
+ inline Point<T> rot90(const Point<T> &z)
{
- return xy<T>(-z.y,z.x);
+ return Point<T>(-z.y,z.x);
}
///Rotate by 180 degrees
///Returns its parameter rotated by 180 degrees.
- ///\relates xy
+ ///\relates Point
///
template<typename T>
- inline xy<T> rot180(const xy<T> &z)
+ inline Point<T> rot180(const Point<T> &z)
{
- return xy<T>(-z.x,-z.y);
+ return Point<T>(-z.x,-z.y);
}
///Rotate by 270 degrees
///Returns its parameter rotated by 90 degrees in negative direction.
- ///\relates xy
+ ///\relates Point
///
template<typename T>
- inline xy<T> rot270(const xy<T> &z)
+ inline Point<T> rot270(const Point<T> &z)
{
- return xy<T>(z.y,-z.x);
+ return Point<T>(z.y,-z.x);
}
@@ -257,7 +257,7 @@
///\author Attila Bernath
template<typename T>
class BoundingBox {
- xy<T> bottom_left, top_right;
+ Point<T> bottom_left, top_right;
bool _empty;
public:
@@ -265,7 +265,7 @@
BoundingBox() { _empty = true; }
///Construct an instance from one point
- BoundingBox(xy<T> a) { bottom_left=top_right=a; _empty = false; }
+ BoundingBox(Point<T> a) { bottom_left=top_right=a; _empty = false; }
///Were any points added?
bool empty() const {
@@ -281,7 +281,7 @@
///Give back the bottom left corner.
///If the bounding box is empty, then the return value is not defined.
- xy<T> bottomLeft() const {
+ Point<T> bottomLeft() const {
return bottom_left;
}
@@ -289,7 +289,7 @@
///Set the bottom left corner.
///It should only bee used for non-empty box.
- void bottomLeft(xy<T> p) {
+ void bottomLeft(Point<T> p) {
bottom_left = p;
}
@@ -297,7 +297,7 @@
///Give back the top right corner.
///If the bounding box is empty, then the return value is not defined.
- xy<T> topRight() const {
+ Point<T> topRight() const {
return top_right;
}
@@ -305,7 +305,7 @@
///Set the top right corner.
///It should only bee used for non-empty box.
- void topRight(xy<T> p) {
+ void topRight(Point<T> p) {
top_right = p;
}
@@ -313,15 +313,15 @@
///Give back the bottom right corner.
///If the bounding box is empty, then the return value is not defined.
- xy<T> bottomRight() const {
- return xy<T>(top_right.x,bottom_left.y);
+ Point<T> bottomRight() const {
+ return Point<T>(top_right.x,bottom_left.y);
}
///Set the bottom right corner
///Set the bottom right corner.
///It should only bee used for non-empty box.
- void bottomRight(xy<T> p) {
+ void bottomRight(Point<T> p) {
top_right.x = p.x;
bottom_left.y = p.y;
}
@@ -330,15 +330,15 @@
///Give back the top left corner.
///If the bounding box is empty, then the return value is not defined.
- xy<T> topLeft() const {
- return xy<T>(bottom_left.x,top_right.y);
+ Point<T> topLeft() const {
+ return Point<T>(bottom_left.x,top_right.y);
}
///Set the top left corner
///Set the top left corner.
///It should only bee used for non-empty box.
- void topLeft(xy<T> p) {
+ void topLeft(Point<T> p) {
top_right.y = p.y;
bottom_left.x = p.x;
}
@@ -424,7 +424,7 @@
}
///Checks whether a point is inside a bounding box
- bool inside(const xy<T>& u){
+ bool inside(const Point<T>& u){
if (_empty)
return false;
else{
@@ -434,7 +434,7 @@
}
///Increments a bounding box with a point
- BoundingBox& add(const xy<T>& u){
+ BoundingBox& add(const Point<T>& u){
if (_empty){
bottom_left=top_right=u;
_empty = false;
@@ -449,7 +449,7 @@
}
// ///Sums a bounding box and a point
-// BoundingBox operator +(const xy<T>& u){
+// BoundingBox operator +(const Point<T>& u){
// BoundingBox b = *this;
// return b += u;
// }
@@ -485,7 +485,7 @@
};//class Boundingbox
- ///Map of x-coordinates of an xy<>-map
+ ///Map of x-coordinates of a dim2::Point<>-map
///\ingroup maps
///
@@ -550,7 +550,7 @@
return ConstXMap<M>(m);
}
- ///Map of y-coordinates of an xy<>-map
+ ///Map of y-coordinates of a dim2::Point<>-map
///\ingroup maps
///
@@ -616,9 +616,9 @@
}
- ///Map of the \ref xy::normSquare() "normSquare()" of an \ref xy "xy"-map
+ ///Map of the \ref Point::normSquare() "normSquare()" of an \ref Point "Point"-map
- ///Map of the \ref xy::normSquare() "normSquare()" of an \ref xy "xy"-map
+ ///Map of the \ref Point::normSquare() "normSquare()" of an \ref Point "Point"-map
///\ingroup maps
///
template<class M>
@@ -648,7 +648,8 @@
/// @}
-
+ } //namespce dim2
+
} //namespace lemon
-#endif //LEMON_XY_H
+#endif //LEMON_DIM2_H
Modified: hugo/trunk/lemon/eps.cc
==============================================================================
--- hugo/trunk/lemon/eps.cc (original)
+++ hugo/trunk/lemon/eps.cc Thu Sep 7 15:27:16 2006
@@ -69,13 +69,13 @@
init(x1,y1,x2,y2);
}
- EpsDrawer::EpsDrawer(std::ostream &os,xy<double> s) : local_stream(false),
+ EpsDrawer::EpsDrawer(std::ostream &os,dim2::Point<double> s) : local_stream(false),
out(os)
{
init(0.0,0.0,s.x,s.y);
}
- EpsDrawer::EpsDrawer(std::ostream &os,xy<double> a, xy<double> b) :
+ EpsDrawer::EpsDrawer(std::ostream &os,dim2::Point<double> a, dim2::Point<double> b) :
local_stream(false),
out(os)
{
@@ -97,14 +97,14 @@
init(x1,y1,x2,y2);
}
- EpsDrawer::EpsDrawer(const std::string &name,xy<double> s) :
+ EpsDrawer::EpsDrawer(const std::string &name,dim2::Point<double> s) :
local_stream(true),
out(*new std::ofstream(name.c_str()))
{
init(0.0,0.0,s.x,s.y);
}
- EpsDrawer::EpsDrawer(const std::string &name,xy<double> a, xy<double> b) :
+ EpsDrawer::EpsDrawer(const std::string &name,dim2::Point<double> a, dim2::Point<double> b) :
local_stream(true),
out(*new std::ofstream(name.c_str()))
{
Modified: hugo/trunk/lemon/eps.h
==============================================================================
--- hugo/trunk/lemon/eps.h (original)
+++ hugo/trunk/lemon/eps.h Thu Sep 7 15:27:16 2006
@@ -24,7 +24,7 @@
#include<fstream>
#include<sstream>
#include<lemon/color.h>
-#include<lemon/xy.h>
+#include<lemon/dim2.h>
///\ingroup eps_io
///\file
@@ -100,7 +100,7 @@
///
///\c s determines the upper
///right corner of the bounding box. The lower left corner is (0,0).
- EpsDrawer(std::ostream &os,xy<double> s);
+ EpsDrawer(std::ostream &os,dim2::Point<double> s);
///\e
///The generated file is put to \c os.
@@ -108,7 +108,7 @@
///\c a and \c b
/// determine the lower left and the upper right corners of
///the bounding box, respectively.
- EpsDrawer(std::ostream &os,xy<double> a, xy<double> b);
+ EpsDrawer(std::ostream &os,dim2::Point<double> a, dim2::Point<double> b);
///\e
///The generated picture is put to the file \c name.
@@ -130,7 +130,7 @@
///
///\c s determines the upper
///right corner of the bounding box. The lower left corner is (0,0).
- EpsDrawer(const std::string &name,xy<double> s);
+ EpsDrawer(const std::string &name,dim2::Point<double> s);
///\e
///The generated picture is put to the file \c name.
@@ -138,7 +138,7 @@
///\c a and \c b
/// determine the lower left and the upper right corners of
///the bounding box, respectively.
- EpsDrawer(const std::string &name,xy<double> a, xy<double> b);
+ EpsDrawer(const std::string &name,dim2::Point<double> a, dim2::Point<double> b);
// template<class T> EpsDrawer(std::ostream &os,BoundingBox<T> b)
// template<class T> EpsDrawer(std::ostream &os,BoundingBox<T> b);
@@ -168,22 +168,22 @@
EpsDrawer &circle(double x,double y, double r);
///Draw a line
- template<class T> EpsDrawer &line(xy<T> p1,xy<T> p2)
+ template<class T> EpsDrawer &line(dim2::Point<T> p1,dim2::Point<T> p2)
{
return line(p1.x,p1.y,p2.x,p2.y);
}
///Draw a line from the current point
- template<class T> EpsDrawer &lineTo(xy<T> p)
+ template<class T> EpsDrawer &lineTo(dim2::Point<T> p)
{
return lineTo(p.x,p.y);
}
///Move the current point
- template<class T> EpsDrawer &moveTo(xy<T> p)
+ template<class T> EpsDrawer &moveTo(dim2::Point<T> p)
{
return moveTo(p.x,p.y);
}
///Draw a circle
- template<class T> EpsDrawer &circle(xy<T> p, double r)
+ template<class T> EpsDrawer &circle(dim2::Point<T> p, double r)
{
return circle(p.x,p.y,r);
}
@@ -296,7 +296,7 @@
///\param col Color of the node. The default color is white
///\param brd Color of the node border. The default color is black
template<class T>
- EpsDrawer &node(NodeShapes t, xy<T> pos, double r,
+ EpsDrawer &node(NodeShapes t, dim2::Point<T> pos, double r,
Color col=WHITE, Color brd=BLACK)
{
return node(t,pos.x,pos.y,r,col,brd);
@@ -305,7 +305,7 @@
///Translate the coordinate system
EpsDrawer &translate(double x,double y);
///Translate the coordinate system
- template<class T> EpsDrawer &translate(xy<T> p)
+ template<class T> EpsDrawer &translate(dim2::Point<T> p)
{
return translate(p.x,p.y);
}
@@ -316,7 +316,7 @@
///Scale the coordinate system
EpsDrawer &scale(double s) { return scale(s,s); }
///Scale the coordinate system
- template<class T> EpsDrawer &scale(xy<T> p)
+ template<class T> EpsDrawer &scale(dim2::Point<T> p)
{
return scale(p.x,p.y);
}
@@ -336,7 +336,7 @@
EpsDrawer &operator<<(double d);
///Print a coordinate at the current point
template<class T>
- EpsDrawer &operator<<(xy<T> p)
+ EpsDrawer &operator<<(dim2::Point<T> p)
{
out << "((" << p.x << ',' << p.y <<")) show\n";
return *this;
Modified: hugo/trunk/lemon/graph_to_eps.h
==============================================================================
--- hugo/trunk/lemon/graph_to_eps.h (original)
+++ hugo/trunk/lemon/graph_to_eps.h Thu Sep 7 15:27:16 2006
@@ -35,7 +35,7 @@
#include <cmath>
#include<lemon/bits/invalid.h>
-#include<lemon/xy.h>
+#include<lemon/dim2.h>
#include<lemon/maps.h>
#include<lemon/color.h>
#include<lemon/bits/bezier.h>
@@ -81,7 +81,7 @@
std::ostream& os;
- typedef ConstMap<typename Graph::Node,xy<double> > CoordsMapType;
+ typedef ConstMap<typename Graph::Node,dim2::Point<double> > CoordsMapType;
CoordsMapType _coords;
ConstMap<typename Graph::Node,double > _nodeSizes;
ConstMap<typename Graph::Node,int > _nodeShapes;
@@ -146,7 +146,7 @@
DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout,
bool _pros=false) :
g(_g), os(_os),
- _coords(xy<double>(1,1)), _nodeSizes(.01), _nodeShapes(0),
+ _coords(dim2::Point<double>(1,1)), _nodeSizes(.01), _nodeShapes(0),
_nodeColors(WHITE), _edgeColors(BLACK),
_edgeWidths(1.0), _edgeWidthScale(0.003),
_nodeScale(1.0), _xBorder(10), _yBorder(10), _scale(1.0),
@@ -313,7 +313,7 @@
g.target(e)==g.source(f));
}
template<class TT>
- static std::string psOut(const xy<TT> &p)
+ static std::string psOut(const dim2::Point<TT> &p)
{
std::ostringstream os;
os << p.x << ' ' << p.y;
@@ -337,7 +337,8 @@
///Sets the map of the node coordinates
///Sets the map of the node coordinates.
- ///\param x must be a node map with xy<double> or \ref xy "xy<int>" values.
+ ///\param x must be a node map with dim2::Point<double> or
+ ///\ref dim2::Point "dim2::Point<int>" values.
template<class X> GraphToEps<CoordsTraits<X> > coords(const X &x) {
dontPrint=true;
return GraphToEps<CoordsTraits<X> >(CoordsTraits<X>(*this,x));
@@ -669,7 +670,7 @@
GraphToEps<T> ©right(const std::string &t) {_copyright=t;return *this;}
protected:
- bool isInsideNode(xy<double> p, double r,int t)
+ bool isInsideNode(dim2::Point<double> p, double r,int t)
{
switch(t) {
case CIRCLE:
@@ -736,10 +737,10 @@
double diag_len = 1;
if(!(_absoluteNodeSizes&&_absoluteEdgeWidths)) {
- BoundingBox<double> bb;
+ dim2::BoundingBox<double> bb;
for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]);
if (bb.empty()) {
- bb = BoundingBox<double>(xy<double>(0,0));
+ bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
}
diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare());
if(diag_len<EPSILON) diag_len = 1;
@@ -747,10 +748,10 @@
if(!_absoluteEdgeWidths) _edgeWidthScale*=diag_len;
}
- BoundingBox<double> bb;
+ dim2::BoundingBox<double> bb;
for(NodeIt n(g);n!=INVALID;++n) {
double ns=_nodeSizes[n]*_nodeScale;
- xy<double> p(ns,ns);
+ dim2::Point<double> p(ns,ns);
switch(_nodeShapes[n]) {
case CIRCLE:
case SQUARE:
@@ -760,16 +761,16 @@
break;
case MALE:
bb.add(-p+mycoords[n]);
- bb.add(xy<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]);
+ bb.add(dim2::Point<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]);
break;
case FEMALE:
bb.add(p+mycoords[n]);
- bb.add(xy<double>(-ns,-3.01*ns)+mycoords[n]);
+ bb.add(dim2::Point<double>(-ns,-3.01*ns)+mycoords[n]);
break;
}
}
if (bb.empty()) {
- bb = BoundingBox<double>(xy<double>(0,0));
+ bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
}
if(_scaleToA4)
@@ -870,7 +871,8 @@
double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.height(),
(A4WIDTH-2*A4BORDER)/bb.width());
os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' '
- << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER << " translate\n"
+ << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER
+ << " translate\n"
<< sc << " dup scale\n"
<< -bb.left() << ' ' << -bb.bottom() << " translate\n";
}
@@ -879,7 +881,8 @@
double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(),
(A4WIDTH-2*A4BORDER)/bb.height());
os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' '
- << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER << " translate\n"
+ << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER
+ << " translate\n"
<< sc << " dup scale\n90 rotate\n"
<< -bb.left() << ' ' << -bb.top() << " translate\n";
}
@@ -904,42 +907,43 @@
sw+=_edgeWidths[*e]*_edgeWidthScale+_parEdgeDist;
sw-=_parEdgeDist;
sw/=-2.0;
- xy<double> dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
+ dim2::Point<double>
+ dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
double l=std::sqrt(dvec.normSquare());
///\todo better 'epsilon' would be nice here.
- xy<double> d(dvec/std::max(l,EPSILON));
- xy<double> m;
-// m=xy<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;
+ dim2::Point<double> d(dvec/std::max(l,EPSILON));
+ dim2::Point<double> m;
+// m=dim2::Point<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;
-// m=xy<double>(mycoords[g.source(*i)])+
+// m=dim2::Point<double>(mycoords[g.source(*i)])+
// dvec*(double(_nodeSizes[g.source(*i)])/
// (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)]));
- m=xy<double>(mycoords[g.source(*i)])+
+ m=dim2::Point<double>(mycoords[g.source(*i)])+
d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0;
for(typename std::vector<Edge>::iterator e=i;e!=j;++e) {
sw+=_edgeWidths[*e]*_edgeWidthScale/2.0;
- xy<double> mm=m+rot90(d)*sw/.75;
+ dim2::Point<double> mm=m+rot90(d)*sw/.75;
if(_drawArrows) {
int node_shape;
- xy<double> s=mycoords[g.source(*e)];
- xy<double> t=mycoords[g.target(*e)];
+ dim2::Point<double> s=mycoords[g.source(*e)];
+ dim2::Point<double> t=mycoords[g.target(*e)];
double rn=_nodeSizes[g.target(*e)]*_nodeScale;
node_shape=_nodeShapes[g.target(*e)];
- Bezier3 bez(s,mm,mm,t);
+ dim2::Bezier3 bez(s,mm,mm,t);
double t1=0,t2=1;
for(int i=0;i<INTERPOL_PREC;++i)
if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t2=(t1+t2)/2;
else t1=(t1+t2)/2;
- xy<double> apoint=bez((t1+t2)/2);
+ dim2::Point<double> apoint=bez((t1+t2)/2);
rn = _arrowLength+_edgeWidths[*e]*_edgeWidthScale;
rn*=rn;
t2=(t1+t2)/2;t1=0;
for(int i=0;i<INTERPOL_PREC;++i)
if((bez((t1+t2)/2)-apoint).normSquare()>rn) t1=(t1+t2)/2;
else t2=(t1+t2)/2;
- xy<double> linend=bez((t1+t2)/2);
+ dim2::Point<double> linend=bez((t1+t2)/2);
bez=bez.before((t1+t2)/2);
// rn=_nodeSizes[g.source(*e)]*_nodeScale;
// node_shape=_nodeShapes[g.source(*e)];
@@ -956,7 +960,7 @@
<< bez.p2.x << ' ' << bez.p2.y << ' '
<< bez.p3.x << ' ' << bez.p3.y << ' '
<< bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n";
- xy<double> dd(rot90(linend-apoint));
+ dim2::Point<double> dd(rot90(linend-apoint));
dd*=(.5*_edgeWidths[*e]*_edgeWidthScale+_arrowWidth)/
std::sqrt(dd.normSquare());
os << "newpath " << psOut(apoint) << " moveto "
@@ -982,7 +986,7 @@
if((!_undirected||g.source(e)<g.target(e))&&_edgeWidths[e]>0
&&g.source(e)!=g.target(e))
if(_drawArrows) {
- xy<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]);
+ dim2::Point<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]);
double rn=_nodeSizes[g.target(e)]*_nodeScale;
int node_shape=_nodeShapes[g.target(e)];
double t1=0,t2=1;
Modified: hugo/trunk/lemon/grid_ugraph.h
==============================================================================
--- hugo/trunk/lemon/grid_ugraph.h (original)
+++ hugo/trunk/lemon/grid_ugraph.h Thu Sep 7 15:27:16 2006
@@ -26,7 +26,7 @@
#include <lemon/bits/base_extender.h>
#include <lemon/bits/graph_extender.h>
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
///\ingroup graphs
///\file
@@ -381,15 +381,15 @@
typedef ExtendedGridUGraphBase Parent;
- /// \brief Map to get the indices of the nodes as xy<int>.
+ /// \brief Map to get the indices of the nodes as dim2::Point<int>.
///
- /// Map to get the indices of the nodes as xy<int>.
+ /// Map to get the indices of the nodes as dim2::Point<int>.
class IndexMap {
public:
/// \brief The key type of the map
typedef GridUGraph::Node Key;
/// \brief The value type of the map
- typedef xy<int> Value;
+ typedef dim2::Point<int> Value;
/// \brief Constructor
///
@@ -400,7 +400,7 @@
///
/// The subscript operator.
Value operator[](Key key) const {
- return xy<int>(graph.row(key), graph.col(key));
+ return dim2::Point<int>(graph.row(key), graph.col(key));
}
private:
Modified: hugo/trunk/lemon/hypercube_graph.h
==============================================================================
--- hugo/trunk/lemon/hypercube_graph.h (original)
+++ hugo/trunk/lemon/hypercube_graph.h Thu Sep 7 15:27:16 2006
@@ -275,13 +275,13 @@
///\code
/// const int DIM = 3;
/// HyperCubeGraph graph(DIM);
- /// xy<double> base[DIM];
+ /// dim2::Point<double> base[DIM];
/// for (int k = 0; k < DIM; ++k) {
/// base[k].x = rand() / (RAND_MAX + 1.0);
/// base[k].y = rand() / (RAND_MAX + 1.0);
/// }
- /// HyperCubeGraph::HyperMap<xy<double> >
- /// pos(graph, base, base + DIM, xy<double>(0.0, 0.0));
+ /// HyperCubeGraph::HyperMap<dim2::Point<double> >
+ /// pos(graph, base, base + DIM, dim2::Point<double>(0.0, 0.0));
///\endcode
///
/// \see HyperCubeGraph
Modified: hugo/trunk/lemon/lemon_reader.h
==============================================================================
--- hugo/trunk/lemon/lemon_reader.h (original)
+++ hugo/trunk/lemon/lemon_reader.h Thu Sep 7 15:27:16 2006
@@ -38,7 +38,7 @@
#include <lemon/bits/utility.h>
#include <lemon/bits/item_reader.h>
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
#include <lemon/concept_check.h>
#include <lemon/concept/maps.h>
@@ -183,21 +183,21 @@
};
template <typename Map>
- struct Ref<XMap<Map> > {
- typedef XMap<Map> Type;
+ struct Ref<dim2::XMap<Map> > {
+ typedef dim2::XMap<Map> Type;
};
template <typename Map>
- struct Arg<XMap<Map> > {
- typedef const XMap<Map>& Type;
+ struct Arg<dim2::XMap<Map> > {
+ typedef const dim2::XMap<Map>& Type;
};
template <typename Map>
- struct Ref<YMap<Map> > {
- typedef YMap<Map> Type;
+ struct Ref<dim2::YMap<Map> > {
+ typedef dim2::YMap<Map> Type;
};
template <typename Map>
- struct Arg<YMap<Map> > {
- typedef const YMap<Map>& Type;
+ struct Arg<dim2::YMap<Map> > {
+ typedef const dim2::YMap<Map>& Type;
};
Modified: hugo/trunk/lemon/lemon_writer.h
==============================================================================
--- hugo/trunk/lemon/lemon_writer.h (original)
+++ hugo/trunk/lemon/lemon_writer.h Thu Sep 7 15:27:16 2006
@@ -37,7 +37,7 @@
#include <lemon/bits/item_writer.h>
#include <lemon/bits/utility.h>
#include <lemon/maps.h>
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
#include <lemon/concept_check.h>
#include <lemon/concept/maps.h>
@@ -173,21 +173,21 @@
};
template <typename Map>
- struct Ref<XMap<Map> > {
- typedef XMap<Map> Type;
+ struct Ref<dim2::XMap<Map> > {
+ typedef dim2::XMap<Map> Type;
};
template <typename Map>
- struct Ref<ConstXMap<Map> > {
- typedef ConstXMap<Map> Type;
+ struct Ref<dim2::ConstXMap<Map> > {
+ typedef dim2::ConstXMap<Map> Type;
};
template <typename Map>
- struct Ref<YMap<Map> > {
- typedef YMap<Map> Type;
+ struct Ref<dim2::YMap<Map> > {
+ typedef dim2::YMap<Map> Type;
};
template <typename Map>
- struct Ref<ConstYMap<Map> > {
- typedef ConstYMap<Map> Type;
+ struct Ref<dim2::ConstYMap<Map> > {
+ typedef dim2::ConstYMap<Map> Type;
};
Modified: hugo/trunk/lemon/polynomial.h
==============================================================================
--- hugo/trunk/lemon/polynomial.h (original)
+++ hugo/trunk/lemon/polynomial.h Thu Sep 7 15:27:16 2006
@@ -76,11 +76,11 @@
///The calculation will be done using type \c R.
///The following examples shows the usage of the template parameter \c R.
///\code
- /// Polynomial<xy<double> > line(1);
- /// line[0]=xy<double>(12,25);
- /// line[1]=xy<double>(2,7);
+ /// Polynomial<dim2::Point<double> > line(1);
+ /// line[0]=dim2::Point<double>(12,25);
+ /// line[1]=dim2::Point<double>(2,7);
/// ...
- /// xy<double> d = line.subst<xy<double> >(23.2);
+ /// dim2::Point<double> d = line.subst<dim2::Point<double> >(23.2);
///\endcode
///
///\code
Modified: hugo/trunk/test/Makefile.am
==============================================================================
--- hugo/trunk/test/Makefile.am (original)
+++ hugo/trunk/test/Makefile.am Thu Sep 7 15:27:16 2006
@@ -18,6 +18,7 @@
test/counter_test \
test/dfs_test \
test/dijkstra_test \
+ test/dim_test \
test/edge_set_test \
test/graph_adaptor_test \
test/graph_test \
@@ -39,8 +40,7 @@
test/test_tools_pass \
test/time_measure_test \
test/ugraph_test \
- test/unionfind_test \
- test/xy_test
+ test/unionfind_test
if HAVE_GLPK
check_PROGRAMS += test/lp_test test/mip_test
@@ -60,6 +60,7 @@
test_counter_test_SOURCES = test/counter_test.cc
test_dfs_test_SOURCES = test/dfs_test.cc
test_dijkstra_test_SOURCES = test/dijkstra_test.cc
+test_dim_test_SOURCES = test/dim_test.cc
test_edge_set_test_SOURCES = test/edge_set_test.cc
test_graph_adaptor_test_SOURCES = test/graph_adaptor_test.cc
test_graph_test_SOURCES = test/graph_test.cc
@@ -82,7 +83,6 @@
test_time_measure_test_SOURCES = test/time_measure_test.cc
test_ugraph_test_SOURCES = test/ugraph_test.cc
test_unionfind_test_SOURCES = test/unionfind_test.cc
-test_xy_test_SOURCES = test/xy_test.cc
test_lp_test_SOURCES = test/lp_test.cc
test_lp_test_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS)
Copied: hugo/trunk/test/dim_test.cc (from r2932, /hugo/trunk/test/xy_test.cc)
==============================================================================
--- /hugo/trunk/test/xy_test.cc (original)
+++ hugo/trunk/test/dim_test.cc Thu Sep 7 15:27:16 2006
@@ -16,7 +16,7 @@
*
*/
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
#include <iostream>
#include "test_tools.h"
@@ -25,13 +25,13 @@
int main()
{
- cout << "Testing classes `xy' and `boundingbox'." << endl;
+ cout << "Testing classes `dim2::Point' and `dim2::BoundingBox'." << endl;
- typedef xy<int> XY;
+ typedef dim2::Point<int> Point;
- XY seged;
- XY a(1,2);
- XY b(3,4);
+ Point seged;
+ Point a(1,2);
+ Point b(3,4);
seged = a+b;
check(seged.x==4 && seged.y==6, "Wrong vector addition");
@@ -49,7 +49,7 @@
seged = b/l;
check(seged.x==1 && seged.y==2, "b/l");
- typedef BoundingBox<int> BB;
+ typedef dim2::BoundingBox<int> BB;
BB doboz1;
check(doboz1.empty(), "It should be empty.");
Modified: hugo/trunk/test/polynomial_test.cc
==============================================================================
--- hugo/trunk/test/polynomial_test.cc (original)
+++ hugo/trunk/test/polynomial_test.cc Thu Sep 7 15:27:16 2006
@@ -17,7 +17,7 @@
*/
#include <lemon/polynomial.h>
-#include <lemon/xy.h>
+#include <lemon/dim2.h>
#include <iostream>
#include "test_tools.h"
More information about the Lemon-commits
mailing list