# Ticket #363: lemon-sikgraf_ea56aa8243b1.patch

File lemon-sikgraf_ea56aa8243b1.patch, 128.0 KB (added by gyorokp, 9 years ago)
• ## lemon/Makefile.am

# HG changeset patch
# User Peter Gyorok
# Date 1275937071 -7200
# Node ID ea56aa8243b16ac39e1834d1c83a72724d6553ee
# Parent  0bca98cbebbbc65ed7baecaf7a4f68ab881e28e9

diff -r 0bca98cbebbb -r ea56aa8243b1 lemon/Makefile.am
 a lemon/network_simplex.h \ lemon/pairing_heap.h \ lemon/path.h \ lemon/planar_graph.h \ lemon/planarity.h \ lemon/plane_graph.h \ lemon/preflow.h \ lemon/quad_heap.h \ lemon/radix_heap.h \
• ## lemon/bits/bezier.h

diff -r 0bca98cbebbb -r ea56aa8243b1 lemon/bits/bezier.h
 a #ifndef LEMON_BEZIER_H #define LEMON_BEZIER_H #include //\ingroup misc //\file //\brief Classes to compute with Bezier curves. Point norm() const { return rot90(p2-p1); } Point grad(double) const { return grad(); } Point norm(double t) const { return rot90(grad(t)); } Box boundingBox() const { double minx, miny; double maxx, maxy; if (p1.x < p2.x) { minx = p1.x; maxx = p2.x; } else { minx = p2.x; maxx = p1.x; } if (p1.y < p2.y) { miny = p1.y; maxy = p2.y; } else { miny = p2.y; maxy = p1.y; } return Box(minx, miny, maxx, maxy); } }; class Bezier2 : public BezierBase Bezier1 norm() const { return Bezier1(2.0*rot90(p2-p1),2.0*rot90(p3-p2)); } Point grad(double t) const { return grad()(t); } Point norm(double t) const { return rot90(grad(t)); } Box boundingBox() const { double minx, miny; double maxx, maxy; if (p1.x < p3.x) { minx = p1.x; maxx = p3.x; } else { minx = p3.x; maxx = p1.x; } if (p1.y < p3.y) { miny = p1.y; maxy = p3.y; } else { miny = p3.y; maxy = p1.y; } if (p1.x + p3.x - 2 * p2.x != 0.0) { double t = (p1.x - p2.x) / (p1.x + p3.x - 2 * p2.x); if (t >= 0.0 && t <= 1.0) { double x = ((1-t)*(1-t))*p1.x+(2*(1-t)*t)*p2.x+(t*t)*p3.x; if (x < minx) minx = x; if (x > maxx) maxx = x; } } if (p1.y + p3.y - 2 * p2.y != 0.0) { double t = (p1.y - p2.y) / (p1.y + p3.y - 2 * p2.y); if (t >= 0.0 && t <= 1.0) { double y = ((1-t)*(1-t))*p1.y+(2*(1-t)*t)*p2.y+(t*t)*p3.y; if (y < miny) miny = y; if (y > maxy) maxy = y; } } return Box(minx, miny, maxx, maxy); } }; class Bezier3 : public BezierBase 3.0*rot90(p4-p3)); } Point grad(double t) const { return grad()(t); } Point norm(double t) const { return rot90(grad(t)); } Box boundingBox() const { double minx, miny; double maxx, maxy; if (p1.x < p4.x) { minx = p1.x; maxx = p4.x; } else { minx = p4.x; maxx = p1.x; } if (p1.y < p4.y) { miny = p1.y; maxy = p4.y; } else { miny = p4.y; maxy = p1.y; } if (p1.x - 3 * p2.x + 3 * p3.x - p4.x != 0.0) { double disc = p2.x * p2.x + p3.x * p3.x - p1.x * p3.x + p1.x * p4.x - p2.x * p3.x - p2.x * p4.x; if (disc >= 0.0) { double t = (p1.x + p3.x - 2 * p2.x + std::sqrt(disc)) / (p1.x - 3 * p2.x + 3 * p3.x - p4.x); if (t >= 0.0 && t <= 1.0) { double x = ((1-t)*(1-t)*(1-t))*p1.x+(3*t*(1-t)*(1-t))*p2.x+ (3*t*t*(1-t))*p3.x+(t*t*t)*p4.x; if (x < minx) minx = x; if (x > maxx) maxx = x; } t = (p1.x + p3.x - 2 * p2.x - std::sqrt(disc)) / (p1.x - 3 * p2.x + 3 * p3.x - p4.x); if (t >= 0.0 && t <= 1.0) { double x = ((1-t)*(1-t)*(1-t))*p1.x+(3*t*(1-t)*(1-t))*p2.x+ (3*t*t*(1-t))*p3.x+(t*t*t)*p4.x; if (x < minx) minx = x; if (x > maxx) maxx = x; } } } else if (p1.x + p3.x - 2 * p2.x != 0.0) { double t = (p1.x - p2.x) / (2 * p1.x + 2 * p3.x - 4 * p2.x); if (t >= 0.0 && t <= 1.0) { double x = ((1-t)*(1-t)*(1-t))*p1.x+(3*t*(1-t)*(1-t))*p2.x+ (3*t*t*(1-t))*p3.x+(t*t*t)*p4.x; if (x < minx) minx = x; if (x > maxx) maxx = x; } } if (p1.y - 3 * p2.y + 3 * p3.y - p4.y != 0.0) { double disc = p2.y * p2.y + p3.y * p3.y - p1.y * p3.y + p1.y * p4.y - p2.y * p3.y - p2.y * p4.y; if (disc >= 0.0) { double t = (p1.y + p3.y - 2 * p2.y + std::sqrt(disc)) / (p1.y - 3 * p2.y + 3 * p3.y - p4.y); if (t >= 0.0 && t <= 1.0) { double y = ((1-t)*(1-t)*(1-t))*p1.y+(3*t*(1-t)*(1-t))*p2.y+ (3*t*t*(1-t))*p3.y+(t*t*t)*p4.y; if (y < miny) miny = y; if (y > maxy) maxy = y; } t = (p1.y + p3.y - 2 * p2.y - std::sqrt(disc)) / (p1.y - 3 * p2.y + 3 * p3.y - p4.y); if (t >= 0.0 && t <= 1.0) { double y = ((1-t)*(1-t)*(1-t))*p1.y+(3*t*(1-t)*(1-t))*p2.y+ (3*t*t*(1-t))*p3.y+(t*t*t)*p4.y; if (y < miny) miny = y; if (y > maxy) maxy = y; } } } else if (p1.y + p3.y - 2 * p2.y != 0.0) { double t = (p1.y - p2.y) / (2 * p1.y + 2 * p3.y - 4 * p2.y); if (t >= 0.0 && t <= 1.0) { double y = ((1-t)*(1-t)*(1-t))*p1.y+(3*t*(1-t)*(1-t))*p2.y+ (3*t*t*(1-t))*p3.y+(t*t*t)*p4.y; if (y < miny) miny = y; if (y > maxy) maxy = y; } } return Box(minx, miny, maxx, maxy); } template R recSplit(F &_f,const S &_s,D _d) const
• ## lemon/graph_to_eps.h

diff -r 0bca98cbebbb -r ea56aa8243b1 lemon/graph_to_eps.h
 a double _arrowLength, _arrowWidth; bool _showNodes, _showArcs; bool _customEdgeShapes; bool _enableParallel; double _parArcDist; _nodeScale(.01), _xBorder(10), _yBorder(10), _scale(1.0), _nodeBorderQuotient(.1), _drawArrows(false), _arrowLength(1), _arrowWidth(0.3), _showNodes(true), _showArcs(true), _showNodes(true), _showArcs(true), _customEdgeShapes(false), _enableParallel(false), _parArcDist(1), _showNodeText(false), _nodeTexts(false), _nodeTextSize(1), _showNodePsText(false), _nodePsTexts(false), _nodePsTextsPreamble(0), using T::_showNodes; using T::_showArcs; using T::_customEdgeShapes; using T::_enableParallel; using T::_parArcDist; GraphToEps &hideArcs(bool b=true) {_showArcs=!b;return *this;} ///Hides the nodes GraphToEps &hideNodes(bool b=true) {_showNodes=!b;return *this;} ///Uses default edge shapes GraphToEps &customEdgeShapes(bool b=false) { _customEdgeShapes=b;return *this; } ///Sets the size of the node texts GraphToEps &nodeTextSize(double d) {_nodeTextSize=d;return *this;} public: ~GraphToEps() { } ///Draws the graph. template void edgeToEps(const GR &g, std::ostream &os, const typename GR::Arc e, const Color &col, double width, D t) { } ///Like other functions using ///\ref named-templ-func-param "named template parameters", ///this function calls the algorithm itself, i.e. in this case ///it draws the graph. void run() { template void edgeToEps(const GR &g, std::ostream &os, const typename GR::Arc e, const Color &col, double width, bool b) { g.edgeToEps(os,e,_arcColors[e],_arcWidths[e]*_arcWidthScale); } template void inner_run(D t) { const double EPSILON=1e-9; if(dontPrint) return; if(_showArcs) { os << "%Arcs:\ngsave\n"; if(_enableParallel) { if (_customEdgeShapes) { for(ArcIt e(g);e!=INVALID;++e) { if((!_undirected||g.source(e) == g.target(e)||g.source(e)0) { edgeToEps(g,os,e,_arcColors[e],_arcWidths[e]*_arcWidthScale,t); } } } else if (_enableParallel) { std::vector el; for(ArcIt e(g);e!=INVALID;++e) if((!_undirected||g.source(e)0 if(_pleaseRemoveOsStream) {delete &os;} } ///Draws the graph. ///Like other functions using ///\ref named-templ-func-param "named template parameters", ///this function calls the algorithm itself, i.e. in this case ///it draws the graph. void run(int i = 0) { this->inner_run(i); //for normal graphs } void run(bool b) { this->inner_run(b); //for plane graphs with custom edge shape support } ///\name Aliases ///These are just some aliases to other parameter setting functions. ///\sa graphToEps(GR &g, std::ostream& os) template GraphToEps > graphToEps(GR &g,const char *file_name) graphToEps(const GR &g,const char *file_name) { std::ostream* os = new std::ofstream(file_name); if (!(*os)) {
