diff --git a/smp/src/topology/star.cpp b/smp/src/topology/star.cpp index 1328d4937..08c911d73 100644 --- a/smp/src/topology/star.cpp +++ b/smp/src/topology/star.cpp @@ -32,19 +32,21 @@ Contact: paradiseo-help@lists.gforge.inria.fr void paradiseo::smp::Star::operator()(unsigned nbNode, std::vector>& matrix) const { - matrix.clear(); + matrix.clear(); - matrix.resize(nbNode); + matrix.resize(nbNode); for(auto& line : matrix) line.resize(nbNode); + + std::vector line (nbNode,false); - std::vector line (nbNode,false); + line[_center]=true; + matrix.assign(nbNode,line); - line[0]=true; - matrix.assign(nbNode-1,line); - - line.clear(); - line.assign(nbNode, false); - std::vector>::iterator it = matrix.begin(); - matrix.insert(it, line); + matrix[_center][_center]=false; +} + +void paradiseo::smp::Star::setCenter(unsigned c) +{ + _center=c; } diff --git a/smp/src/topology/star.h b/smp/src/topology/star.h index 079573e70..9ecc4443d 100644 --- a/smp/src/topology/star.h +++ b/smp/src/topology/star.h @@ -39,7 +39,7 @@ namespace smp { /** -*Star: Inherit from TopologyBuilder. Reprents a builder for a star topology : each node excepted the first has every other node for neighor. The first node doesn't have any neighbor. +*Star: Inherit from TopologyBuilder. Represents a builder for a star topology : each node excepted the center has every other node for neighor. The center node doesn't have any neighbor. The center is the first node by default. */ class Star : public TopologyBuilder { @@ -48,6 +48,17 @@ public : *Fills the given matrix for a star topology with the specified number of nodes. */ void operator()(unsigned nbNode, std::vector>& matrix) const; + + /** + *Setter for the variable _center + */ + void setCenter(unsigned c); + +private : + /** + *Index of the node which is the center. The change will not be done before next construction of the topology. + */ + unsigned _center=0; }; }