86 mg.
addArc(arc.tail(), arc.head());
96 for (
const auto& arc: v) {
98 mg.
addEdge(arc.tail(), arc.head());
100 }
while (!v.empty());
102 for (
const auto& arc: mg.
arcs()) {
105 for (
const auto& edge: mg.
edges()) {
123 for (
const auto& c: mg.
parents(a)) {
124 if (!mg.
existsArc(c, b)) {
return true; }
128 for (
const auto& c: mg.
parents(b)) {
129 if (c == a) {
continue; }
138 bool oneFound =
false;
139 for (
const auto& c: mg.
parents(b)) {
140 if (c == a) {
continue; }
167 "(" + std::to_string(node) +
") " + name));
172 attributes.insert(attributes.begin(), {
"dir",
"none"});
173 writer.
edge(edge.first(), edge.second(), attributes);
180 writer.
edge(arc.tail(), arc.head(), attributes);
189 for (
const auto& n:
nodes())
191 for (
const auto& edge:
edges())
192 skel.
addEdge(edge.first(), edge.second());
193 for (
const auto& arc:
arcs())
194 skel.
addEdge(arc.tail(), arc.head());
bool existsArc(const Arc &arc) const
indicates whether a given arc exists
const NodeSet & parents(NodeId id) const
returns the set of nodes with arc ingoing to a given node
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 ...
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
const ArcSet & arcs() const
returns the set of arcs stored within the ArcGraphPart
Virtual base class for PGMs using a DAG.
const ArcSet & arcs() const
return true if the arc tail->head exists in the DAGmodel
Sequence< NodeId > topologicalOrder() const
The topological order stays the same as long as no variable or arcs are added or erased src the topol...
const NodeGraphPart & nodes() const final
Returns a named copy of the internal DAG: each node id is assigned the name of the corresponding vari...
void addArc(const NodeId tail, const NodeId head) override
insert a new arc into the directed graph
const DiscreteVariable & variable(NodeId id) const override
Returns a constant reference over a variable given its node id.
const EdgeSet & edges() const
returns the set of edges stored within the EdgeGraphPart
bool existsEdge(const Edge &edge) const
indicates whether a given edge exists
const ArcSet & arcs() const
wrapping MixedGraph::arcs()
const DAGmodel * _dagmodel_
UndiGraph skeleton() const
const NodeGraphPart & nodes() const
wrapping MixedGraph::nodes()
void _buildEssentialGraph_()
EssentialGraph & operator=(const EssentialGraph &g)
bool _strongly_protected_(NodeId a, NodeId b) const
std::string toDot() const
const EdgeSet & edges() const
wrapping MixedGraph::edges()
Base class for mixed graphs.
void clear() override
removes all the nodes, arcs and edges from the graph
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
void setName(NodeId id, const std::string &name)
sets the name of node id
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
Base class for partially directed acyclic graphs.
void addEdge(NodeId first, NodeId second) final
insert a new edge into the partially directed graph
void addArc(NodeId tail, NodeId head) final
insert a new arc into the directed graph
Base class for undirected graphs.
void addEdge(NodeId first, NodeId second) override
insert a new edge into the undirected graph
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 DotArcOptions * edge(Size a, Size b) const
the options of the undirected edge between a and b, given for (a, b) or for (b, a),...
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.
Class building the essential Graph from a DAGmodel.
Inline implementation of the class building the essential Graph from a DAGmodel.
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,...
gum is the global namespace for all aGrUM entities
static DotStyle read()
the style of the graphs of the section notebook