Skip to content

Commit

Permalink
Adding rank/co-rank methods in adjacent matrix, fixing warnings unsig…
Browse files Browse the repository at this point in the history
…ned/signed in Isomorph
  • Loading branch information
alex-87 committed Mar 10, 2017
1 parent c5d3007 commit 93e6038
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 26 deletions.
11 changes: 3 additions & 8 deletions src/algorithm/HyperGraphStat.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

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

HyperGraphStat::HyperGraphStat(const boost::shared_ptr<HypergrapheAbstrait>& ptrHypergrapheAbstrait) {
_ptrHypergrapheAbstrait = ptrHypergrapheAbstrait;
Expand Down Expand Up @@ -46,14 +47,8 @@ HyperGraphStat::runAlgorithme() {
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);
}

_rang = m.getRank();
_coRang = m.getCoRank();
}

RStructure
Expand Down
6 changes: 3 additions & 3 deletions src/algorithm/Isomorph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ Isomorph::hypergraphTranspose(const boost::shared_ptr<HypergrapheAbstrait>& hpg,
v[id] = *i;
}

for(int u=0; u<hpg->getHyperEdgeList().size(); u++ ) {
for(int h=0; h<hpg->getHyperEdgeList().at(u)->getHyperVertexList().size(); h++) {
for(int q=0; q<hpg->getHyperEdgeList().at(u)->getHyperVertexList().at(h)->getHyperEdgeList().size(); q++) {
for(unsigned int u=0; u<hpg->getHyperEdgeList().size(); u++ ) {
for(unsigned int h=0; h<hpg->getHyperEdgeList().at(u)->getHyperVertexList().size(); h++) {
for(unsigned int q=0; q<hpg->getHyperEdgeList().at(u)->getHyperVertexList().at(h)->getHyperEdgeList().size(); q++) {
boost::add_edge(v[hpg->getHyperEdgeList().at(u)->getHyperVertexList().at(h)->getIdentifier()],
v[hpg->getHyperEdgeList().at(u)->getHyperVertexList().at(h)->getHyperEdgeList().at(q)->getIdentifier()],
graphOut );
Expand Down
2 changes: 1 addition & 1 deletion src/lib/LightTreeLib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <map>
#include <boost/shared_ptr.hpp>

template<class T>
template<typename T>
class LightTree {

public:
Expand Down
59 changes: 49 additions & 10 deletions src/model/AdjacentMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ AdjacentMatrix::addHyperVertex(const boost::shared_ptr<HyperVertex>& hyperVertex

for(unsigned int u=0; u < heList.size(); u++)_adjacentMatrixBool[id][heList[u]->getIdentifier()] = true;

/*
BOOST_FOREACH( auto he, heList ) {
_adjacentMatrixBool[id][he->getIdentifier()] = true;
};
*/
}

void
Expand All @@ -43,11 +38,6 @@ AdjacentMatrix::addHyperEdge(const boost::shared_ptr<HyperEdge>& hyperEdge) {

for(unsigned int u=0; u < hvList.size(); u++)_adjacentMatrixBool[hvList[u]->getIdentifier()][id] = true;

/*
BOOST_FOREACH( HyperVertex& hv, hvList ) {
_adjacentMatrixBool[hv->getIdentifier()][id] = true;
};
*/
}

unsigned int AdjacentMatrix::getVertexDegree(const boost::shared_ptr<HyperVertex>& hyperVertex) const {
Expand Down Expand Up @@ -92,6 +82,55 @@ AdjacentMatrix::isEdgeInVertex(const int& edgeId, const int& vertexId) const {
return _adjacentMatrixBool[edgeId][vertexId];
}

bool
AdjacentMatrix::isEdgeInVertex(const boost::shared_ptr<HyperEdge>& hEdge, const boost::shared_ptr<HyperVertex>& hVertex) const {
return isEdgeInVertex(hEdge->getIdentifier(), hVertex->getIdentifier());
}

bool
AdjacentMatrix::isVertexInEdge(const boost::shared_ptr<HyperVertex>& hVertex, const boost::shared_ptr<HyperEdge>& hEdge) const {
return isVertexInEdge(hVertex->getIdentifier(), hEdge->getIdentifier());
}

unsigned int
AdjacentMatrix::getCoRank() const {

auto edgeSize = [&](const int& edgeId) {
unsigned int sum( 0 );
for(unsigned int i=0; i < _n; i++) {
sum += _adjacentMatrixBool[i][edgeId];
}
return sum;
};

unsigned int corank( -1 );
for(unsigned int i=0; i < _m; i++) {
corank = (edgeSize(i) < corank ? edgeSize(i) : corank);
}

return corank;
}


unsigned int
AdjacentMatrix::getRank() const {

auto edgeSize = [&](const int& edgeId) {
unsigned int sum( 0 );
for(unsigned int i=0; i < _n; i++) {
sum += _adjacentMatrixBool[i][edgeId];
}
return sum;
};

unsigned int rank(0);
for(unsigned int i=0; i < _m; i++) {
rank = (edgeSize(i) > rank ? edgeSize(i) : rank);
}

return rank;
}

LibType::AdjacentMatrixContainerBool&
AdjacentMatrix::getBoolAdjacentMatrix() {
return _adjacentMatrixBool;
Expand Down
2 changes: 0 additions & 2 deletions src/model/Hypergraphe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Hypergraphe::getHyperVertexById(const unsigned int& id) {
BOOST_FOREACH(auto& e, _listHyperVertex) {
if(e->getIdentifier() == id )return e;
}
//return nullptr;
}

boost::shared_ptr<HyperEdge>&
Expand All @@ -41,7 +40,6 @@ Hypergraphe::getHyperEdgeById(const unsigned int& id) {
BOOST_FOREACH(auto& e, _listHyperEdge) {
if(e->getIdentifier() == id )return e;
}
//return nullptr;
}

void
Expand Down
4 changes: 2 additions & 2 deletions src/model/include/AdjacentMatrix.hh
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ public:
* Obtenir le co-rang de l'hypergraphe.
* @return Un entie correspondant au co-rang.
*/
int getCoRank() const;
unsigned int getCoRank() const;

/**
* Obtenir le rang de l'hypergraphe.
* @return Un entie correspondant au rang.
*/
int getRank() const;
unsigned int getRank() const;

/**
* Obtenir les dimensions de la matrice d'adjacence.
Expand Down

0 comments on commit 93e6038

Please sign in to comment.