-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into v1.17---Isomorphism
- Loading branch information
Showing
9 changed files
with
308 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
|
||
#include <boost/foreach.hpp> | ||
#include "include/Path.hh" | ||
#include "../model/include/HyperVertex.hh" | ||
#include "../model/include/HyperEdge.hh" | ||
|
||
Path::Path(boost::shared_ptr<HypergrapheAbstrait>& ptrHypergrapheAbstrait) : | ||
_ptrHypergrapheAbstrait( ptrHypergrapheAbstrait ), _limite(0) { | ||
} | ||
|
||
RStructure | ||
Path::getResult() const { | ||
return _result; | ||
} | ||
|
||
RStructurePath | ||
Path::getPathResult() const { | ||
return _result; | ||
} | ||
|
||
void | ||
Path::setLimit(unsigned int limite) { | ||
_limite = limite; | ||
} | ||
|
||
unsigned int | ||
Path::getLimit() const { | ||
return _limite; | ||
} | ||
|
||
void | ||
Path::setHyperVertex(boost::shared_ptr<HyperVertex>& source, boost::shared_ptr<HyperVertex>& destination) { | ||
_source = source; | ||
_destination = destination; | ||
} | ||
|
||
void Path::runAlgorithme() { | ||
|
||
LibType::PathList pathList( new boost::container::vector<LibType::ListHyperVertex>() ); | ||
|
||
if( _source == _destination ) { | ||
LibType::ListHyperVertex listHyperVertex; | ||
listHyperVertex.push_back( _source ); | ||
listHyperVertex.push_back( _destination ); | ||
_result.setPathResult(pathList); | ||
return; | ||
} | ||
|
||
LibType::ListHyperVertex toVisitVertex; | ||
LibType::ListHyperVertex visitedVertex; | ||
LibType::ListHyperVertex currentPath; | ||
|
||
toVisitVertex.push_back(_source); | ||
|
||
while( (toVisitVertex.size() > 0) && (_limite > pathList->size() || _limite==0) ) { | ||
|
||
boost::shared_ptr<HyperVertex> currentHyperVertex( toVisitVertex.back() ); | ||
visitedVertex.push_back( currentHyperVertex ); | ||
toVisitVertex.pop_back(); | ||
|
||
if( currentHyperVertex == _destination ) { | ||
currentPath.push_back( currentHyperVertex ); | ||
buildPathToPathList(pathList, currentPath); | ||
currentPath.clear(); | ||
currentHyperVertex = _source; | ||
toVisitVertex.clear(); | ||
toVisitVertex.push_back(_source); | ||
} | ||
|
||
for(unsigned int cn = 0; cn < currentHyperVertex->getHyperEdgeList().size(); cn++) { | ||
addVertexList(visitedVertex, toVisitVertex, currentHyperVertex->getHyperEdgeList().at(cn) ); | ||
} | ||
|
||
currentPath.push_back( currentHyperVertex ); | ||
} | ||
|
||
_result.setPathResult(pathList); | ||
} | ||
|
||
void | ||
Path::buildPathToPathList(LibType::PathList& pList, LibType::ListHyperVertex& vList) { | ||
|
||
LibType::ListHyperVertex tmpList; | ||
|
||
BOOST_FOREACH(boost::shared_ptr<HyperVertex> vPtr, vList) { | ||
tmpList.push_back(vPtr); | ||
} | ||
|
||
pList->push_back(tmpList); | ||
} | ||
|
||
void | ||
Path::addVertexList(LibType::ListHyperVertex& noListe, LibType::ListHyperVertex& liste, const boost::shared_ptr<HyperEdge>& hyperEdge) const { | ||
for(unsigned int i=0; i < hyperEdge->getHyperVertexList().size(); i++) { | ||
if( !vertexContained(noListe, hyperEdge->getHyperVertexList().at(i)) ) { | ||
liste.push_back( hyperEdge->getHyperVertexList().at(i) ); | ||
} | ||
} | ||
} | ||
|
||
bool | ||
Path::vertexContained(LibType::ListHyperVertex& liste, boost::shared_ptr<HyperVertex>& vertex) const { | ||
for(unsigned int i=0; i<liste.size(); i++) { | ||
if( vertex == liste.at(i) ) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
|
||
Path::~Path() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* Définition de l'algorithme décidant de l'ensemble des chemins dans un hypergraphe | ||
* reliant un Vertex e1 à un Vertex e2. | ||
*/ | ||
|
||
#ifndef ALGORITHM_INCLUDE_PATH_HH_ | ||
#define ALGORITHM_INCLUDE_PATH_HH_ | ||
|
||
#include "../../model/include/HypergrapheAbstrait.hh" | ||
#include "../../model/include/AlgorithmeAbstrait.hh" | ||
#include "../../model/include/RStructurePath.hh" | ||
|
||
class Path : public AlgorithmeAbstrait { | ||
|
||
public: | ||
|
||
/* | ||
* Constructeur. | ||
* @param boost::shared_ptr<HypergrapheAbstrait> Pointeur partagé vers l'hypergraphe. | ||
*/ | ||
Path(boost::shared_ptr<HypergrapheAbstrait>&); | ||
|
||
/** | ||
* Configurer les vertex à utiliser pour lister les chemins | ||
*/ | ||
void setHyperVertex(boost::shared_ptr<HyperVertex>&, boost::shared_ptr<HyperVertex>&); | ||
|
||
/** | ||
* Obtenir la structure de résultats. | ||
*/ | ||
RStructure getResult() const; | ||
|
||
/** | ||
* Obtenir la structure de résultats. | ||
*/ | ||
RStructurePath getPathResult() const; | ||
|
||
/** | ||
* Fixer la limite du nombre de chemins. Par défaut 0, non-définit. | ||
*/ | ||
void setLimit(unsigned int); | ||
|
||
/** | ||
* Lire la valeur limite. | ||
*/ | ||
unsigned int getLimit() const; | ||
|
||
/** | ||
* Destructeur. | ||
*/ | ||
~Path(); | ||
|
||
|
||
protected: | ||
|
||
/** | ||
* Lancement de l'algorithme | ||
*/ | ||
void runAlgorithme(); | ||
|
||
/** | ||
* Vérifie si l'HyperVertex est contenu dans la liste | ||
*/ | ||
bool vertexContained(LibType::ListHyperVertex&, boost::shared_ptr<HyperVertex>&) const; | ||
|
||
/** | ||
* Ajoute les HyperVertex d'un HyperEdge dans la liste mentionnée. | ||
*/ | ||
void addVertexList(LibType::ListHyperVertex&, LibType::ListHyperVertex&, const boost::shared_ptr<HyperEdge>&) const; | ||
|
||
|
||
void buildPathToPathList(LibType::PathList&, LibType::ListHyperVertex&); | ||
|
||
protected: | ||
|
||
/** | ||
* Pointeur partagé vers l'hypergraphe. | ||
*/ | ||
boost::shared_ptr<HypergrapheAbstrait> | ||
_ptrHypergrapheAbstrait; | ||
|
||
/** | ||
* Vertex source | ||
*/ | ||
boost::shared_ptr<HyperVertex> _source; | ||
|
||
/** | ||
* Vertex destination | ||
*/ | ||
boost::shared_ptr<HyperVertex> _destination; | ||
|
||
/** | ||
* Structure de résultat. | ||
*/ | ||
RStructurePath _result; | ||
|
||
/** | ||
* Valeur limite. | ||
*/ | ||
unsigned int _limite; | ||
}; | ||
|
||
|
||
#endif /* SRC_ALGORITHM_INCLUDE_PATH_HH_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.