Skip to content

Commit

Permalink
Adding stats module for hypergraphs.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-87 committed Dec 21, 2015
1 parent 865a4a3 commit 7ef28e7
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 13 deletions.
65 changes: 65 additions & 0 deletions src/algorithm/HyperGraphStat.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1,67 @@

#include <boost/foreach.hpp>
#include "include/HyperGraphStat.hh"

HyperGraphStat::HyperGraphStat(const boost::shared_ptr<HypergrapheAbstrait>& ptrHypergrapheAbstrait) {
_ptrHypergrapheAbstrait = ptrHypergrapheAbstrait;

_nhEdge = 0;
_nhVertex = 0;
_nhLink = 0;
_rang = 0;
_coRang = 0;
}

unsigned int
HyperGraphStat::getNbrHyperEdge() const {
return _nhEdge;
}

unsigned int
HyperGraphStat::getNbrHyperVertex() const {
return _nhVertex;
}

unsigned int
HyperGraphStat::getNbrLinks() const {
return _nhLink;
}

unsigned int
HyperGraphStat::getRang() const {
return _rang;
}

unsigned int
HyperGraphStat::getCoRang() const {
return _coRang;
}

void
HyperGraphStat::runAlgorithme() {

_nhEdge = _ptrHypergrapheAbstrait->getHyperEdgeList().size();
_nhVertex = _ptrHypergrapheAbstrait->getHyperVertexList().size();

AdjacentMatrix m( _ptrHypergrapheAbstrait->getAdjacentMatrix() );
LibType::ListHyperEdge eList( _ptrHypergrapheAbstrait->getHyperEdgeList() );

_coRang = _nhEdge;

BOOST_FOREACH( auto& hEdge, eList ) {
_nhLink += m.getEdgeSize(hEdge);
if( m.getEdgeSize(hEdge) > _rang ) _rang = m.getEdgeSize(hEdge);
if( m.getEdgeSize(hEdge) < _coRang ) _coRang = m.getEdgeSize(hEdge);
}

}

RStructure
HyperGraphStat::getResult() const {
return _result;
}


HyperGraphStat::~HyperGraphStat() {

}
59 changes: 57 additions & 2 deletions src/algorithm/include/HyperGraphStat.hh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,66 @@
#ifndef ALGORITHM_INCLUDE_HPGSTAT
#define ALGORITHM_INCLUDE_HPGSTAT

class HyperGraphStat {
#include <boost/shared_ptr.hpp>
#include "../../model/include/HypergrapheAbstrait.hh"
#include "../../model/include/Hypergraphe.hh"
#include "../../model/include/HyperVertex.hh"
#include "../../model/include/HyperEdge.hh"
#include "../../model/include/AlgorithmeAbstrait.hh"
#include "../../model/include/RStructure.hh"

class HyperGraphStat : public AlgorithmeAbstrait {

public:

private:
HyperGraphStat(const boost::shared_ptr<HypergrapheAbstrait>&);

RStructure getResult() const;

~HyperGraphStat();


public:

unsigned int getNbrHyperEdge() const;

unsigned int getNbrHyperVertex() const;

unsigned int getNbrLinks() const;

unsigned int getRang() const;

unsigned int getCoRang() const;

protected:

/**
* Lancment de l'algorithme.
*/
void runAlgorithme();

protected:

/**
* Pointeur partagé vers l'hypergraphe.
*/
boost::shared_ptr<HypergrapheAbstrait>
_ptrHypergrapheAbstrait;

/**
* La structure des résultats.
*/
RStructure _result;

unsigned int _nhEdge;

unsigned int _nhVertex;

unsigned int _nhLink;

unsigned int _rang;

unsigned int _coRang;

};

Expand Down
21 changes: 20 additions & 1 deletion src/client/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "../algorithm/include/Simple.hh"
#include "../algorithm/include/Linear.hh"
#include "../algorithm/include/Connected.hh"
#include "../algorithm/include/HyperGraphStat.hh"

#include "../io/include/WriterFile.hh"
#include "../io/include/ReaderFile.hh"
Expand All @@ -52,7 +53,8 @@ int main(int argc, char *argv[]) {
("kregular", "Décide si l'hypergraphe est k-regulier")
("simple", "Décide si l'hypergraphe est simple")
("helly", "Décide si un hypergraphe possède la propriété de Helly")
("connexe", "Décide si l'hypergraphe est connexe");
("connexe", "Décide si l'hypergraphe est connexe")
("stat", "Retourne les statistiques de l'hypergraphe");

boost::program_options::variables_map vm;
boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
Expand Down Expand Up @@ -103,6 +105,23 @@ int main(int argc, char *argv[]) {
ptrHpg = rHyp.getHypergraphe();
}

if( vm.count("stat") ) {
NewAlgorithm(statHpg, HyperGraphStat, ptrHpg);

MotorAlgorithm::setAlgorithme( statHpg );
MotorAlgorithm::runAlgorithme();

boost::shared_ptr<HyperGraphStat> s = boost::static_pointer_cast<HyperGraphStat>( statHpg );

std::cout << "Hyper-vertex : " << s->getNbrHyperVertex() << std::endl
<< "Hyper-edge : " << s->getNbrHyperEdge() << std::endl
<< "Nbr. links : " << s->getNbrLinks() << std::endl
<< "Rang : " << s->getRang() << std::endl
<< "Co-rang : " << s->getCoRang() << std::endl;

return 0;
}

if( vm.count("dual") ) {

NewAlgorithm(dualAlgo, Dual, ptrHpg);
Expand Down
1 change: 0 additions & 1 deletion src/client/include/Client.hh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
#define NewAlgorithm(a, b, c) boost::shared_ptr<AlgorithmeAbstrait> a( new b( c ) );



#endif /* CLIENT_INCLUDE_CLIENT_HH_ */
9 changes: 0 additions & 9 deletions src/model/AdjacentMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,4 @@ LibType::AdjacentMatrixContainerBool&
AdjacentMatrix::getBoolAdjacentMatrix() {
return _adjacentMatrixBool;
}
/*
void AdjacentMatrix::display() const {
for(unsigned int i=0; i<_n; i++) {
for(unsigned int j=0; j<_m; j++) {
std::cout << _adjacentMatrixBool[j][i] << " ";
}
std::cout << " " << std::endl;
}
}*/

0 comments on commit 7ef28e7

Please sign in to comment.