[Lemon-commits] Peter Kovacs: Unify naming scheme of fields in V...

Lemon HG hg at lemon.cs.elte.hu
Wed Oct 17 23:21:03 CEST 2018


details:   http://lemon.cs.elte.hu/hg/lemon/rev/b9fad0f9f8ab
changeset: 1408:b9fad0f9f8ab
user:      Peter Kovacs <kpeter [at] inf.elte.hu>
date:      Sat Oct 07 15:45:56 2017 +0200
description:
	Unify naming scheme of fields in Vf2 and Vf2pp (#597)

diffstat:

 lemon/vf2.h   |   76 +++++++++++-----------
 lemon/vf2pp.h |  190 ++++++++++++++++++++++++++++-----------------------------
 2 files changed, 132 insertions(+), 134 deletions(-)

diffs (truncated from 509 to 300 lines):

diff --git a/lemon/vf2.h b/lemon/vf2.h
--- a/lemon/vf2.h
+++ b/lemon/vf2.h
@@ -112,35 +112,35 @@
            class NEQ = bits::vf2::AlwaysEq >
 #endif
   class Vf2 {
-    //Current depth in the DFS tree.
-    int _depth;
-
-    //Functor with bool operator()(G1::Node,G2::Node), which returns 1
-    //if and only if the two nodes are equivalent
-    NEQ _nEq;
-
-    //_conn[v2] = number of covered neighbours of v2
-    typename G2::template NodeMap<int> _conn;
-
-    //The current mapping. _mapping[v1]=v2 iff v1 has been mapped to v2,
-    //where v1 is a node of G1 and v2 is a node of G2
-    M &_mapping;
-
-    //order[i] is the node of g1 for which a pair is searched if depth=i
-    std::vector<typename G1::Node> order;
-
-    //currEdgeIts[i] is the last used edge iterator in the i-th
-    //depth to find a pair for node order[i]
-    std::vector<typename G2::IncEdgeIt> currEdgeIts;
- 
     //The graph to be embedded
     const G1 &_g1;
 
     //The graph into which g1 is to be embedded
     const G2 &_g2;
 
+    //Functor with bool operator()(G1::Node,G2::Node), which returns 1
+    //if and only if the two nodes are equivalent
+    NEQ _nEq;
+
+    //Current depth in the DFS tree.
+    int _depth;
+
+    //The current mapping. _mapping[v1]=v2 iff v1 has been mapped to v2,
+    //where v1 is a node of G1 and v2 is a node of G2
+    M &_mapping;
+
+    //_order[i] is the node of g1 for which a pair is searched if depth=i
+    std::vector<typename G1::Node> _order;
+ 
+    //_conn[v2] = number of covered neighbours of v2
+    typename G2::template NodeMap<int> _conn;
+
+    //_currEdgeIts[i] is the last used edge iterator in the i-th
+    //depth to find a pair for node _order[i]
+    std::vector<typename G2::IncEdgeIt> _currEdgeIts;
+
     //lookup tables for cutting the searchtree
-    typename G1::template NodeMap<int> rNew1t,rInOut1t;
+    typename G1::template NodeMap<int> _rNew1t, _rInOut1t;
 
     MappingType _mapping_type;
 
@@ -159,11 +159,11 @@
       }
       switch(MT) {
       case INDUCED:
-        return rInOut1t[n1]<=rInOut2&&rNew1t[n1]<=rNew2;
+        return _rInOut1t[n1]<=rInOut2&&_rNew1t[n1]<=rNew2;
       case SUBGRAPH:
-        return rInOut1t[n1]<=rInOut2;
+        return _rInOut1t[n1]<=rInOut2;
       case ISOMORPH:
-        return rInOut1t[n1]==rInOut2&&rNew1t[n1]==rNew2;
+        return _rInOut1t[n1]==rInOut2&&_rNew1t[n1]==rNew2;
       default:
         return false;
       }
@@ -235,12 +235,12 @@
     void setOrder() {
       // we will find pairs for the nodes of g1 in this order
 
-      // bits::vf2::DfsLeaveOrder<G1> v(_g1,order);
+      // bits::vf2::DfsLeaveOrder<G1> v(_g1,_order);
       //   DfsVisit<G1,bits::vf2::DfsLeaveOrder<G1> >dfs(_g1, v);
       //   dfs.run();
 
       //it is more efficient in practice than DFS
-      bits::vf2::BfsLeaveOrder<G1> v(_g1,order);
+      bits::vf2::BfsLeaveOrder<G1> v(_g1,_order);
       BfsVisit<G1,bits::vf2::BfsLeaveOrder<G1> >bfs(_g1, v);
       bfs.run();
     }
@@ -248,14 +248,14 @@
     template<MappingType MT>
     bool extMatch() {
       while(_depth>=0) {
-        if(_depth==static_cast<int>(order.size())) {
+        if(_depth==static_cast<int>(_order.size())) {
           //all nodes of g1 are mapped to nodes of g2
           --_depth;
           return true;
         }
-        typename G1::Node& nodeOfDepth = order[_depth];
+        typename G1::Node& nodeOfDepth = _order[_depth];
         const typename G2::Node& pairOfNodeOfDepth = _mapping[nodeOfDepth];
-        typename G2::IncEdgeIt &edgeItOfDepth = currEdgeIts[_depth];
+        typename G2::IncEdgeIt &edgeItOfDepth = _currEdgeIts[_depth];
         //the node of g2 whose neighbours are the candidates for
         //the pair of nodeOfDepth
         typename G2::Node currPNode;
@@ -326,15 +326,15 @@
     //calculate the lookup table for cutting the search tree
     void setRNew1tRInOut1t() {
       typename G1::template NodeMap<int> tmp(_g1,0);
-      for(unsigned int i=0; i<order.size(); ++i) {
-        const typename G1::Node& orderI = order[i];
+      for(unsigned int i=0; i<_order.size(); ++i) {
+        const typename G1::Node& orderI = _order[i];
         tmp[orderI]=-1;
         for(typename G1::IncEdgeIt e1(_g1,orderI); e1!=INVALID; ++e1) {
           const typename G1::Node currNode=_g1.oppositeNode(orderI,e1);
           if(tmp[currNode]>0)
-            ++rInOut1t[orderI];
+            ++_rInOut1t[orderI];
           else if(tmp[currNode]==0)
-            ++rNew1t[orderI];
+            ++_rNew1t[orderI];
         }
         for(typename G1::IncEdgeIt e1(_g1,orderI); e1!=INVALID; ++e1) {
           const typename G1::Node currNode=_g1.oppositeNode(orderI,e1);
@@ -355,11 +355,11 @@
     ///\param neq A bool-valued binary functor determining whether a node is
     ///mappable to another. By default it is an always true operator.
     Vf2(const G1 &g1, const G2 &g2, M &m, const NEQ &neq = NEQ() ) :
-      _nEq(neq), _conn(g2,0), _mapping(m), order(countNodes(g1)),
-      currEdgeIts(countNodes(g1),INVALID), _g1(g1), _g2(g2), rNew1t(g1,0),
-      rInOut1t(g1,0), _mapping_type(SUBGRAPH), _deallocMappingAfterUse(0)
+      _g1(g1), _g2(g2), _nEq(neq), _depth(0), _mapping(m),
+      _order(countNodes(g1)), _conn(g2,0),
+      _currEdgeIts(countNodes(g1),INVALID), _rNew1t(g1,0), _rInOut1t(g1,0),
+      _mapping_type(SUBGRAPH), _deallocMappingAfterUse(0)
     {
-      _depth=0;
       setOrder();
       setRNew1tRInOut1t();
       for(typename G1::NodeIt n(g1);n!=INVALID;++n)
diff --git a/lemon/vf2pp.h b/lemon/vf2pp.h
--- a/lemon/vf2pp.h
+++ b/lemon/vf2pp.h
@@ -28,12 +28,10 @@
 #include <lemon/bfs.h>
 #include <lemon/bits/vf2_internals.h>
 
-
 #include <vector>
 #include <algorithm>
 #include <utility>
 
-
 namespace lemon {
   namespace bits {
     namespace vf2pp {
@@ -101,38 +99,38 @@
            class M2 = typename G2::template NodeMap<int> >
 #endif
   class Vf2pp {
-    //Current depth in the search tree.
-    int _depth;
-
-    //_conn[v2] = number of covered neighbours of v2
-    typename G2::template NodeMap<int> _conn;
-
-    //The current mapping. _mapping[v1]=v2 iff v1 has been mapped to v2,
-    //where v1 is a node of G1 and v2 is a node of G2
-    M &_mapping;
-
-    //order[i] is a node of g1 for which a pair is searched if depth=i
-    std::vector<typename G1::Node> order;
-
-    //currEdgeIts[i] is the last used edge iterator in the i-th
-    //depth to find a pair for node order[i]
-    std::vector<typename G2::IncEdgeIt> currEdgeIts;
- 
     //The graph to be embedded
     const G1 &_g1;
 
     //The graph into which g1 is to be embedded
     const G2 &_g2;
 
-    //rNewLabels1[v] is a pair of form
+    //Current depth in the search tree.
+    int _depth;
+
+    //The current mapping. _mapping[v1]=v2 iff v1 has been mapped to v2,
+    //where v1 is a node of G1 and v2 is a node of G2
+    M &_mapping;
+
+    //_order[i] is a node of g1 for which a pair is searched if depth=i
+    std::vector<typename G1::Node> _order;
+
+    //_conn[v2] = number of covered neighbours of v2
+    typename G2::template NodeMap<int> _conn;
+
+    //_currEdgeIts[i] is the last used edge iterator in the i-th
+    //depth to find a pair for node _order[i]
+    std::vector<typename G2::IncEdgeIt> _currEdgeIts;
+ 
+    //_rNewLabels1[v] is a pair of form
     //(label; num. of uncov. nodes with such label and no covered neighbours)
     typename G1::template NodeMap<std::vector<std::pair<int,int> > >
-    rNewLabels1;
+    _rNewLabels1;
 
-    //rInOutLabels1[v] is the number of covered neighbours of v for each label
+    //_rInOutLabels1[v] is the number of covered neighbours of v for each label
     //in form (label,number of such labels)
     typename G1::template NodeMap<std::vector<std::pair<int,int> > >
-    rInOutLabels1;
+    _rInOutLabels1;
 
     //_intLabels1[v]==i means that node v has label i in _g1
     //(i is in {0,1,2,..,K-1}, where K is the number of diff. labels)
@@ -143,11 +141,11 @@
     M2 &_intLabels2;
 
     //largest label
-    const int maxLabel;
+    const int _maxLabel;
 
     //lookup tables for manipulating with label class cardinalities
     //(after use they have to be reset to 0..0)
-    std::vector<int> labelTmp1,labelTmp2;
+    std::vector<int> _labelTmp1,_labelTmp2;
 
     MappingType _mapping_type;
 
@@ -161,50 +159,50 @@
       for(typename G2::IncEdgeIt e2(_g2,n2); e2!=INVALID; ++e2) {
         const typename G2::Node currNode=_g2.oppositeNode(n2,e2);
         if(_conn[currNode]>0)
-          --labelTmp1[_intLabels2[currNode]];
+          --_labelTmp1[_intLabels2[currNode]];
         else if(MT!=SUBGRAPH&&_conn[currNode]==0)
-          --labelTmp2[_intLabels2[currNode]];
+          --_labelTmp2[_intLabels2[currNode]];
       }
 
       bool ret=1;
       if(ret) {
-        for(unsigned int i = 0; i < rInOutLabels1[n1].size(); ++i)
-          labelTmp1[rInOutLabels1[n1][i].first]+=rInOutLabels1[n1][i].second;
+        for(unsigned int i = 0; i < _rInOutLabels1[n1].size(); ++i)
+          _labelTmp1[_rInOutLabels1[n1][i].first]+=_rInOutLabels1[n1][i].second;
 
         if(MT!=SUBGRAPH)
-          for(unsigned int i = 0; i < rNewLabels1[n1].size(); ++i)
-            labelTmp2[rNewLabels1[n1][i].first]+=rNewLabels1[n1][i].second;
+          for(unsigned int i = 0; i < _rNewLabels1[n1].size(); ++i)
+            _labelTmp2[_rNewLabels1[n1][i].first]+=_rNewLabels1[n1][i].second;
 
         switch(MT) {
         case INDUCED:
-          for(unsigned int i = 0; i < rInOutLabels1[n1].size(); ++i)
-            if(labelTmp1[rInOutLabels1[n1][i].first]>0) {
+          for(unsigned int i = 0; i < _rInOutLabels1[n1].size(); ++i)
+            if(_labelTmp1[_rInOutLabels1[n1][i].first]>0) {
               ret=0;
               break;
             }
           if(ret)
-            for(unsigned int i = 0; i < rNewLabels1[n1].size(); ++i)
-              if(labelTmp2[rNewLabels1[n1][i].first]>0) {
+            for(unsigned int i = 0; i < _rNewLabels1[n1].size(); ++i)
+              if(_labelTmp2[_rNewLabels1[n1][i].first]>0) {
                 ret=0;
                 break;
               }
           break;
         case SUBGRAPH:
-          for(unsigned int i = 0; i < rInOutLabels1[n1].size(); ++i)
-            if(labelTmp1[rInOutLabels1[n1][i].first]>0) {
+          for(unsigned int i = 0; i < _rInOutLabels1[n1].size(); ++i)
+            if(_labelTmp1[_rInOutLabels1[n1][i].first]>0) {
               ret=0;
               break;
             }
           break;
         case ISOMORPH:
-          for(unsigned int i = 0; i < rInOutLabels1[n1].size(); ++i)
-            if(labelTmp1[rInOutLabels1[n1][i].first]!=0) {
+          for(unsigned int i = 0; i < _rInOutLabels1[n1].size(); ++i)
+            if(_labelTmp1[_rInOutLabels1[n1][i].first]!=0) {
               ret=0;
               break;
             }
           if(ret)
-            for(unsigned int i = 0; i < rNewLabels1[n1].size(); ++i)
-              if(labelTmp2[rNewLabels1[n1][i].first]!=0) {
+            for(unsigned int i = 0; i < _rNewLabels1[n1].size(); ++i)
+              if(_labelTmp2[_rNewLabels1[n1][i].first]!=0) {
                 ret=0;


More information about the Lemon-commits mailing list