Add the possibility of changing the center of Star Topology

This commit is contained in:
lasnier 2012-12-04 17:41:15 +01:00
commit 7b195096f3
2 changed files with 24 additions and 11 deletions

View file

@ -32,19 +32,21 @@ Contact: paradiseo-help@lists.gforge.inria.fr
void paradiseo::smp::Star::operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const
{
matrix.clear();
matrix.clear();
matrix.resize(nbNode);
matrix.resize(nbNode);
for(auto& line : matrix)
line.resize(nbNode);
std::vector<bool> line (nbNode,false);
std::vector<bool> 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<std::vector<bool>>::iterator it = matrix.begin();
matrix.insert(it, line);
matrix[_center][_center]=false;
}
void paradiseo::smp::Star::setCenter(unsigned c)
{
_center=c;
}

View file

@ -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<std::vector<bool>>& 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;
};
}