LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/expr - node_trie_algorithm.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 31 31 100.0 %
Date: 2026-04-23 10:47:37 Functions: 1 1 100.0 %
Branches: 25 30 83.3 %

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * This file is part of the cvc5 project.
       3                 :            :  *
       4                 :            :  * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
       5                 :            :  * in the top-level source directory and their institutional affiliations.
       6                 :            :  * All rights reserved.  See the file COPYING in the top-level source
       7                 :            :  * directory for licensing information.
       8                 :            :  * ****************************************************************************
       9                 :            :  *
      10                 :            :  * Algorithms for node tries
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "expr/node_trie_algorithm.h"
      14                 :            : 
      15                 :            : namespace cvc5::internal {
      16                 :            : 
      17                 :     128278 : void nodeTriePathPairProcess(const TNodeTrie* t,
      18                 :            :                              size_t arity,
      19                 :            :                              NodeTriePathPairProcessCallback& ntpc)
      20                 :            : {
      21                 :     128278 :   std::vector<std::tuple<const TNodeTrie*, const TNodeTrie*, size_t>> visit;
      22                 :     128278 :   std::tuple<const TNodeTrie*, const TNodeTrie*, size_t> cur;
      23                 :            :   const TNodeTrie* t1;
      24                 :            :   const TNodeTrie* t2;
      25                 :            :   size_t depth;
      26                 :     128278 :   visit.emplace_back(t, nullptr, 0);
      27                 :            :   do
      28                 :            :   {
      29                 :    1032403 :     cur = visit.back();
      30                 :    1032403 :     t1 = std::get<0>(cur);
      31                 :    1032403 :     t2 = std::get<1>(cur);
      32                 :    1032403 :     depth = std::get<2>(cur);
      33                 :    1032403 :     visit.pop_back();
      34         [ +  + ]:    1032403 :     if (depth == arity)
      35                 :            :     {
      36                 :            :       // We are at the leaves. If we split the path, process the data.
      37         [ +  - ]:     443631 :       if (t2 != nullptr)
      38                 :            :       {
      39                 :     443631 :         ntpc.processData(t1->getData(), t2->getData());
      40                 :            :       }
      41                 :            :     }
      42         [ +  + ]:     588772 :     else if (t2 == nullptr)
      43                 :            :     {
      44                 :            :       // we are exploring paths with a common prefix
      45         [ +  + ]:     242607 :       if (depth < (arity - 1))
      46                 :            :       {
      47                 :            :         // continue exploring paths with common prefix, internal to each child
      48         [ +  + ]:     177208 :         for (const std::pair<const TNode, TNodeTrie>& tt : t1->d_data)
      49                 :            :         {
      50                 :     114329 :           visit.emplace_back(&tt.second, nullptr, depth + 1);
      51                 :            :         }
      52                 :            :       }
      53                 :            :       // consider splitting the path at this node
      54                 :     242607 :       for (std::map<TNode, TNodeTrie>::const_iterator it = t1->d_data.begin();
      55         [ +  + ]:    1126570 :            it != t1->d_data.end();
      56                 :     883963 :            ++it)
      57                 :            :       {
      58                 :     883963 :         std::map<TNode, TNodeTrie>::const_iterator it2 = it;
      59                 :     883963 :         ++it2;
      60         [ +  + ]:    5868888 :         for (; it2 != t1->d_data.end(); ++it2)
      61                 :            :         {
      62         [ +  + ]:    4984925 :           if (ntpc.considerPath(it->first, it2->first))
      63                 :            :           {
      64                 :     537842 :             visit.emplace_back(&it->second, &it2->second, depth + 1);
      65                 :            :           }
      66                 :            :         }
      67                 :            :       }
      68                 :            :     }
      69                 :            :     else
      70                 :            :     {
      71 [ -  + ][ -  + ]:     346165 :       Assert(t1 != t2);
                 [ -  - ]
      72                 :            :       // considering two different paths, take the product of their children
      73         [ +  + ]:     898116 :       for (const std::pair<const TNode, TNodeTrie>& tt1 : t1->d_data)
      74                 :            :       {
      75         [ +  + ]:    1248426 :         for (const std::pair<const TNode, TNodeTrie>& tt2 : t2->d_data)
      76                 :            :         {
      77         [ +  + ]:     696475 :           if (ntpc.considerPath(tt1.first, tt2.first))
      78                 :            :           {
      79                 :     251954 :             visit.emplace_back(&tt1.second, &tt2.second, depth + 1);
      80                 :            :           }
      81                 :            :         }
      82                 :            :       }
      83                 :            :     }
      84         [ +  + ]:    1032403 :   } while (!visit.empty());
      85                 :     128278 : }
      86                 :            : 
      87                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14