COIN-OR::LEMON - Graph Library

Changeset 1408:b9fad0f9f8ab in lemon for lemon/vf2.h


Ignore:
Timestamp:
10/07/17 15:45:56 (7 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Unify naming scheme of fields in Vf2 and Vf2pp (#597)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/vf2.h

    r1407 r1408  
    113113#endif
    114114  class Vf2 {
    115     //Current depth in the DFS tree.
    116     int _depth;
     115    //The graph to be embedded
     116    const G1 &_g1;
     117
     118    //The graph into which g1 is to be embedded
     119    const G2 &_g2;
    117120
    118121    //Functor with bool operator()(G1::Node,G2::Node), which returns 1
     
    120123    NEQ _nEq;
    121124
    122     //_conn[v2] = number of covered neighbours of v2
    123     typename G2::template NodeMap<int> _conn;
     125    //Current depth in the DFS tree.
     126    int _depth;
    124127
    125128    //The current mapping. _mapping[v1]=v2 iff v1 has been mapped to v2,
     
    127130    M &_mapping;
    128131
    129     //order[i] is the node of g1 for which a pair is searched if depth=i
    130     std::vector<typename G1::Node> order;
    131 
    132     //currEdgeIts[i] is the last used edge iterator in the i-th
    133     //depth to find a pair for node order[i]
    134     std::vector<typename G2::IncEdgeIt> currEdgeIts;
     132    //_order[i] is the node of g1 for which a pair is searched if depth=i
     133    std::vector<typename G1::Node> _order;
    135134 
    136     //The graph to be embedded
    137     const G1 &_g1;
    138 
    139     //The graph into which g1 is to be embedded
    140     const G2 &_g2;
     135    //_conn[v2] = number of covered neighbours of v2
     136    typename G2::template NodeMap<int> _conn;
     137
     138    //_currEdgeIts[i] is the last used edge iterator in the i-th
     139    //depth to find a pair for node _order[i]
     140    std::vector<typename G2::IncEdgeIt> _currEdgeIts;
    141141
    142142    //lookup tables for cutting the searchtree
    143     typename G1::template NodeMap<int> rNew1t,rInOut1t;
     143    typename G1::template NodeMap<int> _rNew1t, _rInOut1t;
    144144
    145145    MappingType _mapping_type;
     
    160160      switch(MT) {
    161161      case INDUCED:
    162         return rInOut1t[n1]<=rInOut2&&rNew1t[n1]<=rNew2;
     162        return _rInOut1t[n1]<=rInOut2&&_rNew1t[n1]<=rNew2;
    163163      case SUBGRAPH:
    164         return rInOut1t[n1]<=rInOut2;
     164        return _rInOut1t[n1]<=rInOut2;
    165165      case ISOMORPH:
    166         return rInOut1t[n1]==rInOut2&&rNew1t[n1]==rNew2;
     166        return _rInOut1t[n1]==rInOut2&&_rNew1t[n1]==rNew2;
    167167      default:
    168168        return false;
     
    236236      // we will find pairs for the nodes of g1 in this order
    237237
    238       // bits::vf2::DfsLeaveOrder<G1> v(_g1,order);
     238      // bits::vf2::DfsLeaveOrder<G1> v(_g1,_order);
    239239      //   DfsVisit<G1,bits::vf2::DfsLeaveOrder<G1> >dfs(_g1, v);
    240240      //   dfs.run();
    241241
    242242      //it is more efficient in practice than DFS
    243       bits::vf2::BfsLeaveOrder<G1> v(_g1,order);
     243      bits::vf2::BfsLeaveOrder<G1> v(_g1,_order);
    244244      BfsVisit<G1,bits::vf2::BfsLeaveOrder<G1> >bfs(_g1, v);
    245245      bfs.run();
     
    249249    bool extMatch() {
    250250      while(_depth>=0) {
    251         if(_depth==static_cast<int>(order.size())) {
     251        if(_depth==static_cast<int>(_order.size())) {
    252252          //all nodes of g1 are mapped to nodes of g2
    253253          --_depth;
    254254          return true;
    255255        }
    256         typename G1::Node& nodeOfDepth = order[_depth];
     256        typename G1::Node& nodeOfDepth = _order[_depth];
    257257        const typename G2::Node& pairOfNodeOfDepth = _mapping[nodeOfDepth];
    258         typename G2::IncEdgeIt &edgeItOfDepth = currEdgeIts[_depth];
     258        typename G2::IncEdgeIt &edgeItOfDepth = _currEdgeIts[_depth];
    259259        //the node of g2 whose neighbours are the candidates for
    260260        //the pair of nodeOfDepth
     
    327327    void setRNew1tRInOut1t() {
    328328      typename G1::template NodeMap<int> tmp(_g1,0);
    329       for(unsigned int i=0; i<order.size(); ++i) {
    330         const typename G1::Node& orderI = order[i];
     329      for(unsigned int i=0; i<_order.size(); ++i) {
     330        const typename G1::Node& orderI = _order[i];
    331331        tmp[orderI]=-1;
    332332        for(typename G1::IncEdgeIt e1(_g1,orderI); e1!=INVALID; ++e1) {
    333333          const typename G1::Node currNode=_g1.oppositeNode(orderI,e1);
    334334          if(tmp[currNode]>0)
    335             ++rInOut1t[orderI];
     335            ++_rInOut1t[orderI];
    336336          else if(tmp[currNode]==0)
    337             ++rNew1t[orderI];
     337            ++_rNew1t[orderI];
    338338        }
    339339        for(typename G1::IncEdgeIt e1(_g1,orderI); e1!=INVALID; ++e1) {
     
    356356    ///mappable to another. By default it is an always true operator.
    357357    Vf2(const G1 &g1, const G2 &g2, M &m, const NEQ &neq = NEQ() ) :
    358       _nEq(neq), _conn(g2,0), _mapping(m), order(countNodes(g1)),
    359       currEdgeIts(countNodes(g1),INVALID), _g1(g1), _g2(g2), rNew1t(g1,0),
    360       rInOut1t(g1,0), _mapping_type(SUBGRAPH), _deallocMappingAfterUse(0)
     358      _g1(g1), _g2(g2), _nEq(neq), _depth(0), _mapping(m),
     359      _order(countNodes(g1)), _conn(g2,0),
     360      _currEdgeIts(countNodes(g1),INVALID), _rNew1t(g1,0), _rInOut1t(g1,0),
     361      _mapping_type(SUBGRAPH), _deallocMappingAfterUse(0)
    361362    {
    362       _depth=0;
    363363      setOrder();
    364364      setRNew1tRInOut1t();
Note: See TracChangeset for help on using the changeset viewer.