/usr/include/shogun/multiclass/tree/TreeMachineNode.h is in libshogun-dev 3.2.0-7.3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2012 Chiyuan Zhang
* Copyright (C) 2012 Chiyuan Zhang
*/
#ifndef TREEMACHINENODE_H__
#define TREEMACHINENODE_H__
#include <shogun/base/SGObject.h>
#include <shogun/base/Parameter.h>
namespace shogun
{
/** The node of the tree structure forming a TreeMachine */
template <typename T>
class CTreeMachineNode
: public CSGObject
{
public:
/** constructor */
CTreeMachineNode()
:m_left(NULL), m_right(NULL), m_parent(NULL), m_machine(-1)
{
SG_ADD((CSGObject**)&m_left,"m_left", "Left subtree", MS_NOT_AVAILABLE);
SG_ADD((CSGObject**)&m_right,"m_right", "Right subtree", MS_NOT_AVAILABLE);
SG_ADD((CSGObject**)&m_parent,"m_parent", "Parent node", MS_NOT_AVAILABLE);
SG_ADD(&m_machine,"m_machine", "Index of associated machine", MS_NOT_AVAILABLE);
}
/** destructor */
virtual ~CTreeMachineNode()
{
SG_UNREF(m_left);
SG_UNREF(m_right);
}
/** get name */
virtual const char* get_name() const { return "TreeMachineNode"; }
/** set machine index
* @param idx the machine index
*/
void machine(int32_t idx)
{
m_machine = idx;
}
/** get machine */
int32_t machine()
{
return m_machine;
}
/** set parent node
* @param par parent node
*/
void parent(CTreeMachineNode *par)
{
m_parent = par;
}
/** get parent node */
CTreeMachineNode *parent()
{
return m_parent;
}
/** set left subtree
* @param l left subtree
*/
void left(CTreeMachineNode *l)
{
SG_REF(l);
SG_UNREF(m_left);
m_left = l;
m_left->parent(this);
}
/** get left subtree */
CTreeMachineNode *left()
{
return m_left;
}
/** set right subtree
* @param r right subtree
*/
void right(CTreeMachineNode *r)
{
SG_REF(r);
SG_UNREF(m_right);
m_right = r;
m_right->parent(this);
}
/** get right subtree */
CTreeMachineNode *right()
{
return m_right;
}
/** extra data carried by the tree node */
T data;
/** print function */
typedef void (*data_print_func_t) (const T&);
/** debug print the tree structure
* @param data_print_func the function to print the data payload
*/
void debug_print(data_print_func_t data_print_func)
{
debug_print_impl(data_print_func, this, 0);
}
private:
CTreeMachineNode *m_left; ///< left subtree
CTreeMachineNode *m_right; ///< right subtree
CTreeMachineNode *m_parent; ///< parent node
int32_t m_machine; ///< machine index associated with this node
/** implementation of printing the tree for debugging purpose */
static void debug_print_impl(data_print_func_t data_print_func, CTreeMachineNode<T> *node, int32_t depth)
{
for (int32_t i=0; i < depth; ++i)
SG_SPRINT(" ")
data_print_func(node->data);
if (node->left())
debug_print_impl(data_print_func, node->left(), depth+1);
if (node->right())
debug_print_impl(data_print_func, node->right(), depth+1);
}
};
} /* shogun */
#endif /* end of include guard: TREEMACHINENODE_H__ */
|