├── CMakeLists.txt ├── FindGecode.cmake ├── LICENSE ├── README.md ├── demo ├── CMakeLists.txt ├── Client.cpp ├── RandomHypergraphe.cpp └── include │ ├── Client.hh │ └── RandomHypergraphe.hh ├── doxyfile ├── include └── Hypergraph │ ├── algorithm │ ├── Connected.hh │ ├── Diameter.hh │ ├── Dual.hh │ ├── Helly.hh │ ├── HyperGraphStat.hh │ ├── Isomorph.hh │ ├── IsomorphSpace.hh │ ├── Linear.hh │ ├── Path.hh │ ├── Simple.hh │ ├── kRegular.hh │ └── kUniform.hh │ ├── io │ ├── ReaderAbstrait.hh │ ├── ReaderFile.hh │ ├── WriterAbstrait.hh │ └── WriterFile.hh │ └── model │ ├── AdjacentMatrix.hh │ ├── AlgorithmeAbstrait.hh │ ├── HyperEdge.hh │ ├── HyperFactory.hh │ ├── HyperVertex.hh │ ├── Hypergraphe.hh │ ├── HypergrapheAbstrait.hh │ ├── LibType.hh │ ├── MotorAlgorithm.hh │ ├── RStructure.hh │ └── RStructurePath.hh ├── src ├── CMakeLists.txt ├── algorithm │ ├── Connected.cpp │ ├── Diameter.cpp │ ├── Dual.cpp │ ├── Helly.cpp │ ├── HyperGraphStat.cpp │ ├── Isomorph.cpp │ ├── IsomorphSpace.cpp │ ├── Linear.cpp │ ├── Path.cpp │ ├── Simple.cpp │ ├── include │ │ ├── Connected.hh │ │ ├── Diameter.hh │ │ ├── Dual.hh │ │ ├── Helly.hh │ │ ├── HyperGraphStat.hh │ │ ├── Isomorph.hh │ │ ├── IsomorphSpace.hh │ │ ├── Linear.hh │ │ ├── Path.hh │ │ ├── Simple.hh │ │ ├── kRegular.hh │ │ └── kUniform.hh │ ├── kRegular.cpp │ └── kUniform.cpp ├── io │ ├── ReaderAbstrait.cpp │ ├── ReaderFile.cpp │ ├── WriterAbstrait.cpp │ ├── WriterFile.cpp │ └── include │ │ ├── ReaderAbstrait.hh │ │ ├── ReaderFile.hh │ │ ├── WriterAbstrait.hh │ │ └── WriterFile.hh ├── lib │ └── LightTreeLib.hpp └── model │ ├── AdjacentMatrix.cpp │ ├── AlgorithmeAbstrait.cpp │ ├── HyperEdge.cpp │ ├── HyperFactory.cpp │ ├── HyperVertex.cpp │ ├── Hypergraphe.cpp │ ├── HypergrapheAbstrait.cpp │ ├── MotorAlgorithm.cpp │ ├── RStructure.cpp │ ├── RStructurePath.cpp │ └── include │ ├── AdjacentMatrix.hh │ ├── AlgorithmeAbstrait.hh │ ├── HyperEdge.hh │ ├── HyperFactory.hh │ ├── HyperVertex.hh │ ├── Hypergraphe.hh │ ├── HypergrapheAbstrait.hh │ ├── LibType.hh │ ├── MotorAlgorithm.hh │ ├── RStructure.hh │ └── RStructurePath.hh └── test ├── CMakeLists.txt ├── test.cpp ├── test_algorithm.cpp └── test_io.cpp /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required( VERSION 2.8 ) 2 | 3 | project(HYPERGRAPHLIB) 4 | 5 | find_package( Boost 1.54 ) 6 | find_package( Boost COMPONENTS program_options REQUIRED ) 7 | 8 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}") 9 | 10 | find_package(Gecode REQUIRED COMPONENTS kernel support int set driver flatzinc minimodel search) 11 | 12 | set(Boost_DEBUG off) 13 | 14 | set( CMAKE_CXX_FLAGS "-O3 -std=c++11" ) 15 | 16 | add_subdirectory(src) 17 | add_subdirectory(demo) 18 | add_subdirectory(test) 19 | 20 | 21 | -------------------------------------------------------------------------------- /FindGecode.cmake: -------------------------------------------------------------------------------- 1 | message(STATUS "Finding Gecode...") 2 | 3 | #Works under the assumption than when gecode is installed at least the kernel component exists 4 | # Look for the header file 5 | 6 | find_path(GECODE_INCLUDE_DIR NAMES gecode/kernel.hh) 7 | find_file(GECODE_CONFIG gecode/support/config.hpp) 8 | 9 | ## Extract the version 10 | if(GECODE_CONFIG) 11 | file(STRINGS ${GECODE_CONFIG} GECODE_LINE_VERSION REGEX "^#define GECODE_VERSION .*") 12 | string(REGEX MATCH "[0-9].[0-9].[0-9]" GECODE_VERSION ${GECODE_LINE_VERSION}) 13 | endif() 14 | 15 | message(STATUS " version found ${GECODE_VERSION}") 16 | 17 | # in this variable we will store all the libraries for the requested 18 | # components 19 | set(GECODE_LIBRARIES) 20 | 21 | # Look for the library 22 | find_library(GECODE_LIBRARY NAMES gecodekernel) 23 | find_library(GECODE_SUPPORT_LIBRARY NAMES gecodesupport) 24 | 25 | if(GECODE_LIBRARY AND GECODE_SUPPORT_LIBRARY) 26 | list(APPEND GECODE_LIBRARIES ${GECODE_LIBRARY} ${GECODE_SUPPORT_LIBRARY}) 27 | else() 28 | message("Main libraries of Gecode were not found") 29 | endif() 30 | 31 | # First try to find the main headers 32 | set(CMAKE_FIND_FRAMEWORK "NEVER") 33 | 34 | foreach(COMPONENT ${Gecode_FIND_COMPONENTS}) 35 | set(GECODE_${COMPONENT}__ gecode${COMPONENT}) 36 | # message(STATUS "${GECODE_${COMPONENT}__}") 37 | find_library(GECODE_${COMPONENT} ${GECODE_${COMPONENT}__}) 38 | if (GECODE_${COMPONENT}) 39 | message(STATUS " ${COMPONENT}: ${GECODE_${COMPONENT}}") 40 | list(APPEND GECODE_LIBRARIES ${GECODE_${COMPONENT}}) 41 | endif() 42 | endforeach() 43 | 44 | #message(STATUS "Gecode libraries: ${GECODE_LIBRARIES}") 45 | find_file(GECODE_VIMP gecode/kernel/var-imp.hpp) 46 | ## Detect if gecode has already support for CPRel. Sets variable GECODE_HAS_CPREL 47 | ## to Yes 48 | set(GECODE_CPREL_CLASS "CPRelVarImpBase") 49 | file(STRINGS ${GECODE_VIMP} GECODE_LINE_CPREL_CLASS 50 | REGEX "^.*class ${GECODE_CPREL_CLASS} .*") 51 | message(STATUS "Gecode class: ${GECODE_LINE_CPREL_CLASS}") 52 | list(LENGTH GECODE_LINE_CPREL_CLASS GECODE_CPREL_SUPPORT) 53 | 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2015 Alexis LE GOADEC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB psrce *.cpp) 2 | 3 | add_executable(demo ${psrce}) 4 | target_link_libraries (demo hypergraph) 5 | 6 | if(Boost_FOUND) 7 | include_directories(${Boost_INCLUDE_DIRS}) 8 | target_link_libraries(demo ${Boost_LIBRARIES}) 9 | endif() 10 | 11 | find_package(OpenMP) 12 | if (OPENMP_FOUND) 13 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 14 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 15 | endif() 16 | 17 | include_directories(${GECODE_INCLUDE_DIR}) 18 | target_link_libraries(demo ${GECODE_LIBRARIES}) 19 | 20 | -------------------------------------------------------------------------------- /demo/RandomHypergraphe.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "include/RandomHypergraphe.hh" 3 | #include "../include/Hypergraph/model/HyperFactory.hh" 4 | #include "../include/Hypergraph/model/Hypergraphe.hh" 5 | 6 | #include 7 | #include 8 | 9 | RandomHypergraphe::RandomHypergraphe() : _ptrHypergrapheAbstrait( new Hypergraphe ) { 10 | 11 | } 12 | 13 | void 14 | RandomHypergraphe::generateHypergraphe(unsigned int nbVertex, unsigned int nbEdge) { 15 | 16 | std::vector> listVertex; 17 | std::vector> listEdge; 18 | 19 | boost::random::mt19937 gen; 20 | gen.seed( std::time(0) ); 21 | 22 | boost::uniform_int<> uInt8Dist(0, std::numeric_limits::max()); 23 | boost::variate_generator< boost::mt19937&, boost::uniform_int<> > getRand(gen, uInt8Dist); 24 | 25 | HyperFactory::startSession( _ptrHypergrapheAbstrait ); 26 | 27 | for(unsigned int i=0; iaddHyperVertex( listVertex.at(i) ); 42 | } 43 | 44 | for(unsigned int i=0; iaddHyperEdge( listEdge.at(i) ); 46 | } 47 | 48 | HyperFactory::closeSession(); 49 | 50 | _ptrHypergrapheAbstrait->flush(); 51 | 52 | } 53 | 54 | boost::shared_ptr& 55 | RandomHypergraphe::getHypergraphe() { 56 | return _ptrHypergrapheAbstrait; 57 | } 58 | -------------------------------------------------------------------------------- /demo/include/Client.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #ifndef CLIENT_INCLUDE_CLIENT_HH_ 28 | #define CLIENT_INCLUDE_CLIENT_HH_ 29 | 30 | #define VERSION_MAJOR 2 31 | #define VERSION_MINOR 0 32 | #define VERSION_BUILD 0 33 | 34 | #define NewAlgorithm(a, b, c) boost::shared_ptr a( new b( c ) ); 35 | #define NewAlgorithm2(a, b, c, d) boost::shared_ptr a( new b( c , d ) ); 36 | 37 | 38 | #endif /* CLIENT_INCLUDE_CLIENT_HH_ */ 39 | -------------------------------------------------------------------------------- /demo/include/RandomHypergraphe.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #ifndef CLIENT_INCLUDE_RANDOMHYPERGRAPHE_HH_ 28 | #define CLIENT_INCLUDE_RANDOMHYPERGRAPHE_HH_ 29 | 30 | #include 31 | #include "../../include/Hypergraph/model/HypergrapheAbstrait.hh" 32 | 33 | class RandomHypergraphe { 34 | 35 | public: 36 | 37 | RandomHypergraphe(); 38 | 39 | void generateHypergraphe(unsigned int, unsigned int); 40 | 41 | boost::shared_ptr& 42 | getHypergraphe(); 43 | 44 | protected: 45 | 46 | boost::shared_ptr 47 | _ptrHypergrapheAbstrait; 48 | 49 | }; 50 | 51 | 52 | #endif /* CLIENT_INCLUDE_RANDOMHYPERGRAPHE_HH_ */ 53 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/Connected.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de l'algorithme décidant la connexité d'un hypergraphe. 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_CONNECTED_HH_ 30 | #define ALGORITHM_INCLUDE_CONNECTED_HH_ 31 | 32 | #include "../model/HypergrapheAbstrait.hh" 33 | #include "../model/AlgorithmeAbstrait.hh" 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | /** 40 | * Algorithme décidant la connexité d'un hypergraphe. 41 | */ 42 | class Connected : public AlgorithmeAbstrait { 43 | 44 | public: 45 | 46 | /** 47 | * Constructeur. 48 | * @param boost::shared_ptr Pointeur partagé vers l'hypergraphe. 49 | */ 50 | Connected(boost::shared_ptr&); 51 | 52 | /** 53 | * Obtenir la structure de résultats. 54 | */ 55 | RStructure getResult() const; 56 | 57 | /** 58 | * Destructeur. 59 | */ 60 | ~Connected(); 61 | 62 | 63 | protected: 64 | 65 | /** 66 | * Fonction de lancement de l'algorithme. 67 | */ 68 | void runAlgorithme(); 69 | 70 | /** 71 | * Exploration verticale d'un chemin de la matrice. 72 | * @param Vecteur des visités. 73 | * @param Pile des "à visiter". 74 | * @param Identifiant de la ligne. 75 | */ 76 | void exploreVertical(std::vector&, std::stack&, unsigned int); 77 | 78 | /** 79 | * Exploration horizontale d'un chemin dans la matrice. 80 | * @param Vecteur des visités. 81 | * @param Pile des "à visiter". 82 | * @param Identifiant de la colonne. 83 | */ 84 | void exploreHorizontal(std::vector&, std::stack&, unsigned int); 85 | 86 | /** 87 | * Vérifier si un hyper-vertex a déjà été visité. 88 | * @param Vecteur des hyper-vertex visités. 89 | * @param Identifiant à vérifier. 90 | * @return True si déjà visité, False sinon. 91 | */ 92 | bool isVertexVisited(std::vector&, unsigned int) const; 93 | 94 | /** 95 | * Vérifier si une hyper-arête a déjà été visitée. 96 | * @param Vecteur des hyper-arêtes visités. 97 | * @param Identifiant à vérifier. 98 | * @return True si déjà visité, False sinon. 99 | */ 100 | bool isEdgeVisited(std::vector&, unsigned int) const; 101 | 102 | /* 103 | 104 | bool isPath(HyperVertex&, HyperVertex&) const; 105 | 106 | bool isVisited(std::vector&, const HyperEdge&) const; 107 | 108 | */ 109 | 110 | 111 | protected: 112 | 113 | /** 114 | * Pointeur partagé vers l'hypergraphe. 115 | */ 116 | boost::shared_ptr 117 | _ptrHypergrapheAbstrait; 118 | 119 | /** 120 | * Structure de résultat. 121 | */ 122 | RStructure _result; 123 | 124 | }; 125 | 126 | 127 | #endif /* ALGORITHM_INCLUDE_CONNECTED_HH_ */ 128 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/Diameter.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #ifndef ALGORITHM_INCLUDE_DIAMETER_HH_ 28 | #define ALGORITHM_INCLUDE_DIAMETER_HH_ 29 | 30 | #include 31 | #include "../model/HypergrapheAbstrait.hh" 32 | #include "../model/AlgorithmeAbstrait.hh" 33 | 34 | 35 | class Diameter : public AlgorithmeAbstrait { 36 | 37 | public: 38 | 39 | Diameter(boost::shared_ptr&); 40 | 41 | RStructure getResult() const; 42 | 43 | ~Diameter(); 44 | 45 | 46 | protected: 47 | 48 | void runAlgorithme(); 49 | 50 | 51 | protected: 52 | 53 | boost::shared_ptr 54 | _ptrHypergrapheAbstrait; 55 | 56 | RStructure _result; 57 | 58 | }; 59 | 60 | 61 | 62 | #endif /* ALGORITHM_INCLUDE_DIAMETER_HH_ */ 63 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/Dual.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de l'algorithme du Dual de l'hypergraphe. 28 | */ 29 | 30 | #ifndef ALGORITHM_INCLUDE_DUAL_HH_ 31 | #define ALGORITHM_INCLUDE_DUAL_HH_ 32 | 33 | #include 34 | #include "../model/HypergrapheAbstrait.hh" 35 | #include "../model/AlgorithmeAbstrait.hh" 36 | 37 | /** 38 | * Algorithme du Dual de l'hypergraphe. 39 | */ 40 | class Dual : public AlgorithmeAbstrait { 41 | 42 | public: 43 | 44 | /** 45 | * Constructeur. 46 | * @param Pointeur partagé vers l'hypergraphe. 47 | */ 48 | Dual(const boost::shared_ptr&); 49 | 50 | /** 51 | * Obtenir la structure des résultats. 52 | * @return La structure des résultats. 53 | */ 54 | RStructure getResult() const; 55 | 56 | /** 57 | * Destructeur. 58 | */ 59 | ~Dual(); 60 | 61 | protected: 62 | 63 | /** 64 | * Lancement de l'algorithme 65 | */ 66 | void runAlgorithme(); 67 | 68 | protected: 69 | 70 | /** 71 | * Pointeur partagé vers l'hypergraphe. 72 | */ 73 | boost::shared_ptr 74 | _ptrHypergrapheAbstrait; 75 | 76 | /** 77 | * Pointeur partagé vers le dual de l'hypergraphe. 78 | */ 79 | boost::shared_ptr 80 | _ptrDualHypergraphe; 81 | 82 | /** 83 | * Structure de résultat. 84 | */ 85 | RStructure _result; 86 | 87 | }; 88 | 89 | 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/Helly.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de l'algorithme vérifiant la propriété de Helly dans l'hypergraphe. 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_HELLY_HH_ 30 | #define ALGORITHM_INCLUDE_HELLY_HH_ 31 | 32 | #include "../model/AlgorithmeAbstrait.hh" 33 | #include "../model/RStructure.hh" 34 | 35 | /** 36 | * Algorithme vérifiant la propriété de Helly dans l'hypergraphe. 37 | */ 38 | class Helly : public AlgorithmeAbstrait { 39 | 40 | public: 41 | 42 | /** 43 | * Constructeur. 44 | * @param Pointeur partagé vers l'hypergraphe. 45 | */ 46 | Helly(const boost::shared_ptr&); 47 | 48 | /** 49 | * Obtenir la structure des résultats. 50 | * @return La structure des résultats. 51 | */ 52 | RStructure getResult() const; 53 | 54 | /** 55 | * Déstructeur. 56 | */ 57 | ~Helly(); 58 | 59 | protected: 60 | 61 | /** 62 | * Lancement de l'algorithme. 63 | */ 64 | void runAlgorithme(); 65 | 66 | /** 67 | * Construit la liste des hyper-arête contienant les deux hyper-vertex. 68 | * @param Le premier hyper-vertex. 69 | * @param Le second hyper-vertex. 70 | * @return La liste des hyper-rêtes contennt les deux hyper-vertex. 71 | */ 72 | LibType::ListHyperEdge& allContainXY(boost::shared_ptr&, boost::shared_ptr&); 73 | 74 | /** 75 | * Vérifie si l'intersection entre les éléments de la liste n'est pas vide. 76 | * @param La liste des hyper-arêtes. 77 | * @return True s'il n'y a aucune intersection vide, False sinon. 78 | */ 79 | bool nonEmptyIntersection(LibType::ListHyperEdge&); 80 | 81 | /** 82 | * Vérifie si l'intersection entre ces deux hyper-arêtes n'est pas vide. 83 | * @param Première hyper-arête. 84 | * @param Seconde hyper-arête. 85 | * @return True s'il y a intersection non-vide, False sinon. 86 | */ 87 | bool nonEmptyBetween(boost::shared_ptr&, boost::shared_ptr&); 88 | 89 | /** 90 | * Vérifie si les deux hyper-vertex sont voisins. 91 | * @param Premier hyper-vertex. 92 | * @param Second hyper-vertex 93 | * @return True s'il sont voisin, False sinon. 94 | */ 95 | bool voisin(boost::shared_ptr&, boost::shared_ptr&); 96 | 97 | /** 98 | * Concaténation de deux listes d'hyper-arêtes. 99 | * @param Destination. 100 | * @param Source à concaténer. 101 | */ 102 | void concatenate(LibType::ListHyperEdge&, LibType::ListHyperEdge&); 103 | 104 | 105 | protected: 106 | 107 | /** 108 | * Pointeur partagé vers l'hypergraphe. 109 | */ 110 | boost::shared_ptr 111 | _ptrHypergrapheAbstrait; 112 | 113 | /** 114 | * Structure des résultats. 115 | */ 116 | RStructure _result; 117 | 118 | }; 119 | 120 | 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/HyperGraphStat.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de l'algorithme de génération des statistiques de l'hypergraphe. 28 | */ 29 | 30 | #ifndef ALGORITHM_INCLUDE_HPGSTAT 31 | #define ALGORITHM_INCLUDE_HPGSTAT 32 | 33 | #include 34 | #include "../model/HypergrapheAbstrait.hh" 35 | #include "../model/Hypergraphe.hh" 36 | #include "../model/HyperVertex.hh" 37 | #include "../model/HyperEdge.hh" 38 | #include "../model/AlgorithmeAbstrait.hh" 39 | #include "../model/RStructure.hh" 40 | 41 | 42 | /** 43 | * Algorithme de génération des statistiques de l'hypergraphe. 44 | */ 45 | class HyperGraphStat : public AlgorithmeAbstrait { 46 | 47 | public: 48 | 49 | /** 50 | * Constructeur. 51 | * @param Pointeur partagé vers l'hypergraphe. 52 | */ 53 | HyperGraphStat(const boost::shared_ptr&); 54 | 55 | /** 56 | * Obtenir la structure des résultats - inutilisé ici. 57 | * @return La structure des résultats - inutilisé ici. 58 | */ 59 | RStructure getResult() const; 60 | 61 | /** 62 | * Destructeur. 63 | */ 64 | ~HyperGraphStat(); 65 | 66 | 67 | public: 68 | 69 | /** 70 | * Obtenir le nombre d'hyper-arêtes. 71 | */ 72 | unsigned int getNbrHyperEdge() const; 73 | 74 | /** 75 | * Obtenir le nombre d'hyper-vertex. 76 | */ 77 | unsigned int getNbrHyperVertex() const; 78 | 79 | /** 80 | * Obtenir le nombre de connexions vertex-arêtes. 81 | */ 82 | unsigned int getNbrLinks() const; 83 | 84 | /** 85 | * Obtenir le rang de l'hypergraphe. 86 | */ 87 | unsigned int getRang() const; 88 | 89 | /** 90 | * Obtenir le co-rang de l'hypergraphe. 91 | */ 92 | unsigned int getCoRang() const; 93 | 94 | protected: 95 | 96 | /** 97 | * Lancment de l'algorithme. 98 | */ 99 | void runAlgorithme(); 100 | 101 | protected: 102 | 103 | /** 104 | * Pointeur partagé vers l'hypergraphe. 105 | */ 106 | boost::shared_ptr 107 | _ptrHypergrapheAbstrait; 108 | 109 | /** 110 | * La structure des résultats - inutilisée ici. 111 | */ 112 | RStructure _result; 113 | 114 | /** 115 | * Le nombre d'hyper-arêtes. 116 | */ 117 | unsigned int _nhEdge; 118 | 119 | /** 120 | * Le nombre d'hyper-vertex. 121 | */ 122 | unsigned int _nhVertex; 123 | 124 | /** 125 | * Le nombre de connexions vertex-arêtes 126 | */ 127 | unsigned int _nhLink; 128 | 129 | /** 130 | * Le rang de l'hypergraphe 131 | */ 132 | unsigned int _rang; 133 | 134 | /** 135 | * Le co-rang de l'hypergraphe 136 | */ 137 | unsigned int _coRang; 138 | 139 | }; 140 | 141 | 142 | #endif 143 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/Isomorph.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #ifndef ALGORITHM_INCLUDE_ISOMORPHISM_HH_ 28 | #define ALGORITHM_INCLUDE_ISOMORPHISM_HH_ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "../model/HypergrapheAbstrait.hh" 36 | #include "../model/AlgorithmeAbstrait.hh" 37 | 38 | class Isomorph : public AlgorithmeAbstrait { 39 | 40 | public: 41 | 42 | Isomorph(const boost::shared_ptr&, const boost::shared_ptr&); 43 | 44 | RStructure getResult() const; 45 | 46 | ~Isomorph(); 47 | 48 | protected: 49 | 50 | typedef boost::adjacency_list > 51 | graph_t; 52 | 53 | void hypergraphTranspose(const boost::shared_ptr&, graph_t&); 54 | 55 | void runAlgorithme(); 56 | 57 | protected: 58 | 59 | boost::shared_ptr 60 | _ptrHypergrapheAbstraitA; 61 | 62 | boost::shared_ptr 63 | _ptrHypergrapheAbstraitB; 64 | 65 | RStructure _result; 66 | 67 | }; 68 | 69 | 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/IsomorphSpace.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #ifndef ALGORITHM_INCLUDE_ISOMORPHISMSPACE_HH_ 28 | #define ALGORITHM_INCLUDE_ISOMORPHISMSPACE_HH_ 29 | 30 | #include 31 | #include 32 | #include 33 | #include "../../model/include/LibType.hh" 34 | #include "../../model/include/Hypergraphe.hh" 35 | #include "../../model/include/HyperVertex.hh" 36 | #include "../../model/include/HyperEdge.hh" 37 | 38 | class HypergrapheAbstrait; 39 | 40 | class IsomorphSpace : public Gecode::Space { 41 | 42 | public: 43 | 44 | IsomorphSpace(const boost::shared_ptr&, const boost::shared_ptr&); 45 | 46 | void postConstraints(); 47 | 48 | Gecode::Space * copy(bool share); 49 | 50 | IsomorphSpace(bool share, IsomorphSpace& p); 51 | 52 | 53 | 54 | 55 | Gecode::IntVarArray _varEdge; 56 | 57 | Gecode::IntVarArray _bVarEdge; 58 | 59 | Gecode::IntVarArray _bVarEdge2; 60 | 61 | protected: 62 | 63 | boost::shared_ptr _ptrHypergrapheA; 64 | 65 | boost::shared_ptr _ptrHypergrapheB; 66 | 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/Linear.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de la classe de l'algorithme linear sur l'hypergraphe. 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_LINEAR_HH_ 30 | #define ALGORITHM_INCLUDE_LINEAR_HH_ 31 | 32 | #include "../model/AlgorithmeAbstrait.hh" 33 | 34 | /** 35 | * Algorithme linear sur l'hypergraphe. 36 | */ 37 | class Linear : public AlgorithmeAbstrait { 38 | 39 | public: 40 | 41 | /** 42 | * Constructeur 43 | * @param Pointeur partagé sur l'hypergraphe. 44 | */ 45 | Linear(boost::shared_ptr&); 46 | 47 | /** 48 | * Obtenir la structure des résutats. 49 | */ 50 | RStructure getResult() const; 51 | 52 | /** 53 | * Destructeur. 54 | */ 55 | ~Linear(); 56 | 57 | 58 | protected: 59 | 60 | /** 61 | * Lancement de l'algorithme. 62 | */ 63 | void runAlgorithme(); 64 | 65 | 66 | protected: 67 | 68 | /** 69 | * Pointeur partagé vers l'hypergraphe. 70 | */ 71 | boost::shared_ptr 72 | _ptrHypergrapheAbstrait; 73 | 74 | /** 75 | * Structure des résutats. 76 | */ 77 | RStructure _result; 78 | 79 | }; 80 | 81 | 82 | 83 | #endif /* ALGORITHM_INCLUDE_LINEAR_HH_ */ 84 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/Path.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de l'algorithme décidant de l'ensemble des chemins dans un hypergraphe 28 | * reliant un Vertex e1 à un Vertex e2. 29 | */ 30 | 31 | #ifndef ALGORITHM_INCLUDE_PATH_HH_ 32 | #define ALGORITHM_INCLUDE_PATH_HH_ 33 | 34 | #include "../model/HypergrapheAbstrait.hh" 35 | #include "../model/AlgorithmeAbstrait.hh" 36 | #include "../model/RStructurePath.hh" 37 | 38 | class Path : public AlgorithmeAbstrait { 39 | 40 | public: 41 | 42 | /* 43 | * Constructeur. 44 | * @param boost::shared_ptr Pointeur partagé vers l'hypergraphe. 45 | */ 46 | Path(boost::shared_ptr&); 47 | 48 | /** 49 | * Configurer les vertex à utiliser pour lister les chemins 50 | */ 51 | void setHyperVertex(boost::shared_ptr&, boost::shared_ptr&); 52 | 53 | /** 54 | * Obtenir la structure de résultats. 55 | */ 56 | RStructure getResult() const; 57 | 58 | /** 59 | * Obtenir la structure de résultats. 60 | */ 61 | RStructurePath getPathResult() const; 62 | 63 | /** 64 | * Fixer la limite du nombre de chemins. Par défaut 0, non-définit. 65 | */ 66 | void setLimit(unsigned int); 67 | 68 | /** 69 | * Lire la valeur limite. 70 | */ 71 | unsigned int getLimit() const; 72 | 73 | /** 74 | * Destructeur. 75 | */ 76 | ~Path(); 77 | 78 | 79 | protected: 80 | 81 | /** 82 | * Lancement de l'algorithme 83 | */ 84 | void runAlgorithme(); 85 | 86 | /** 87 | * Vérifie si l'HyperVertex est contenu dans la liste 88 | */ 89 | bool vertexContained(LibType::ListHyperVertex&, boost::shared_ptr&) const; 90 | 91 | /** 92 | * Ajoute les HyperVertex d'un HyperEdge dans la liste mentionnée. 93 | */ 94 | void addVertexList(LibType::ListHyperVertex&, LibType::ListHyperVertex&, const boost::shared_ptr&) const; 95 | 96 | 97 | void buildPathToPathList(LibType::PathList&, LibType::ListHyperVertex&); 98 | 99 | protected: 100 | 101 | /** 102 | * Pointeur partagé vers l'hypergraphe. 103 | */ 104 | boost::shared_ptr 105 | _ptrHypergrapheAbstrait; 106 | 107 | /** 108 | * Vertex source 109 | */ 110 | boost::shared_ptr _source; 111 | 112 | /** 113 | * Vertex destination 114 | */ 115 | boost::shared_ptr _destination; 116 | 117 | /** 118 | * Structure de résultat. 119 | */ 120 | RStructurePath _result; 121 | 122 | /** 123 | * Valeur limite. 124 | */ 125 | unsigned int _limite; 126 | }; 127 | 128 | 129 | #endif /* SRC_ALGORITHM_INCLUDE_PATH_HH_ */ 130 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/Simple.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de la classe de l'algorithme simple sur l'hypergraphe. 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_SIMPLE_HH_ 30 | #define ALGORITHM_INCLUDE_SIMPLE_HH_ 31 | 32 | #include 33 | #include "../model/HypergrapheAbstrait.hh" 34 | #include "../model/Hypergraphe.hh" 35 | #include "../model/HyperVertex.hh" 36 | #include "../model/HyperEdge.hh" 37 | #include "../model/AlgorithmeAbstrait.hh" 38 | #include "../model/RStructure.hh" 39 | #include "Linear.hh" 40 | 41 | /** 42 | * Algorithme simple sur l'hypergraphe. 43 | */ 44 | class Simple : public AlgorithmeAbstrait { 45 | 46 | public: 47 | 48 | /** 49 | * Constructeur 50 | * @param Pointeur partagé sur l'hypergraphe. 51 | */ 52 | Simple(boost::shared_ptr&); 53 | 54 | /** 55 | * Obtenir la structure des résultats. 56 | * @return La structure des résultats. 57 | */ 58 | RStructure getResult() const; 59 | 60 | /** 61 | * Destructeur. 62 | */ 63 | ~Simple(); 64 | 65 | 66 | protected: 67 | 68 | friend class Linear; 69 | 70 | /** 71 | * Lancement de l'algorithme. 72 | */ 73 | void runAlgorithme(); 74 | 75 | /** 76 | * Vérification de l'inclusion entre hyper-arête via les vertex. 77 | * @param Première liste. 78 | * @param Seconde liste. 79 | * @return True si c'est le cas, False sinon. 80 | */ 81 | bool subsetVertexList(const LibType::ListHyperVertex&, const LibType::ListHyperVertex&) const; 82 | 83 | /** 84 | * Vérifie si un hyper-vertex est contenu dans la liste. 85 | * @param Liste des hyper-vertex. 86 | * @param L'hyer-vertex. 87 | * @return True si c'est le cas, False sinon. 88 | */ 89 | bool contains(const LibType::ListHyperVertex&, const boost::shared_ptr&) const; 90 | 91 | 92 | protected: 93 | 94 | /** 95 | * Pointeur partagé vers l'hypergraphe. 96 | */ 97 | boost::shared_ptr 98 | _ptrHypergrapheAbstrait; 99 | 100 | /** 101 | * Structure des résultats. 102 | */ 103 | RStructure _result; 104 | 105 | 106 | }; 107 | 108 | 109 | 110 | #endif /* ALGORITHM_INCLUDE_SIMPLE_HH_ */ 111 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/kRegular.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de la classe de l'algorithme k-regular sur l'hypergraphe. 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_KREGULAR_HH_ 30 | #define ALGORITHM_INCLUDE_KREGULAR_HH_ 31 | 32 | #include 33 | #include "../model/HypergrapheAbstrait.hh" 34 | #include "../model/Hypergraphe.hh" 35 | #include "../model/HyperVertex.hh" 36 | #include "../model/HyperEdge.hh" 37 | #include "../model/AlgorithmeAbstrait.hh" 38 | #include "../model/RStructure.hh" 39 | 40 | /** 41 | * Algorithme k-regular sur l'hypergraphe. 42 | */ 43 | class kRegular : public AlgorithmeAbstrait { 44 | 45 | public: 46 | 47 | /** 48 | * Constructeur. 49 | * @param Pointeur partagé vers l'hypergraphe. 50 | */ 51 | kRegular(const boost::shared_ptr&); 52 | 53 | /** 54 | * Obtenir la structure des résultats. 55 | * @return La structure des résultats. 56 | */ 57 | RStructure getResult() const; 58 | 59 | /** 60 | * Destructeur. 61 | */ 62 | ~kRegular(); 63 | 64 | protected: 65 | 66 | /** 67 | * Lancment de l'algorithme. 68 | */ 69 | void runAlgorithme(); 70 | 71 | protected: 72 | 73 | /** 74 | * Pointeur partagé vers l'hypergraphe. 75 | */ 76 | boost::shared_ptr 77 | _ptrHypergrapheAbstrait; 78 | 79 | /** 80 | * La structure des résultats. 81 | */ 82 | RStructure _result; 83 | 84 | }; 85 | 86 | 87 | #endif /* ALGORITHM_INCLUDE_KREGULAR_HH_ */ 88 | -------------------------------------------------------------------------------- /include/Hypergraph/algorithm/kUniform.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de la classe de l'algorithme k-uniforme sur l'hypergraphe. 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_KUNIFORM_HH_ 30 | #define ALGORITHM_INCLUDE_KUNIFORM_HH_ 31 | 32 | #include 33 | #include "../model/HypergrapheAbstrait.hh" 34 | #include "../model/Hypergraphe.hh" 35 | #include "../model/HyperVertex.hh" 36 | #include "../model/HyperEdge.hh" 37 | #include "../model/AlgorithmeAbstrait.hh" 38 | #include "../model/RStructure.hh" 39 | 40 | /** 41 | * Algorithme k-uniforme sur l'hypergraphe. 42 | */ 43 | class kUniform : public AlgorithmeAbstrait { 44 | 45 | public: 46 | 47 | /** 48 | * Constructeur 49 | * @param Pointeur partagé sur l'hypergraphe. 50 | * @param Valeur de k. 51 | */ 52 | kUniform(boost::shared_ptr& ptrHypergrapheAbstrait, const unsigned int&); 53 | 54 | /** 55 | * Obtenir la structure des résultats. 56 | * @return La structure des résultats. 57 | */ 58 | RStructure getResult() const; 59 | 60 | /** 61 | * Destructeur. 62 | */ 63 | ~kUniform(); 64 | 65 | 66 | protected: 67 | 68 | /** 69 | * Lancement de l'algorithme. 70 | */ 71 | void runAlgorithme(); 72 | 73 | 74 | protected: 75 | 76 | /** 77 | * Pointeur partagé vers l'hypergraphe. 78 | */ 79 | boost::shared_ptr 80 | _ptrHypergrapheAbstrait; 81 | 82 | /** 83 | * Valeur de k. 84 | */ 85 | unsigned int _k; 86 | 87 | /** 88 | * Structure des résultats. 89 | */ 90 | RStructure _result; 91 | 92 | }; 93 | 94 | 95 | 96 | #endif /* ALGORITHM_INCLUDE_KUNIFORM_HH_ */ 97 | -------------------------------------------------------------------------------- /include/Hypergraph/io/ReaderAbstrait.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Interface du module de lecture d'instance. 28 | */ 29 | #ifndef IO_INCLUDE_READERABSTRAIT_HH_ 30 | #define IO_INCLUDE_READERABSTRAIT_HH_ 31 | 32 | #include "../model/HypergrapheAbstrait.hh" 33 | #include 34 | 35 | /** 36 | * Dfinition de l'interface du module de lecture d'instance. 37 | */ 38 | class ReaderAbstrait { 39 | 40 | public: 41 | 42 | /** 43 | * Constructeur. 44 | * @param Pointeur partagé sur l'hypergrahe. 45 | */ 46 | ReaderAbstrait(const boost::shared_ptr&); 47 | 48 | /** 49 | * Lecture de l'instance et construction de l'hypergraphe. 50 | * @param Le flux entrant. 51 | */ 52 | virtual void readHypergraphe(std::istream&) = 0; 53 | 54 | /** 55 | * Obtenir l'hypergraphe après construction. 56 | */ 57 | boost::shared_ptr& 58 | getHypergraphe(); 59 | 60 | /** 61 | * Déstructeur virtuel. 62 | */ 63 | virtual ~ReaderAbstrait(); 64 | 65 | 66 | protected: 67 | 68 | /** 69 | * Lire les hyper-vertex de l'instance. 70 | * @param Le flux entrant. 71 | */ 72 | virtual void readHypergrapheHyperVertex(std::istream&) = 0; 73 | 74 | /** 75 | * Lire les hyper-arêtes de l'instance. 76 | * @param Le flux entrant. 77 | */ 78 | virtual void readHypergrapheHyperEdge(std::istream&) = 0; 79 | 80 | 81 | protected: 82 | 83 | /** 84 | * Pointeur partagé vers l'hypergraphe. 85 | */ 86 | boost::shared_ptr 87 | _ptrHypergrapheAbstrait; 88 | 89 | }; 90 | 91 | 92 | 93 | #endif /* IO_INCLUDE_READERABSTRAIT_HH_ */ 94 | -------------------------------------------------------------------------------- /include/Hypergraph/io/ReaderFile.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Module de lecture. 28 | */ 29 | #ifndef IO_INCLUDE_READERFILE_HH_ 30 | #define IO_INCLUDE_READERFILE_HH_ 31 | 32 | #include "ReaderAbstrait.hh" 33 | #include 34 | 35 | 36 | /** 37 | * Déclaration du module de lecture. 38 | */ 39 | class ReaderFile : public ReaderAbstrait { 40 | 41 | public: 42 | 43 | /** 44 | * Constructeur. 45 | */ 46 | ReaderFile(); 47 | 48 | /** 49 | * Lecture de l'instance de l'hypergraphe. 50 | * @param Le flux entrant. 51 | */ 52 | void readHypergraphe(std::istream&); 53 | 54 | /** 55 | * Deestructeur. 56 | */ 57 | ~ReaderFile(); 58 | 59 | 60 | protected: 61 | 62 | /** 63 | * Lecture des hyper-vertex de l'instance. 64 | * @param Le flux entrant. 65 | */ 66 | void readHypergrapheHyperVertex(std::istream&); 67 | 68 | /** 69 | * Lecture des hyper-arêtes de l'instance. 70 | * @param Le flux entrant. 71 | */ 72 | void readHypergrapheHyperEdge(std::istream&); 73 | 74 | /** 75 | * Obtenir l'hyper-vertex via l'identifiant numérique. 76 | * @param L'identifiant numérique. 77 | */ 78 | boost::shared_ptr& hyperVertexById(unsigned int&); 79 | 80 | /** 81 | * Obtenir l'hyper-arête via l'identifiant numérique. 82 | * @param L'identifiant numérique. 83 | */ 84 | boost::shared_ptr& hyperEdgeById(unsigned int&); 85 | 86 | /** 87 | * Construction de l'instance après lecture. 88 | */ 89 | void flush(); 90 | 91 | 92 | protected: 93 | 94 | /** 95 | * Liste des hyper-vertex lus. 96 | */ 97 | LibType::ListHyperVertex 98 | _listHyperVertex; 99 | 100 | /** 101 | * Liste des hyper-arêtes lues. 102 | */ 103 | LibType::ListHyperEdge 104 | _listHyperEdge; 105 | 106 | }; 107 | 108 | 109 | #endif /* IO_INCLUDE_READERFILE_HH_ */ 110 | -------------------------------------------------------------------------------- /include/Hypergraph/io/WriterAbstrait.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Interface du module d'écriture d'instance. 28 | */ 29 | #ifndef IO_INCLUDE_WRITERABSTRAIT_HH_ 30 | #define IO_INCLUDE_WRITERABSTRAIT_HH_ 31 | 32 | #include "../model/HypergrapheAbstrait.hh" 33 | #include 34 | 35 | /** 36 | * Déclaration de l'interface du module d'écriture d'instance. 37 | */ 38 | class WriterAbstrait { 39 | 40 | public: 41 | 42 | /** 43 | * Constructeur. 44 | * @param Pointeur partagé vers l'hypergraphe. 45 | */ 46 | WriterAbstrait(const boost::shared_ptr&); 47 | 48 | /** 49 | * Ecriture de la matrice d'adjacence sur la sortie indiquée. 50 | * @param Le flux de sortie. 51 | */ 52 | virtual void writeAdjacentMatrix(std::ostream&) const = 0; 53 | 54 | /** 55 | * Ecriture de l'hypergraphe sur le flux de sortie. 56 | * @param Le flux de sortie. 57 | */ 58 | virtual void writeHypergraph(std::ostream&) const = 0; 59 | 60 | /** 61 | * Destructeur virtuel. 62 | */ 63 | virtual ~WriterAbstrait(); 64 | 65 | 66 | protected: 67 | 68 | /** 69 | * Ecriture des hyper-vertex sur le flux de sortie. 70 | * @param Le flux de sortie. 71 | */ 72 | virtual void writeHypergrapheHyperVertex(std::ostream&) const = 0; 73 | 74 | /** 75 | * Ecriture des hyper-arêtes sur le flux de sortie. 76 | * @param Le flux de sortie. 77 | */ 78 | virtual void writeHypergrapheHyperEdge(std::ostream&) const = 0; 79 | 80 | 81 | protected: 82 | 83 | /** 84 | * Pointeur partagé vers l'hypergraphe. 85 | */ 86 | boost::shared_ptr 87 | _ptrHypergrapheAbstrait; 88 | 89 | }; 90 | 91 | 92 | 93 | #endif /* IO_INCLUDE_WRITERABSTRAIT_HH_ */ 94 | -------------------------------------------------------------------------------- /include/Hypergraph/io/WriterFile.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Module d'écriture d'une instance d'hypergraphe. 28 | */ 29 | #ifndef IO_INCLUDE_WRITERFILE_HH_ 30 | #define IO_INCLUDE_WRITERFILE_HH_ 31 | 32 | #include "WriterAbstrait.hh" 33 | 34 | /** 35 | * Délaration du module d'écriture de l'instance d'un hypergraphe. 36 | */ 37 | class WriterFile : public WriterAbstrait { 38 | 39 | public: 40 | 41 | /** 42 | * Constructeur. 43 | * @param Pointeur partagé vers l'hypergraphe. 44 | */ 45 | WriterFile(const boost::shared_ptr&); 46 | 47 | /** 48 | * Eciture de la matrice d'adjacence sur le flux de sortie. 49 | * @param Le flux de sortie. 50 | */ 51 | void writeAdjacentMatrix(std::ostream&) const; 52 | 53 | /** 54 | * Ecriture de l'instance de l'hypergraphe sur le flux de sortie. 55 | * @param Le flux de sortie. 56 | */ 57 | void writeHypergraph(std::ostream&) const; 58 | 59 | 60 | protected: 61 | 62 | /** 63 | * Ecriture des hyper-vertex sur le flux de sortie. 64 | * @param Le flux de sortie. 65 | */ 66 | void writeHypergrapheHyperVertex(std::ostream&) const; 67 | 68 | /** 69 | * Ecriture des hyper-arêtes sur le flux de sortie. 70 | * @param Le flux de sortie. 71 | */ 72 | void writeHypergrapheHyperEdge(std::ostream&) const; 73 | 74 | 75 | protected: 76 | 77 | }; 78 | 79 | 80 | 81 | #endif /* IO_INCLUDE_READERFILE_HH_ */ 82 | -------------------------------------------------------------------------------- /include/Hypergraph/model/AlgorithmeAbstrait.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de l'interface d'un algorithme. 28 | */ 29 | 30 | 31 | #ifndef MODEL_INCLUDE_ALGORITHMEABSTRAIT_HH_ 32 | #define MODEL_INCLUDE_ALGORITHMEABSTRAIT_HH_ 33 | 34 | #include "RStructure.hh" 35 | 36 | class MotorAlgorithm; 37 | 38 | /** 39 | * Classe abstraite définissant les méthodes obligatoires d'un algorithme. 40 | */ 41 | class AlgorithmeAbstrait { 42 | 43 | public: 44 | 45 | /** 46 | * Obtenir la structure de description du résultat. 47 | * @return La structure de description du résultat. 48 | */ 49 | virtual RStructure getResult() const = 0; 50 | 51 | /** 52 | * Destructeur abstrait. 53 | */ 54 | virtual ~AlgorithmeAbstrait(); 55 | 56 | 57 | protected: 58 | 59 | friend class MotorAlgorithm; 60 | 61 | /** 62 | * Fonction princiale de lancement de l'algorithme. 63 | */ 64 | virtual void runAlgorithme() = 0; 65 | 66 | }; 67 | 68 | 69 | #endif /* MODEL_INCLUDE_ALGORITHMEABSTRAIT_HH_ */ 70 | -------------------------------------------------------------------------------- /include/Hypergraph/model/HyperEdge.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Modélisation d'une hyper-arête. 28 | */ 29 | #ifndef _HYPEREDGE_HH 30 | #define _HYPEREDGE_HH 31 | 32 | #include 33 | 34 | #include "LibType.hh" 35 | #include "HypergrapheAbstrait.hh" 36 | 37 | /** 38 | * Définition de l'hyper-arête. 39 | */ 40 | class HyperEdge { 41 | 42 | public: 43 | 44 | /** 45 | * Constructeur. 46 | * @param Pointeur partagé vers l'hypergraphe. 47 | * @param Identifiant numérique de l'hyper-arête. 48 | */ 49 | HyperEdge(const boost::shared_ptr&, unsigned int& identifier); 50 | 51 | /** 52 | * Ajouter un hyper-vertex dans l'hyper-arête. 53 | * @param L'hyper-vertex à ajouter. 54 | */ 55 | void addHyperVertex(boost::shared_ptr&); 56 | 57 | /** 58 | * Affectation de la liste des hyper-vertex contenu dans l'hyper-arête. 59 | * @param Liste des hyper-vertex. 60 | */ 61 | void setHyperVertexList(LibType::ListHyperVertex&); 62 | 63 | /** 64 | * Obtenir la liste des hyper-vertex contenu dans l'hyper-arête. 65 | * @return La liste des hyper-vertex. 66 | */ 67 | LibType::ListHyperVertex& getHyperVertexList(); 68 | 69 | /** 70 | * Obtenir l'effectif de l'hyper-arête. 71 | * @return L'effectif. 72 | */ 73 | const unsigned int getEffectif() const; 74 | 75 | /** 76 | * Obtenir l'identifiant numérique de l'hyper-arête. 77 | * @return L'identifiant de l'hyper-arête. 78 | */ 79 | const unsigned int& getIdentifier() const; 80 | 81 | /** 82 | * Vérifie l'appartenance d'un hyper-vertex dans l'hyper-arête. 83 | * @param Le vertex 84 | * @return True si l'hyper-vertex est présent dans l'hyper-arête, False sinon. 85 | */ 86 | bool containVertex(boost::shared_ptr&) const; 87 | 88 | /** 89 | * Surcharge de l'opérateur, afin de vérifier l'expression à l'aide de l'identifiant numérique. 90 | */ 91 | bool operator==(const boost::shared_ptr&) const; 92 | 93 | /** 94 | * Surcharge de l'opérateur, afin de vérifier l'expression à l'aide de l'identifiant numérique. 95 | */ 96 | bool operator<(const boost::shared_ptr&) const; 97 | 98 | /** 99 | * Surcharge de l'opérateur, afin de vérifier l'expression à l'aide de l'identifiant numérique. 100 | */ 101 | bool operator>(const boost::shared_ptr&) const; 102 | 103 | /** 104 | * Obtenir la liste des hyper-vertex contenu dans l'hyper-arête. 105 | * @return La liste des hyper-vertex. 106 | */ 107 | const LibType::ListHyperVertex& getHyperVertexList() const; 108 | 109 | protected: 110 | 111 | /** 112 | * Pointeur partagé sur l'hypergraphe. 113 | */ 114 | boost::shared_ptr 115 | _ptrHypergraphe; 116 | 117 | /** 118 | * L'identifiant numérique. 119 | */ 120 | unsigned int _identifier; 121 | 122 | /** 123 | * Liste des hyper-vertex. 124 | */ 125 | LibType::ListHyperVertex 126 | _listHyperVertex; 127 | 128 | }; 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /include/Hypergraph/model/HyperFactory.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Définition de la fabrique d'un hypergraphe. 28 | */ 29 | #ifndef MODEL_INCLUDE_HYPERFACTORY_HH_ 30 | #define MODEL_INCLUDE_HYPERFACTORY_HH_ 31 | 32 | #include "HyperVertex.hh" 33 | #include "HyperEdge.hh" 34 | 35 | /** 36 | * Classe modélisant la fabrique de l'hypergraphe. 37 | */ 38 | class HyperFactory { 39 | 40 | public: 41 | 42 | /** 43 | * Instance unique de la fabrique. 44 | */ 45 | static HyperFactory& Instance(); 46 | 47 | 48 | public: 49 | 50 | /** 51 | * Démarrer une session de fabrication d'un hypergraphe. 52 | * @param Pointeur partagé vers l'hypergraphe. 53 | */ 54 | static void startSession(boost::shared_ptr& ptrHypergrapheAbstrait); 55 | 56 | /** 57 | * Création d'un nouvel hyper-vertex. 58 | * @return Nouvel hyper-vertex. 59 | */ 60 | static const boost::shared_ptr newHyperVertex(); 61 | 62 | /** 63 | * Création d'une nouvelle hyper-arête. 64 | * @return Nouvelle hyper-arête. 65 | */ 66 | static const boost::shared_ptr newHyperEdge(); 67 | 68 | /** 69 | * Relier une hyper-arête à un hyper-vertex. 70 | * @param L'hyper-vertex à relier. 71 | * @param L'hyper-arête à relier. 72 | */ 73 | static void link(boost::shared_ptr&, boost::shared_ptr&); 74 | 75 | /** 76 | * Test si une session est déjà en cours. 77 | * @return True si c'est le cas, False sinon. 78 | */ 79 | static bool isSession(); 80 | 81 | /** 82 | * Terminer la session de construction. 83 | */ 84 | static void closeSession(); 85 | 86 | 87 | private: 88 | 89 | /** 90 | * Constructeur 91 | */ 92 | HyperFactory(); 93 | 94 | /** 95 | * Constructeur 96 | */ 97 | HyperFactory(const HyperFactory&); 98 | 99 | /** 100 | * Constructeur 101 | */ 102 | HyperFactory& operator= (const HyperFactory&); 103 | 104 | /** 105 | * Destructeur 106 | */ 107 | ~HyperFactory(); 108 | 109 | 110 | private: 111 | 112 | /** 113 | * Instnce unique de la fabrique. 114 | */ 115 | static HyperFactory _instance; 116 | 117 | /** 118 | * Compteur des indexes des hyper-vertex. 119 | */ 120 | static unsigned int _indexVertex; 121 | 122 | /** 123 | * Compteur des indexes des hyper-arêtes. 124 | */ 125 | static unsigned int _indexEdge; 126 | 127 | /** 128 | * Indicateur de session. 129 | */ 130 | static bool _isSession; 131 | 132 | /** 133 | * Pointeur partagé vers l'hypergraphe. 134 | */ 135 | static boost::shared_ptr _ptrHypergrapheAbstrait; 136 | 137 | }; 138 | 139 | 140 | #endif /* MODEL_INCLUDE_HYPERFACTORY_HH_ */ 141 | -------------------------------------------------------------------------------- /include/Hypergraph/model/HyperVertex.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Modélisation de l'hyper-vertex. 28 | */ 29 | 30 | #ifndef HYPER_VERTEX_HH 31 | #define HYPER_VERTEX_HH 32 | 33 | #include 34 | 35 | #include "LibType.hh" 36 | #include "HypergrapheAbstrait.hh" 37 | 38 | /** 39 | * Déclaration de la classe de l'hyper-vertex. 40 | */ 41 | class HyperVertex { 42 | 43 | public: 44 | 45 | /** 46 | * Constructeur. 47 | * @param Pointeur partagé vers l'hypergraphe auquel appartient l'hyper-vertex. 48 | * @param L'identifiant numérique de l'hyper-vertex. 49 | */ 50 | HyperVertex(const boost::shared_ptr&, unsigned int& identifier); 51 | 52 | /** 53 | * Ajouter une hyper-arête à l'hyper-vertex. 54 | * @param L'hyper-arête à ajouter. 55 | */ 56 | void addHyperEdge(boost::shared_ptr&); 57 | 58 | /** 59 | * Obtenir le nombre d'hyper-arêtes dans lequel l'hyper-vertex est inclus. 60 | * @return Le nombre d'hyper-arêtes dans lequel l'hyper-vertex est inclus. 61 | */ 62 | const unsigned int getVertexDegree() const; 63 | 64 | /** 65 | * Vérifier si l'hyper-arête contient cet hyer-vertex. 66 | * @param L'hyper-arête 67 | * @return True si l'hyper-vertex est inclus dans l'hyper-arête. 68 | */ 69 | bool containEdge(boost::shared_ptr&) const; 70 | 71 | /** 72 | * Obtenir l'identifiant numérique de l'hyper-vertex. 73 | * @return L'identifiant numérique de l'hyper-vertex. 74 | */ 75 | const unsigned int& getIdentifier() const; 76 | 77 | /** 78 | * Surcharge de l'opérateur, dont l'expression est basé sur l'identifiant numérique. 79 | */ 80 | bool operator==(const boost::shared_ptr&) const; 81 | 82 | /** 83 | * Surcharge de l'opérateur, dont l'expression est basé sur l'identifiant numérique. 84 | */ 85 | bool operator<(const boost::shared_ptr&) const; 86 | 87 | /** 88 | * Surcharge de l'opérateur, dont l'expression est basé sur l'identifiant numérique. 89 | */ 90 | bool operator>(const boost::shared_ptr&) const; 91 | 92 | /** 93 | * Obtenir la liste des hyper-arêtes contenant l'hyper-vertex. 94 | * @return La liste des hyper-arêtes contenant l'hyper-vertex. 95 | */ 96 | const LibType::ListHyperEdge& getHyperEdgeList() const; 97 | 98 | 99 | protected: 100 | 101 | /** 102 | * Pointeur partagé sur l'hypergraphe. 103 | */ 104 | boost::shared_ptr 105 | _ptrHypergraphe; 106 | 107 | /** 108 | * Identifiant numérique. 109 | */ 110 | unsigned int _identifier; 111 | 112 | /** 113 | * Liste des hyper-arêtes contenant l'hyper-vertex. 114 | */ 115 | LibType::ListHyperEdge 116 | _listHyperEdge; 117 | 118 | }; 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /include/Hypergraph/model/Hypergraphe.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Classe modélisant un hypergraphe. 28 | */ 29 | #ifndef MODEL_INCLUDE_HYPERGRAPHE_HH_ 30 | #define MODEL_INCLUDE_HYPERGRAPHE_HH_ 31 | 32 | #include "HypergrapheAbstrait.hh" 33 | 34 | /** 35 | * Modélisation de l'hypergraphe. 36 | */ 37 | class Hypergraphe : public HypergrapheAbstrait { 38 | 39 | public: 40 | 41 | /** 42 | * Constructeur par défaut. 43 | */ 44 | Hypergraphe(); 45 | 46 | /** 47 | * Ajouter un hyper-vertex à l'hypergraphe. 48 | * @param L'hyper-vertex à ajouter. 49 | */ 50 | void addHyperVertex(const boost::shared_ptr&); 51 | 52 | /** 53 | * Ajouter une hyper-arête à l'hypergraphe. 54 | * @param L'hyper-arête à ajouter. 55 | */ 56 | void addHyperEdge(const boost::shared_ptr&); 57 | 58 | /** 59 | * Obtenir un hyper-vertex à l'aide de son identifiant. 60 | * @param L'identifiant de l'hyper-vertex à obtenir. 61 | */ 62 | boost::shared_ptr& getHyperVertexById(const unsigned int&); 63 | 64 | /** 65 | * Obtenir une hyper-arête à l'aide de son identifiant. 66 | * @param L'identifiant de l'hyper-arête à obtenir. 67 | */ 68 | boost::shared_ptr& getHyperEdgeById(const unsigned int&); 69 | 70 | /** 71 | * Construction de l'hypergraphe, notamment de sa matrice d'adjacence. 72 | */ 73 | void flush(); 74 | 75 | /** 76 | * Destructeur. 77 | */ 78 | ~Hypergraphe(); 79 | 80 | protected: 81 | 82 | }; 83 | 84 | 85 | 86 | #endif /* MODEL_INCLUDE_HYPERGRAPHE_HH_ */ 87 | -------------------------------------------------------------------------------- /include/Hypergraph/model/LibType.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #ifndef MODEL_INCLUDE_LIBTYPE_HH_ 28 | #define MODEL_INCLUDE_LIBTYPE_HH_ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | 37 | class HyperVertex; 38 | 39 | class HyperEdge; 40 | 41 | class LibType { 42 | 43 | public: 44 | 45 | 46 | typedef boost::multi_array 47 | AdjacentMatrixContainerBool; 48 | 49 | typedef boost::multi_array 50 | AdjacentMatrixContainerInt; 51 | 52 | typedef boost::container::vector > 53 | ListHyperVertex; 54 | 55 | typedef boost::container::vector > 56 | ListHyperEdge; 57 | 58 | typedef std::map, int> 59 | IndexerHyperVertex; 60 | 61 | typedef std::map, int> 62 | IndexerHyperEdge; 63 | 64 | typedef std::map > 65 | HyperVertexIndexer; 66 | 67 | typedef std::map > 68 | HyperEdgeIndexer; 69 | 70 | typedef boost::shared_ptr > 71 | PathList; 72 | 73 | private: 74 | 75 | LibType(); 76 | LibType(const LibType&) = delete; 77 | LibType& operator=(const LibType&) = delete; 78 | }; 79 | 80 | 81 | #endif /* MODEL_INCLUDE_LIBTYPE_HH_ */ 82 | -------------------------------------------------------------------------------- /include/Hypergraph/model/MotorAlgorithm.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Moteur des algorithmes. Avant de lancer un algorithme, 28 | * on configure le moteur, qui fait office de lanceur, afin 29 | * d'éviter les erreurs lors du paraléllisme. 30 | */ 31 | #ifndef MODEL_INCLUDE_MOTORALGORITHM_HH_ 32 | #define MODEL_INCLUDE_MOTORALGORITHM_HH_ 33 | 34 | #include 35 | 36 | #include "AlgorithmeAbstrait.hh" 37 | 38 | /** 39 | * Moteur algorithmique. 40 | */ 41 | class MotorAlgorithm { 42 | 43 | public: 44 | 45 | /** 46 | * Obtenir l'instance du moteur. 47 | * @return L'instance du moteur. 48 | */ 49 | static MotorAlgorithm& Instance(); 50 | 51 | /** 52 | * Insérer l'algorithme à lancer. 53 | * @param Pointeur partagé sur l'algorithme. 54 | */ 55 | static void setAlgorithme(boost::shared_ptr&); 56 | 57 | /** 58 | * Lancer l'algorithme. 59 | */ 60 | static void runAlgorithme(); 61 | 62 | /** 63 | * Indicateur de bloquage du moteur. 64 | * @return True si le lanceur est bloqué, False sinon. 65 | */ 66 | static bool isLock(); 67 | 68 | private: 69 | 70 | /** 71 | * Bloquage des setters et du lanceur. 72 | */ 73 | static void lock(); 74 | 75 | /** 76 | * Débloquage des setters et du lanceur. 77 | */ 78 | static void unlock(); 79 | 80 | private: 81 | 82 | /** 83 | * Constructeur (copie). 84 | */ 85 | MotorAlgorithm(const MotorAlgorithm&); 86 | 87 | /** 88 | * Constructeur. 89 | */ 90 | MotorAlgorithm& operator= (const MotorAlgorithm&); 91 | 92 | /** 93 | * Constructeur. 94 | */ 95 | MotorAlgorithm(); 96 | 97 | /** 98 | * Déstructeur. 99 | */ 100 | ~MotorAlgorithm(); 101 | 102 | private: 103 | 104 | /** 105 | * Descripteur du statut bloquant. 106 | */ 107 | static bool _lock; 108 | 109 | /** 110 | * Instance unique du moteur. 111 | */ 112 | static MotorAlgorithm _instance; 113 | 114 | /** 115 | * Pointeur partagé de l'algorithme. 116 | */ 117 | static boost::shared_ptr _algorithme; 118 | 119 | }; 120 | 121 | 122 | 123 | #endif /* MODEL_INCLUDE_MOTORALGORITHM_HH_ */ 124 | -------------------------------------------------------------------------------- /include/Hypergraph/model/RStructure.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Structure de description du résultat. Cet objet 28 | * est la représentation du résultat produit par tout algorithme. 29 | */ 30 | #ifndef MODEL_INCLUDE_RSTRUCTURE_HH_ 31 | #define MODEL_INCLUDE_RSTRUCTURE_HH_ 32 | 33 | #include "HypergrapheAbstrait.hh" 34 | #include 35 | 36 | /** 37 | * Structure de description du résultat. 38 | */ 39 | class RStructure { 40 | 41 | public: 42 | 43 | /** 44 | * Ajouter un résultat entier. 45 | */ 46 | void setIntegerResult(); 47 | 48 | /** 49 | * Ajouter un résultat booléen. 50 | * @param Le résultat booléen. 51 | */ 52 | void setBooleanResult(bool); 53 | 54 | /** 55 | * Ajouter un résultat de type HypergrapheAbstrait. 56 | * @param L'hypergraphe faisant office de résultat. 57 | */ 58 | void setHypergrapheResult(const boost::shared_ptr&); 59 | 60 | public: 61 | 62 | /** 63 | * Lire un résultat entier. 64 | * @return Le résutat en tant que nombre entier. 65 | */ 66 | int getIntegerResult() const; 67 | 68 | /** 69 | * Lire un résutat booléen. 70 | * @return Le résultat en tant que valeur booléenne. 71 | */ 72 | bool getBooleanResult() const; 73 | 74 | /** 75 | * Lire un résultat de typ HypergrapheAbstrait 76 | * @return Le résultat de type HypergrapheAbstrait 77 | */ 78 | boost::shared_ptr getHypergrapheResult() const; 79 | 80 | protected: 81 | 82 | /** 83 | * La valeur du résultat entier. 84 | */ 85 | int _integerResult; 86 | 87 | /** 88 | * La valeur du résultat booléen. 89 | */ 90 | bool _booleanResult; 91 | 92 | /** 93 | * L'hypergraphe faisant office de résultat. 94 | */ 95 | boost::shared_ptr _hypergrapheResult; 96 | 97 | }; 98 | 99 | 100 | 101 | #endif /* MODEL_INCLUDE_RSTRUCTURE_HH_ */ 102 | 103 | -------------------------------------------------------------------------------- /include/Hypergraph/model/RStructurePath.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Structure de description du résultat. Cet objet 28 | * est la représentation du résultat produit par tout algorithme. 29 | */ 30 | #ifndef MODEL_INCLUDE_RSTRUCTURE_PATH_HH_ 31 | #define MODEL_INCLUDE_RSTRUCTURE_PATH_HH_ 32 | 33 | #include "RStructure.hh" 34 | 35 | class RStructurePath : public RStructure { 36 | 37 | public: 38 | 39 | RStructurePath(); 40 | 41 | void setPathResult(LibType::PathList&); 42 | 43 | LibType::PathList getPathResult(); 44 | 45 | protected: 46 | 47 | LibType::PathList _pathList; 48 | 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB psrc */*.cpp) 2 | 3 | add_library(hypergraph SHARED ${psrc}) 4 | 5 | install (TARGETS hypergraph DESTINATION lib) 6 | install (DIRECTORY "${PROJECT_BINARY_DIR}/include/Hypergraph" 7 | DESTINATION include) 8 | 9 | if(Boost_FOUND) 10 | include_directories(${Boost_INCLUDE_DIRS}) 11 | target_link_libraries(hypergraph ${Boost_LIBRARIES}) 12 | endif() 13 | 14 | find_package(OpenMP) 15 | if (OPENMP_FOUND) 16 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 17 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 18 | endif() 19 | 20 | include_directories(${GECODE_INCLUDE_DIR}) 21 | target_link_libraries(hypergraph ${GECODE_LIBRARIES}) 22 | 23 | -------------------------------------------------------------------------------- /src/algorithm/Diameter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/Diameter.hh" 28 | 29 | 30 | Diameter::Diameter(boost::shared_ptr& ptrHypergrapheAbstrait) : _ptrHypergrapheAbstrait(ptrHypergrapheAbstrait) { 31 | 32 | } 33 | 34 | void 35 | Diameter::runAlgorithme() { 36 | 37 | } 38 | 39 | RStructure 40 | Diameter::getResult() const { 41 | return _result; 42 | } 43 | 44 | Diameter::~Diameter() { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/algorithm/Dual.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/Dual.hh" 28 | #include "../model/include/HyperFactory.hh" 29 | #include "../model/include/Hypergraphe.hh" 30 | #include "../model/include/HyperEdge.hh" 31 | #include "../model/include/HyperVertex.hh" 32 | #include 33 | 34 | 35 | Dual::Dual(const boost::shared_ptr& ptrHypergrapheAbstrait) : _ptrDualHypergraphe( new Hypergraphe() ) { 36 | _ptrHypergrapheAbstrait = ptrHypergrapheAbstrait; 37 | } 38 | 39 | RStructure 40 | Dual::getResult() const { 41 | return _result; 42 | } 43 | 44 | void 45 | Dual::runAlgorithme() { 46 | 47 | LibType::IndexerHyperVertex indexVertex ( _ptrHypergrapheAbstrait->getIndexHyperVertex() ); 48 | LibType::IndexerHyperEdge indexEdge ( _ptrHypergrapheAbstrait->getIndexHyperEdge() ); 49 | 50 | LibType::ListHyperVertex listVertex; 51 | LibType::ListHyperEdge listEdge; 52 | 53 | HyperFactory::startSession(_ptrDualHypergraphe); 54 | #pragma omp parallel sections 55 | { 56 | #pragma omp section 57 | { 58 | for(unsigned int i=0; igetAdjacentMatrix().isVertexInEdge(itemEdge->getIdentifier(), itemVertex->getIdentifier())) { 72 | HyperFactory::link(itemVertex, itemEdge); 73 | } 74 | } 75 | } 76 | 77 | #pragma omp parallel sections 78 | { 79 | #pragma omp section 80 | { 81 | BOOST_FOREACH(auto& itemVertex, listVertex) { 82 | _ptrDualHypergraphe->addHyperVertex(itemVertex); 83 | } 84 | } 85 | #pragma omp section 86 | { 87 | BOOST_FOREACH(auto& itemEdge, listEdge) { 88 | _ptrDualHypergraphe->addHyperEdge(itemEdge); 89 | } 90 | } 91 | } 92 | HyperFactory::closeSession(); 93 | 94 | _ptrDualHypergraphe->flush(); 95 | _result.setHypergrapheResult( _ptrDualHypergraphe ); 96 | } 97 | 98 | Dual::~Dual() { 99 | } 100 | -------------------------------------------------------------------------------- /src/algorithm/Helly.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/Helly.hh" 28 | #include "../model/include/Hypergraphe.hh" 29 | #include "../model/include/HyperVertex.hh" 30 | #include "../model/include/HyperEdge.hh" 31 | #include 32 | 33 | Helly::Helly(const boost::shared_ptr& ptrHypergrapheAbstrait) : 34 | _ptrHypergrapheAbstrait( ptrHypergrapheAbstrait ) { 35 | 36 | } 37 | 38 | void 39 | Helly::runAlgorithme() { 40 | 41 | _result.setBooleanResult(true); 42 | 43 | BOOST_FOREACH(auto& x, _ptrHypergrapheAbstrait->getHyperVertexList()) { 44 | BOOST_FOREACH(auto& y, _ptrHypergrapheAbstrait->getHyperVertexList()) { 45 | 46 | LibType::ListHyperEdge X_xy( allContainXY(x, y) ); 47 | BOOST_FOREACH(auto& v, _ptrHypergrapheAbstrait->getHyperVertexList()) { 48 | 49 | if( voisin(x, v) && voisin(y, v) ) { 50 | LibType::ListHyperEdge X_xv( allContainXY(x, v) ); 51 | LibType::ListHyperEdge X_yv( allContainXY(y, v) ); 52 | 53 | LibType::ListHyperEdge X; 54 | concatenate(X, X_xy); 55 | concatenate(X, X_xv); 56 | concatenate(X, X_yv); 57 | 58 | if( !nonEmptyIntersection(X) ) { 59 | _result.setBooleanResult(false); 60 | return; 61 | } 62 | } 63 | } 64 | 65 | } 66 | } 67 | } 68 | 69 | bool 70 | Helly::voisin(boost::shared_ptr& v1, boost::shared_ptr& v2) { 71 | BOOST_FOREACH(auto& element1, v1->getHyperEdgeList() ) { 72 | BOOST_FOREACH(auto& element2, v2->getHyperEdgeList() ) { 73 | if( element1==element2 ) { 74 | return true; 75 | } 76 | } 77 | } 78 | return false; 79 | } 80 | 81 | void 82 | Helly::concatenate(LibType::ListHyperEdge& dest, LibType::ListHyperEdge& src) { 83 | BOOST_FOREACH(auto& e, src) { 84 | dest.push_back(e); 85 | } 86 | } 87 | 88 | bool 89 | Helly::nonEmptyIntersection(LibType::ListHyperEdge& ensemble) { 90 | for(unsigned int i=0; i& e1, boost::shared_ptr& e2) { 101 | BOOST_FOREACH(auto& a, e1->getHyperVertexList()) { 102 | BOOST_FOREACH(auto& b, e2->getHyperVertexList()) { 103 | if(a==b)return true; 104 | } 105 | } 106 | return false; 107 | } 108 | 109 | LibType::ListHyperEdge& 110 | Helly::allContainXY(boost::shared_ptr& v1, boost::shared_ptr& v2) { 111 | LibType::ListHyperEdge * elist = new LibType::ListHyperEdge(); 112 | BOOST_FOREACH(auto& e, _ptrHypergrapheAbstrait->getHyperEdgeList()) { 113 | if( e->containVertex(v1) && e->containVertex(v2) ) { 114 | elist->push_back(e); 115 | } 116 | } 117 | return *elist; 118 | } 119 | 120 | RStructure 121 | Helly::getResult() const { 122 | return _result; 123 | } 124 | 125 | Helly::~Helly() { 126 | 127 | } 128 | -------------------------------------------------------------------------------- /src/algorithm/HyperGraphStat.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include 28 | #include "include/HyperGraphStat.hh" 29 | #include "../model/include/AdjacentMatrix.hh" 30 | 31 | HyperGraphStat::HyperGraphStat(const boost::shared_ptr& ptrHypergrapheAbstrait) { 32 | _ptrHypergrapheAbstrait = ptrHypergrapheAbstrait; 33 | 34 | _nhEdge = 0; 35 | _nhVertex = 0; 36 | _nhLink = 0; 37 | _rang = 0; 38 | _coRang = 0; 39 | } 40 | 41 | unsigned int 42 | HyperGraphStat::getNbrHyperEdge() const { 43 | return _nhEdge; 44 | } 45 | 46 | unsigned int 47 | HyperGraphStat::getNbrHyperVertex() const { 48 | return _nhVertex; 49 | } 50 | 51 | unsigned int 52 | HyperGraphStat::getNbrLinks() const { 53 | return _nhLink; 54 | } 55 | 56 | unsigned int 57 | HyperGraphStat::getRang() const { 58 | return _rang; 59 | } 60 | 61 | unsigned int 62 | HyperGraphStat::getCoRang() const { 63 | return _coRang; 64 | } 65 | 66 | void 67 | HyperGraphStat::runAlgorithme() { 68 | 69 | _nhEdge = _ptrHypergrapheAbstrait->getHyperEdgeList().size(); 70 | _nhVertex = _ptrHypergrapheAbstrait->getHyperVertexList().size(); 71 | 72 | AdjacentMatrix m( _ptrHypergrapheAbstrait->getAdjacentMatrix() ); 73 | LibType::ListHyperEdge eList( _ptrHypergrapheAbstrait->getHyperEdgeList() ); 74 | 75 | _rang = m.getRank(); 76 | _coRang = m.getCoRank(); 77 | } 78 | 79 | RStructure 80 | HyperGraphStat::getResult() const { 81 | return _result; 82 | } 83 | 84 | 85 | HyperGraphStat::~HyperGraphStat() { 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/algorithm/Isomorph.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/Isomorph.hh" 28 | #include "include/IsomorphSpace.hh" 29 | #include "../model/include/Hypergraphe.hh" 30 | #include "../model/include/HyperVertex.hh" 31 | #include "../model/include/HyperEdge.hh" 32 | #include 33 | #include 34 | #include 35 | 36 | Isomorph::Isomorph(const boost::shared_ptr& ptrHypergrapheAbstraitA, 37 | const boost::shared_ptr& ptrHypergrapheAbstraitB) 38 | : _ptrHypergrapheAbstraitA(ptrHypergrapheAbstraitA), 39 | _ptrHypergrapheAbstraitB(ptrHypergrapheAbstraitB) { 40 | 41 | } 42 | 43 | void 44 | Isomorph::runAlgorithme() { 45 | 46 | bool ret = false; 47 | 48 | if( _ptrHypergrapheAbstraitA->getHyperEdgeList().size() != _ptrHypergrapheAbstraitB->getHyperEdgeList().size() || 49 | _ptrHypergrapheAbstraitA->getHyperVertexList().size() != _ptrHypergrapheAbstraitB->getHyperVertexList().size() 50 | ) { 51 | _result.setBooleanResult( ret ); 52 | return; 53 | } 54 | 55 | IsomorphSpace * is = new IsomorphSpace(_ptrHypergrapheAbstraitA, _ptrHypergrapheAbstraitB); 56 | is->postConstraints(); 57 | 58 | unsigned int nbrThreadsSupported( std::thread::hardware_concurrency() ); 59 | 60 | if( nbrThreadsSupported <= 0 ) { 61 | nbrThreadsSupported = 1; 62 | }; 63 | 64 | Gecode::Search::Options opt; 65 | opt.threads = nbrThreadsSupported; 66 | 67 | Gecode::DFS ensembleSolution(is, opt); 68 | 69 | if( ensembleSolution.next() ) ret = true; 70 | else ret = false; 71 | 72 | delete is; 73 | 74 | _result.setBooleanResult( ret ); 75 | } 76 | 77 | RStructure 78 | Isomorph::getResult() const { 79 | return _result; 80 | } 81 | 82 | Isomorph::~Isomorph() { 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/algorithm/Linear.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/Linear.hh" 28 | #include "include/Simple.hh" 29 | #include 30 | 31 | Linear::Linear(boost::shared_ptr& ptrHypergrapheAbstrait) : 32 | _ptrHypergrapheAbstrait( ptrHypergrapheAbstrait ) { 33 | 34 | } 35 | 36 | void 37 | Linear::runAlgorithme() { 38 | 39 | Simple a( _ptrHypergrapheAbstrait ); 40 | a.runAlgorithme(); 41 | 42 | if( !a.getResult().getBooleanResult() ) { 43 | _result.setBooleanResult(false); 44 | return; 45 | } 46 | 47 | _result.setBooleanResult(true); 48 | 49 | LibType::ListHyperVertex listVertex( _ptrHypergrapheAbstrait->getHyperVertexList() ); 50 | LibType::ListHyperEdge listEdge ( _ptrHypergrapheAbstrait->getHyperEdgeList() ); 51 | 52 | for(unsigned int i=0; igetHyperVertexList() ); 56 | for(unsigned int k=0; kcontainVertex(subListVertex.at(k)) )counter++; 58 | }; 59 | if( counter > 1 ) { 60 | _result.setBooleanResult(false); 61 | break; 62 | } 63 | } 64 | } 65 | 66 | } 67 | 68 | RStructure 69 | Linear::getResult() const { 70 | return _result; 71 | } 72 | 73 | Linear::~Linear() { 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/algorithm/Simple.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | #include "include/Simple.hh" 27 | #include 28 | 29 | Simple::Simple(boost::shared_ptr& ptrHypergraphe) : _ptrHypergrapheAbstrait( ptrHypergraphe ) { 30 | 31 | } 32 | 33 | void 34 | Simple::runAlgorithme() { 35 | 36 | _result.setBooleanResult(true); 37 | 38 | LibType::ListHyperVertex listVertex( _ptrHypergrapheAbstrait->getHyperVertexList() ); 39 | LibType::ListHyperEdge listEdge ( _ptrHypergrapheAbstrait->getHyperEdgeList() ); 40 | 41 | unsigned int i( 0 ), j( 0 ); 42 | for(i=0; i < listEdge.size(); i++) { 43 | for(j=i; j < listEdge.size(); j++) { 44 | if( i!=j && subsetVertexList(listEdge.at(i)->getHyperVertexList(), listEdge.at(j)->getHyperVertexList()) ) { 45 | _result.setBooleanResult(false); 46 | break; 47 | }; 48 | }; 49 | }; 50 | 51 | } 52 | 53 | bool 54 | Simple::subsetVertexList(const LibType::ListHyperVertex& vList1, const LibType::ListHyperVertex& vList2) const { 55 | 56 | bool ret1( true ), ret2( true ); 57 | 58 | #pragma omp parallel sections 59 | { 60 | 61 | #pragma omp section 62 | { 63 | 64 | BOOST_FOREACH(const auto& v, vList1) { 65 | if( !contains(vList2, v))ret1 = false; 66 | } 67 | 68 | } 69 | 70 | #pragma omp section 71 | { 72 | 73 | BOOST_FOREACH(const auto& v, vList2) { 74 | if( !contains(vList1, v))ret2 = false; 75 | } 76 | 77 | } 78 | 79 | } 80 | 81 | return (ret1 || ret2); 82 | } 83 | 84 | bool 85 | Simple::contains(const LibType::ListHyperVertex& vList, const boost::shared_ptr& v) const { 86 | 87 | bool ret( false ); 88 | BOOST_FOREACH(const auto& w, vList) { 89 | if( w==v ) { 90 | ret = true; 91 | break; 92 | } 93 | } 94 | return ret; 95 | } 96 | 97 | RStructure 98 | Simple::getResult() const { 99 | return _result; 100 | } 101 | 102 | Simple::~Simple() { 103 | 104 | } 105 | -------------------------------------------------------------------------------- /src/algorithm/include/Connected.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Definition of the algorithm deciding the connectivity of a hypergraph. 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_CONNECTED_HH_ 30 | #define ALGORITHM_INCLUDE_CONNECTED_HH_ 31 | 32 | #include "../../model/include/HypergrapheAbstrait.hh" 33 | #include "../../model/include/AlgorithmeAbstrait.hh" 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | /** 40 | * Definition of the algorithm deciding the connectivity of a hypergraph. 41 | */ 42 | class Connected : public AlgorithmeAbstrait { 43 | 44 | public: 45 | 46 | /** 47 | * Constructor. 48 | * @param boost::shared_ptr Hypergraph shared pointer 49 | */ 50 | Connected(boost::shared_ptr&); 51 | 52 | /** 53 | * Get result structure 54 | * @return Result structure 55 | */ 56 | RStructure getResult() const; 57 | 58 | /** 59 | * Destructor. 60 | */ 61 | ~Connected(); 62 | 63 | 64 | protected: 65 | 66 | /** 67 | * Run the algorithm 68 | */ 69 | void runAlgorithme(); 70 | 71 | /** 72 | * Vertical scan of a path of the matrix 73 | * @param Visited 74 | * @param To-visit stack 75 | * @param Row Id 76 | */ 77 | void exploreVertical(std::vector&, std::stack&, unsigned int); 78 | 79 | /** 80 | * Horizontal scan of a path of the matrix 81 | * @param Visited 82 | * @param To-visit stack 83 | * @param Column Id 84 | */ 85 | void exploreHorizontal(std::vector&, std::stack&, unsigned int); 86 | 87 | /** 88 | * Check whether hyper-vertex already visited 89 | * @param Visited 90 | * @param Hyper-vertex Id to visit 91 | * @return True or False 92 | */ 93 | bool isVertexVisited(std::vector&, unsigned int) const; 94 | 95 | /** 96 | * Check whether hyper-edge already visited 97 | * @param Visited 98 | * @param Hyper-edge Id to visit 99 | * @return True or False 100 | */ 101 | bool isEdgeVisited(std::vector&, unsigned int) const; 102 | 103 | 104 | protected: 105 | 106 | /** 107 | * Hypergraph shared pointer 108 | */ 109 | boost::shared_ptr 110 | _ptrHypergrapheAbstrait; 111 | 112 | /** 113 | * Result structure 114 | */ 115 | RStructure _result; 116 | 117 | }; 118 | 119 | 120 | #endif /* ALGORITHM_INCLUDE_CONNECTED_HH_ */ 121 | -------------------------------------------------------------------------------- /src/algorithm/include/Diameter.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | #ifndef ALGORITHM_INCLUDE_DIAMETER_HH_ 27 | #define ALGORITHM_INCLUDE_DIAMETER_HH_ 28 | 29 | #include 30 | #include "../../model/include/HypergrapheAbstrait.hh" 31 | #include "../../model/include/AlgorithmeAbstrait.hh" 32 | 33 | 34 | class Diameter : public AlgorithmeAbstrait { 35 | 36 | public: 37 | 38 | Diameter(boost::shared_ptr&); 39 | 40 | RStructure getResult() const; 41 | 42 | ~Diameter(); 43 | 44 | 45 | protected: 46 | 47 | void runAlgorithme(); 48 | 49 | 50 | protected: 51 | 52 | boost::shared_ptr 53 | _ptrHypergrapheAbstrait; 54 | 55 | RStructure _result; 56 | 57 | }; 58 | 59 | 60 | 61 | #endif /* ALGORITHM_INCLUDE_DIAMETER_HH_ */ 62 | -------------------------------------------------------------------------------- /src/algorithm/include/Dual.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Hypergraph dual algorithm 28 | */ 29 | 30 | #ifndef ALGORITHM_INCLUDE_DUAL_HH_ 31 | #define ALGORITHM_INCLUDE_DUAL_HH_ 32 | 33 | #include 34 | #include "../../model/include/HypergrapheAbstrait.hh" 35 | #include "../../model/include/AlgorithmeAbstrait.hh" 36 | 37 | /** 38 | * Hypergraph dual algorithm 39 | */ 40 | class Dual : public AlgorithmeAbstrait { 41 | 42 | public: 43 | 44 | /** 45 | * Constructor. 46 | * @param Hypergraph shareedpointer 47 | */ 48 | Dual(const boost::shared_ptr&); 49 | 50 | /** 51 | * Get result structure 52 | * @return Result structure 53 | */ 54 | RStructure getResult() const; 55 | 56 | /** 57 | * Destructor. 58 | */ 59 | ~Dual(); 60 | 61 | protected: 62 | 63 | /** 64 | * Run the algorithm 65 | */ 66 | void runAlgorithme(); 67 | 68 | protected: 69 | 70 | /** 71 | * Hypergraph shared pointer 72 | */ 73 | boost::shared_ptr 74 | _ptrHypergrapheAbstrait; 75 | 76 | /** 77 | * Dual hypergraph shared pointer 78 | */ 79 | boost::shared_ptr 80 | _ptrDualHypergraphe; 81 | 82 | /** 83 | * Result structure 84 | */ 85 | RStructure _result; 86 | 87 | }; 88 | 89 | 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /src/algorithm/include/Helly.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Helly property algorithm 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_HELLY_HH_ 30 | #define ALGORITHM_INCLUDE_HELLY_HH_ 31 | 32 | #include "../../model/include/AlgorithmeAbstrait.hh" 33 | #include "../../model/include/RStructure.hh" 34 | 35 | /** 36 | * Helly property algorithm 37 | */ 38 | class Helly : public AlgorithmeAbstrait { 39 | 40 | public: 41 | 42 | /** 43 | * Constructor. 44 | * @param Hypergraph shared pointer 45 | */ 46 | Helly(const boost::shared_ptr&); 47 | 48 | /** 49 | * Get result structure 50 | * @return Result structure 51 | */ 52 | RStructure getResult() const; 53 | 54 | /** 55 | * Déstructor. 56 | */ 57 | ~Helly(); 58 | 59 | protected: 60 | 61 | /** 62 | * Run the algorithm 63 | */ 64 | void runAlgorithme(); 65 | 66 | /** 67 | * Constructs the hyper-edge list containing the two hyper-vertices 68 | * @param First hyper-vertex. 69 | * @param Second hyper-vertex. 70 | * @return List containing the two hyper-vertices 71 | */ 72 | LibType::ListHyperEdge& allContainXY(boost::shared_ptr&, boost::shared_ptr&); 73 | 74 | /** 75 | * Checks whether the intersection between the elements in the list is not empty 76 | * @param Hyper-edge list 77 | * @return True or False 78 | */ 79 | bool nonEmptyIntersection(LibType::ListHyperEdge&); 80 | 81 | /** 82 | * Checks whether the intersection between these two hyper-edges is not empty 83 | * @param First hyper-edge 84 | * @param Second hyper-edge 85 | * @return True or False 86 | */ 87 | bool nonEmptyBetween(boost::shared_ptr&, boost::shared_ptr&); 88 | 89 | /** 90 | * Checks whether the two hyper-vertexes are neighbors 91 | * @param First hyper-vertex 92 | * @param Second hyper-vertex 93 | * @return True or False 94 | */ 95 | bool voisin(boost::shared_ptr&, boost::shared_ptr&); 96 | 97 | /** 98 | * Concatenation of two lists of hyper-edges 99 | * @param Destination 100 | * @param Source to concatenate 101 | */ 102 | void concatenate(LibType::ListHyperEdge&, LibType::ListHyperEdge&); 103 | 104 | 105 | protected: 106 | 107 | /** 108 | * Hypergraph shared pointer 109 | */ 110 | boost::shared_ptr 111 | _ptrHypergrapheAbstrait; 112 | 113 | /** 114 | * Result structure 115 | */ 116 | RStructure _result; 117 | 118 | }; 119 | 120 | 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /src/algorithm/include/HyperGraphStat.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Stats on hypergraph 28 | */ 29 | 30 | #ifndef ALGORITHM_INCLUDE_HPGSTAT 31 | #define ALGORITHM_INCLUDE_HPGSTAT 32 | 33 | #include 34 | #include "../../model/include/HypergrapheAbstrait.hh" 35 | #include "../../model/include/Hypergraphe.hh" 36 | #include "../../model/include/HyperVertex.hh" 37 | #include "../../model/include/HyperEdge.hh" 38 | #include "../../model/include/AlgorithmeAbstrait.hh" 39 | #include "../../model/include/RStructure.hh" 40 | 41 | 42 | /** 43 | * Stats on hypergraph 44 | */ 45 | class HyperGraphStat : public AlgorithmeAbstrait { 46 | 47 | public: 48 | 49 | /** 50 | * Constructor. 51 | * @param Hypergraph shared pointer 52 | */ 53 | HyperGraphStat(const boost::shared_ptr&); 54 | 55 | /** 56 | * Unused here 57 | */ 58 | RStructure getResult() const; 59 | 60 | /** 61 | * Destructor. 62 | */ 63 | ~HyperGraphStat(); 64 | 65 | 66 | public: 67 | 68 | /** 69 | * Get hyper-edge count 70 | */ 71 | unsigned int getNbrHyperEdge() const; 72 | 73 | /** 74 | * Get hyper-vertex count 75 | */ 76 | unsigned int getNbrHyperVertex() const; 77 | 78 | /** 79 | * Get links count 80 | */ 81 | unsigned int getNbrLinks() const; 82 | 83 | /** 84 | * Get hypergraph's rank 85 | */ 86 | unsigned int getRang() const; 87 | 88 | /** 89 | * Get hypergraph's co-rank 90 | */ 91 | unsigned int getCoRang() const; 92 | 93 | protected: 94 | 95 | /** 96 | * Run the algorithm 97 | */ 98 | void runAlgorithme(); 99 | 100 | protected: 101 | 102 | /** 103 | * Hypergraph shared pointer 104 | */ 105 | boost::shared_ptr 106 | _ptrHypergrapheAbstrait; 107 | 108 | /** 109 | * Unused here 110 | */ 111 | RStructure _result; 112 | 113 | /** 114 | * Hyper-edge count 115 | */ 116 | unsigned int _nhEdge; 117 | 118 | /** 119 | * Hyper-vertex count 120 | */ 121 | unsigned int _nhVertex; 122 | 123 | /** 124 | * Links count 125 | */ 126 | unsigned int _nhLink; 127 | 128 | /** 129 | * Hypergraph's rank 130 | */ 131 | unsigned int _rang; 132 | 133 | /** 134 | * Hypergraph's co-rank 135 | */ 136 | unsigned int _coRang; 137 | 138 | }; 139 | 140 | 141 | #endif 142 | -------------------------------------------------------------------------------- /src/algorithm/include/Isomorph.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Isomorphism algorithm 28 | */ 29 | 30 | #ifndef ALGORITHM_INCLUDE_ISOMORPHISM_HH_ 31 | #define ALGORITHM_INCLUDE_ISOMORPHISM_HH_ 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "../../model/include/HypergrapheAbstrait.hh" 39 | #include "../../model/include/AlgorithmeAbstrait.hh" 40 | 41 | /** 42 | * Isomorphism algorithm 43 | */ 44 | class Isomorph : public AlgorithmeAbstrait { 45 | 46 | public: 47 | 48 | /** 49 | * Constructor. 50 | * @param Hypergraph shared pointer 51 | * @param Hypergraph shared pointer 52 | */ 53 | Isomorph(const boost::shared_ptr&, const boost::shared_ptr&); 54 | 55 | /** 56 | * Get result structure 57 | * @Result structure 58 | */ 59 | RStructure getResult() const; 60 | 61 | /** 62 | * Destructor 63 | */ 64 | ~Isomorph(); 65 | 66 | protected: 67 | 68 | /** 69 | * Run the algorithm 70 | */ 71 | void runAlgorithme(); 72 | 73 | protected: 74 | 75 | /** 76 | * Hypergraph shared pointer 77 | */ 78 | boost::shared_ptr 79 | _ptrHypergrapheAbstraitA; 80 | 81 | /** 82 | * Hypergraph shared pointer 83 | */ 84 | boost::shared_ptr 85 | _ptrHypergrapheAbstraitB; 86 | 87 | /** 88 | * Result structure 89 | */ 90 | RStructure _result; 91 | 92 | }; 93 | 94 | 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /src/algorithm/include/IsomorphSpace.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #ifndef ALGORITHM_INCLUDE_ISOMORPHISMSPACE_HH_ 28 | #define ALGORITHM_INCLUDE_ISOMORPHISMSPACE_HH_ 29 | 30 | #include 31 | #include 32 | #include 33 | #include "../../model/include/LibType.hh" 34 | #include "../../model/include/Hypergraphe.hh" 35 | #include "../../model/include/HyperVertex.hh" 36 | #include "../../model/include/HyperEdge.hh" 37 | 38 | class HypergrapheAbstrait; 39 | 40 | class IsomorphSpace : public Gecode::Space { 41 | 42 | public: 43 | 44 | IsomorphSpace(const boost::shared_ptr&, const boost::shared_ptr&); 45 | 46 | void postConstraints(); 47 | 48 | #if GECODE_VERSION_NUMBER > 500100 49 | 50 | Gecode::Space * copy(); 51 | 52 | IsomorphSpace(IsomorphSpace& p); 53 | 54 | #else 55 | 56 | Gecode::Space * copy(bool share); 57 | 58 | IsomorphSpace(bool share, IsomorphSpace& p); 59 | 60 | #endif 61 | 62 | 63 | Gecode::IntVarArray _varEdge; 64 | 65 | Gecode::IntVarArray _bVarEdge; 66 | 67 | Gecode::IntVarArray _bVarEdge2; 68 | 69 | protected: 70 | 71 | boost::shared_ptr _ptrHypergrapheA; 72 | 73 | boost::shared_ptr _ptrHypergrapheB; 74 | 75 | }; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/algorithm/include/Linear.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Linear algorithm 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_LINEAR_HH_ 30 | #define ALGORITHM_INCLUDE_LINEAR_HH_ 31 | 32 | #include "../../model/include/AlgorithmeAbstrait.hh" 33 | 34 | /** 35 | * Linear algorithm 36 | */ 37 | class Linear : public AlgorithmeAbstrait { 38 | 39 | public: 40 | 41 | /** 42 | * Constructor 43 | * @param Hypergraph shared pointer 44 | */ 45 | Linear(boost::shared_ptr&); 46 | 47 | /** 48 | * get result structure 49 | * @return Result structure 50 | */ 51 | RStructure getResult() const; 52 | 53 | /** 54 | * Destructeur. 55 | */ 56 | ~Linear(); 57 | 58 | 59 | protected: 60 | 61 | /** 62 | * Run the algorithm 63 | */ 64 | void runAlgorithme(); 65 | 66 | 67 | protected: 68 | 69 | /** 70 | * Hypergraph shared pointer 71 | */ 72 | boost::shared_ptr 73 | _ptrHypergrapheAbstrait; 74 | 75 | /** 76 | * Result structure 77 | */ 78 | RStructure _result; 79 | 80 | }; 81 | 82 | 83 | 84 | #endif /* ALGORITHM_INCLUDE_LINEAR_HH_ */ 85 | -------------------------------------------------------------------------------- /src/algorithm/include/Path.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Search algorithm for paths from hyper-vertex e1 to hyper-vertex e2 28 | */ 29 | 30 | #ifndef ALGORITHM_INCLUDE_PATH_HH_ 31 | #define ALGORITHM_INCLUDE_PATH_HH_ 32 | 33 | #include "../../model/include/HypergrapheAbstrait.hh" 34 | #include "../../model/include/AlgorithmeAbstrait.hh" 35 | #include "../../model/include/RStructurePath.hh" 36 | 37 | /** 38 | * Search algorithm for paths from hyper-vertex e1 to hyper-vertex e2 39 | */ 40 | class Path : public AlgorithmeAbstrait { 41 | 42 | public: 43 | 44 | /* 45 | * Constructor. 46 | * @param boost::shared_ptr Hypergraph shared pointer 47 | */ 48 | Path(boost::shared_ptr&); 49 | 50 | /** 51 | * Configure the vertices to use to list paths 52 | */ 53 | void setHyperVertex(boost::shared_ptr&, boost::shared_ptr&); 54 | 55 | /** 56 | * Get result structure 57 | * @return Result structure 58 | */ 59 | RStructure getResult() const; 60 | 61 | /** 62 | * Get path result structure 63 | * @return Path result structure 64 | */ 65 | RStructurePath getPathResult() const; 66 | 67 | /** 68 | * Set the limit of paths. Default 0 if not set 69 | */ 70 | void setLimit(unsigned int); 71 | 72 | /** 73 | * Get limit 74 | */ 75 | unsigned int getLimit() const; 76 | 77 | /** 78 | * Destructor. 79 | */ 80 | ~Path(); 81 | 82 | 83 | protected: 84 | 85 | /** 86 | * Run the algorithm 87 | */ 88 | void runAlgorithme(); 89 | 90 | /** 91 | * Checks if HyperVertex is contained in the list 92 | */ 93 | bool vertexContained(LibType::ListHyperVertex&, boost::shared_ptr&) const; 94 | 95 | /** 96 | * Add the Hyper-vertex of an hyper-edge to the mentioned list 97 | */ 98 | void addVertexList(LibType::ListHyperVertex&, LibType::ListHyperVertex&, const boost::shared_ptr&) const; 99 | 100 | 101 | void buildPathToPathList(LibType::PathList&, LibType::ListHyperVertex&); 102 | 103 | protected: 104 | 105 | /** 106 | * Hypergraph shared pointer 107 | */ 108 | boost::shared_ptr 109 | _ptrHypergrapheAbstrait; 110 | 111 | /** 112 | * Source hyper-vertex 113 | */ 114 | boost::shared_ptr _source; 115 | 116 | /** 117 | * Destination hyper-vertex 118 | */ 119 | boost::shared_ptr _destination; 120 | 121 | /** 122 | * Path result structure 123 | */ 124 | RStructurePath _result; 125 | 126 | /** 127 | * Limit 128 | */ 129 | unsigned int _limite; 130 | }; 131 | 132 | 133 | #endif /* SRC_ALGORITHM_INCLUDE_PATH_HH_ */ 134 | -------------------------------------------------------------------------------- /src/algorithm/include/Simple.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Simple algorithm 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_SIMPLE_HH_ 30 | #define ALGORITHM_INCLUDE_SIMPLE_HH_ 31 | 32 | #include 33 | #include "../../model/include/HypergrapheAbstrait.hh" 34 | #include "../../model/include/Hypergraphe.hh" 35 | #include "../../model/include/HyperVertex.hh" 36 | #include "../../model/include/HyperEdge.hh" 37 | #include "../../model/include/AlgorithmeAbstrait.hh" 38 | #include "../../model/include/RStructure.hh" 39 | #include "Linear.hh" 40 | 41 | /** 42 | * Simple algorithm 43 | */ 44 | class Simple : public AlgorithmeAbstrait { 45 | 46 | public: 47 | 48 | /** 49 | * Constructor 50 | * @param Hypergraph shared pointer 51 | */ 52 | Simple(boost::shared_ptr&); 53 | 54 | /** 55 | * get result structure 56 | * @return Result structure 57 | */ 58 | RStructure getResult() const; 59 | 60 | /** 61 | * Destructor. 62 | */ 63 | ~Simple(); 64 | 65 | 66 | protected: 67 | 68 | friend class Linear; 69 | 70 | /** 71 | * Run the algoithm 72 | */ 73 | void runAlgorithme(); 74 | 75 | /** 76 | * Verification of inclusion between hyper-vertex via vertex 77 | * @param First list 78 | * @param Seconde list 79 | * @return True or False 80 | */ 81 | bool subsetVertexList(const LibType::ListHyperVertex&, const LibType::ListHyperVertex&) const; 82 | 83 | /** 84 | * Checks if a hyper-vertex is contained in the list 85 | * @param Hyper-vertex list 86 | * @param The hyer-vertex. 87 | * @return True or False 88 | */ 89 | bool contains(const LibType::ListHyperVertex&, const boost::shared_ptr&) const; 90 | 91 | 92 | protected: 93 | 94 | /** 95 | * Hypergraph shared pointer 96 | */ 97 | boost::shared_ptr 98 | _ptrHypergrapheAbstrait; 99 | 100 | /** 101 | * Result structure 102 | */ 103 | RStructure _result; 104 | 105 | 106 | }; 107 | 108 | 109 | 110 | #endif /* ALGORITHM_INCLUDE_SIMPLE_HH_ */ 111 | -------------------------------------------------------------------------------- /src/algorithm/include/kRegular.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * K-regular algorithm 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_KREGULAR_HH_ 30 | #define ALGORITHM_INCLUDE_KREGULAR_HH_ 31 | 32 | #include 33 | #include "../../model/include/HypergrapheAbstrait.hh" 34 | #include "../../model/include/Hypergraphe.hh" 35 | #include "../../model/include/HyperVertex.hh" 36 | #include "../../model/include/HyperEdge.hh" 37 | #include "../../model/include/AlgorithmeAbstrait.hh" 38 | #include "../../model/include/RStructure.hh" 39 | 40 | /** 41 | * K-regular algorithm 42 | */ 43 | class kRegular : public AlgorithmeAbstrait { 44 | 45 | public: 46 | 47 | /** 48 | * Constructor. 49 | * @param Hypergraph shared pointer 50 | */ 51 | kRegular(const boost::shared_ptr&); 52 | 53 | /** 54 | * Get result structure 55 | * @return Result structure 56 | */ 57 | RStructure getResult() const; 58 | 59 | /** 60 | * Destructor. 61 | */ 62 | ~kRegular(); 63 | 64 | protected: 65 | 66 | /** 67 | * Run the algorithm 68 | */ 69 | void runAlgorithme(); 70 | 71 | protected: 72 | 73 | /** 74 | * Hypergraph shared pointer 75 | */ 76 | boost::shared_ptr 77 | _ptrHypergrapheAbstrait; 78 | 79 | /** 80 | * Result structure 81 | */ 82 | RStructure _result; 83 | 84 | }; 85 | 86 | 87 | #endif /* ALGORITHM_INCLUDE_KREGULAR_HH_ */ 88 | -------------------------------------------------------------------------------- /src/algorithm/include/kUniform.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * K-uniforme algorithm 28 | */ 29 | #ifndef ALGORITHM_INCLUDE_KUNIFORM_HH_ 30 | #define ALGORITHM_INCLUDE_KUNIFORM_HH_ 31 | 32 | #include 33 | #include "../../model/include/HypergrapheAbstrait.hh" 34 | #include "../../model/include/Hypergraphe.hh" 35 | #include "../../model/include/HyperVertex.hh" 36 | #include "../../model/include/HyperEdge.hh" 37 | #include "../../model/include/AlgorithmeAbstrait.hh" 38 | #include "../../model/include/RStructure.hh" 39 | 40 | /** 41 | * K-uniforme algorithm 42 | */ 43 | class kUniform : public AlgorithmeAbstrait { 44 | 45 | public: 46 | 47 | /** 48 | * Constructor 49 | * @param Hypergraph shared pointer 50 | * @param K value 51 | */ 52 | kUniform(boost::shared_ptr& ptrHypergrapheAbstrait, const unsigned int&); 53 | 54 | /** 55 | * Get result structure 56 | * @return Result structure 57 | */ 58 | RStructure getResult() const; 59 | 60 | /** 61 | * Destructor. 62 | */ 63 | ~kUniform(); 64 | 65 | 66 | protected: 67 | 68 | /** 69 | * Run the algorithm 70 | */ 71 | void runAlgorithme(); 72 | 73 | 74 | protected: 75 | 76 | /** 77 | * Hypergraph shared pointer 78 | */ 79 | boost::shared_ptr 80 | _ptrHypergrapheAbstrait; 81 | 82 | /** 83 | * K value 84 | */ 85 | unsigned int _k; 86 | 87 | /** 88 | * Result structure 89 | */ 90 | RStructure _result; 91 | 92 | }; 93 | 94 | 95 | 96 | #endif /* ALGORITHM_INCLUDE_KUNIFORM_HH_ */ 97 | -------------------------------------------------------------------------------- /src/algorithm/kRegular.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | #include "include/kRegular.hh" 27 | #include 28 | 29 | kRegular::kRegular(const boost::shared_ptr& ptrHypergrapheAbstrait) { 30 | _ptrHypergrapheAbstrait = ptrHypergrapheAbstrait; 31 | } 32 | 33 | void 34 | kRegular::runAlgorithme() { 35 | 36 | _result.setBooleanResult(true); 37 | AdjacentMatrix matrix ( _ptrHypergrapheAbstrait->getAdjacentMatrix() ); 38 | 39 | int compteur = -1; 40 | BOOST_FOREACH(const auto& e, _ptrHypergrapheAbstrait->getIndexHyperVertex() ) { 41 | if(compteur==-1) { 42 | compteur = matrix.getVertexDegree(e.first); 43 | } else { 44 | if( (int)matrix.getVertexDegree(e.first) != compteur ) { 45 | _result.setBooleanResult(false); 46 | }; 47 | }; 48 | } 49 | 50 | if( compteur==-1 ) _result.setBooleanResult(true); 51 | } 52 | 53 | RStructure 54 | kRegular::getResult() const { 55 | return _result; 56 | } 57 | 58 | kRegular::~kRegular() { 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/algorithm/kUniform.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/kUniform.hh" 28 | #include 29 | 30 | 31 | kUniform::kUniform(boost::shared_ptr& ptrHypergrapheAbstrait, const unsigned int& k) : 32 | _ptrHypergrapheAbstrait( ptrHypergrapheAbstrait ), 33 | _k( k ) { 34 | } 35 | 36 | RStructure 37 | kUniform::getResult() const { 38 | return _result; 39 | } 40 | 41 | void 42 | kUniform::runAlgorithme() { 43 | 44 | AdjacentMatrix matrix ( _ptrHypergrapheAbstrait->getAdjacentMatrix() ); 45 | _result.setBooleanResult(true); 46 | 47 | BOOST_FOREACH(const auto& e, _ptrHypergrapheAbstrait->getIndexHyperEdge() ) { 48 | if( matrix.getEdgeSize(e.first) != _k ) { 49 | _result.setBooleanResult(false); 50 | }; 51 | } 52 | } 53 | 54 | kUniform::~kUniform() { 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/io/ReaderAbstrait.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/ReaderAbstrait.hh" 28 | 29 | ReaderAbstrait::ReaderAbstrait(const boost::shared_ptr& p) { 30 | _ptrHypergrapheAbstrait = p; 31 | } 32 | 33 | boost::shared_ptr& 34 | ReaderAbstrait::getHypergraphe() { 35 | return _ptrHypergrapheAbstrait; 36 | } 37 | 38 | ReaderAbstrait::~ReaderAbstrait() { 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/io/ReaderFile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/ReaderFile.hh" 28 | #include "../model/include/HyperFactory.hh" 29 | #include "../model/include/Hypergraphe.hh" 30 | 31 | #include 32 | #include 33 | 34 | ReaderFile::ReaderFile() : ReaderAbstrait( boost::shared_ptr( new Hypergraphe() ) ) { 35 | 36 | } 37 | 38 | void 39 | ReaderFile::readHypergraphe(std::istream& entree) { 40 | 41 | while( HyperFactory::isSession() ); 42 | HyperFactory::startSession( _ptrHypergrapheAbstrait ); 43 | 44 | readHypergrapheHyperVertex( entree ); 45 | readHypergrapheHyperEdge( entree ); 46 | 47 | unsigned int vertex( 0 ); 48 | unsigned int edge( 0 ); 49 | 50 | entree >> edge; 51 | entree >> vertex; 52 | 53 | while( entree ) { 54 | 55 | HyperFactory::link( hyperVertexById(vertex), hyperEdgeById(edge) ); 56 | 57 | entree >> edge; 58 | entree >> vertex; 59 | 60 | }; 61 | 62 | flush(); 63 | 64 | HyperFactory::closeSession(); 65 | } 66 | 67 | void 68 | ReaderFile::readHypergrapheHyperVertex(std::istream& entree) { 69 | 70 | std::string s; 71 | std::getline(entree, s); 72 | 73 | std::stringstream k( s ); 74 | 75 | unsigned int i( 0 ); 76 | while( k >> i ) { 77 | boost::shared_ptr ptrHv( new HyperVertex(_ptrHypergrapheAbstrait, i) ); 78 | _listHyperVertex.push_back( ptrHv ); 79 | } 80 | } 81 | 82 | void 83 | ReaderFile::readHypergrapheHyperEdge(std::istream& entree) { 84 | 85 | std::string s; 86 | std::getline(entree, s); 87 | 88 | std::stringstream k( s ); 89 | 90 | unsigned int i( 0 ); 91 | while( k >> i ) { 92 | boost::shared_ptr ptrHe( new HyperEdge(_ptrHypergrapheAbstrait, i) ); 93 | _listHyperEdge.push_back( ptrHe ); 94 | } 95 | } 96 | 97 | void 98 | ReaderFile::flush() { 99 | 100 | #pragma omp parallel sections 101 | { 102 | 103 | #pragma omp section 104 | { 105 | BOOST_FOREACH(auto& vertex, _listHyperVertex) { 106 | _ptrHypergrapheAbstrait->addHyperVertex( vertex ); 107 | } 108 | } 109 | 110 | #pragma omp section 111 | { 112 | BOOST_FOREACH(auto& edge, _listHyperEdge) { 113 | _ptrHypergrapheAbstrait->addHyperEdge( edge ); 114 | } 115 | } 116 | 117 | } 118 | 119 | _ptrHypergrapheAbstrait->flush(); 120 | } 121 | 122 | boost::shared_ptr& 123 | ReaderFile::hyperVertexById(unsigned int& id) { 124 | int r = 0; 125 | for(unsigned int i = 0; i < _listHyperVertex.size(); i++) 126 | if( id == _listHyperVertex.at(i)->getIdentifier() ) 127 | r = i; 128 | return _listHyperVertex.at( r ); 129 | } 130 | 131 | boost::shared_ptr& 132 | ReaderFile::hyperEdgeById(unsigned int& id) { 133 | int r = 0; 134 | for(unsigned int i = 0; i < _listHyperEdge.size(); i++) 135 | if( id == _listHyperEdge.at(i)->getIdentifier() ) 136 | r = i; 137 | return _listHyperEdge.at( r ); 138 | } 139 | 140 | ReaderFile::~ReaderFile() { 141 | 142 | } 143 | -------------------------------------------------------------------------------- /src/io/WriterAbstrait.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/WriterAbstrait.hh" 28 | 29 | WriterAbstrait::WriterAbstrait(const boost::shared_ptr& ptrHypergrapheAbstrait) : 30 | _ptrHypergrapheAbstrait( ptrHypergrapheAbstrait ){ 31 | 32 | } 33 | 34 | WriterAbstrait::~WriterAbstrait() { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/io/WriterFile.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/WriterFile.hh" 28 | 29 | #include "../model/include/HypergrapheAbstrait.hh" 30 | #include "../model/include/HyperVertex.hh" 31 | #include "../model/include/HyperEdge.hh" 32 | 33 | #include 34 | #include 35 | 36 | WriterFile::WriterFile(const boost::shared_ptr& ptrHypergrapheAbstrait) : 37 | WriterAbstrait( ptrHypergrapheAbstrait ) { 38 | 39 | } 40 | 41 | void 42 | WriterFile::writeAdjacentMatrix(std::ostream& sortie) const { 43 | 44 | LibType::AdjacentMatrixContainerBool 45 | adjacentMatrixBool( _ptrHypergrapheAbstrait->getAdjacentMatrix().getBoolAdjacentMatrix() ); 46 | 47 | boost::tuple 48 | matrixDimension( _ptrHypergrapheAbstrait->getAdjacentMatrix().getMatrixDimension() ); 49 | 50 | unsigned int n( matrixDimension.get<0>() ), m( matrixDimension.get<1>() ); 51 | 52 | for(unsigned int i=0; igetHyperEdgeList() ); 67 | 68 | BOOST_FOREACH(const auto& edge, listEdge) { 69 | LibType::ListHyperVertex vertexList( edge->getHyperVertexList() ); 70 | BOOST_FOREACH(const auto& vertex, vertexList) { 71 | sortie << edge->getIdentifier() << " " << vertex->getIdentifier() << std::endl; 72 | } 73 | } 74 | } 75 | 76 | void 77 | WriterFile::writeHypergrapheHyperVertex(std::ostream& sortie) const { 78 | 79 | LibType::ListHyperVertex listVertex( _ptrHypergrapheAbstrait->getHyperVertexList() ); 80 | 81 | BOOST_FOREACH(const auto& vertex, listVertex) { 82 | sortie << vertex->getIdentifier() << " "; 83 | } 84 | 85 | sortie << "\n"; 86 | } 87 | 88 | void 89 | WriterFile::writeHypergrapheHyperEdge(std::ostream& sortie) const { 90 | 91 | LibType::ListHyperEdge listEdge( _ptrHypergrapheAbstrait->getHyperEdgeList() ); 92 | 93 | BOOST_FOREACH(const auto& edge, listEdge) { 94 | sortie << edge->getIdentifier() << " "; 95 | } 96 | 97 | sortie << "\n"; 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/io/include/ReaderAbstrait.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Input interface 28 | */ 29 | #ifndef IO_INCLUDE_READERABSTRAIT_HH_ 30 | #define IO_INCLUDE_READERABSTRAIT_HH_ 31 | 32 | #include "../../model/include/HypergrapheAbstrait.hh" 33 | #include 34 | 35 | /** 36 | * Input interface 37 | */ 38 | class ReaderAbstrait { 39 | 40 | public: 41 | 42 | /** 43 | * Constructor 44 | * @param HypergrapheAbstrait shared pointer 45 | */ 46 | ReaderAbstrait(const boost::shared_ptr&); 47 | 48 | /** 49 | * Read and build the hypergraph 50 | * @param Input flow 51 | */ 52 | virtual void readHypergraphe(std::istream&) = 0; 53 | 54 | /** 55 | * Get the hypergraph after building 56 | */ 57 | boost::shared_ptr& 58 | getHypergraphe(); 59 | 60 | /** 61 | * Virtual destructor 62 | */ 63 | virtual ~ReaderAbstrait(); 64 | 65 | 66 | protected: 67 | 68 | /** 69 | * Read hyper-vertex 70 | * @param Input flow 71 | */ 72 | virtual void readHypergrapheHyperVertex(std::istream&) = 0; 73 | 74 | /** 75 | * Read hyper-edge 76 | * @param Input flow 77 | */ 78 | virtual void readHypergrapheHyperEdge(std::istream&) = 0; 79 | 80 | 81 | protected: 82 | 83 | /** 84 | * HypergrapheAbstrait shared pointer 85 | */ 86 | boost::shared_ptr 87 | _ptrHypergrapheAbstrait; 88 | 89 | }; 90 | 91 | 92 | 93 | #endif /* IO_INCLUDE_READERABSTRAIT_HH_ */ 94 | -------------------------------------------------------------------------------- /src/io/include/ReaderFile.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Input module 28 | */ 29 | #ifndef IO_INCLUDE_READERFILE_HH_ 30 | #define IO_INCLUDE_READERFILE_HH_ 31 | 32 | #include "ReaderAbstrait.hh" 33 | #include 34 | 35 | 36 | /** 37 | * Input module 38 | */ 39 | class ReaderFile : public ReaderAbstrait { 40 | 41 | public: 42 | 43 | /** 44 | * Constructor 45 | */ 46 | ReaderFile(); 47 | 48 | /** 49 | * Read and build the hypergraph 50 | * @param Input flow 51 | */ 52 | void readHypergraphe(std::istream&); 53 | 54 | /** 55 | * Destructor 56 | */ 57 | ~ReaderFile(); 58 | 59 | 60 | protected: 61 | 62 | /** 63 | * Read hyper-vertex 64 | * @param Input flow 65 | */ 66 | void readHypergrapheHyperVertex(std::istream&); 67 | 68 | /** 69 | * Read hyper-edge 70 | * @param Input flow 71 | */ 72 | void readHypergrapheHyperEdge(std::istream&); 73 | 74 | /** 75 | * Get hyper-vertex by Id 76 | * @param Id 77 | */ 78 | boost::shared_ptr& hyperVertexById(unsigned int&); 79 | 80 | /** 81 | * Get hyper-edge by Id 82 | * @param Id 83 | */ 84 | boost::shared_ptr& hyperEdgeById(unsigned int&); 85 | 86 | /** 87 | * Build the hypergraph 88 | */ 89 | void flush(); 90 | 91 | 92 | protected: 93 | 94 | /** 95 | * Read hyper-vertex 96 | */ 97 | LibType::ListHyperVertex 98 | _listHyperVertex; 99 | 100 | /** 101 | * Read hyper-edge 102 | */ 103 | LibType::ListHyperEdge 104 | _listHyperEdge; 105 | 106 | }; 107 | 108 | 109 | #endif /* IO_INCLUDE_READERFILE_HH_ */ 110 | -------------------------------------------------------------------------------- /src/io/include/WriterAbstrait.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Output interface 28 | */ 29 | #ifndef IO_INCLUDE_WRITERABSTRAIT_HH_ 30 | #define IO_INCLUDE_WRITERABSTRAIT_HH_ 31 | 32 | #include "../../model/include/HypergrapheAbstrait.hh" 33 | #include 34 | 35 | /** 36 | * Output interface 37 | */ 38 | class WriterAbstrait { 39 | 40 | public: 41 | 42 | /** 43 | * Constructor 44 | * @param HypergrapheAbstrait shared pointer 45 | */ 46 | WriterAbstrait(const boost::shared_ptr&); 47 | 48 | /** 49 | * Adajency matrix output 50 | * @param Output flow 51 | */ 52 | virtual void writeAdjacentMatrix(std::ostream&) const = 0; 53 | 54 | /** 55 | * Hypergraph output write 56 | * @param Output flow 57 | */ 58 | virtual void writeHypergraph(std::ostream&) const = 0; 59 | 60 | /** 61 | * Virtual destructor 62 | */ 63 | virtual ~WriterAbstrait(); 64 | 65 | 66 | protected: 67 | 68 | /** 69 | * Output hyper-vertex write 70 | * @param Output flow 71 | */ 72 | virtual void writeHypergrapheHyperVertex(std::ostream&) const = 0; 73 | 74 | /** 75 | * Output hyper-edge write 76 | * @param Output flow 77 | */ 78 | virtual void writeHypergrapheHyperEdge(std::ostream&) const = 0; 79 | 80 | 81 | protected: 82 | 83 | /** 84 | * HypergrapheAbstrait shared pointer 85 | */ 86 | boost::shared_ptr 87 | _ptrHypergrapheAbstrait; 88 | 89 | }; 90 | 91 | 92 | 93 | #endif /* IO_INCLUDE_WRITERABSTRAIT_HH_ */ 94 | -------------------------------------------------------------------------------- /src/io/include/WriterFile.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Output module 28 | */ 29 | #ifndef IO_INCLUDE_WRITERFILE_HH_ 30 | #define IO_INCLUDE_WRITERFILE_HH_ 31 | 32 | #include "WriterAbstrait.hh" 33 | 34 | /** 35 | * Output module 36 | */ 37 | class WriterFile : public WriterAbstrait { 38 | 39 | public: 40 | 41 | /** 42 | * Constructor 43 | * @param HypergrapheAbstrait shared pointer 44 | */ 45 | WriterFile(const boost::shared_ptr&); 46 | 47 | /** 48 | * Adajency matrix output 49 | * @param Output flow 50 | */ 51 | void writeAdjacentMatrix(std::ostream&) const; 52 | 53 | /** 54 | * Hypergraph output write 55 | * @param Output flow 56 | */ 57 | void writeHypergraph(std::ostream&) const; 58 | 59 | 60 | protected: 61 | 62 | /** 63 | * Output hyper-vertex write 64 | * @param Output flow 65 | */ 66 | void writeHypergrapheHyperVertex(std::ostream&) const; 67 | 68 | /** 69 | * Output hyper-edge write 70 | * @param Output flow 71 | */ 72 | void writeHypergrapheHyperEdge(std::ostream&) const; 73 | 74 | 75 | protected: 76 | 77 | }; 78 | 79 | 80 | 81 | #endif /* IO_INCLUDE_READERFILE_HH_ */ 82 | -------------------------------------------------------------------------------- /src/lib/LightTreeLib.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /* 27 | * LightTreeLib - Small C++ Template library - Used in HypergraphLib 28 | * 29 | */ 30 | 31 | #ifndef LIGHTTREELIB_HPP_ 32 | #define LIGHTTREELIB_HPP_ 33 | 34 | #include 35 | #include 36 | 37 | template 38 | class LightTree { 39 | 40 | public: 41 | 42 | LightTree(const T& t) : _t( t ) { 43 | _cnt = 0; 44 | } 45 | 46 | void 47 | setElement(const T& t) { 48 | _t = t; 49 | } 50 | 51 | void 52 | addNode(boost::shared_ptr >& lightTree) { 53 | _mapNode[_cnt] = lightTree; 54 | _cnt++; 55 | } 56 | 57 | boost::shared_ptr >& 58 | getNode(unsigned int nodeId) { 59 | return _mapNode[nodeId]; 60 | } 61 | 62 | unsigned int 63 | getCardinal() const { 64 | return _cnt; 65 | } 66 | 67 | T& 68 | getElement() { 69 | return _t; 70 | } 71 | 72 | ~LightTree() { 73 | } 74 | 75 | private: 76 | 77 | T _t; 78 | unsigned int _cnt; 79 | std::map > > _mapNode; 80 | 81 | }; 82 | 83 | 84 | #endif /* LIGHTTREELIB_HPP_ */ 85 | -------------------------------------------------------------------------------- /src/model/AlgorithmeAbstrait.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/AlgorithmeAbstrait.hh" 28 | 29 | AlgorithmeAbstrait::~AlgorithmeAbstrait() { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/model/HyperEdge.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/HyperEdge.hh" 28 | #include "include/HyperVertex.hh" 29 | #include 30 | 31 | 32 | HyperEdge::HyperEdge(const boost::shared_ptr& ptrHypergraphe, unsigned int& identifier) : 33 | _ptrHypergraphe( ptrHypergraphe ), 34 | _identifier( identifier ){ 35 | 36 | } 37 | 38 | void 39 | HyperEdge::addHyperVertex(boost::shared_ptr& hyperVertex) { 40 | if( !containVertex(hyperVertex) ) { 41 | _listHyperVertex.push_back( hyperVertex ); 42 | }; 43 | } 44 | 45 | void 46 | HyperEdge::setHyperVertexList(LibType::ListHyperVertex& listHyperVertex) { 47 | _listHyperVertex = listHyperVertex; 48 | } 49 | 50 | const unsigned int 51 | HyperEdge::getEffectif() const { 52 | return _listHyperVertex.size(); 53 | } 54 | 55 | const unsigned int& 56 | HyperEdge::getIdentifier() const { 57 | return _identifier; 58 | } 59 | 60 | bool HyperEdge::operator==(const boost::shared_ptr& hyperEdge) const { 61 | return _identifier==hyperEdge->getIdentifier(); 62 | } 63 | 64 | bool 65 | HyperEdge::operator<(const boost::shared_ptr& hyperEdge) const { 66 | return _identifier < hyperEdge->getIdentifier(); 67 | } 68 | 69 | bool 70 | HyperEdge::operator>(const boost::shared_ptr& hyperEdge) const { 71 | return _identifier > hyperEdge->getIdentifier(); 72 | } 73 | 74 | bool HyperEdge::containVertex(boost::shared_ptr& hyperVertex) const { 75 | 76 | int i = 0; 77 | const int N = _listHyperVertex.size(); 78 | bool ret = false; 79 | 80 | #pragma omp parallel for schedule(dynamic) 81 | for( i=0 ; i 29 | 30 | HyperFactory::HyperFactory() { 31 | } 32 | 33 | HyperFactory& HyperFactory::Instance() { 34 | return _instance; 35 | } 36 | 37 | void 38 | HyperFactory::startSession(boost::shared_ptr& ptrHypergrapheAbstrait) { 39 | 40 | _ptrHypergrapheAbstrait = ptrHypergrapheAbstrait; 41 | _indexVertex = _ptrHypergrapheAbstrait->getHyperVertexList().size(); 42 | _indexEdge = _ptrHypergrapheAbstrait->getHyperEdgeList().size(); 43 | _isSession = true; 44 | } 45 | 46 | const boost::shared_ptr 47 | HyperFactory::newHyperVertex() { 48 | _indexVertex++; 49 | unsigned int u( _indexVertex - 1); 50 | return boost::shared_ptr( new HyperVertex(_ptrHypergrapheAbstrait, u) ); 51 | } 52 | 53 | const boost::shared_ptr 54 | HyperFactory::newHyperEdge() { 55 | _indexEdge++; 56 | unsigned int u( _indexEdge - 1); 57 | return boost::shared_ptr( new HyperEdge(_ptrHypergrapheAbstrait, u) ); 58 | } 59 | 60 | void 61 | HyperFactory::link(boost::shared_ptr& hyperVertex, boost::shared_ptr& hyperEdge) { 62 | hyperVertex->addHyperEdge(hyperEdge); 63 | hyperEdge->addHyperVertex(hyperVertex); 64 | } 65 | 66 | bool 67 | HyperFactory::isSession() { 68 | return _isSession; 69 | } 70 | 71 | void 72 | HyperFactory::closeSession() { 73 | _ptrHypergrapheAbstrait.reset(); 74 | _isSession = false; 75 | } 76 | 77 | HyperFactory::~HyperFactory() { 78 | } 79 | 80 | 81 | HyperFactory HyperFactory::_instance = HyperFactory(); 82 | unsigned int HyperFactory::_indexVertex = 0; 83 | unsigned int HyperFactory::_indexEdge = 0; 84 | bool HyperFactory::_isSession = false; 85 | boost::shared_ptr HyperFactory::_ptrHypergrapheAbstrait = nullptr; 86 | -------------------------------------------------------------------------------- /src/model/HyperVertex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/HyperVertex.hh" 28 | #include "include/HyperEdge.hh" 29 | #include 30 | 31 | 32 | HyperVertex::HyperVertex(const boost::shared_ptr& ptrHypergraphe, unsigned int& identifier) : 33 | _ptrHypergraphe( ptrHypergraphe ), 34 | _identifier( identifier ){ 35 | } 36 | 37 | void 38 | HyperVertex::addHyperEdge(boost::shared_ptr& hyperEdge) { 39 | if( !containEdge(hyperEdge) ) { 40 | _listHyperEdge.push_back( hyperEdge ); 41 | }; 42 | } 43 | 44 | const unsigned int 45 | HyperVertex::getVertexDegree() const { 46 | return _listHyperEdge.size(); 47 | } 48 | 49 | const unsigned int& 50 | HyperVertex::getIdentifier() const { 51 | return _identifier; 52 | } 53 | 54 | bool 55 | HyperVertex::operator ==(const boost::shared_ptr& hyperVertex) const { 56 | return _identifier==hyperVertex->getIdentifier(); 57 | } 58 | 59 | bool 60 | HyperVertex::operator<(const boost::shared_ptr& hyperVertex) const { 61 | return _identifier < hyperVertex->getIdentifier(); 62 | } 63 | 64 | bool 65 | HyperVertex::operator>(const boost::shared_ptr& hyperVertex) const { 66 | return _identifier > hyperVertex->getIdentifier(); 67 | } 68 | 69 | bool 70 | HyperVertex::containEdge(boost::shared_ptr& hyperEdge) const { 71 | 72 | int i = 0; 73 | const int N = _listHyperEdge.size(); 74 | bool ret = false; 75 | 76 | #pragma omp for schedule(dynamic) 77 | for( i=0 ; i 31 | 32 | #include 33 | 34 | Hypergraphe::Hypergraphe() : HypergrapheAbstrait() { 35 | 36 | } 37 | 38 | void 39 | Hypergraphe::addHyperVertex(const boost::shared_ptr& hyperVertex) { 40 | _indexHyperVertex[hyperVertex] = hyperVertex->getIdentifier(); 41 | _hyperVertexIndexer.insert( std::pair >(hyperVertex->getIdentifier(), hyperVertex)); 42 | _listHyperVertex.push_back(hyperVertex); 43 | } 44 | 45 | void 46 | Hypergraphe::addHyperEdge(const boost::shared_ptr& hyperEdge) { 47 | _indexHyperEdge[hyperEdge] = hyperEdge->getIdentifier(); 48 | _hyperEdgeIndexer.insert( std::pair >(hyperEdge->getIdentifier() ,hyperEdge)); 49 | _listHyperEdge.push_back(hyperEdge); 50 | } 51 | 52 | boost::shared_ptr& 53 | Hypergraphe::getHyperVertexById(const unsigned int& id) { 54 | return _hyperVertexIndexer.at(id); 55 | 56 | BOOST_FOREACH(auto& e, _listHyperVertex) { 57 | if(e->getIdentifier() == id )return e; 58 | } 59 | } 60 | 61 | boost::shared_ptr& 62 | Hypergraphe::getHyperEdgeById(const unsigned int& id) { 63 | return _hyperEdgeIndexer.at(id); 64 | 65 | BOOST_FOREACH(auto& e, _listHyperEdge) { 66 | if(e->getIdentifier() == id )return e; 67 | } 68 | } 69 | 70 | void 71 | Hypergraphe::flush() { 72 | 73 | unsigned int m( _hyperVertexIndexer.size() ); 74 | unsigned int n( _hyperEdgeIndexer.size() ); 75 | 76 | _adjacentMatrix.resize(0, 0); 77 | _adjacentMatrix.resize(m, n); 78 | 79 | #pragma omp parallel sections 80 | { 81 | 82 | #pragma omp section 83 | { 84 | 85 | for(const auto& it : _hyperVertexIndexer ) { 86 | _adjacentMatrix.addHyperVertex( it.second ); 87 | } 88 | } 89 | 90 | #pragma omp section 91 | { 92 | 93 | for(const auto& it : _hyperEdgeIndexer ) { 94 | _adjacentMatrix.addHyperEdge( it.second ); 95 | } 96 | } 97 | 98 | } 99 | } 100 | 101 | Hypergraphe::~Hypergraphe() { 102 | 103 | } 104 | -------------------------------------------------------------------------------- /src/model/HypergrapheAbstrait.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/HypergrapheAbstrait.hh" 28 | #include "include/HyperVertex.hh" 29 | #include "include/HyperEdge.hh" 30 | 31 | HypergrapheAbstrait::HypergrapheAbstrait() : _adjacentMatrix(0, 0) { 32 | 33 | } 34 | 35 | LibType::IndexerHyperVertex& 36 | HypergrapheAbstrait::getIndexHyperVertex() { 37 | return _indexHyperVertex; 38 | } 39 | 40 | LibType::IndexerHyperEdge& 41 | HypergrapheAbstrait::getIndexHyperEdge() { 42 | return _indexHyperEdge; 43 | } 44 | 45 | LibType::ListHyperVertex& 46 | HypergrapheAbstrait::getHyperVertexList() { 47 | return _listHyperVertex; 48 | } 49 | 50 | LibType::ListHyperEdge& 51 | HypergrapheAbstrait::getHyperEdgeList() { 52 | return _listHyperEdge; 53 | } 54 | 55 | AdjacentMatrix& 56 | HypergrapheAbstrait::getAdjacentMatrix() { 57 | return _adjacentMatrix; 58 | } 59 | 60 | bool 61 | HypergrapheAbstrait::isHyperVertexInHyperEdge(boost::shared_ptr& hv, boost::shared_ptr& he) const { 62 | return _adjacentMatrix.isVertexInEdge(hv->getIdentifier(), he->getIdentifier()); 63 | } 64 | 65 | HypergrapheAbstrait::~HypergrapheAbstrait() { 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/model/MotorAlgorithm.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/MotorAlgorithm.hh" 28 | 29 | MotorAlgorithm::MotorAlgorithm() { 30 | } 31 | 32 | MotorAlgorithm& 33 | MotorAlgorithm::Instance() { 34 | return _instance; 35 | } 36 | 37 | void 38 | MotorAlgorithm::setAlgorithme(boost::shared_ptr& algorithme) { 39 | if( MotorAlgorithm::isLock() )return; 40 | _algorithme = algorithme; 41 | } 42 | 43 | void 44 | MotorAlgorithm::runAlgorithme() { 45 | if( MotorAlgorithm::isLock() )return; 46 | MotorAlgorithm::lock(); 47 | _algorithme->runAlgorithme(); 48 | MotorAlgorithm::unlock(); 49 | } 50 | 51 | bool 52 | MotorAlgorithm::isLock() { 53 | return _lock; 54 | } 55 | 56 | void 57 | MotorAlgorithm::lock() { 58 | _lock = true; 59 | } 60 | 61 | void 62 | MotorAlgorithm::unlock() { 63 | _lock = false; 64 | } 65 | 66 | MotorAlgorithm::~MotorAlgorithm() { 67 | } 68 | 69 | 70 | bool MotorAlgorithm::_lock = false; 71 | MotorAlgorithm MotorAlgorithm::_instance = MotorAlgorithm(); 72 | boost::shared_ptr MotorAlgorithm::_algorithme = nullptr; 73 | -------------------------------------------------------------------------------- /src/model/RStructure.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/RStructure.hh" 28 | 29 | void 30 | RStructure::setBooleanResult(bool result) { 31 | _booleanResult = result; 32 | } 33 | 34 | bool 35 | RStructure::getBooleanResult() const { 36 | return _booleanResult; 37 | } 38 | 39 | void 40 | RStructure::setHypergrapheResult(const boost::shared_ptr& ptrHypergrapheAbstrait) { 41 | _hypergrapheResult = ptrHypergrapheAbstrait; 42 | } 43 | 44 | boost::shared_ptr 45 | RStructure::getHypergrapheResult() const { 46 | return _hypergrapheResult; 47 | } 48 | -------------------------------------------------------------------------------- /src/model/RStructurePath.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #include "include/RStructurePath.hh" 28 | 29 | RStructurePath::RStructurePath() : RStructure() { 30 | 31 | } 32 | 33 | void 34 | RStructurePath::setPathResult(LibType::PathList& pathList) { 35 | _pathList = pathList; 36 | } 37 | 38 | LibType::PathList 39 | RStructurePath::getPathResult() { 40 | return _pathList; 41 | } 42 | -------------------------------------------------------------------------------- /src/model/include/AlgorithmeAbstrait.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Algorithm interface 28 | */ 29 | 30 | #ifndef MODEL_INCLUDE_ALGORITHMEABSTRAIT_HH_ 31 | #define MODEL_INCLUDE_ALGORITHMEABSTRAIT_HH_ 32 | 33 | #include "RStructure.hh" 34 | 35 | class MotorAlgorithm; 36 | 37 | /** 38 | * Algorithm interface 39 | */ 40 | class AlgorithmeAbstrait { 41 | 42 | public: 43 | 44 | /** 45 | * Get the result structure 46 | * @return The result structure 47 | */ 48 | virtual RStructure getResult() const = 0; 49 | 50 | /** 51 | * Abstract destructor 52 | */ 53 | virtual ~AlgorithmeAbstrait(); 54 | 55 | 56 | protected: 57 | 58 | friend class MotorAlgorithm; 59 | 60 | /** 61 | * Run the algorithm 62 | */ 63 | virtual void runAlgorithme() = 0; 64 | 65 | }; 66 | 67 | 68 | #endif /* MODEL_INCLUDE_ALGORITHMEABSTRAIT_HH_ */ 69 | -------------------------------------------------------------------------------- /src/model/include/HyperEdge.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Hyper-edge object 28 | */ 29 | #ifndef _HYPEREDGE_HH 30 | #define _HYPEREDGE_HH 31 | 32 | #include 33 | 34 | #include "LibType.hh" 35 | #include "HypergrapheAbstrait.hh" 36 | 37 | /** 38 | * Hyper-edge object 39 | */ 40 | class HyperEdge { 41 | 42 | public: 43 | 44 | /** 45 | * Constructor 46 | * @param HypergrapheAbstrait shared pointer 47 | * @param Hyper-edge Id 48 | */ 49 | HyperEdge(const boost::shared_ptr&, unsigned int& identifier); 50 | 51 | /** 52 | * Add hyper-vertex 53 | * @param Hyper-vertex to add 54 | */ 55 | void addHyperVertex(boost::shared_ptr&); 56 | 57 | /** 58 | * Assignment of the list of hyper-vertex contained in the hyper-edge 59 | * @param Hyper-vertex list. 60 | */ 61 | void setHyperVertexList(LibType::ListHyperVertex&); 62 | 63 | /** 64 | * Get the hyper-vertex list containing the hyper-edge 65 | * @return The hyper-vertex list containing the hyper-edge 66 | */ 67 | LibType::ListHyperVertex& getHyperVertexList(); 68 | 69 | /** 70 | * Get the count of contained hyper-vertex 71 | * @return The count 72 | */ 73 | const unsigned int getEffectif() const; 74 | 75 | /** 76 | * Get the ID 77 | * @return The Id 78 | */ 79 | const unsigned int& getIdentifier() const; 80 | 81 | /** 82 | * Check whether the hyper-edge contains the specified hyper-vertex 83 | * @param Hyper-vertex 84 | * @return True or False 85 | */ 86 | bool containVertex(boost::shared_ptr&) const; 87 | 88 | /** 89 | * Operator == overload. Based on the Id 90 | */ 91 | bool operator==(const boost::shared_ptr&) const; 92 | 93 | /** 94 | * Operator < overload. Based on the Id 95 | */ 96 | bool operator<(const boost::shared_ptr&) const; 97 | 98 | /** 99 | * Operator > overload. Based on the Id 100 | */ 101 | bool operator>(const boost::shared_ptr&) const; 102 | 103 | /** 104 | * Get the hyper-vertex list contained the hyper-edge 105 | * @return The hyper-vertex list contained the hyper-edge 106 | */ 107 | const LibType::ListHyperVertex& getHyperVertexList() const; 108 | 109 | protected: 110 | 111 | /** 112 | * HypergrapheAbstrait shared pointer 113 | */ 114 | boost::shared_ptr 115 | _ptrHypergraphe; 116 | 117 | /** 118 | * Id 119 | */ 120 | unsigned int _identifier; 121 | 122 | /** 123 | * Hyper-vertex list 124 | */ 125 | LibType::ListHyperVertex 126 | _listHyperVertex; 127 | 128 | }; 129 | 130 | #endif 131 | -------------------------------------------------------------------------------- /src/model/include/HyperFactory.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Hypergraph factory object 28 | */ 29 | #ifndef MODEL_INCLUDE_HYPERFACTORY_HH_ 30 | #define MODEL_INCLUDE_HYPERFACTORY_HH_ 31 | 32 | #include "HyperVertex.hh" 33 | #include "HyperEdge.hh" 34 | 35 | /** 36 | * Hypergraph factory object 37 | */ 38 | class HyperFactory { 39 | 40 | public: 41 | 42 | /** 43 | * Singleton instance 44 | */ 45 | static HyperFactory& Instance(); 46 | 47 | 48 | public: 49 | 50 | /** 51 | * Start a factory session 52 | * @param Hypergraph shared pointer 53 | */ 54 | static void startSession(boost::shared_ptr& ptrHypergrapheAbstrait); 55 | 56 | /** 57 | * Create a hyper-vertex 58 | * @return New hyper-vertex 59 | */ 60 | static const boost::shared_ptr newHyperVertex(); 61 | 62 | /** 63 | * Create a hyper-edge 64 | * @return New hyper-edge 65 | */ 66 | static const boost::shared_ptr newHyperEdge(); 67 | 68 | /** 69 | * Link hyper-edge to hyper-vertex 70 | * @param L'hyper-vertex 71 | * @param L'hyper-edge 72 | */ 73 | static void link(boost::shared_ptr&, boost::shared_ptr&); 74 | 75 | /** 76 | * Check whether a session is already started 77 | * @return True or False 78 | */ 79 | static bool isSession(); 80 | 81 | /** 82 | * End the factory session 83 | */ 84 | static void closeSession(); 85 | 86 | 87 | private: 88 | 89 | /** 90 | * Constructor 91 | */ 92 | HyperFactory(); 93 | 94 | /** 95 | * Constructor 96 | */ 97 | HyperFactory(const HyperFactory&); 98 | 99 | /** 100 | * Constructor 101 | */ 102 | HyperFactory& operator= (const HyperFactory&); 103 | 104 | /** 105 | * Destructor 106 | */ 107 | ~HyperFactory(); 108 | 109 | 110 | private: 111 | 112 | /** 113 | * Singleton instance 114 | */ 115 | static HyperFactory _instance; 116 | 117 | /** 118 | * Hyper-vertex counter 119 | */ 120 | static unsigned int _indexVertex; 121 | 122 | /** 123 | * Hyper-edge counter 124 | */ 125 | static unsigned int _indexEdge; 126 | 127 | /** 128 | * Session flag 129 | */ 130 | static bool _isSession; 131 | 132 | /** 133 | * HypergrapheAbstrait shared pointer 134 | */ 135 | static boost::shared_ptr _ptrHypergrapheAbstrait; 136 | 137 | }; 138 | 139 | 140 | #endif /* MODEL_INCLUDE_HYPERFACTORY_HH_ */ 141 | -------------------------------------------------------------------------------- /src/model/include/HyperVertex.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Hyper-vertex object 28 | */ 29 | 30 | #ifndef HYPER_VERTEX_HH 31 | #define HYPER_VERTEX_HH 32 | 33 | #include 34 | 35 | #include "LibType.hh" 36 | #include "HypergrapheAbstrait.hh" 37 | 38 | /** 39 | * Hyper-vertex object 40 | */ 41 | class HyperVertex { 42 | 43 | public: 44 | 45 | /** 46 | * Constructor 47 | * @param Hypergraph shared pointer 48 | * @param Hyper-vertex Id 49 | */ 50 | HyperVertex(const boost::shared_ptr&, unsigned int& identifier); 51 | 52 | /** 53 | * Add hyper-edge 54 | * @param Hyper-edge to add 55 | */ 56 | void addHyperEdge(boost::shared_ptr&); 57 | 58 | /** 59 | * Get the hyper-vertex's degree 60 | * @return The hyper-vertex's degree 61 | */ 62 | const unsigned int getVertexDegree() const; 63 | 64 | /** 65 | * Check whether the hyper-vertex is contained into the specified hyper-edge 66 | * @param Hyper-edge 67 | * @return True or False 68 | */ 69 | bool containEdge(boost::shared_ptr&) const; 70 | 71 | /** 72 | * Get the hyper-vertex's Id 73 | * @return The hyper-vertex's Id 74 | */ 75 | const unsigned int& getIdentifier() const; 76 | 77 | /** 78 | * Operator == overload. Based on the Id 79 | */ 80 | bool operator==(const boost::shared_ptr&) const; 81 | 82 | /** 83 | * Operator < overload. Based on the Id 84 | */ 85 | bool operator<(const boost::shared_ptr&) const; 86 | 87 | /** 88 | * Operator > overload. Based on the Id 89 | */ 90 | bool operator>(const boost::shared_ptr&) const; 91 | 92 | /** 93 | * Get the hyper-edges list containing the hyper-vertex 94 | * @return The hyper-edges list containing the hyper-vertex 95 | */ 96 | const LibType::ListHyperEdge& getHyperEdgeList() const; 97 | 98 | 99 | protected: 100 | 101 | /** 102 | * HypergrapheAbstrait shared pointer 103 | */ 104 | boost::shared_ptr 105 | _ptrHypergraphe; 106 | 107 | /** 108 | * Id 109 | */ 110 | unsigned int _identifier; 111 | 112 | /** 113 | * Hyper-edges list containing the hyper-vertex 114 | */ 115 | LibType::ListHyperEdge 116 | _listHyperEdge; 117 | 118 | }; 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /src/model/include/Hypergraphe.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Hypergraph object 28 | */ 29 | #ifndef MODEL_INCLUDE_HYPERGRAPHE_HH_ 30 | #define MODEL_INCLUDE_HYPERGRAPHE_HH_ 31 | 32 | #include "HypergrapheAbstrait.hh" 33 | 34 | /** 35 | * Hypergraph object 36 | */ 37 | class Hypergraphe : public HypergrapheAbstrait { 38 | 39 | public: 40 | 41 | /** 42 | * Default constructor 43 | */ 44 | Hypergraphe(); 45 | 46 | /** 47 | * Add hyper-vertex 48 | * @param Hyper-vertex to add 49 | */ 50 | void addHyperVertex(const boost::shared_ptr&); 51 | 52 | /** 53 | * Add hyper-edge 54 | * @param Hyper-edge to add 55 | */ 56 | void addHyperEdge(const boost::shared_ptr&); 57 | 58 | /** 59 | * Get hyper-vertex by Id 60 | * @param Hyper-vertex's Id 61 | */ 62 | boost::shared_ptr& getHyperVertexById(const unsigned int&); 63 | 64 | /** 65 | * Get hyper-edge by Id 66 | * @param Hyper-edge's Id 67 | */ 68 | boost::shared_ptr& getHyperEdgeById(const unsigned int&); 69 | 70 | /** 71 | * Build the adjacency matrix 72 | */ 73 | void flush(); 74 | 75 | /** 76 | * Destructor 77 | */ 78 | ~Hypergraphe(); 79 | 80 | protected: 81 | 82 | }; 83 | 84 | 85 | 86 | #endif /* MODEL_INCLUDE_HYPERGRAPHE_HH_ */ 87 | -------------------------------------------------------------------------------- /src/model/include/LibType.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | 27 | #ifndef MODEL_INCLUDE_LIBTYPE_HH_ 28 | #define MODEL_INCLUDE_LIBTYPE_HH_ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | 37 | class HyperVertex; 38 | 39 | class HyperEdge; 40 | 41 | class LibType { 42 | 43 | public: 44 | 45 | 46 | typedef boost::multi_array 47 | AdjacentMatrixContainerBool; 48 | 49 | typedef boost::multi_array 50 | AdjacentMatrixContainerInt; 51 | 52 | typedef boost::container::vector > 53 | ListHyperVertex; 54 | 55 | typedef boost::container::vector > 56 | ListHyperEdge; 57 | 58 | typedef std::map, int> 59 | IndexerHyperVertex; 60 | 61 | typedef std::map, int> 62 | IndexerHyperEdge; 63 | 64 | typedef std::map > 65 | HyperVertexIndexer; 66 | 67 | typedef std::map > 68 | HyperEdgeIndexer; 69 | 70 | typedef boost::shared_ptr > 71 | PathList; 72 | 73 | private: 74 | 75 | LibType(); 76 | LibType(const LibType&) = delete; 77 | LibType& operator=(const LibType&) = delete; 78 | }; 79 | 80 | 81 | #endif /* MODEL_INCLUDE_LIBTYPE_HH_ */ 82 | -------------------------------------------------------------------------------- /src/model/include/MotorAlgorithm.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Algorithmic engine 28 | */ 29 | #ifndef MODEL_INCLUDE_MOTORALGORITHM_HH_ 30 | #define MODEL_INCLUDE_MOTORALGORITHM_HH_ 31 | 32 | #include 33 | 34 | #include "AlgorithmeAbstrait.hh" 35 | 36 | /** 37 | * Algorithmic engine 38 | */ 39 | class MotorAlgorithm { 40 | 41 | public: 42 | 43 | /** 44 | * Get the instance 45 | * @return The instance 46 | */ 47 | static MotorAlgorithm& Instance(); 48 | 49 | /** 50 | * Set the algorithm 51 | * @param The algorithm 52 | */ 53 | static void setAlgorithme(boost::shared_ptr&); 54 | 55 | /** 56 | * Run the algorithm 57 | */ 58 | static void runAlgorithme(); 59 | 60 | /** 61 | * Check whether the engine is running 62 | * @return True or False 63 | */ 64 | static bool isLock(); 65 | 66 | private: 67 | 68 | /** 69 | * Lock the engine 70 | */ 71 | static void lock(); 72 | 73 | /** 74 | * Unlock the engine 75 | */ 76 | static void unlock(); 77 | 78 | private: 79 | 80 | /** 81 | * Constructor 82 | * @param The algorithm 83 | */ 84 | MotorAlgorithm(const MotorAlgorithm&); 85 | 86 | /** 87 | * Constructor 88 | * @param The algorithm 89 | */ 90 | MotorAlgorithm& operator= (const MotorAlgorithm&); 91 | 92 | /** 93 | * Constructor 94 | */ 95 | MotorAlgorithm(); 96 | 97 | /** 98 | * Destructor 99 | */ 100 | ~MotorAlgorithm(); 101 | 102 | private: 103 | 104 | /** 105 | * Lock descriptor 106 | */ 107 | static bool _lock; 108 | 109 | /** 110 | * Singleton instance 111 | */ 112 | static MotorAlgorithm _instance; 113 | 114 | /** 115 | * The algorithm 116 | */ 117 | static boost::shared_ptr _algorithme; 118 | 119 | }; 120 | 121 | 122 | 123 | #endif /* MODEL_INCLUDE_MOTORALGORITHM_HH_ */ 124 | -------------------------------------------------------------------------------- /src/model/include/RStructure.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Result description structure 28 | */ 29 | #ifndef MODEL_INCLUDE_RSTRUCTURE_HH_ 30 | #define MODEL_INCLUDE_RSTRUCTURE_HH_ 31 | 32 | #include "HypergrapheAbstrait.hh" 33 | #include 34 | 35 | /** 36 | * Result description structure 37 | */ 38 | class RStructure { 39 | 40 | public: 41 | 42 | /** 43 | * Add integer result 44 | */ 45 | void setIntegerResult(); 46 | 47 | /** 48 | * Add boolean result 49 | */ 50 | void setBooleanResult(bool); 51 | 52 | /** 53 | * Add HypergraphAbstrait result 54 | */ 55 | void setHypergrapheResult(const boost::shared_ptr&); 56 | 57 | public: 58 | 59 | /** 60 | * Get integer result 61 | * @return Integer result 62 | */ 63 | int getIntegerResult() const; 64 | 65 | /** 66 | * Get boolean result 67 | * @return Boolean result 68 | */ 69 | bool getBooleanResult() const; 70 | 71 | /** 72 | * Get HypergraphAbstrait result 73 | * @return HypergraphAbstrait result 74 | */ 75 | boost::shared_ptr getHypergrapheResult() const; 76 | 77 | protected: 78 | 79 | /** 80 | * Integer result value 81 | */ 82 | int _integerResult; 83 | 84 | /** 85 | * Boolean result value 86 | */ 87 | bool _booleanResult; 88 | 89 | /** 90 | * HypergraphAbstrait result shared pointer 91 | */ 92 | boost::shared_ptr _hypergrapheResult; 93 | 94 | }; 95 | 96 | 97 | 98 | #endif /* MODEL_INCLUDE_RSTRUCTURE_HH_ */ 99 | 100 | -------------------------------------------------------------------------------- /src/model/include/RStructurePath.hh: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | /** 27 | * Path result description structure 28 | */ 29 | #ifndef MODEL_INCLUDE_RSTRUCTURE_PATH_HH_ 30 | #define MODEL_INCLUDE_RSTRUCTURE_PATH_HH_ 31 | 32 | #include "RStructure.hh" 33 | 34 | class RStructurePath : public RStructure { 35 | 36 | public: 37 | 38 | RStructurePath(); 39 | 40 | void setPathResult(LibType::PathList&); 41 | 42 | LibType::PathList getPathResult(); 43 | 44 | protected: 45 | 46 | LibType::PathList _pathList; 47 | 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(test_model test.cpp) 2 | add_executable(test_algorithm test_algorithm.cpp) 3 | add_executable(test_io test_io.cpp) 4 | 5 | target_link_libraries(test_model hypergraph) 6 | target_link_libraries(test_algorithm hypergraph) 7 | target_link_libraries(test_io hypergraph) 8 | 9 | if(Boost_FOUND) 10 | include_directories(${Boost_INCLUDE_DIRS}) 11 | target_link_libraries(test_model ${Boost_LIBRARIES}) 12 | target_link_libraries(test_algorithm ${Boost_LIBRARIES}) 13 | target_link_libraries(test_io ${Boost_LIBRARIES}) 14 | endif() 15 | 16 | find_package(OpenMP) 17 | if (OPENMP_FOUND) 18 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") 19 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 20 | endif() 21 | 22 | include_directories(${GECODE_INCLUDE_DIR}) 23 | target_link_libraries(test_model ${GECODE_LIBRARIES}) 24 | target_link_libraries(test_algorithm ${GECODE_LIBRARIES}) 25 | target_link_libraries(test_io ${GECODE_LIBRARIES}) 26 | 27 | target_link_libraries(test_model criterion) 28 | target_link_libraries(test_algorithm criterion) 29 | target_link_libraries(test_io criterion) 30 | 31 | enable_testing() 32 | add_test("Model creation" test_model) 33 | add_test("Algorithm results" test_algorithm) 34 | add_test("IO Tests" test_io) 35 | -------------------------------------------------------------------------------- /test/test_io.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2015 Alexis LE GOADEC 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | * 24 | */ 25 | 26 | #include "../include/Hypergraph/model/HyperFactory.hh" 27 | #include "../include/Hypergraph/model/HypergrapheAbstrait.hh" 28 | #include "../include/Hypergraph/model/Hypergraphe.hh" 29 | 30 | #include "../include/Hypergraph/io/ReaderFile.hh" 31 | #include "../include/Hypergraph/io/WriterFile.hh" 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | boost::shared_ptr ptrHpg; 39 | 40 | void setup(void) { 41 | 42 | ptrHpg.reset ( new Hypergraphe ); 43 | 44 | HyperFactory::startSession(ptrHpg); 45 | 46 | std::vector> listVertex; 47 | 48 | boost::shared_ptr ptrEdge1 ( HyperFactory::newHyperEdge() ); 49 | boost::shared_ptr ptrEdge2 ( HyperFactory::newHyperEdge() ); 50 | 51 | for(unsigned int i = 0; i < 50; i++) { 52 | 53 | boost::shared_ptr ptrVertexA( HyperFactory::newHyperVertex() ); 54 | boost::shared_ptr ptrVertexB( HyperFactory::newHyperVertex() ); 55 | 56 | HyperFactory::link(ptrVertexA, ptrEdge1); 57 | HyperFactory::link(ptrVertexB, ptrEdge2); 58 | 59 | listVertex.push_back(ptrVertexA); 60 | listVertex.push_back(ptrVertexB); 61 | } 62 | 63 | for(unsigned int t=0; t < listVertex.size(); t++) { 64 | ptrHpg->addHyperVertex( listVertex.at( t ) ); 65 | } 66 | 67 | ptrHpg->addHyperEdge(ptrEdge1); 68 | ptrHpg->addHyperEdge(ptrEdge2); 69 | 70 | ptrHpg->flush(); 71 | 72 | HyperFactory::closeSession(); 73 | 74 | } 75 | 76 | void teardown(void) { 77 | } 78 | 79 | Test(test_model, hpg_io, .init = setup, .fini = teardown) { 80 | 81 | std::stringstream trsf; 82 | std::stringstream trsf2; 83 | std::stringstream a, b; 84 | 85 | WriterFile fWriter (ptrHpg); 86 | fWriter.writeHypergraph( trsf ); 87 | 88 | a << trsf.str(); 89 | 90 | ReaderFile fReader; 91 | fReader.readHypergraphe( trsf ); 92 | 93 | WriterFile fWriter2 (fReader.getHypergraphe() ); 94 | fWriter.writeHypergraph( trsf2 ); 95 | 96 | b << trsf2.str(); 97 | 98 | cr_expect(a.str() == b.str(), "Input / Output not eqal"); 99 | } 100 | --------------------------------------------------------------------------------