Adding an option to construct half-theta and half-Yao graphs

This commit is contained in:
Frédérik Paradis 2016-11-08 13:53:32 -05:00
parent 340133a0e4
commit 9e0fc621e5
2 changed files with 26 additions and 12 deletions

View File

@ -78,6 +78,9 @@ private:
/* Store the number of cones. */
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
* stored in rays[0].
*/
@ -90,10 +93,13 @@ public:
\param initial_direction A direction denoting one of the rays dividing the
cones. This allows arbitary rotations of the rays that divide
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,
Direction_2 initial_direction = Direction_2(1,0)
): cone_number(k), rays(std::vector<Direction_2>(k))
Direction_2 initial_direction = Direction_2(1,0),
bool half_theta = false
): cone_number(k), rays(std::vector<Direction_2>(k)), half(half_theta)
{
if (k<2) {
@ -131,7 +137,8 @@ public:
unsigned int j; // index of the ccw ray
// 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;
add_edges_in_cone(rays[i], rays[j], g);
}

View File

@ -73,6 +73,9 @@ private:
/* Store the number of cones. */
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
stored in rays[0]. */
std::vector<Direction_2> rays;
@ -85,10 +88,13 @@ public:
\param initial_direction A direction denoting one of the rays dividing the
cones. This allows arbitary rotations of the rays that divide
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,
Direction_2 initial_direction = Direction_2(1,0)
): cone_number(k), rays(std::vector<Direction_2>(k))
Direction_2 initial_direction = Direction_2(1,0),
bool half_yao = false
): cone_number(k), rays(std::vector<Direction_2>(k)), half(half_yao)
{
if (k<2) {
@ -127,7 +133,8 @@ public:
unsigned int j; // index of the ccw ray
// 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;
add_edges_in_cone(rays[i], rays[j], g);
}