• ## new file lemon/planar_graph.h

diff -r 0bca98cbebbb -r ea56aa8243b1 lemon/planar_graph.h
• ## new file lemon/plane_graph.h

diff -r 0bca98cbebbb -r ea56aa8243b1 lemon/plane_graph.h
• ## test/CMakeLists.txt

diff -r 0bca98cbebbb -r ea56aa8243b1 test/CMakeLists.txt
 a min_cost_flow_test min_mean_cycle_test path_test planar_graph_test planarity_test preflow_test radix_sort_test
• ## test/Makefile.am

diff -r 0bca98cbebbb -r ea56aa8243b1 test/Makefile.am
 a test/min_cost_flow_test \ test/min_mean_cycle_test \ test/path_test \ test/planar_graph_test \ test/planarity_test \ test/preflow_test \ test/radix_sort_test \ test_min_cost_flow_test_SOURCES = test/min_cost_flow_test.cc test_min_mean_cycle_test_SOURCES = test/min_mean_cycle_test.cc test_path_test_SOURCES = test/path_test.cc test_planar_graph_test_SOURCES = test/planar_graph_test.cc test_planarity_test_SOURCES = test/planarity_test.cc test_preflow_test_SOURCES = test/preflow_test.cc test_radix_sort_test_SOURCES = test/radix_sort_test.cc
• ## new file test/planar_graph_test.cc

diff -r 0bca98cbebbb -r ea56aa8243b1 test/planar_graph_test.cc
diff -r 0bca98cbebbb -r ea56aa8243b1 test/planar_graph_test.h