LCOV - code coverage report
Current view: top level - bayesnet/classifiers - SPODE.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 10 10
Test Date: 2024-04-30 20:26:57 Functions: 100.0 % 3 3

            Line data    Source code
       1              : // ***************************************************************
       2              : // SPDX-FileCopyrightText: Copyright 2024 Ricardo Montañana Gómez
       3              : // SPDX-FileType: SOURCE
       4              : // SPDX-License-Identifier: MIT
       5              : // ***************************************************************
       6              : 
       7              : #include "SPODE.h"
       8              : 
       9              : namespace bayesnet {
      10              : 
      11          562 :     SPODE::SPODE(int root) : Classifier(Network()), root(root) {}
      12              : 
      13          508 :     void SPODE::buildModel(const torch::Tensor& weights)
      14              :     {
      15              :         // 0. Add all nodes to the model
      16          508 :         addNodes();
      17              :         // 1. Add edges from the class node to all other nodes
      18              :         // 2. Add edges from the root node to all other nodes
      19        12840 :         for (int i = 0; i < static_cast<int>(features.size()); ++i) {
      20        12332 :             model.addEdge(className, features[i]);
      21        12332 :             if (i != root) {
      22        11824 :                 model.addEdge(features[root], features[i]);
      23              :             }
      24              :         }
      25          508 :     }
      26           34 :     std::vector<std::string> SPODE::graph(const std::string& name) const
      27              :     {
      28           34 :         return model.graph(name);
      29              :     }
      30              : 
      31              : }
        

Generated by: LCOV version 2.0-1