diff -r 120b9031eada -r 76349d8212d3 lemon/vf2.h --- a/lemon/vf2.h Sat Oct 07 00:14:05 2017 +0200 +++ b/lemon/vf2.h Sat Oct 07 03:18:49 2017 +0200 @@ -53,8 +53,6 @@ } }; - - template class DfsLeaveOrder : public DfsVisitor { const G &_g; @@ -93,7 +91,7 @@ /// ///There is also a \ref vf2() "function-type interface" called \ref vf2() ///for the %VF2 algorithm, which is probably more convenient in most - ///use-cases. + ///use cases. /// ///\tparam G1 The type of the graph to be embedded. ///The default type is \ref ListDigraph. @@ -102,7 +100,7 @@ ///\tparam M The type of the NodeMap storing the mapping. ///By default, it is G1::NodeMap ///\tparam NEQ A bool-valued binary functor determinining whether a node is - ///mappable to another. By default it is an always true operator. + ///mappable to another. By default, it is an always-true operator. /// ///\sa vf2() #ifdef DOXYGEN @@ -116,23 +114,31 @@ class Vf2 { //Current depth in the DFS tree. int _depth; + //Functor with bool operator()(G1::Node,G2::Node), which returns 1 - //ifff the two nodes are equivalent. + //if and only if the two nodes are equivalent NEQ _nEq; + //_conn[v2] = number of covered neighbours of v2 typename G2::template NodeMap _conn; - //Current mapping. We index it by the nodes of g1, and match[v] is - //a node of g2. + + //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 we search a pair if depth=i + + //order[i] is the node of g1 for which a pair is searched if depth=i std::vector order; - //currEdgeIts[i] is an edge iterator, witch is last used in the ith - //depth to find a pair for order[i]. + + //currEdgeIts[i] is the last used edge iterator in the i-th + //depth to find a pair for node order[i] std::vector currEdgeIts; - //The small graph. + + //The graph to be embedded const G1 &_g1; - //The large graph. + + //The graph into which g1 is to be embedded const G2 &_g2; + //lookup tables for cutting the searchtree typename G1::template NodeMap rNew1t,rInOut1t; @@ -242,34 +248,34 @@ template bool extMatch() { while(_depth>=0) { - //there are not nodes in g1, which has not pair in g2. if(_depth==static_cast(order.size())) { + //all nodes of g1 are mapped to nodes of g2 --_depth; return true; } typename G1::Node& nodeOfDepth = order[_depth]; const typename G2::Node& pairOfNodeOfDepth = _mapping[nodeOfDepth]; typename G2::IncEdgeIt &edgeItOfDepth = currEdgeIts[_depth]; - //the node of g2, which neighbours are the candidates for + //the node of g2 whose neighbours are the candidates for //the pair of nodeOfDepth typename G2::Node currPNode; if(edgeItOfDepth==INVALID) { typename G1::IncEdgeIt fstMatchedE(_g1,nodeOfDepth); - //if pairOfNodeOfDepth!=INVALID, we dont use - //fstMatchedE - if(pairOfNodeOfDepth==INVALID) + //if pairOfNodeOfDepth!=INVALID, we don't use fstMatchedE + if(pairOfNodeOfDepth==INVALID) { for(; fstMatchedE!=INVALID && _mapping[_g1.oppositeNode(nodeOfDepth, fstMatchedE)]==INVALID; ++fstMatchedE) ; //find fstMatchedE + } if(fstMatchedE==INVALID||pairOfNodeOfDepth!=INVALID) { - //We found no covered neighbours, this means - //the graph is not connected(or _depth==0). Each - //uncovered(and there are some other properties due + //We found no covered neighbours, this means that + //the graph is not connected (or _depth==0). Each + //uncovered (and there are some other properties due //to the spec. problem types) node of g2 is - //candidate. We can read the iterator of the last + //candidate. We can read the iterator of the last //tried node from the match if it is not the first - //try(match[nodeOfDepth]!=INVALID) + //try (match[nodeOfDepth]!=INVALID) typename G2::NodeIt n2(_g2); //if it's not the first try if(pairOfNodeOfDepth!=INVALID) { @@ -317,7 +323,7 @@ return false; } - //calc. the lookup table for cut the searchtree + //calculate the lookup table for cutting the search tree void setRNew1tRInOut1t() { typename G1::template NodeMap tmp(_g1,0); for(unsigned int i=0; i