13#include <unordered_map>
38 const std::vector<std::string> &states);
53 const std::string &new_state1,
54 const std::string &new_state2);
70 void add_edge(
const std::string &parent_name,
const std::string &child_name);
103 void set_cpt(
const std::string &name,
const std::vector<double> &cpt);
Directed graphical model over discrete variables.
void add_edge(NodeId parent, NodeId child)
Adds a directed edge from parent to child.
const std::vector< NodeId > & get_parents(NodeId id) const
Parents of a variable, in the order their edges were added.
std::unordered_map< std::string, NodeId > name_to_id_
std::vector< VariableMetadata > variables_
indexed by NodeId
std::vector< std::vector< NodeId > > parents_
parents_[child], in edge insertion order
void set_cpt(NodeId id, const std::vector< double > &cpt)
Stores the conditional probability table of a variable.
std::vector< std::vector< NodeId > > children_
children_[parent], in edge insertion order
std::size_t num_variables() const
Number of variables added so far.
const std::vector< NodeId > & get_children(NodeId id) const
Children of a variable, in the order their edges were added.
const VariableMetadata & get_variable(NodeId id) const
Metadata of a variable.
NodeId add_variable(const std::string &name, const std::vector< std::string > &states)
Adds a variable.
void split_state(NodeId id, std::size_t state_idx, const std::string &new_state1, const std::string &new_state2)
Replaces one state of a variable by two states.
std::uint32_t NodeId
Handle of a variable within one Graph.
Basic BNCore types: the NodeId variable handle and the VariableMetadata record that Graph stores for ...