From 44e25b1406a6359dd4ab6f7a7b68c87acc132278 Mon Sep 17 00:00:00 2001 From: lasnier Date: Fri, 23 Nov 2012 21:27:39 +0100 Subject: [PATCH] Add of isolateNode method --- smp/src/topology/abstractTopology.h | 6 ++++ smp/src/topology/topology.cpp | 16 ++++++++-- smp/src/topology/topology.h | 6 ++++ smp/test/t-smpTopo.cpp | 45 +++++++++++++++++++++++++---- 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/smp/src/topology/abstractTopology.h b/smp/src/topology/abstractTopology.h index bd20209ef..0265f4961 100644 --- a/smp/src/topology/abstractTopology.h +++ b/smp/src/topology/abstractTopology.h @@ -59,6 +59,12 @@ public : * @param nbNode number of nodes for the topology */ 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; }; } diff --git a/smp/src/topology/topology.cpp b/smp/src/topology/topology.cpp index 70e876ae2..2046e797b 100644 --- a/smp/src/topology/topology.cpp +++ b/smp/src/topology/topology.cpp @@ -28,8 +28,6 @@ Contact: paradiseo-help@lists.gforge.inria.fr */ -#include - template std::vector paradiseo::smp::Topology::getIdNeighbors(unsigned idNode) const { @@ -45,3 +43,17 @@ void paradiseo::smp::Topology::construct(unsigned nbNode) { _builder(nbNode, _matrix); } + + +template +void paradiseo::smp::Topology::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; + } +} diff --git a/smp/src/topology/topology.h b/smp/src/topology/topology.h index d6f05296b..5981c01c4 100644 --- a/smp/src/topology/topology.h +++ b/smp/src/topology/topology.h @@ -68,6 +68,12 @@ public : */ 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 : TopologyType _builder; diff --git a/smp/test/t-smpTopo.cpp b/smp/test/t-smpTopo.cpp index e827f3386..f1ad4ffc7 100644 --- a/smp/test/t-smpTopo.cpp +++ b/smp/test/t-smpTopo.cpp @@ -20,26 +20,50 @@ int main() std::vector neighbors=topo_comp.getIdNeighbors(1); std::cout << "neighbors of Node 1 : "< topo_star; @@ -49,16 +73,21 @@ int main() neighbors=topo_star.getIdNeighbors(0); std::cout < topo_ring; @@ -68,18 +97,24 @@ int main() neighbors=topo_ring.getIdNeighbors(4); std::cout <