Consistency of names and guard in topology.h
This commit is contained in:
parent
95b7b80f19
commit
6b2a695622
11 changed files with 47 additions and 42 deletions
|
|
@ -50,15 +50,15 @@ public :
|
|||
|
||||
/**
|
||||
* Return a vector containing the index of nearby nodes according to the topology
|
||||
* @param idIsland index of the node of which you want the neighbors.
|
||||
* @param idNode index of the node of which you want the neighbors.
|
||||
*/
|
||||
virtual std::vector<unsigned> getIdNeighbors(unsigned idIsland) const =0;
|
||||
virtual std::vector<unsigned> getIdNeighbors(unsigned idNode) const =0;
|
||||
|
||||
/**
|
||||
* Construct or re-construct a topology with the given number of nodes.
|
||||
* @param nbIsland number of nodes for the topology
|
||||
* @param nbNode number of nodes for the topology
|
||||
*/
|
||||
virtual void construct(unsigned nbIsland) =0;
|
||||
virtual void construct(unsigned nbNode) =0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
#include <topology/complete.h>
|
||||
#include <vector>
|
||||
|
||||
void paradiseo::smp::Complete::operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const
|
||||
void paradiseo::smp::Complete::operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const
|
||||
{
|
||||
matrix.clear();
|
||||
std::vector<bool> line;
|
||||
line.assign(nbIsland,true);
|
||||
matrix.assign(nbIsland, line);
|
||||
for(int i=0;i<nbIsland;i++)
|
||||
line.assign(nbNode,true);
|
||||
matrix.assign(nbNode, line);
|
||||
for(int i=0;i<nbNode;i++)
|
||||
matrix[i][i]=false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public :
|
|||
/**
|
||||
*Fills the given matrix for a complete topology with the specified number of nodes.
|
||||
*/
|
||||
void operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const;
|
||||
void operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
#include <vector>
|
||||
#include <topology/ring.h>
|
||||
|
||||
void paradiseo::smp::Ring::operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const
|
||||
void paradiseo::smp::Ring::operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const
|
||||
{
|
||||
matrix.clear();
|
||||
std::vector<bool> line;
|
||||
line.assign(nbIsland, false);
|
||||
matrix.assign(nbIsland, line);
|
||||
line.assign(nbNode, false);
|
||||
matrix.assign(nbNode, line);
|
||||
|
||||
for(int i=0; i<nbIsland;i++)
|
||||
matrix[i][(i+1)%nbIsland]=true;
|
||||
for(int i=0; i<nbNode;i++)
|
||||
matrix[i][(i+1)%nbNode]=true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public :
|
|||
/**
|
||||
*Fills the given matrix for a ring topology with the specified number of nodes.
|
||||
*/
|
||||
void operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const;
|
||||
void operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,16 +30,16 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
#include <vector>
|
||||
#include <topology/star.h>
|
||||
|
||||
void paradiseo::smp::Star::operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const
|
||||
void paradiseo::smp::Star::operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const
|
||||
{
|
||||
matrix.clear();
|
||||
std::vector<bool> line (nbIsland,false);
|
||||
std::vector<bool> line (nbNode,false);
|
||||
|
||||
line[0]=true;
|
||||
matrix.assign(nbIsland-1,line);
|
||||
matrix.assign(nbNode-1,line);
|
||||
|
||||
line.clear();
|
||||
line.assign(nbIsland, false);
|
||||
line.assign(nbNode, false);
|
||||
std::vector<std::vector<bool>>::iterator it = matrix.begin();
|
||||
matrix.insert(it, line);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public :
|
|||
/**
|
||||
*Fills the given matrix for a star topology with the specified number of nodes.
|
||||
*/
|
||||
void operator()(unsigned nbIsland, std::vector<std::vector<bool>>& matrix) const;
|
||||
void operator()(unsigned nbNode, std::vector<std::vector<bool>>& matrix) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,17 +31,17 @@ Contact: paradiseo-help@lists.gforge.inria.fr
|
|||
#include <vector>
|
||||
|
||||
template <class TopologyType>
|
||||
std::vector<unsigned> paradiseo::smp::Topology<TopologyType>::getIdNeighbors(unsigned idIsland) const
|
||||
std::vector<unsigned> paradiseo::smp::Topology<TopologyType>::getIdNeighbors(unsigned idNode) const
|
||||
{
|
||||
std::vector<unsigned> neighbors;
|
||||
for(unsigned j=0; j<_matrix.size();j++)
|
||||
if(_matrix[idIsland][j]) neighbors.push_back(j);
|
||||
if(_matrix[idNode][j]) neighbors.push_back(j);
|
||||
|
||||
return neighbors;
|
||||
}
|
||||
|
||||
template <class TopologyType>
|
||||
void paradiseo::smp::Topology<TopologyType>::construct(unsigned nbIsland)
|
||||
void paradiseo::smp::Topology<TopologyType>::construct(unsigned nbNode)
|
||||
{
|
||||
_builder(nbIsland, _matrix);
|
||||
_builder(nbNode, _matrix);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
|||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
|
||||
#ifndef TOPOLOGY_H_
|
||||
#define TOPOLOGY_H_
|
||||
|
||||
#include <vector>
|
||||
#include <topology/abstractTopology.h>
|
||||
|
||||
|
|
@ -57,13 +60,13 @@ public :
|
|||
* Inherited from AbstractTopology
|
||||
* @see smp::topology::AbstractTopology::getIdNeighbors
|
||||
*/
|
||||
std::vector<unsigned> getIdNeighbors(unsigned idIsland) const;
|
||||
std::vector<unsigned> getIdNeighbors(unsigned idNode) const;
|
||||
|
||||
/**
|
||||
* Inherited from AbstractTopology : construct or re-construct a topology with the given number of nodes
|
||||
* @param nbIsland number of nodes for the topology
|
||||
* @param nbNode number of nodes for the topology
|
||||
*/
|
||||
void construct(unsigned nbIsland);
|
||||
void construct(unsigned nbNode);
|
||||
|
||||
private :
|
||||
|
||||
|
|
@ -76,3 +79,5 @@ private :
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
<abstractIsland.h>
|
||||
<abstractNode.h>
|
||||
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
|
||||
|
||||
Alexandre Quemy, Thibault Lasnier - INSA Rouen
|
||||
|
|
@ -48,7 +48,7 @@ public :
|
|||
*Build th topology with the given number of nodes in the matrix.
|
||||
*@see smp::topology::Ring, smp::topology::Star, smp::topology::Complete
|
||||
**/
|
||||
virtual void operator()(unsigned _nbIsland, std::vector<std::vector<bool>>& _matrix) const = 0;
|
||||
virtual void operator()(unsigned _nbNode, std::vector<std::vector<bool>>& _matrix) const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,25 +16,25 @@ int main()
|
|||
Topology<Complete> topo_comp;
|
||||
topo_comp.construct(n);
|
||||
|
||||
std::cout << std::endl << "---------------" << std::endl << "Test of Complete Topology (" << n <<" islands) :"<<std::endl;
|
||||
std::cout << std::endl << "---------------" << std::endl << "Test of Complete Topology (" << n <<" nodes) :"<<std::endl;
|
||||
|
||||
std::vector<unsigned> neighbors=topo_comp.getIdNeighbors(1);
|
||||
std::cout << "neighbors of Island 1 : "<<std::endl;
|
||||
std::cout << "neighbors of Node 1 : "<<std::endl;
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
|
||||
neighbors=topo_comp.getIdNeighbors(2);
|
||||
std::cout <<std::endl << "Neighbors of Island 2 : "<<std::endl;
|
||||
std::cout <<std::endl << "Neighbors of Node 2 : "<<std::endl;
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
||||
//Re-construct Topology with different number of islands
|
||||
//Re-construct Topology with different number of nodes
|
||||
n=3;
|
||||
topo_comp.construct(n);
|
||||
neighbors=topo_comp.getIdNeighbors(2);
|
||||
std::cout <<"Changing number of islands to "<< n <<" : "<<std::endl;
|
||||
std::cout <<std::endl << "Neighbors of Island 2 : "<<std::endl;
|
||||
std::cout <<"Changing number of nodes to "<< n <<" : "<<std::endl;
|
||||
std::cout <<std::endl << "Neighbors of Node 2 : "<<std::endl;
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
|
@ -45,16 +45,16 @@ int main()
|
|||
Topology<Star> topo_star;
|
||||
topo_star.construct(n);
|
||||
|
||||
std::cout << std::endl << "---------------" << std::endl << "Test of Star Topology (" << n <<" islands) :" << std::endl;
|
||||
std::cout << std::endl << "---------------" << std::endl << "Test of Star Topology (" << n <<" nodes) :" << std::endl;
|
||||
|
||||
neighbors=topo_star.getIdNeighbors(0);
|
||||
std::cout <<std::endl << "Neighbors of Island 0 : "<<std::endl;
|
||||
std::cout <<std::endl << "Neighbors of Node 0 : "<<std::endl;
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
||||
neighbors=topo_star.getIdNeighbors(1);
|
||||
std::cout <<std::endl << "Neighbors of Island 1 : "<<std::endl;
|
||||
std::cout <<std::endl << "Neighbors of Node 1 : "<<std::endl;
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
|
@ -64,22 +64,22 @@ int main()
|
|||
Topology<Ring> topo_ring;
|
||||
topo_ring.construct(n);
|
||||
|
||||
std::cout << std::endl << "---------------" << std::endl << "Test of Ring Topology (" << n <<" islands) :" << std::endl;
|
||||
std::cout << std::endl << "---------------" << std::endl << "Test of Ring Topology (" << n <<" nodes) :" << std::endl;
|
||||
|
||||
neighbors=topo_ring.getIdNeighbors(4);
|
||||
std::cout <<std::endl << "Neighbors of Island 4 : "<<std::endl;
|
||||
std::cout <<std::endl << "Neighbors of Node 4 : "<<std::endl;
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
||||
neighbors=topo_ring.getIdNeighbors(7);
|
||||
std::cout <<std::endl << "Neighbors of Island 7 : "<<std::endl;
|
||||
std::cout <<std::endl << "Neighbors of Node 7 : "<<std::endl;
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
||||
neighbors=topo_ring.getIdNeighbors(0);
|
||||
std::cout <<std::endl << "Neighbors of Island 0 : "<<std::endl;
|
||||
std::cout <<std::endl << "Neighbors of Node 0 : "<<std::endl;
|
||||
for (int i=0; i < neighbors.size(); i++)
|
||||
std::cout << " " << neighbors[i];
|
||||
std::cout << std::endl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue