60 bool nodes_resize_policy,
62 bool arcs_resize_policy,
64 bool edges_resize_policy) :
70 edges_resize_policy) {
71 GUM_CONSTRUCTOR(
PDAG);
94 bool alreadyOriented) {
95 if (node == goal)
return alreadyOriented;
96 if (marked.
contains(node))
return false;
98 for (
const auto nod: gr.
children(node))
106 if (n1 == n2)
return false;
108 for (
const auto nod: this->
children(n1))
132 output =
"digraph \"no_name\" {\n";
134 std::string tab =
" ";
135 output += tab +
"rankdir = TD;\n";
136 output += tab +
"node [style=filled,fillcolor=white,color=black];\n";
137 output += tab +
"graph [style=filled,color=\"#F5F5F5\"];\n";
140 auto nodeDecl = [&](
NodeId n) -> std::string {
return std::to_string(n) +
dotNodeLabel(n); };
142 for (
const auto node:
nodes()) {
144 output += tab + nodeDecl(node) +
";\n";
145 treatedNodes.
insert(node);
151 for (
const auto node:
nodes()) {
152 if (!treatedNodes.
exists(node)) {
153 output += tab +
"subgraph cluster_" + std::to_string(cluster++) +
"{{\n";
154 output += tab + tab +
"rank=same;\n" + tab + tab;
156 output += nodeDecl(cc) +
';';
159 output +=
'\n' + tab +
"}}\n\n";
163 for (
const auto node:
nodes()) {
164 for (
const auto child:
children(node)) {
165 output += std::format(
"{}{}->{};", tab, node, child);
169 output +=
'\n' + tab +
"edge [dir=none];\n";
171 for (
const auto node:
nodes()) {
174 output += std::format(
"{}{}->{};", tab, node, other);
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 NodeSet & neighbours(NodeId id) const
returns the set of node neighbours to a given node
Generic doubly linked lists.
Val & insert(const Val &val)
Inserts a new element at the end of the chained list (alias of pushBack).
bool exists(const Val &val) const
Checks whether there exists a given element in the list.
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
std::string dotNodeLabel(NodeId id) const
returns " [label=\"...\"]" with DOT-escaped name, or "" if no name
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.
void insert(const Key &k)
Inserts a new element into the set.
Base class for undirected graphs.
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.
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)