From 61de3aa5e64764650d33a8065c9b86fce0ec2ae5 Mon Sep 17 00:00:00 2001 From: Weisheng Si Date: Fri, 18 Dec 2015 15:40:10 +1100 Subject: [PATCH] Add cpp, cmd and data files for test suite --- .../test/Cone_spanners_2/cones_exact.cmd | 1 + .../test/Cone_spanners_2/cones_exact.cpp | 54 +++++++++++++ .../test/Cone_spanners_2/cones_inexact.cmd | 1 + .../test/Cone_spanners_2/cones_inexact.cpp | 54 +++++++++++++ .../test/Cone_spanners_2/data/n20.cin | 20 +++++ .../test/Cone_spanners_2/data/n9.cin | 9 +++ .../test/Cone_spanners_2/theta_exact.cmd | 1 + .../test/Cone_spanners_2/theta_exact.cpp | 77 ++++++++++++++++++ .../test/Cone_spanners_2/theta_inexact.cmd | 1 + .../test/Cone_spanners_2/theta_inexact.cpp | 78 ++++++++++++++++++ .../test/Cone_spanners_2/yao_exact.cmd | 1 + .../test/Cone_spanners_2/yao_exact.cpp | 79 +++++++++++++++++++ .../test/Cone_spanners_2/yao_inexact.cmd | 1 + .../test/Cone_spanners_2/yao_inexact.cpp | 79 +++++++++++++++++++ 14 files changed, 456 insertions(+) create mode 100644 Cone_spanners_2/test/Cone_spanners_2/cones_exact.cmd create mode 100644 Cone_spanners_2/test/Cone_spanners_2/cones_exact.cpp create mode 100644 Cone_spanners_2/test/Cone_spanners_2/cones_inexact.cmd create mode 100644 Cone_spanners_2/test/Cone_spanners_2/cones_inexact.cpp create mode 100644 Cone_spanners_2/test/Cone_spanners_2/data/n20.cin create mode 100644 Cone_spanners_2/test/Cone_spanners_2/data/n9.cin create mode 100644 Cone_spanners_2/test/Cone_spanners_2/theta_exact.cmd create mode 100644 Cone_spanners_2/test/Cone_spanners_2/theta_exact.cpp create mode 100644 Cone_spanners_2/test/Cone_spanners_2/theta_inexact.cmd create mode 100644 Cone_spanners_2/test/Cone_spanners_2/theta_inexact.cpp create mode 100644 Cone_spanners_2/test/Cone_spanners_2/yao_exact.cmd create mode 100644 Cone_spanners_2/test/Cone_spanners_2/yao_exact.cpp create mode 100644 Cone_spanners_2/test/Cone_spanners_2/yao_inexact.cmd create mode 100644 Cone_spanners_2/test/Cone_spanners_2/yao_inexact.cpp diff --git a/Cone_spanners_2/test/Cone_spanners_2/cones_exact.cmd b/Cone_spanners_2/test/Cone_spanners_2/cones_exact.cmd new file mode 100644 index 00000000000..98d9bcb75a6 --- /dev/null +++ b/Cone_spanners_2/test/Cone_spanners_2/cones_exact.cmd @@ -0,0 +1 @@ +17 diff --git a/Cone_spanners_2/test/Cone_spanners_2/cones_exact.cpp b/Cone_spanners_2/test/Cone_spanners_2/cones_exact.cpp new file mode 100644 index 00000000000..192a587544f --- /dev/null +++ b/Cone_spanners_2/test/Cone_spanners_2/cones_exact.cpp @@ -0,0 +1,54 @@ +/** @file cones_exact.cpp + * A test application that computes the cone boundaries exactly given the number of cones + * and the initial direction. + * + * Authors: Weisheng Si and Quincy Tse, University of Western Sydney + */ +#include +#include +#include +#include +#include +#include + +// select the kernel type +typedef CGAL::Exact_predicates_exact_constructions_kernel_with_root_of Kernel; +typedef Kernel::Point_2 Point_2; +typedef Kernel::Direction_2 Direction_2; + +int main(int argc, char ** argv) { + + if (argc < 2) { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + unsigned long k = atol(argv[1]); + if (k<2) { + std::cout << "The number of cones should be larger than 1!" << std::endl; + return 1; + } + + Direction_2 initial_direction; + if (argc == 2) + initial_direction = Direction_2(1, 0); // default initial_direction + else if (argc == 4) + initial_direction = Direction_2(atof(argv[2]), atof(argv[3])); + else { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + // construct the functor + CGAL::Compute_cone_boundaries_2 cones; + // create the vector rays to store the results + std::vector rays(k); + // compute the cone boundaries and store them in rays + cones(k, initial_direction, rays.begin()); + + // display the computed rays, starting from the initial direction, ccw order + for (int i=0; i +#include +#include +#include +#include +#include + +// select the kernel type +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_2 Point_2; +typedef Kernel::Direction_2 Direction_2; + +int main(int argc, char ** argv) { + + if (argc < 2) { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + unsigned long k = atol(argv[1]); + if (k<2) { + std::cout << "The number of cones should be larger than 1!" << std::endl; + return 1; + } + + Direction_2 initial_direction; + if (argc == 2) + initial_direction = Direction_2(1, 0); // default initial_direction + else if (argc == 4) + initial_direction = Direction_2(atof(argv[2]), atof(argv[3])); + else { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + // construct the functor + CGAL::Compute_cone_boundaries_2 cones; + // create the vector rays to store the results + std::vector rays(k); + // compute the cone boundaries and store them in rays + cones(k, initial_direction, rays.begin()); + + // display the computed rays, starting from the initial direction, ccw order + for (int i=0; i +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// select the kernel type +typedef CGAL::Exact_predicates_exact_constructions_kernel_with_root_of Kernel; +typedef Kernel::Point_2 Point_2; +typedef Kernel::Direction_2 Direction_2; +// define the graph type +typedef boost::adjacency_list Graph; + +int main(int argc, char ** argv) { + + if (argc < 3) { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + unsigned long k = atol(argv[1]); + if (k<2) { + std::cout << "The number of cones should be larger than 1!" << std::endl; + return 1; + } + + // open the file containing the vertex list + std::ifstream inf(argv[2]); + if (!inf) { + std::cout << "Cannot open file " << argv[2] << "!" << std::endl; + return 1; + } + + Direction_2 initial_direction; + if (argc == 3) + initial_direction = Direction_2(1, 0); // default initial_direction + else if (argc == 5) + initial_direction = Direction_2(atof(argv[3]), atof(argv[4])); + else { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + // iterators for reading the vertex list file + std::istream_iterator input_begin( inf ); + std::istream_iterator input_end; + + // initialize the functor + CGAL::Construct_theta_graph_2 theta(k, initial_direction); + // create an adjacency_list object + Graph g; + // construct the theta graph on the vertex list + theta(input_begin, input_end, g); + + // obtain the number of vertices in the constructed graph + unsigned int n = boost::num_vertices(g); + // generate gnuplot files for plotting this graph + std::string file_prefix = "t" + std::to_string(k) + "n" + std::to_string(n); + CGAL::gnuplot_output_2(g, file_prefix); + + return 0; +} diff --git a/Cone_spanners_2/test/Cone_spanners_2/theta_inexact.cmd b/Cone_spanners_2/test/Cone_spanners_2/theta_inexact.cmd new file mode 100644 index 00000000000..ddce4442855 --- /dev/null +++ b/Cone_spanners_2/test/Cone_spanners_2/theta_inexact.cmd @@ -0,0 +1 @@ +4 data/n9.cin diff --git a/Cone_spanners_2/test/Cone_spanners_2/theta_inexact.cpp b/Cone_spanners_2/test/Cone_spanners_2/theta_inexact.cpp new file mode 100644 index 00000000000..5eb7fcb6fe9 --- /dev/null +++ b/Cone_spanners_2/test/Cone_spanners_2/theta_inexact.cpp @@ -0,0 +1,78 @@ +/** @file theta_inexact.cpp + * + * A test application that constructs a Theta graph inexactly with the vertex list + * given in a file, and then generates the Gnuplot files for plotting the constructed Theta graph. + * + * Authors: Weisheng Si and Quincy Tse, University of Western Sydney + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// select the kernel type +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_2 Point_2; +typedef Kernel::Direction_2 Direction_2; +// define the graph type +typedef boost::adjacency_list Graph; + +int main(int argc, char ** argv) { + + if (argc < 3) { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + unsigned long k = atol(argv[1]); + if (k<2) { + std::cout << "The number of cones should be larger than 1!" << std::endl; + return 1; + } + + // open the file containing the vertex list + std::ifstream inf(argv[2]); + if (!inf) { + std::cout << "Cannot open file " << argv[2] << "!" << std::endl; + return 1; + } + + Direction_2 initial_direction; + if (argc == 3) + initial_direction = Direction_2(1, 0); // default initial_direction + else if (argc == 5) + initial_direction = Direction_2(atof(argv[3]), atof(argv[4])); + else { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + // iterators for reading the vertex list file + std::istream_iterator input_begin( inf ); + std::istream_iterator input_end; + + // initialize the functor + CGAL::Construct_theta_graph_2 theta(k, initial_direction); + // create an adjacency_list object + Graph g; + // construct the theta graph on the vertex list + theta(input_begin, input_end, g); + + // obtain the number of vertices in the constructed graph + unsigned int n = boost::num_vertices(g); + // generate gnuplot files for plotting this graph + std::string file_prefix = "t" + std::to_string(k) + "n" + std::to_string(n); + CGAL::gnuplot_output_2(g, file_prefix); + + return 0; +} diff --git a/Cone_spanners_2/test/Cone_spanners_2/yao_exact.cmd b/Cone_spanners_2/test/Cone_spanners_2/yao_exact.cmd new file mode 100644 index 00000000000..b4446988c08 --- /dev/null +++ b/Cone_spanners_2/test/Cone_spanners_2/yao_exact.cmd @@ -0,0 +1 @@ +4 data/n20.cin diff --git a/Cone_spanners_2/test/Cone_spanners_2/yao_exact.cpp b/Cone_spanners_2/test/Cone_spanners_2/yao_exact.cpp new file mode 100644 index 00000000000..2105cc4218e --- /dev/null +++ b/Cone_spanners_2/test/Cone_spanners_2/yao_exact.cpp @@ -0,0 +1,79 @@ +/** @file yao_exact.cpp + * + * A test application that constructs a Yao graph exactly with the vertex list given + * in a file, and then generates the Gnuplot files to plot the constructed Yao graph. + * + * Authors: Weisheng Si, Quincy Tse, Western Sydney University + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// select the kernel type +typedef CGAL::Exact_predicates_exact_constructions_kernel_with_root_of Kernel; +typedef Kernel::Point_2 Point_2; +typedef Kernel::Direction_2 Direction_2; +typedef boost::adjacency_list Graph; + +int main(int argc, char ** argv) { + + if (argc < 3) { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + unsigned long k = atol(argv[1]); + if (k<2) { + std::cout << "The number of cones should be larger than 1!" << std::endl; + return 1; + } + + // open the file containing the vertex list + std::ifstream inf(argv[2]); + if (!inf) { + std::cout << "Cannot open file " << argv[2] << "!" << std::endl; + return 1; + } + + Direction_2 initial_direction; + if (argc == 3) + initial_direction = Direction_2(1, 0); // default initial_direction + else if (argc == 5) + initial_direction = Direction_2(atof(argv[3]), atof(argv[4])); + else { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + // iterators for reading the vertex list file + std::istream_iterator input_begin( inf ); + std::istream_iterator input_end; + + // initialize the functor + CGAL::Construct_yao_graph_2 yao(k, initial_direction); + // create an adjacency_list object + Graph g; + // construct the yao graph on the vertex list + yao(input_begin, input_end, g); + + // obtain the number of vertices in the constructed graph + unsigned int n = boost::num_vertices(g); + + // generate gnuplot files for plotting this graph + std::string fileprefix = "y" + std::to_string(k) + "n" + std::to_string(n); + CGAL::gnuplot_output_2(g, fileprefix); + + return 0; +} diff --git a/Cone_spanners_2/test/Cone_spanners_2/yao_inexact.cmd b/Cone_spanners_2/test/Cone_spanners_2/yao_inexact.cmd new file mode 100644 index 00000000000..ddce4442855 --- /dev/null +++ b/Cone_spanners_2/test/Cone_spanners_2/yao_inexact.cmd @@ -0,0 +1 @@ +4 data/n9.cin diff --git a/Cone_spanners_2/test/Cone_spanners_2/yao_inexact.cpp b/Cone_spanners_2/test/Cone_spanners_2/yao_inexact.cpp new file mode 100644 index 00000000000..eb3a6e80e4d --- /dev/null +++ b/Cone_spanners_2/test/Cone_spanners_2/yao_inexact.cpp @@ -0,0 +1,79 @@ +/** @file yao_inexact.cpp + * + * A test application that constructs a Yao graph inexactly with the vertex list given + * in a file, and then generates the Gnuplot files to plot the constructed Yao graph. + * + * Authors: Weisheng Si, Quincy Tse, Western Sydney University + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// select the kernel type +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_2 Point_2; +typedef Kernel::Direction_2 Direction_2; +typedef boost::adjacency_list Graph; + +int main(int argc, char ** argv) { + + if (argc < 3) { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + unsigned long k = atol(argv[1]); + if (k<2) { + std::cout << "The number of cones should be larger than 1!" << std::endl; + return 1; + } + + // open the file containing the vertex list + std::ifstream inf(argv[2]); + if (!inf) { + std::cout << "Cannot open file " << argv[2] << "!" << std::endl; + return 1; + } + + Direction_2 initial_direction; + if (argc == 3) + initial_direction = Direction_2(1, 0); // default initial_direction + else if (argc == 5) + initial_direction = Direction_2(atof(argv[3]), atof(argv[4])); + else { + std::cout << "Usage: " << argv[0] << " [ ]" << std::endl; + return 1; + } + + // iterators for reading the vertex list file + std::istream_iterator input_begin( inf ); + std::istream_iterator input_end; + + // initialize the functor + CGAL::Construct_yao_graph_2 yao(k, initial_direction); + // create an adjacency_list object + Graph g; + // construct the yao graph on the vertex list + yao(input_begin, input_end, g); + + // obtain the number of vertices in the constructed graph + unsigned int n = boost::num_vertices(g); + + // generate gnuplot files for plotting this graph + std::string fileprefix = "y" + std::to_string(k) + "n" + std::to_string(n); + CGAL::gnuplot_output_2(g, fileprefix); + + return 0; +}