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

@ -40,11 +40,13 @@ void paradiseo::smp::Star::operator()(unsigned nbNode, std::vector<std::vector<b
std::vector<bool> line (nbNode,false);
line[0]=true;
matrix.assign(nbNode-1,line);
line[_center]=true;
matrix.assign(nbNode,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;
};
}