COIN-OR::LEMON - Graph Library

Changeset 1407:76349d8212d3 in lemon for lemon/vf2.h


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

Improve and unify comments and API docs of VF2 algorithms (#597)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/vf2.h

    r1405 r1407  
    5454      };
    5555
    56 
    57 
    5856      template <class G>
    5957      class DfsLeaveOrder : public DfsVisitor<G> {
     
    9492  ///There is also a \ref vf2() "function-type interface" called \ref vf2()
    9593  ///for the %VF2 algorithm, which is probably more convenient in most
    96   ///use-cases.
     94  ///use cases.
    9795  ///
    9896  ///\tparam G1 The type of the graph to be embedded.
     
    103101  ///By default, it is G1::NodeMap<G2::Node>
    104102  ///\tparam NEQ A bool-valued binary functor determinining whether a node is
    105   ///mappable to another. By default it is an always true operator.
     103  ///mappable to another. By default, it is an always-true operator.
    106104  ///
    107105  ///\sa vf2()
     
    117115    //Current depth in the DFS tree.
    118116    int _depth;
     117
    119118    //Functor with bool operator()(G1::Node,G2::Node), which returns 1
    120     //ifff the two nodes are equivalent.
     119    //if and only if the two nodes are equivalent
    121120    NEQ _nEq;
    122121
     122    //_conn[v2] = number of covered neighbours of v2
    123123    typename G2::template NodeMap<int> _conn;
    124     //Current mapping. We index it by the nodes of g1, and match[v] is
    125     //a node of g2.
     124
     125    //The current mapping. _mapping[v1]=v2 iff v1 has been mapped to v2,
     126    //where v1 is a node of G1 and v2 is a node of G2
    126127    M &_mapping;
    127     //order[i] is the node of g1, for which we search a pair if depth=i
     128
     129    //order[i] is the node of g1 for which a pair is searched if depth=i
    128130    std::vector<typename G1::Node> order;
    129     //currEdgeIts[i] is an edge iterator, witch is last used in the ith
    130     //depth to find a pair for order[i].
     131
     132    //currEdgeIts[i] is the last used edge iterator in the i-th
     133    //depth to find a pair for node order[i]
    131134    std::vector<typename G2::IncEdgeIt> currEdgeIts;
    132     //The small graph.
     135 
     136    //The graph to be embedded
    133137    const G1 &_g1;
    134     //The large graph.
     138
     139    //The graph into which g1 is to be embedded
    135140    const G2 &_g2;
     141
    136142    //lookup tables for cutting the searchtree
    137143    typename G1::template NodeMap<int> rNew1t,rInOut1t;
     
    243249    bool extMatch() {
    244250      while(_depth>=0) {
    245         //there are not nodes in g1, which has not pair in g2.
    246251        if(_depth==static_cast<int>(order.size())) {
     252          //all nodes of g1 are mapped to nodes of g2
    247253          --_depth;
    248254          return true;
     
    251257        const typename G2::Node& pairOfNodeOfDepth = _mapping[nodeOfDepth];
    252258        typename G2::IncEdgeIt &edgeItOfDepth = currEdgeIts[_depth];
    253         //the node of g2, which neighbours are the candidates for
     259        //the node of g2 whose neighbours are the candidates for
    254260        //the pair of nodeOfDepth
    255261        typename G2::Node currPNode;
    256262        if(edgeItOfDepth==INVALID) {
    257263          typename G1::IncEdgeIt fstMatchedE(_g1,nodeOfDepth);
    258           //if pairOfNodeOfDepth!=INVALID, we dont use
    259           //fstMatchedE
    260           if(pairOfNodeOfDepth==INVALID)
     264          //if pairOfNodeOfDepth!=INVALID, we don't use fstMatchedE
     265          if(pairOfNodeOfDepth==INVALID) {
    261266            for(; fstMatchedE!=INVALID &&
    262267                  _mapping[_g1.oppositeNode(nodeOfDepth,
    263268                                            fstMatchedE)]==INVALID;
    264269                ++fstMatchedE) ; //find fstMatchedE
     270          }
    265271          if(fstMatchedE==INVALID||pairOfNodeOfDepth!=INVALID) {
    266             //We found no covered neighbours, this means
    267             //the graph is not connected(or _depth==0). Each
    268             //uncovered(and there are some other properties due
     272            //We found no covered neighbours, this means that
     273            //the graph is not connected (or _depth==0). Each
     274            //uncovered (and there are some other properties due
    269275            //to the spec. problem types) node of g2 is
    270             //candidate.  We can read the iterator of the last
     276            //candidate. We can read the iterator of the last
    271277            //tried node from the match if it is not the first
    272             //try(match[nodeOfDepth]!=INVALID)
     278            //try (match[nodeOfDepth]!=INVALID)
    273279            typename G2::NodeIt n2(_g2);
    274280            //if it's not the first try
     
    318324    }
    319325
    320     //calc. the lookup table for cut the searchtree
     326    //calculate the lookup table for cutting the search tree
    321327    void setRNew1tRInOut1t() {
    322328      typename G1::template NodeMap<int> tmp(_g1,0);
     
    352358      _nEq(neq), _conn(g2,0), _mapping(m), order(countNodes(g1)),
    353359      currEdgeIts(countNodes(g1),INVALID), _g1(g1), _g2(g2), rNew1t(g1,0),
    354       rInOut1t(g1,0), _mapping_type(SUBGRAPH), _deallocMappingAfterUse(0) {
     360      rInOut1t(g1,0), _mapping_type(SUBGRAPH), _deallocMappingAfterUse(0)
     361    {
    355362      _depth=0;
    356363      setOrder();
     
    441448
    442449  /// Auxiliary class for the function-type interface of %VF2 algorithm.
    443 
     450  ///
    444451  /// This auxiliary class implements the named parameters of
    445452  /// \ref vf2() "function-type interface" of \ref Vf2 algorithm.
    446453  ///
    447   /// \warning This class should only be used through the function \ref vf2().
     454  /// \warning This class is not to be used directly.
    448455  ///
    449456  /// \tparam TR The traits class that defines various types used by the
     
    466473  public:
    467474    ///Constructor
    468     Vf2Wizard(const Graph1 &g1,const Graph2 &g2) : Base(g1,g2) {
    469     }
     475    Vf2Wizard(const Graph1 &g1,const Graph2 &g2) : Base(g1,g2) {}
    470476
    471477    ///Copy constructor
    472     Vf2Wizard(const Base &b) : Base(b) { }
     478    Vf2Wizard(const Base &b) : Base(b) {}
    473479
    474480    ///Copy constructor
Note: See TracChangeset for help on using the changeset viewer.