This file is indexed.

/usr/include/shogun/structure/FactorGraph.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
 * 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) 2013 Shell Hu
 * Copyright (C) 2013 Shell Hu
 */

#ifndef __FACTORGRAPH_H__
#define __FACTORGRAPH_H__

#include <shogun/lib/DynamicObjectArray.h>
#include <shogun/lib/SGVector.h>
#include <shogun/structure/Factor.h>
#include <shogun/labels/FactorGraphLabels.h>
#include <shogun/structure/DisjointSet.h>

namespace shogun
{

/** @brief Class CFactorGraph a factor graph is a structured input in general
 */
class CFactorGraph : public CSGObject
{

public:
	CFactorGraph();

	/** Constructor
	 *
	 * @param card cardinalities of all the variables in the factor graph
	 */
	CFactorGraph(const SGVector<int32_t> card);

	/** Copy constructor
	 *
	 * @param fg a factor graph instance
	 */
	CFactorGraph(const CFactorGraph &fg);

	/** deconstructor */
	~CFactorGraph();

	/** @return class name */
	virtual const char* get_name() const { return "FactorGraph"; }

	/** add a factor
	 *
	 * @param factor a factor pointer
	 */
	void add_factor(CFactor* factor);

	/** add a data source
	 *
	 * @param datasource a factor data source
	 */
	void add_data_source(CFactorDataSource* datasource);

	/** @return all the factors */
	CDynamicObjectArray* get_factors() const;

	/** @return all the shared data */
	CDynamicObjectArray* get_factor_data_sources() const;

	/** @return number of factors */
	int32_t get_num_factors() const;

	/** @return cardinalities */
	SGVector<int32_t> get_cardinalities() const;

	/** set cardinalities
	 *
	 * @param cards cardinalities of all variables
	 */
	void set_cardinalities(SGVector<int32_t> cards);

	/** compute energy tables in the factor graph */
	void compute_energies();

	/** evaluate energy given full assignment
	 *
	 * @param state an assignment
	 */
	float64_t evaluate_energy(const SGVector<int32_t> state) const;

	/** evaluate energy for a given fully observed assignment
	 *
	 * @param obs factor graph observation
	 */
	float64_t evaluate_energy(const CFactorGraphObservation* obs) const;

	/** @return energy table for the graph */
	SGVector<float64_t> evaluate_energies() const;

	/** @return disjoint set */
	CDisjointSet* get_disjoint_set() const;

	/** @return number of edges */
	int32_t get_num_edges() const;

	/** @return number of variable nodes */
	int32_t get_num_vars() const;

	/** connect graph nodes by performing union-find algorithm
	 * NOTE: make sure call this func before performing inference
	 * and other functions related to structure analysis
	 */
	void connect_components();

	/** @return is acyclic graph or not */
	bool is_acyclic_graph() const;

	/** @return is connected graph or not */
	bool is_connected_graph() const;

	/** @return is tree graph or not */
	bool is_tree_graph() const;

	/** perform loss-augmentation
	 *
	 * @param gt an observation (states and loss weights are stored in it)
	 */
	virtual void loss_augmentation(CFactorGraphObservation* gt);

	/** perform loss-augmentation
	 *
	 * @param states_gt ground truth states
	 * @param loss weighted loss for each variable
	 */
	virtual void loss_augmentation(SGVector<int32_t> states_gt, \
		SGVector<float64_t> loss = SGVector<float64_t>());

private:
	/** register parameters */
	void register_parameters();

	/** initialization */
	void init();

protected:
	// TODO: FactorNode, VariableNode, such that they have IDs

	/** cardinalities */
	SGVector<int32_t> m_cardinalities;

	/** added factors */
	CDynamicObjectArray* m_factors;

	/** added data sources */
	CDynamicObjectArray* m_datasources;

	/** disjoint set */
	CDisjointSet* m_dset;

	/** if has circle in the graph */
	bool m_has_cycle;

	/** number of edges */
	int32_t m_num_edges;

};

}

#endif