61 bool nodes_resize_policy,
63 bool arcs_resize_policy,
65 bool edges_resize_policy) :
71 edges_resize_policy) {
72 GUM_CONSTRUCTOR(
PDAG);
95 bool alreadyOriented) {
96 if (node == goal)
return alreadyOriented;
97 if (marked.
contains(node))
return false;
99 for (
const auto nod: gr.
children(node))
107 if (n1 == n2)
return false;
109 for (
const auto nod: this->
children(n1))
139 for (
const auto node:
nodes()) {
142 treatedNodes.
insert(node);
147 for (
const auto node:
nodes()) {
148 if (treatedNodes.
exists(node))
continue;
150 {{
"style",
"filled"}, {
"color",
"#F5F5F5"}, {
"rank",
"same"}});
158 for (
const auto& arc:
arcs())
161 for (
const auto& edge:
edges()) {
163 attributes.insert(attributes.begin(), {
"dir",
"none"});
164 writer.
edge(edge.first(), edge.second(), attributes);
Base classes for partially directed acyclic graphs.
Inline implementation of Base classes for directed acylic graphs.
d-Separation and c-Separation tests for aGrUM graphs.
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 ...
const ArcSet & arcs() const
returns the set of arcs stored within the ArcGraphPart
const EdgeSet & edges() const
returns the set of edges stored within the EdgeGraphPart
const NodeSet & neighbours(NodeId id) const
returns the set of node neighbours to a given node
NodeSet chainComponent(NodeId node) const
returns the set of nodes reachable by undirected path
MixedGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
Class for node sets in graph.
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
bool empty() const
alias for emptyNodes
void writeDotNode(dot::DotWriter &writer, const dot::DotStyle &style, const dot::DotOptions &options, NodeId id) const
writes a node in the dot language, with the label "(id) name" if it is named and the colors given by ...
Base class for partially directed acyclic graphs.
std::string toDot() const override
to friendly display mixed graph in DOT format
UndiGraph moralizedAncestralGraph(const NodeSet &nodes) const
build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
PDAG(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
UndiGraph moralGraph() const
build a UndiGraph by moralizing the PDAG
~PDAG() override
destructor
bool hasMixedReallyOrientedPath(NodeId n1, NodeId n2) const
returns true if a mixed edge/directed arc path from node1 to node2 in the arc/edge set exists with at...
bool cSeparation(NodeId X, NodeId Y, const NodeSet &Z) const
check if node X and node Y are independent given nodes Z (in the sense of c-separation)
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
void insert(const Key &k)
Inserts a new element into the set.
Base class for undirected graphs.
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),...
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).
void endSubgraph()
Closes the last subgraph that is open.
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 beginSubgraph(std::string_view name, const DotAttributes &attributes={})
Opens a subgraph : subgraph "name" { key="value"; ... .
The statements common to the graphs drawn with graphviz : preamble, attributes of nodes and arcs.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
Moralization algorithms for aGrUM directed and mixed graphs.
void writePreamble(DotWriter &writer, const DotStyle &style, const DotOptions &options, std::string_view defaultLabel)
Writes the beginning of a graph, as pyAgrum displays it.
DotAttributes arcAttributes(const DotArcOptions *options)
The attributes of an arc or an edge given by the options : color, penwidth, label,...
bool cSeparated(const G &g, NodeId X, NodeId Y, const NodeSet &Z)
Returns true iff X and Y are c-separated by Z in g.
UndiGraph moralizedAncestralGraph(const G &g, const NodeSet &query)
Returns the moralized ancestral graph of query in g.
UndiGraph moralGraph(const G &g)
Returns the moral graph of g.
gum is the global namespace for all aGrUM entities
bool rec_hasMixedReallyOrientedPath(const PDAG &gr, NodeSet &marked, NodeId node, NodeId goal, bool alreadyOriented)
static DotStyle read()
the style of the graphs of the section notebook