65 for (const auto child: _model_.children(node)) {
66 if (_mb_.existsNode(child) && !_mb_.existsArc(Arc(node, child))) {
67 _mb_.addArc(node, child);
68 _specialArcs_.insert(Arc(node, child));
74 _mb_.
setName(node, _model_.variable(node).name());
83 if (
size() != other.
size())
return false;
87 for (
const auto& nid:
nodes()) {
91 for (
const auto& arc:
arcs()) {
112 "(" + std::to_string(node) +
") " + name);
114 writer.
node(node, attributes);
122 writer.
edge(node, chi, attributes);
Class building the markovBlanket from a DAGmodel and a node name.
Inline implementation of the class building the essential Graph from a DAGmodel.
NodeSet children(const NodeSet &ids) const
returns the set of nodes which consists in the node and its parents returns the set of children of a ...
The base class for all directed edges.
Virtual base class for PGMs using a DAG.
const ArcSet & arcs() const
return true if the arc tail->head exists in the DAGmodel
Size size() const final
Returns the number of variables in this Directed Graphical Model.
Size sizeArcs() const
Returns the number of arcs in this Directed Graphical Model.
bool exists(NodeId node) const final
Return true if this node exists in this graphical model.
const DAG & internalDag() const
Returns a const reference to the internal (unnamed) DAG. O(1), no copy. Use for stable references or ...
NodeId idFromName(std::string_view name) const override
Returns the NodeId of a variable given its name.
const DiscreteVariable & variable(NodeId id) const override
Returns a constant reference over a variable given its node id.
Exception: at least one argument passed to a function is not what was expected.
MarkovBlanket(const DAGmodel &m, NodeId n, int level=1)
std::string toDot() const
bool hasSameStructure(const DAGmodel &other) const
Size sizeArcs() const
wrapping DAG::sizeArcs()
const ArcSet & arcs() const
wrapping DAG::arcs()
const NodeGraphPart & nodes() const
wrapping DAG::nodes()
Size size() const
wrapping DAG::size()
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
void setName(NodeId id, const std::string &name)
sets the name of node id
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
const std::string & name() const
returns the name of the variable
The options given to a toDot(const DotOptions&).
const DotArcOptions * arc(Size tail, Size head) const
the options of the arc from tail to head, or nullptr if none was given for it
const DotNodeOptions * node(Size node) const
the options of a node, or nullptr if none was given for it
Writes a graph in the dot language, statement after statement, in the order of the calls.
void edge(std::string_view from, std::string_view to, const DotAttributes &attributes={})
an edge from from to to (-> in a directed graph, -- in an undirected one).
std::string str() const
The graph written so far, closed. It can be called at any moment, and the writer can be used after.
void node(std::string_view id, const DotAttributes &attributes={})
a node, whose identifier is id (quoted).
The statements common to the graphs drawn with graphviz : preamble, attributes of nodes and arcs.
#define GUM_ERROR(type, msg)
Size NodeId
Type for node ids.
DotAttributes nodeAttributes(const DotStyle &style, const DotNodeOptions *options, std::string_view defaultLabel, std::string_view defaultTooltip)
The attributes of a node : its label and tooltip, and its colors if the options give some.
void writePreamble(DotWriter &writer, const DotStyle &style, const DotOptions &options, std::string_view defaultLabel)
Writes the beginning of a graph, as pyAgrum displays it.
void addDefaultAttribute(DotAttributes &attributes, std::string_view key, std::string_view value)
Adds an attribute at the beginning of the list, unless the list already gives a value for this key : ...
DotAttributes arcAttributes(const DotArcOptions *options)
The attributes of an arc or an edge given by the options : color, penwidth, label,...
DAG markovBlanket(const G &g, NodeId node, int level=1)
Returns the level-level Markov blanket of node in g as a DAG.
gum is the global namespace for all aGrUM entities
static DotStyle read()
the style of the graphs of the section notebook