Git Product home page Git Product logo

alex-87 / hypergraphlib Goto Github PK

View Code? Open in Web Editor NEW
21.0 10.0 3.0 634 KB

C++ Hypergraph modelling Library using Boost and OpenMP with some algorithms, including isomorphism using Gecode.

Home Page: https://alex-87.github.io/HyperGraphLib

License: MIT License

CMake 1.74% C++ 98.26%
algorithm hypergraph boost school-project library computer-science hypergraphs-modelisation-library gecode constraint-programming algorithms

hypergraphlib's Introduction

HyperGraphLib

Hypergraphs modelling library with algorithms, the official page for more informations.

hypergraph

How to build and install HyperGraphLib

In a terminal:

git clone https://github.com/alex-87/HyperGraphLib.git
cd HyperGraphLib
cmake CMakeLists.txt
make
make install #Some privileges could be required

See the official page for more informations :)

Where is the documentation ?

The documentation, generated using Doxygen is available at the technical documentation page.

Minimum required

To compile HyperGraphLib, you need:

Example

#include <iostream>
#include <boost/shared_ptr.hpp>
#include <Hypergraph/model/Hypergraphe.hh>
#include <Hypergraph/model/HyperFactory.hh>
#include <Hypergraph/model/MotorAlgorithm.hh>
#include <Hypergraph/algorithm/Isomorph.hh>
#include <Hypergraph/algorithm/Simple.hh>

int main(int argc, char * argv[]) {

    // Creating the hypergraph inside smart pointer
    boost::shared_ptr<HypergrapheAbstrait> ptrHpg( new Hypergraphe() );

    // Starting the create session
    HyperFactory::startSession(ptrHpg);

    // Creating the hyper-edges
    boost::shared_ptr<HyperEdge> ptrEdge1 ( HyperFactory::newHyperEdge() );
    boost::shared_ptr<HyperEdge> ptrEdge2 ( HyperFactory::newHyperEdge() );

    // Creating the hyper-vertexes
    boost::shared_ptr<HyperVertex> ptrVertexA( HyperFactory::newHyperVertex() );
    boost::shared_ptr<HyperVertex> ptrVertexB( HyperFactory::newHyperVertex() );

    // The hyper-vertex A is contained inside the hyper-edge 1
    HyperFactory::link(ptrVertexA, ptrEdge1);
    // The hyper-vertex B is contained inside the hyper-edge 2
    HyperFactory::link(ptrVertexB, ptrEdge2);

    // Adding the hyper-vertexes in the hypergraph
    ptrHpg->addHyperVertex( ptrVertexA );
    ptrHpg->addHyperVertex( ptrVertexB );

    // Adding the hyper-edges in the hypergraph
    ptrHpg->addHyperEdge(ptrEdge1);
    ptrHpg->addHyperEdge(ptrEdge2);

    // Creating the adjacent matrix inside the hypergraph
    ptrHpg->flush();

    // Closing the session
    HyperFactory::closeSession();


    // -- -- --


    // Initializing the Isomorphism algorithm with ptrHpg (twice, just for the example)
    boost::shared_ptr<AlgorithmeAbstrait> isomorphPtr( new Isomorph( ptrHpg , ptrHpg ) );

    // Setting the motor's algorithm
    MotorAlgorithm::setAlgorithme( isomorphPtr );

    // Running the motor
    MotorAlgorithm::runAlgorithme();

    // Getting the result
    RStructure r1( isomorphPtr->getResult() );

    if( r1.getBooleanResult() ) {
    	std::cout << "The hypergraph is isomorph with itself" << std::endl;
    }

    // -- -- --

    // Initializing the Simple algorithm with ptrHpg (twice, just for the example)
    boost::shared_ptr<AlgorithmeAbstrait> simplephPtr( new Simple( ptrHpg ) );

    // Setting the motor's algorithm
    MotorAlgorithm::setAlgorithme( simplephPtr );

    // Running the motor
    MotorAlgorithm::runAlgorithme();

    // Getting the result
    RStructure r2( simplephPtr->getResult() );

    if( r2.getBooleanResult() ) {
        std::cout << "The hypergraph is simple." << std::endl;
    }

    return 0;
}

Compiling the example (Unix / Linux)

g++ example.cpp -o example -lhypergraph

The output is:

$ ./example
The hypergraph is isomorph with itself
The hypergraph is simple.

Boost Library

This software uses the Boost Library. Please see the Boost license at http://www.boost.org/LICENSE_1_0.txt

Gecode Library

This software uses the Gecode Library. Please see the Boost license at https://www.gecode.org/license.html

License

This software is licensed under the MIT License.

hypergraphlib's People

Contributors

alex-87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hypergraphlib's Issues

Documentation for isomorphism algorithm

Hello,
could you please share some information about the implementation of the hypergraph isomorphism algorithm?
Did you implement some procedure taken from a published paper, or is it your own implementation?
How does it work?
Thanks!

Support for Directed Hypergraphs?

It would be great to have a directed hypergraph library in C++. Looking at HyperEdge.cpp, it would seem straightforward to split the vertex set into "head set" and "tail set", but I don't know how such modification would affect the analytic parts of the library. Any suggestions? (Sorry for writing in English ...)

To implement multi-threaded hyper vertex for Path Search algorithm

In order to improve the Path Search algorithm, to implement threaded-nodes could increase the algorithm's performances.

The idea would be to build a smart hyper vertex network able to find itself a path between source and destination, returning all possible paths, and automatically detecting/avoiding circuits.

Singleton instance for MotorAlgorithm

Incomplete singleton instance method leads to an incomplete singleton element.

To do :

  • To create the new MotorAlgorithm instance on the "instance" method
  • To update the code in order to get the MotorAlgorithm instance instead of calling static methods

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.