mirror of https://github.com/CGAL/cgal
Adding an option to construct half-theta and half-Yao graphs
This commit is contained in:
parent
340133a0e4
commit
9e0fc621e5
|
|
@ -78,6 +78,9 @@ private:
|
||||||
/* Store the number of cones. */
|
/* Store the number of cones. */
|
||||||
unsigned int cone_number;
|
unsigned int cone_number;
|
||||||
|
|
||||||
|
/* Store wheter this is an half-theta graph */
|
||||||
|
bool half;
|
||||||
|
|
||||||
/* Store the directions of the rays dividing the plane. The initial direction will be
|
/* Store the directions of the rays dividing the plane. The initial direction will be
|
||||||
* stored in rays[0].
|
* stored in rays[0].
|
||||||
*/
|
*/
|
||||||
|
|
@ -90,10 +93,13 @@ public:
|
||||||
\param initial_direction A direction denoting one of the rays dividing the
|
\param initial_direction A direction denoting one of the rays dividing the
|
||||||
cones. This allows arbitary rotations of the rays that divide
|
cones. This allows arbitary rotations of the rays that divide
|
||||||
the plane. (default: positive x-axis)
|
the plane. (default: positive x-axis)
|
||||||
|
\param half_theta Indicates whether all the cones are used or just half of
|
||||||
|
them (default: all cones).
|
||||||
*/
|
*/
|
||||||
Construct_theta_graph_2 (unsigned int k,
|
Construct_theta_graph_2 (unsigned int k,
|
||||||
Direction_2 initial_direction = Direction_2(1,0)
|
Direction_2 initial_direction = Direction_2(1,0),
|
||||||
): cone_number(k), rays(std::vector<Direction_2>(k))
|
bool half_theta = false
|
||||||
|
): cone_number(k), rays(std::vector<Direction_2>(k)), half(half_theta)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (k<2) {
|
if (k<2) {
|
||||||
|
|
@ -131,7 +137,8 @@ public:
|
||||||
unsigned int j; // index of the ccw ray
|
unsigned int j; // index of the ccw ray
|
||||||
|
|
||||||
// add edges into the graph for every cone
|
// add edges into the graph for every cone
|
||||||
for (i = 0; i < cone_number; i++) {
|
int increment = half ? 2 : 1;
|
||||||
|
for (i = 0; i < cone_number; i += increment) {
|
||||||
j = (i+1) % cone_number;
|
j = (i+1) % cone_number;
|
||||||
add_edges_in_cone(rays[i], rays[j], g);
|
add_edges_in_cone(rays[i], rays[j], g);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,9 @@ private:
|
||||||
/* Store the number of cones. */
|
/* Store the number of cones. */
|
||||||
unsigned int cone_number;
|
unsigned int cone_number;
|
||||||
|
|
||||||
|
/* Store wheter this is an half-theta graph */
|
||||||
|
bool half;
|
||||||
|
|
||||||
/* Store the directions of the rays dividing the plane. The initial direction will be
|
/* Store the directions of the rays dividing the plane. The initial direction will be
|
||||||
stored in rays[0]. */
|
stored in rays[0]. */
|
||||||
std::vector<Direction_2> rays;
|
std::vector<Direction_2> rays;
|
||||||
|
|
@ -85,10 +88,13 @@ public:
|
||||||
\param initial_direction A direction denoting one of the rays dividing the
|
\param initial_direction A direction denoting one of the rays dividing the
|
||||||
cones. This allows arbitary rotations of the rays that divide
|
cones. This allows arbitary rotations of the rays that divide
|
||||||
the plane. (default: positive x-axis)
|
the plane. (default: positive x-axis)
|
||||||
|
\param half_yao Indicates whether all the cones are used or just half of
|
||||||
|
them (default: all cones).
|
||||||
*/
|
*/
|
||||||
Construct_yao_graph_2 (unsigned int k,
|
Construct_yao_graph_2 (unsigned int k,
|
||||||
Direction_2 initial_direction = Direction_2(1,0)
|
Direction_2 initial_direction = Direction_2(1,0),
|
||||||
): cone_number(k), rays(std::vector<Direction_2>(k))
|
bool half_yao = false
|
||||||
|
): cone_number(k), rays(std::vector<Direction_2>(k)), half(half_yao)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (k<2) {
|
if (k<2) {
|
||||||
|
|
@ -127,7 +133,8 @@ public:
|
||||||
unsigned int j; // index of the ccw ray
|
unsigned int j; // index of the ccw ray
|
||||||
|
|
||||||
// add edges into the graph for every cone
|
// add edges into the graph for every cone
|
||||||
for (i = 0; i < cone_number; i++) {
|
int increment = half ? 2 : 1;
|
||||||
|
for (i = 0; i < cone_number; i += increment) {
|
||||||
j = (i+1) % cone_number;
|
j = (i+1) % cone_number;
|
||||||
add_edges_in_cone(rays[i], rays[j], g);
|
add_edges_in_cone(rays[i], rays[j], g);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue