Add of isolateNode method
This commit is contained in:
parent
6b2a695622
commit
44e25b1406
4 changed files with 66 additions and 7 deletions
|
|
@ -59,6 +59,12 @@ public :
|
||||||
* @param nbNode number of nodes for the topology
|
* @param nbNode number of nodes for the topology
|
||||||
*/
|
*/
|
||||||
virtual void construct(unsigned nbNode) =0;
|
virtual void construct(unsigned nbNode) =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Changes the topology : removes any connection from/to the given node.
|
||||||
|
*@param idNode index of the node to be isolated
|
||||||
|
*/
|
||||||
|
virtual void isolateNode(unsigned idNode) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,6 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
template <class TopologyType>
|
template <class TopologyType>
|
||||||
std::vector<unsigned> paradiseo::smp::Topology<TopologyType>::getIdNeighbors(unsigned idNode) const
|
std::vector<unsigned> paradiseo::smp::Topology<TopologyType>::getIdNeighbors(unsigned idNode) const
|
||||||
{
|
{
|
||||||
|
|
@ -45,3 +43,17 @@ void paradiseo::smp::Topology<TopologyType>::construct(unsigned nbNode)
|
||||||
{
|
{
|
||||||
_builder(nbNode, _matrix);
|
_builder(nbNode, _matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class TopologyType>
|
||||||
|
void paradiseo::smp::Topology<TopologyType>::isolateNode(unsigned idNode)
|
||||||
|
{
|
||||||
|
for(int i=0;i<_matrix.size();i++)
|
||||||
|
{
|
||||||
|
//Line of idNode to false : no connection FROM this node
|
||||||
|
_matrix[idNode][i]=false;
|
||||||
|
|
||||||
|
//Column of idNode to false : no connection TO this node
|
||||||
|
_matrix[i][idNode]=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,12 @@ public :
|
||||||
*/
|
*/
|
||||||
void construct(unsigned nbNode);
|
void construct(unsigned nbNode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Inherited from AbstractTopology : changes the topology : removes any connection from/to the given node.
|
||||||
|
*@param idNode index of the node to be isolated
|
||||||
|
*/
|
||||||
|
void isolateNode(unsigned idNode);
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
TopologyType _builder;
|
TopologyType _builder;
|
||||||
|
|
|
||||||
|
|
@ -20,26 +20,50 @@ int main()
|
||||||
|
|
||||||
std::vector<unsigned> neighbors=topo_comp.getIdNeighbors(1);
|
std::vector<unsigned> neighbors=topo_comp.getIdNeighbors(1);
|
||||||
std::cout << "neighbors of Node 1 : "<<std::endl;
|
std::cout << "neighbors of Node 1 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
|
|
||||||
neighbors=topo_comp.getIdNeighbors(2);
|
neighbors=topo_comp.getIdNeighbors(2);
|
||||||
std::cout <<std::endl << "Neighbors of Node 2 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 2 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
//Isolate an node
|
||||||
|
topo_comp.isolateNode(2);
|
||||||
|
neighbors=topo_comp.getIdNeighbors(2);
|
||||||
|
std::cout <<std::endl << "Neighbors of Node 2 after isolation : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
|
std::cout << " " << neighbors[i];
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
neighbors=topo_comp.getIdNeighbors(3);
|
||||||
|
std::cout <<"Neighbors of Node 3 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
|
std::cout << " " << neighbors[i];
|
||||||
|
std::cout << std::endl;
|
||||||
|
|
||||||
//Re-construct Topology with different number of nodes
|
//Re-construct Topology with different number of nodes
|
||||||
n=3;
|
n=3;
|
||||||
topo_comp.construct(n);
|
topo_comp.construct(n);
|
||||||
neighbors=topo_comp.getIdNeighbors(2);
|
neighbors=topo_comp.getIdNeighbors(2);
|
||||||
std::cout <<"Changing number of nodes to "<< n <<" : "<<std::endl;
|
std::cout <<"Changing number of nodes to "<< n <<",";
|
||||||
std::cout <<std::endl << "Neighbors of Node 2 : "<<std::endl;
|
std::cout <<"Neighbors of Node 2 : "<<std::endl;
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//Test of Star Topology
|
//Test of Star Topology
|
||||||
n=4;
|
n=4;
|
||||||
Topology<Star> topo_star;
|
Topology<Star> topo_star;
|
||||||
|
|
@ -49,16 +73,21 @@ int main()
|
||||||
|
|
||||||
neighbors=topo_star.getIdNeighbors(0);
|
neighbors=topo_star.getIdNeighbors(0);
|
||||||
std::cout <<std::endl << "Neighbors of Node 0 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 0 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
neighbors=topo_star.getIdNeighbors(1);
|
neighbors=topo_star.getIdNeighbors(1);
|
||||||
std::cout <<std::endl << "Neighbors of Node 1 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 1 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
//Test of Ring Topology
|
//Test of Ring Topology
|
||||||
n=8;
|
n=8;
|
||||||
Topology<Ring> topo_ring;
|
Topology<Ring> topo_ring;
|
||||||
|
|
@ -68,18 +97,24 @@ int main()
|
||||||
|
|
||||||
neighbors=topo_ring.getIdNeighbors(4);
|
neighbors=topo_ring.getIdNeighbors(4);
|
||||||
std::cout <<std::endl << "Neighbors of Node 4 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 4 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
neighbors=topo_ring.getIdNeighbors(7);
|
neighbors=topo_ring.getIdNeighbors(7);
|
||||||
std::cout <<std::endl << "Neighbors of Node 7 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 7 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
||||||
neighbors=topo_ring.getIdNeighbors(0);
|
neighbors=topo_ring.getIdNeighbors(0);
|
||||||
std::cout <<std::endl << "Neighbors of Node 0 : "<<std::endl;
|
std::cout <<std::endl << "Neighbors of Node 0 : "<<std::endl;
|
||||||
|
if(neighbors.empty())
|
||||||
|
std::cout <<"None";
|
||||||
for (int i=0; i < neighbors.size(); i++)
|
for (int i=0; i < neighbors.size(); i++)
|
||||||
std::cout << " " << neighbors[i];
|
std::cout << " " << neighbors[i];
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue