Adding the choice of even or odd cones for half-theta/yao-graphs in cone spanners ipelet

This commit is contained in:
Frédérik Paradis 2016-12-01 15:57:34 -05:00
parent 8e71637b81
commit 6a68396aa2
2 changed files with 23 additions and 11 deletions

View File

@ -28,13 +28,15 @@ typedef boost::adjacency_list<boost::listS,
Point_2 Point_2
> Graph; > Graph;
const std::string labels[] = { "Theta-k-graph", "Yao-k-graph", "Half-theta-k-graph", "Half-Yao-k-graph", "k cones", "Help" }; const std::string labels[] = { "Theta-k-graph", "Yao-k-graph", "Half-theta-k-graph with even cones", "Half-Yao-k-graph with even cones", "Half-theta-k-graph with odd cones", "Half-Yao-k-graph with odd cones", "k cones", "Help" };
const std::string hmsg[] = { const std::string hmsg[] = {
"Compute a theta-graph with k cones.", "Draws a theta-graph with k cones.",
"Compute a Yao-graph with k cones.", "Draws a Yao-graph with k cones.",
"Compute an half-theta-graph with k cones.", "Draws an half-theta-graph with the even of k cones.",
"Compute an half-Yao-graph with k cones.", "Draws an half-Yao-graph with the even of k cones.",
"Draw k cones around the points.", "Draws an half-theta-graph with the odd of k cones.",
"Draws an half-Yao-graph with the odd of k cones.",
"Draws k cones around the points.",
}; };
class Cone_spanners_ipelet class Cone_spanners_ipelet
@ -56,6 +58,8 @@ void Cone_spanners_ipelet::protected_run(int fn)
case 2: case 2:
case 3: case 3:
case 4: case 4:
case 5:
case 6:
{ {
std::vector<Point_2> points_read; std::vector<Point_2> points_read;
read_active_objects( read_active_objects(
@ -84,18 +88,23 @@ void Cone_spanners_ipelet::protected_run(int fn)
} }
break; break;
} }
case 5: case 7:
show_help(); show_help();
return; return;
} }
if(fn >= 0 && fn <= 3) { if(fn >= 0 && fn <= 5) {
bool half = (fn == 2 || fn == 3); CGAL::Half half = CGAL::ALL_CONES;
if(fn == 2 || fn == 3)
half = CGAL::EVEN_CONES;
else if(fn == 4 || fn == 5)
half = CGAL::ODD_CONES;
Graph g; Graph g;
switch (fn){ switch (fn){
case 0: case 0:
case 2: case 2:
case 4:
{ {
CGAL::Construct_theta_graph_2<Kernel, Graph> theta(number_of_cones, Direction_2(1,0), half); CGAL::Construct_theta_graph_2<Kernel, Graph> theta(number_of_cones, Direction_2(1,0), half);
theta(lst.begin(), lst.end(), g); theta(lst.begin(), lst.end(), g);
@ -103,6 +112,7 @@ void Cone_spanners_ipelet::protected_run(int fn)
} }
case 1: case 1:
case 3: case 3:
case 5:
{ {
CGAL::Construct_yao_graph_2<Kernel, Graph> yao(number_of_cones, Direction_2(1,0), half); CGAL::Construct_yao_graph_2<Kernel, Graph> yao(number_of_cones, Direction_2(1,0), half);
yao(lst.begin(), lst.end(), g); yao(lst.begin(), lst.end(), g);

View File

@ -19,8 +19,10 @@ end
methods = { methods = {
{ label="Theta-k-graph" }, { label="Theta-k-graph" },
{ label="Yao-k-graph" }, { label="Yao-k-graph" },
{ label="Half-theta-k-graph" }, { label="Half-theta-k-graph with even cones" },
{ label="Half-Yao-k-graph" }, { label="Half-Yao-k-graph with even cones" },
{ label="Half-theta-k-graph with odd cones" },
{ label="Half-Yao-k-grap with odd cones" },
{ label="k cones" }, { label="k cones" },
{ label="Help" }, { label="Help" },
} }