aGrUM  0.18.1
a C++ library for (probabilistic) graphical models
gum::DAG Class Reference

Base class for dag. More...

#include <DAG.h>

+ Inheritance diagram for gum::DAG:
+ Collaboration diagram for gum::DAG:

Public Attributes

Signaler1< NodeIdonNodeAdded
 
Signaler1< NodeIdonNodeDeleted
 
Signaler2< NodeId, NodeIdonArcAdded
 
Signaler2< NodeId, NodeIdonArcDeleted
 

Public Member Functions

UndiGraph moralGraph () const
 
bool hasDirectedPath (const NodeId from, const NodeId to)
 checks whether there exists a directed path from from to to More...
 
Constructors / Destructors
 DAG (Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
 default constructor More...
 
 DAG (const DAG &g)
 copy constructor More...
 
virtual ~DAG ()
 destructor More...
 
Operators
DAGoperator= (const DAG &g)
 copy operator More...
 
Accessors/Modifiers
virtual void addArc (const NodeId tail, const NodeId head)
 insert a new arc into the directed graph More...
 
Operators
bool operator== (const DiGraph &g) const
 tests whether two DiGraphs are identical (same nodes, same arcs) More...
 
bool operator!= (const DiGraph &g) const
 tests whether two DiGraphs are different More...
 
Operators
bool operator== (const NodeGraphPart &p) const
 check whether two NodeGraphParts contain the same nodes More...
 
bool operator!= (const NodeGraphPart &p) const
 check whether two NodeGraphParts contain different nodes More...
 
Operators
bool operator== (const ArcGraphPart &p) const
 tests whether two ArcGraphParts contain the same arcs More...
 
bool operator!= (const ArcGraphPart &p) const
 tests whether two ArcGraphParts contain different arcs More...
 
Accessors/Modifiers
virtual void eraseNode (const NodeId id)
 remove a node and its adjacent arcs from the graph More...
 
virtual void clear ()
 removes all the nodes and arcs from the graph More...
 
virtual const std::string toString () const
 to friendly display the content of the graph More...
 
virtual const std::string toDot () const
 to friendly display the content of the graph in the DOT syntax More...
 
const Sequence< NodeId > & topologicalOrder (bool clear=true) const
 The topological order stays the same as long as no variable or arcs are added or erased src the topology. More...
 
Accessors/Modifiers
void populateNodes (const NodeGraphPart &s)
 populateNodes clears *this and fills it with the same nodes as "s" More...
 
template<typename T >
void populateNodesFromProperty (const NodeProperty< T > &h)
 populateNodesFromProperty clears *this and fills it with the keys of "h" More...
 
NodeId nextNodeId () const
 returns a new node id, not yet used by any node More...
 
virtual NodeId addNode ()
 insert a new node and return its id More...
 
std::vector< NodeIdaddNodes (Size n)
 insert n nodes More...
 
virtual void addNodeWithId (const NodeId id)
 try to insert a node with the given id More...
 
bool existsNode (const NodeId id) const
 returns true iff the NodeGraphPart contains the given nodeId More...
 
bool exists (const NodeId id) const
 alias for existsNode More...
 
bool emptyNodes () const
 indicates whether there exists nodes in the NodeGraphPart More...
 
bool empty () const
 alias for emptyNodes More...
 
virtual void clearNodes ()
 remove all the nodes from the NodeGraphPart More...
 
Size sizeNodes () const
 returns the number of nodes in the NodeGraphPart More...
 
Size size () const
 alias for sizeNodes More...
 
NodeId bound () const
 returns a number n such that all node ids are strictly lower than n More...
 
NodeSet asNodeSet () const
 returns a copy of the set of nodes represented by the NodeGraphPart More...
 
const NodeGraphPartnodes () const
 return *this as a NodeGraphPart More...
 
node_iterator_safe beginSafe () const
 a begin iterator to parse the set of nodes contained in the NodeGraphPart More...
 
const node_iterator_safeendSafe () const noexcept
 the end iterator to parse the set of nodes contained in the NodeGraphPart More...
 
node_iterator begin () const noexcept
 a begin iterator to parse the set of nodes contained in the NodeGraphPart More...
 
const node_iteratorend () const noexcept
 the end iterator to parse the set of nodes contained in the NodeGraphPart More...
 
template<typename VAL >
NodeProperty< VAL > nodesProperty (VAL(*f)(const NodeId &), Size size=0) const
 a method to create a HashTable with key:NodeId and value:VAL More...
 
template<typename VAL >
NodeProperty< VAL > nodesProperty (const VAL &a, Size size=0) const
 a method to create a hashMap with key:NodeId and value:VAL More...
 
template<typename VAL >
List< VAL > listMapNodes (VAL(*f)(const NodeId &)) const
 a method to create a list of VAL from a set of nodes (using for every nodee, say x, the VAL f(x)) More...
 
Accessors/Modifiers
virtual void eraseArc (const Arc &arc)
 removes an arc from the ArcGraphPart More...
 
bool existsArc (const Arc &arc) const
 indicates whether a given arc exists More...
 
bool existsArc (const NodeId tail, const NodeId head) const
 indicates whether a given arc exists More...
 
bool emptyArcs () const
 indicates wether the ArcGraphPart contains any arc More...
 
void clearArcs ()
 removes all the arcs from the ArcGraphPart More...
 
Size sizeArcs () const
 indicates the number of arcs stored within the ArcGraphPart More...
 
const ArcSetarcs () const
 returns the set of arcs stored within the ArcGraphPart More...
 
const NodeSetparents (const NodeId id) const
 returns the set of nodes with arc ingoing to a given node More...
 
const NodeSetchildren (const NodeId id) const
 returns the set of nodes with arc outgoing from a given node More...
 
void eraseParents (const NodeId id)
 erase all the parents of a given node More...
 
void unvirtualizedEraseParents (const NodeId id)
 same function as eraseParents but without any virtual call to an erase More...
 
void eraseChildren (const NodeId id)
 removes all the children of a given node More...
 
void unvirtualizedEraseChildren (const NodeId id)
 same function as eraseChildren but without any virtual call to an erase More...
 
template<typename VAL >
ArcProperty< VAL > arcsProperty (VAL(*f)(const Arc &), Size size=0) const
 a method to create a hashMap of VAL from a set of arcs (using for every arc, say x, the VAL f(x)) More...
 
template<typename VAL >
ArcProperty< VAL > arcsProperty (const VAL &a, Size size=0) const
 a method to create a hashMap of VAL from a set of arcs (using for every arc, say x, the VAL a) More...
 
template<typename VAL >
List< VAL > listMapArcs (VAL(*f)(const Arc &)) const
 a method to create a list of VAL from a set of arcs (using for every arc, say x, the VAL f(x)) More...
 
const std::vector< NodeIddirectedPath (const NodeId node1, const NodeId node2) const
 returns a directed path from node1 to node2 belonging to the set of arcs More...
 
const std::vector< NodeIddirectedUnorientedPath (const NodeId node1, const NodeId node2) const
 returns an unoriented (directed) path from node1 to node2 in the arc set More...
 

Public Types

typedef NodeGraphPartIterator NodeIterator
 
typedef NodeGraphPartIterator NodeConstIterator
 
typedef NodeGraphPartIteratorSafe NodeIteratorSafe
 
typedef NodeGraphPartIteratorSafe NodeConstIteratorSafe
 
typedef ArcSetIterator ArcIterator
 
using node_iterator = NodeGraphPartIterator
 types for STL compliance More...
 
using node_const_iterator = NodeGraphPartIterator
 types for STL compliance More...
 
using node_iterator_safe = NodeGraphPartIteratorSafe
 types for STL compliance More...
 
using node_const_iterator_safe = NodeGraphPartIteratorSafe
 types for STL compliance More...
 

Protected Member Functions

void eraseSetOfArcs_ (const ArcSet &set)
 a (virtualized) function to remove a given set of arcs More...
 
void unvirtualizedEraseSetOfArcs_ (const ArcSet &set)
 similar to eraseSetOfArcs_ except that it is unvirtualized More...
 

Detailed Description

Base class for dag.

This is the base class for Directed Acyclic Graph : addArc may throw a DirectedCycle if any (directed) cycle is created by this arc.

exemple de code
// creating empty graphs
gum::DAG g1,g2;
// adding nodes and arcs to g1
g1.addArc( i1,i2 );
g1.addArc( i1,i3 );
g1.addArc( i2,i3 );
//throw an InvalidNode
// g1.addArc( i1+i2+i3,i1 );
// throw an InvalidDirectedCycle
// g1.addArc( i3,i1 );
// copying graphs
gum::DAG g3 = g1;
g2 = g1;
gum::DAG g4=g1;
// check if a graph has no node
if ( g1.empty() ) cerr << "graph g1 is empty" << endl;
// remove all the nodes (as well as their adjacent arcs)
g1.clear();
// remove some arc
g4.eraseArc( Arc ( i1,i3 ) );
// remove node
g2.eraseNode( i2 );
// parse a graph
for ( const auto node : g3.nodes() ) // type of node = gum::NodeId
cerr << node << endl;
for ( const auto& arc= g3.arcs()) // type of arc : gum::Arc&
cerr << iter << endl;
for ( const auto node :g3.pare nts( gum::NodeId(3) ))
cerr << " - "<<*iter;
cerr<<endl;
// remove all the arcs that are parent of a given node

Definition at line 102 of file DAG.h.

Member Typedef Documentation

◆ ArcIterator

Definition at line 81 of file arcGraphPart.h.

◆ node_const_iterator

types for STL compliance

Definition at line 259 of file nodeGraphPart.h.

◆ node_const_iterator_safe

types for STL compliance

Definition at line 261 of file nodeGraphPart.h.

◆ node_iterator

types for STL compliance

Definition at line 258 of file nodeGraphPart.h.

◆ node_iterator_safe

types for STL compliance

Definition at line 260 of file nodeGraphPart.h.

◆ NodeConstIterator

Definition at line 268 of file nodeGraphPart.h.

◆ NodeConstIteratorSafe

◆ NodeIterator

Definition at line 267 of file nodeGraphPart.h.

◆ NodeIteratorSafe

Constructor & Destructor Documentation

◆ DAG() [1/2]

gum::DAG::DAG ( Size  nodes_size = HashTableConst::default_size,
bool  nodes_resize_policy = true,
Size  arcs_size = HashTableConst::default_size,
bool  arcs_resize_policy = true 
)
explicit

default constructor

Parameters
nodes_sizethe size of the hash table used to store all the nodes
nodes_resize_policythe resizing policy of this hash table
arcs_sizethe size of the hash table used to store all the arcs
arcs_resize_policythe resizing policy of this hash table

Definition at line 38 of file DAG.cpp.

41  :
42  NodeGraphPart(nodes_size, nodes_resize_policy),
43  DiGraph(nodes_size, nodes_resize_policy, arcs_size, arcs_resize_policy) {
44  GUM_CONSTRUCTOR(DAG);
45  }
DiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
Definition: diGraph.cpp:37
DAG(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
Definition: DAG.cpp:38
NodeGraphPart(Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true)
default constructor

◆ DAG() [2/2]

gum::DAG::DAG ( const DAG g)

copy constructor

Parameters
gthe DAG to copy

Definition at line 48 of file DAG.cpp.

48 : NodeGraphPart(g), DiGraph(g) { GUM_CONS_CPY(DAG); }
DiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
Definition: diGraph.cpp:37
DAG(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
Definition: DAG.cpp:38
NodeGraphPart(Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true)
default constructor

◆ ~DAG()

gum::DAG::~DAG ( )
virtual

destructor

Definition at line 50 of file DAG.cpp.

50 { GUM_DESTRUCTOR(DAG); }
DAG(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
Definition: DAG.cpp:38

Member Function Documentation

◆ addArc()

INLINE void gum::DAG::addArc ( const NodeId  tail,
const NodeId  head 
)
virtual

insert a new arc into the directed graph

Parameters
tailthe id of the tail of the new inserted arc
headthe id of the head of the new inserted arc
Warning
if the arc already exists, nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeif head or tail does not belong to the graph nodes
InvalidDirectedCycleif any (directed) cycle is created by this arc.
Warning
Unfortunately, this means that addArc is not in constant time anymore.

Reimplemented from gum::DiGraph.

Definition at line 43 of file DAG_inl.h.

References gum::DiGraph::addArc(), GUM_ERROR, and gum::DiGraph::hasDirectedPath().

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::addArc(), gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::addArcs2Dag__(), gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::addArcs2Dag__(), gum::MarkovBlanket::buildMarkovBlanket__(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAndAddArcsToDag__(), gum::prm::LayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph(), gum::BayesNetFragment< GUM_SCALAR >::installArc_(), gum::BayesNetFragment< GUM_SCALAR >::installNode(), gum::learning::genericBNLearner::learnDAG__(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::learning::Miic::learnStructure(), gum::MarkovBlanket::MarkovBlanket(), and gum::BayesNet< double >::reverseArc().

43  {
44  if (hasDirectedPath(head, tail)) {
45  GUM_ERROR(InvalidDirectedCycle, "Add a directed cycle in a dag !");
46  }
47 
48  // checking whether tail and head do belong to the graph is performed
49  // within class DiGraph
50  DiGraph::addArc(tail, head);
51  }
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: diGraph_inl.h:35
bool hasDirectedPath(const NodeId from, const NodeId to)
checks whether there exists a directed path from from to to
Definition: diGraph.cpp:137
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addNode()

INLINE NodeId gum::NodeGraphPart::addNode ( )
virtualinherited

insert a new node and return its id

Returns
the id chosen by the internal idFactory

Reimplemented in gum::CliqueGraph.

Definition at line 253 of file nodeGraphPart_inl.h.

References GUM_EMIT1.

Referenced by gum::prm::gspan::DFSTree< GUM_SCALAR >::addChild__(), gum::prm::StructuredInference< GUM_SCALAR >::addEdgesInReducedGraph__(), gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::addInterface2Dag__(), gum::prm::ClassDependencyGraph< GUM_SCALAR >::addNode__(), gum::prm::gspan::DFSTree< GUM_SCALAR >::addRoot(), gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::addTypes2Dag__(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::buildPatternGraph__(), gum::prm::StructuredInference< GUM_SCALAR >::buildPatternGraph__(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::checkAndAddNodesToDag__(), gum::prm::LayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::prm::gspan::DFSTree< GUM_SCALAR >::growPattern(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::IncrementalGraphLearner(), gum::prm::gspan::DFSTree< GUM_SCALAR >::initialiaze_root__(), gum::prm::gspan::EdgeGrowth< GUM_SCALAR >::insert(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::insertNode_(), and gum::LeafAggregator::update().

253  {
254  NodeId newNode;
255 
256  // fill the first hole if holes exist
257  if (holes__ && (!holes__->empty())) {
258  newNode = *(holes__->begin());
259  eraseHole__(newNode);
260  } else {
261  newNode = boundVal__;
262  ++boundVal__;
264  }
265 
266  GUM_EMIT1(onNodeAdded, newNode);
267 
268  return newNode;
269  }
bool empty() const noexcept
Indicates whether the set is the empty set.
Definition: set_tpl.h:707
#define GUM_EMIT1(signal, arg1)
Definition: signaler1.h:42
iterator begin() const
The usual unsafe begin iterator to parse the set.
Definition: set_tpl.h:517
NodeSet * holes__
the set of nodes not contained in the NodeGraphPart in the interval 1..max__
Signaler1< NodeId > onNodeAdded
NodeId boundVal__
the id below which NodeIds may belong to the NodeGraphPart
void updateEndIteratorSafe__()
updating endIterator (always at max__+1)
Size NodeId
Type for node ids.
Definition: graphElements.h:98
void eraseHole__(NodeId id)
to delete hole.
+ Here is the caller graph for this function:

◆ addNodes()

INLINE std::vector< NodeId > gum::NodeGraphPart::addNodes ( Size  n)
inherited

insert n nodes

Parameters
nthe number of nodes to add
Returns
the vector of chosen ids

Definition at line 271 of file nodeGraphPart_inl.h.

271  {
272  std::vector< NodeId > v;
273  v.reserve(N);
274  for (Idx i = 0; i < N; i++)
275  v.push_back(this->addNode());
276  return v;
277  }

◆ addNodeWithId()

void gum::NodeGraphPart::addNodeWithId ( const NodeId  id)
virtualinherited

try to insert a node with the given id

Warning
This method should be carefully used. Please prefer populateNodes or populateNodesFromProperty when possible
Exceptions
DuplicateElementexception if the id already exists

Definition at line 132 of file nodeGraphPart.cpp.

References gum::NodeGraphPart::boundVal__, gum::NodeGraphPart::eraseHole__(), GUM_EMIT1, GUM_ERROR, gum::NodeGraphPart::holes__, gum::NodeGraphPart::holes_resize_policy__, gum::NodeGraphPart::holes_size__, gum::NodeGraphPart::inHoles__(), gum::Set< Key, Alloc >::insert(), gum::NodeGraphPart::onNodeAdded, and gum::NodeGraphPart::updateEndIteratorSafe__().

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::addNode_(), gum::prm::gspan::Pattern::addNodeWithLabel(), gum::EssentialGraph::buildEssentialGraph__(), gum::MarkovBlanket::buildMarkovBlanket__(), gum::prm::StructuredInference< GUM_SCALAR >::CData::CData(), gum::SpanningForestPrim::computeInAComponent__(), gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph(), gum::BayesNetFragment< GUM_SCALAR >::installNode(), gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::InterfaceGraph(), gum::learning::genericBNLearner::learnDAG__(), gum::learning::Miic::learnStructure(), gum::InfluenceDiagram< GUM_SCALAR >::moralGraph_(), gum::DAGmodel::moralizedAncestralGraph(), gum::UndiGraph::partialUndiGraph(), gum::learning::genericBNLearner::prepare_miic_3off2__(), gum::EssentialGraph::skeleton(), gum::prm::GSpan< GUM_SCALAR >::sortPatterns__(), and gum::learning::StructuralConstraintDAG::StructuralConstraintDAG().

132  {
133  if (id >= boundVal__) {
134  if (id > boundVal__) { // we have to add holes
136 
137  for (NodeId i = boundVal__; i < id; ++i)
138  holes__->insert(i);
139  }
140 
141  boundVal__ = id + 1;
142 
144  } else {
145  if (inHoles__(id)) { // we fill a hole
146  eraseHole__(id);
147  } else {
148  GUM_ERROR(DuplicateElement, "Id " << id << " is already used");
149  }
150  }
151 
152  GUM_EMIT1(onNodeAdded, id);
153  }
bool holes_resize_policy__
value for holes__ configuration
#define GUM_EMIT1(signal, arg1)
Definition: signaler1.h:42
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
NodeSet * holes__
the set of nodes not contained in the NodeGraphPart in the interval 1..max__
Signaler1< NodeId > onNodeAdded
NodeId boundVal__
the id below which NodeIds may belong to the NodeGraphPart
void updateEndIteratorSafe__()
updating endIterator (always at max__+1)
bool inHoles__(NodeId id) const
Size NodeId
Type for node ids.
Definition: graphElements.h:98
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:613
void eraseHole__(NodeId id)
to delete hole.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
Size holes_size__
value for holes__ configuration
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ arcs()

INLINE const ArcSet & gum::ArcGraphPart::arcs ( ) const
inherited

returns the set of arcs stored within the ArcGraphPart

Definition at line 39 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::arcs__.

Referenced by gum::MarkovBlanket::arcs(), gum::EssentialGraph::arcs(), gum::DAGmodel::arcs(), gum::prm::gspan::Pattern::arcs(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), moralGraph(), and gum::DiGraph::toDot().

39 { return arcs__; }
Set< Arc > arcs__
the set of all the arcs contained within the ArcGraphPart
Definition: arcGraphPart.h:269
+ Here is the caller graph for this function:

◆ arcsProperty() [1/2]

template<typename VAL >
ArcProperty< VAL > gum::ArcGraphPart::arcsProperty ( VAL(*)(const Arc &)  f,
Size  size = 0 
) const
inherited

a method to create a hashMap of VAL from a set of arcs (using for every arc, say x, the VAL f(x))

Parameters
fa function assigning a VAL to any arc
sizean optional parameter enabling to fine-tune the returned Property. Roughly speaking, it is a good practice to have a size equal to half the number of arcs. If you do not specify this parameter, the method will assign it for you.

◆ arcsProperty() [2/2]

template<typename VAL >
ArcProperty< VAL > gum::ArcGraphPart::arcsProperty ( const VAL &  a,
Size  size = 0 
) const
inherited

a method to create a hashMap of VAL from a set of arcs (using for every arc, say x, the VAL a)

Parameters
athe default value assigned to each arc in the returned Property
sizean optional parameter enabling to fine-tune the returned Property. Roughly speaking, it is a good practice to have a size equal to half the number of arcs. If you do not specify this parameter, the method will assign it for you.

◆ asNodeSet()

INLINE NodeSet gum::NodeGraphPart::asNodeSet ( ) const
inherited

returns a copy of the set of nodes represented by the NodeGraphPart

Warning
this function is o(n) where n is the number of nodes. In space and in time. Usually, when you need to parse the nodes of a NodeGraphPart, prefer using
for(const auto n : nodes())
rather than
for(const auto n : asNodeSet())
as this is faster and consumes much less memory.

Definition at line 361 of file nodeGraphPart_inl.h.

References gum::Set< Key, Alloc >::insert().

Referenced by gum::AggregatorDecomposition< GUM_SCALAR >::getDecomposedAggregator(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), and gum::MarkovBlanket::MarkovBlanket().

361  {
362  NodeSet son(sizeNodes());
363 
364  if (!empty()) {
365  for (NodeId n = 0; n < boundVal__; ++n) {
366  if (!inHoles__(n)) son.insert(n);
367  }
368  }
369 
370  return son;
371  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
bool empty() const
alias for emptyNodes
Size sizeNodes() const
returns the number of nodes in the NodeGraphPart
NodeId boundVal__
the id below which NodeIds may belong to the NodeGraphPart
bool inHoles__(NodeId id) const
Size NodeId
Type for node ids.
Definition: graphElements.h:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ begin()

INLINE NodeGraphPartIterator gum::NodeGraphPart::begin ( ) const
noexceptinherited

a begin iterator to parse the set of nodes contained in the NodeGraphPart

Definition at line 333 of file nodeGraphPart_inl.h.

References gum::NodeGraphPartIterator::validate_().

Referenced by gum::prm::gspan::DFSTree< GUM_SCALAR >::parent().

333  {
334  NodeGraphPartIterator it(*this);
335  it.validate_(); // stop the iterator at the first not-in-holes
336  return it;
337  }
friend class NodeGraphPartIterator
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ beginSafe()

INLINE NodeGraphPartIteratorSafe gum::NodeGraphPart::beginSafe ( ) const
inherited

a begin iterator to parse the set of nodes contained in the NodeGraphPart

Definition at line 319 of file nodeGraphPart_inl.h.

References gum::NodeGraphPartIterator::validate_().

319  {
320  NodeGraphPartIteratorSafe it(*this);
321  it.validate_(); // stop the iterator at the first not-in-holes
322  return it;
323  }
friend class NodeGraphPartIteratorSafe
+ Here is the call graph for this function:

◆ bound()

INLINE NodeId gum::NodeGraphPart::bound ( ) const
inherited

returns a number n such that all node ids are strictly lower than n

Definition at line 308 of file nodeGraphPart_inl.h.

Referenced by gum::NodeGraphPart::clearNodes__(), gum::StaticTriangulation::computeEliminationTree__(), gum::NodeGraphPartIterator::setPos_(), and gum::NodeGraphPartIterator::validate_().

308 { return boundVal__; }
NodeId boundVal__
the id below which NodeIds may belong to the NodeGraphPart
+ Here is the caller graph for this function:

◆ children()

INLINE const NodeSet & gum::ArcGraphPart::children ( const NodeId  id) const
inherited

returns the set of nodes with arc outgoing from a given node

Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is outgoing from the given node.

Parameters
idthe node which is the tail of the arcs returned

Definition at line 62 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::checkChildren__(), and gum::ArcGraphPart::children__.

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::AR__(), gum::ArcGraphPart::ArcGraphPart(), gum::EssentialGraph::buildEssentialGraph__(), gum::MarkovBlanket::children(), gum::EssentialGraph::children(), gum::DAGmodel::children(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::connect__(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::directedPath__(), gum::ArcGraphPart::directedUnorientedPath(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::ArcGraphPart::eraseChildren(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::prm::gspan::Pattern::expandCodeIsMinimal__(), gum::InfluenceDiagram< GUM_SCALAR >::getChildrenDecision_(), gum::DiGraph::hasDirectedPath(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::initialize_(), gum::prm::gspan::Pattern::isMinimal(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_(), gum::MixedGraph::mixedUnorientedPath(), gum::prm::gspan::Pattern::not_rec__(), gum::prm::gspan::Pattern::rec__(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::prm::gspan::Pattern::remove(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), gum::MarkovBlanket::toDot(), gum::EssentialGraph::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::MixedGraph::toDot(), and gum::ArcGraphPart::unvirtualizedEraseChildren().

62  {
63  checkChildren__(id);
64  return *(children__[id]);
65  }
NodeProperty< NodeSet *> children__
for each arc, the set of its children
Definition: arcGraphPart.h:275
void checkChildren__(const NodeId id) const
when the ArcGraphPart contains no arc outgoing from a given node, this function adds an empty set ent...
+ Here is the call graph for this function:

◆ clear()

INLINE void gum::DiGraph::clear ( )
virtualinherited

removes all the nodes and arcs from the graph

Reimplemented from gum::NodeGraphPart.

Reimplemented in gum::MixedGraph.

Definition at line 43 of file diGraph_inl.h.

References gum::ArcGraphPart::clearArcs(), and gum::NodeGraphPart::clearNodes().

Referenced by gum::DiGraph::operator=().

43  {
46  }
void clearArcs()
removes all the arcs from the ArcGraphPart
virtual void clearNodes()
remove all the nodes from the NodeGraphPart
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearArcs()

void gum::ArcGraphPart::clearArcs ( )
inherited

removes all the arcs from the ArcGraphPart

Definition at line 79 of file arcGraphPart.cpp.

References gum::ArcGraphPart::arcs__, gum::ArcGraphPart::children__, gum::Set< Key, Alloc >::clear(), GUM_EMIT2, gum::ArcGraphPart::onArcDeleted, and gum::ArcGraphPart::parents__.

Referenced by gum::DiGraph::clear(), gum::MixedGraph::clear(), gum::ArcGraphPart::operator=(), gum::MixedGraph::operator=(), and gum::ArcGraphPart::~ArcGraphPart().

79  {
80  for (const auto& elt: parents__)
81  delete elt.second;
82 
83  parents__.clear();
84 
85  for (const auto& elt: children__)
86  delete elt.second;
87 
88  children__.clear();
89 
90  // we need this copy only if at least one onArcDeleted listener exists
91  if (onArcDeleted.hasListener()) {
92  ArcSet tmp = arcs__;
93  arcs__.clear();
94 
95  for (const auto& arc: tmp)
96  GUM_EMIT2(onArcDeleted, arc.tail(), arc.head());
97  } else {
98  arcs__.clear();
99  }
100  }
NodeProperty< NodeSet *> children__
for each arc, the set of its children
Definition: arcGraphPart.h:275
Set< Arc > ArcSet
Some typdefs and define for shortcuts ...
Set< Arc > arcs__
the set of all the arcs contained within the ArcGraphPart
Definition: arcGraphPart.h:269
#define GUM_EMIT2(signal, arg1, arg2)
Definition: signaler2.h:42
NodeProperty< NodeSet *> parents__
for each arc, the sets of its parents
Definition: arcGraphPart.h:272
Signaler2< NodeId, NodeId > onArcDeleted
Definition: arcGraphPart.h:84
void clear()
Removes all the elements, if any, from the set.
Definition: set_tpl.h:375
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearNodes()

INLINE void gum::NodeGraphPart::clearNodes ( )
virtualinherited

remove all the nodes from the NodeGraphPart

Definition at line 310 of file nodeGraphPart_inl.h.

Referenced by gum::DiGraph::clear(), gum::UndiGraph::clear(), gum::MixedGraph::clear(), and gum::MixedGraph::operator=().

310 { clearNodes__(); }
void clearNodes__()
code for clearing nodes (called twice)
+ Here is the caller graph for this function:

◆ directedPath()

const std::vector< NodeId > gum::ArcGraphPart::directedPath ( const NodeId  node1,
const NodeId  node2 
) const
inherited

returns a directed path from node1 to node2 belonging to the set of arcs

Parameters
node1the id from which the path begins
node2the id to which the path ends
Exceptions
NotFoundexception is raised if no path can be found between the two nodes

Definition at line 155 of file arcGraphPart.cpp.

References gum::List< Val, Alloc >::empty(), gum::HashTable< Key, Val, Alloc >::exists(), gum::List< Val, Alloc >::front(), GUM_ERROR, gum::HashTable< Key, Val, Alloc >::insert(), gum::ArcGraphPart::parents(), gum::List< Val, Alloc >::popFront(), and gum::List< Val, Alloc >::pushBack().

Referenced by gum::learning::Miic::orientation_latents_().

156  {
157  // not recursive version => use a FIFO for simulating the recursion
158  List< NodeId > nodeFIFO;
159  nodeFIFO.pushBack(n2);
160 
161  // mark[node] = successor if visited, else mark[node] does not exist
162  NodeProperty< NodeId > mark;
163  mark.insert(n2, n2);
164 
165  NodeId current;
166 
167  while (!nodeFIFO.empty()) {
168  current = nodeFIFO.front();
169  nodeFIFO.popFront();
170 
171  // check the parents
172 
173  for (const auto new_one: parents(current)) {
174  if (mark.exists(new_one)) // if this node is already marked, do not
175  continue; // check it again
176 
177  mark.insert(new_one, current);
178 
179  if (new_one == n1) {
180  std::vector< NodeId > v;
181 
182  for (current = n1; current != n2; current = mark[current])
183  v.push_back(current);
184 
185  v.push_back(n2);
186 
187  return v;
188  }
189 
190  nodeFIFO.pushBack(new_one);
191  }
192  }
193 
194  GUM_ERROR(NotFound, "no path found");
195  }
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ directedUnorientedPath()

const std::vector< NodeId > gum::ArcGraphPart::directedUnorientedPath ( const NodeId  node1,
const NodeId  node2 
) const
inherited

returns an unoriented (directed) path from node1 to node2 in the arc set

Parameters
node1the id from which the path begins
node2the id to which the path ends
Exceptions
NotFoundexception is raised if no path can be found between the two nodes

Definition at line 198 of file arcGraphPart.cpp.

References gum::ArcGraphPart::children(), gum::List< Val, Alloc >::empty(), gum::HashTable< Key, Val, Alloc >::exists(), gum::List< Val, Alloc >::front(), GUM_ERROR, gum::HashTable< Key, Val, Alloc >::insert(), gum::ArcGraphPart::parents(), gum::List< Val, Alloc >::popFront(), and gum::List< Val, Alloc >::pushBack().

198  {
199  // not recursive version => use a FIFO for simulating the recursion
200  List< NodeId > nodeFIFO;
201  nodeFIFO.pushBack(n2);
202 
203  // mark[node] = successor if visited, else mark[node] does not exist
204  NodeProperty< NodeId > mark;
205  mark.insert(n2, n2);
206 
207  NodeId current;
208 
209  while (!nodeFIFO.empty()) {
210  current = nodeFIFO.front();
211  nodeFIFO.popFront();
212 
213  // check the parents
214  for (const auto new_one: parents(current)) {
215  if (mark.exists(new_one)) // the node has already been visited
216  continue;
217 
218  mark.insert(new_one, current);
219 
220  if (new_one == n1) {
221  std::vector< NodeId > v;
222 
223  for (current = n1; current != n2; current = mark[current])
224  v.push_back(current);
225 
226  v.push_back(n2);
227 
228  return v;
229  }
230 
231  nodeFIFO.pushBack(new_one);
232  }
233 
234  // check the children
235  for (const auto new_one: children(current)) {
236  if (mark.exists(new_one)) // the node has already been visited
237  continue;
238 
239  mark.insert(new_one, current);
240 
241  if (new_one == n1) {
242  std::vector< NodeId > v;
243 
244  for (current = n1; current != n2; current = mark[current])
245  v.push_back(current);
246 
247  v.push_back(n2);
248 
249  return v;
250  }
251 
252  nodeFIFO.pushBack(new_one);
253  }
254  }
255 
256  GUM_ERROR(NotFound, "no path found");
257  }
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
+ Here is the call graph for this function:

◆ empty()

INLINE bool gum::NodeGraphPart::empty ( ) const
inherited

alias for emptyNodes

Definition at line 306 of file nodeGraphPart_inl.h.

Referenced by gum::prm::gspan::Pattern::remove().

306 { return emptyNodes(); }
bool emptyNodes() const
indicates whether there exists nodes in the NodeGraphPart
+ Here is the caller graph for this function:

◆ emptyArcs()

INLINE bool gum::ArcGraphPart::emptyArcs ( ) const
inherited

indicates wether the ArcGraphPart contains any arc

Definition at line 35 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::arcs__, and gum::Set< Key, Alloc >::empty().

35 { return arcs__.empty(); }
bool empty() const noexcept
Indicates whether the set is the empty set.
Definition: set_tpl.h:707
Set< Arc > arcs__
the set of all the arcs contained within the ArcGraphPart
Definition: arcGraphPart.h:269
+ Here is the call graph for this function:

◆ emptyNodes()

INLINE bool gum::NodeGraphPart::emptyNodes ( ) const
inherited

indicates whether there exists nodes in the NodeGraphPart

Definition at line 304 of file nodeGraphPart_inl.h.

304 { return (sizeNodes() == 0); }
Size sizeNodes() const
returns the number of nodes in the NodeGraphPart

◆ end()

INLINE const NodeGraphPartIterator & gum::NodeGraphPart::end ( ) const
noexceptinherited

the end iterator to parse the set of nodes contained in the NodeGraphPart

Definition at line 339 of file nodeGraphPart_inl.h.

339  {
340  return endIteratorSafe__;
341  }
NodeGraphPartIteratorSafe endIteratorSafe__
the end iterator (used to speed-up parsings of the NodeGraphPart)

◆ endSafe()

INLINE const NodeGraphPartIteratorSafe & gum::NodeGraphPart::endSafe ( ) const
noexceptinherited

the end iterator to parse the set of nodes contained in the NodeGraphPart

Definition at line 329 of file nodeGraphPart_inl.h.

329  {
330  return endIteratorSafe__;
331  }
NodeGraphPartIteratorSafe endIteratorSafe__
the end iterator (used to speed-up parsings of the NodeGraphPart)

◆ eraseArc()

INLINE void gum::ArcGraphPart::eraseArc ( const Arc arc)
virtualinherited

removes an arc from the ArcGraphPart

Parameters
arcthe arc to be removed
Warning
if the arc does not exist, nothing is done. In particular, no exception is thrown. However, the signal onArcDeleted is fired only if a node is effectively removed.

Definition at line 79 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::arcs__, gum::ArcGraphPart::children__, gum::Set< Key, Alloc >::erase(), gum::ArcGraphPart::existsArc(), GUM_EMIT2, gum::Arc::head(), gum::ArcGraphPart::onArcDeleted, gum::ArcGraphPart::parents__, and gum::Arc::tail().

Referenced by gum::EssentialGraph::buildEssentialGraph__(), gum::DAGCycleDetector::eraseArc(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), gum::ArcGraphPart::eraseChildren(), gum::ArcGraphPart::eraseParents(), gum::ArcGraphPart::eraseSetOfArcs_(), gum::prm::LayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::learning::genericBNLearner::learnDAG__(), gum::learning::GreedyHillClimbing::learnStructure(), gum::learning::LocalSearchWithTabuList::learnStructure(), gum::learning::Miic::orientation_3off2_(), gum::learning::Miic::orientation_latents_(), gum::learning::Miic::orientation_miic_(), gum::prm::gspan::Pattern::pop_back(), gum::BayesNet< double >::reverseArc(), gum::BayesNetFragment< GUM_SCALAR >::uninstallArc_(), gum::ArcGraphPart::unvirtualizedEraseChildren(), gum::ArcGraphPart::unvirtualizedEraseParents(), and gum::ArcGraphPart::unvirtualizedEraseSetOfArcs_().

79  {
80  // ASSUMING tail and head exists in parents__ anf children__
81  // (if not, it is an error)
82  if (existsArc(arc)) {
83  NodeId tail = arc.tail(), head = arc.head();
84  parents__[head]->erase(tail);
85  children__[tail]->erase(head);
86  arcs__.erase(arc);
87  GUM_EMIT2(onArcDeleted, tail, head);
88  }
89  }
NodeProperty< NodeSet *> children__
for each arc, the set of its children
Definition: arcGraphPart.h:275
void erase(const Key &k)
Erases an element from the set.
Definition: set_tpl.h:656
Set< Arc > arcs__
the set of all the arcs contained within the ArcGraphPart
Definition: arcGraphPart.h:269
#define GUM_EMIT2(signal, arg1, arg2)
Definition: signaler2.h:42
NodeProperty< NodeSet *> parents__
for each arc, the sets of its parents
Definition: arcGraphPart.h:272
Signaler2< NodeId, NodeId > onArcDeleted
Definition: arcGraphPart.h:84
bool existsArc(const Arc &arc) const
indicates whether a given arc exists
Size NodeId
Type for node ids.
Definition: graphElements.h:98
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eraseChildren()

INLINE void gum::ArcGraphPart::eraseChildren ( const NodeId  id)
inherited

removes all the children of a given node

Parameters
idthe node all the children of which will be removed
Warning
although this method is not virtual, it calls method eraseArc( const Arc& arc ) and, as such, has a "virtual" behaviour. If you do not wish it to have this "virtual" behaviour, call instead method unvirtualizedEraseChildren
if no arc is a parent of id, nothing is done. In particular, no exception is thrown.

Definition at line 110 of file arcGraphPart_inl.h.

References gum::Set< Key, Alloc >::beginSafe(), gum::ArcGraphPart::children(), gum::ArcGraphPart::children__, gum::Set< Key, Alloc >::endSafe(), and gum::ArcGraphPart::eraseArc().

110  {
111  if (children__.exists(id)) {
112  NodeSet& children = *(children__[id]);
113 
114  for (auto iter = children.beginSafe(); // safe iterator needed here
115  iter != children.endSafe();
116  ++iter) {
117  // warning: use this erase so that you actually use the vritualized
118  // arc removal function
119  eraseArc(Arc(id, *iter));
120  }
121  }
122  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
NodeProperty< NodeSet *> children__
for each arc, the set of its children
Definition: arcGraphPart.h:275
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
+ Here is the call graph for this function:

◆ eraseNode()

INLINE void gum::DiGraph::eraseNode ( const NodeId  id)
virtualinherited

remove a node and its adjacent arcs from the graph

Parameters
idthe id of the node to be removed
Warning
if the node does not exist, nothing is done. In particular, no exception is raised.

Reimplemented from gum::NodeGraphPart.

Reimplemented in gum::MixedGraph.

Definition at line 69 of file diGraph_inl.h.

References gum::NodeGraphPart::eraseNode(), gum::ArcGraphPart::unvirtualizedEraseChildren(), and gum::ArcGraphPart::unvirtualizedEraseParents().

Referenced by gum::BarrenNodesFinder::barrenNodes(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::prm::gspan::Pattern::pop_back(), gum::prm::gspan::Pattern::remove(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallNode().

69  {
70  // warning: to remove the arcs adjacent to id, use the unvirtualized
71  // versions
72  // of arc removals
75 
77  }
void unvirtualizedEraseChildren(const NodeId id)
same function as eraseChildren but without any virtual call to an erase
void unvirtualizedEraseParents(const NodeId id)
same function as eraseParents but without any virtual call to an erase
virtual void eraseNode(const NodeId id)
erase the node with the given id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eraseParents()

INLINE void gum::ArcGraphPart::eraseParents ( const NodeId  id)
inherited

erase all the parents of a given node

Parameters
idthe node all the parents of which will be removed
Warning
although this method is not virtual, it calls method eraseArc( const Arc& arc ) and, as such, has a "virtual" behaviour. If you do not wish it to have this "virtual" behaviour, call instead method unvirtualizedEraseParents
if no arc is a parent of id, nothing is done. In particular, no exception is thrown.

Definition at line 96 of file arcGraphPart_inl.h.

References gum::Set< Key, Alloc >::beginSafe(), gum::Set< Key, Alloc >::endSafe(), gum::ArcGraphPart::eraseArc(), gum::ArcGraphPart::parents(), and gum::ArcGraphPart::parents__.

96  {
97  if (parents__.exists(id)) {
98  NodeSet& parents = *(parents__[id]);
99 
100  for (auto iter = parents.beginSafe(); // safe iterator needed here
101  iter != parents.endSafe();
102  ++iter) {
103  // warning: use this erase so that you actually use the virtualized
104  // arc removal function
105  eraseArc(Arc(*iter, id));
106  }
107  }
108  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
NodeProperty< NodeSet *> parents__
for each arc, the sets of its parents
Definition: arcGraphPart.h:272
+ Here is the call graph for this function:

◆ eraseSetOfArcs_()

INLINE void gum::ArcGraphPart::eraseSetOfArcs_ ( const ArcSet set)
protectedinherited

a (virtualized) function to remove a given set of arcs

Warning
this function uses eraseArc, which is a virtual function. Hence the behaviour of this function is that of a virtual function

Definition at line 91 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::eraseArc().

91  {
92  for (const auto& arc: set)
93  eraseArc(arc);
94  }
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
+ Here is the call graph for this function:

◆ exists()

INLINE bool gum::NodeGraphPart::exists ( const NodeId  id) const
inherited

alias for existsNode

Definition at line 292 of file nodeGraphPart_inl.h.

Referenced by gum::prm::gspan::Pattern::addArc(), gum::DiGraph::addArc(), gum::UndiGraph::addEdge(), gum::MarkovBlanket::buildMarkovBlanket__(), gum::prm::gspan::Pattern::exists(), gum::prm::ClassBayesNet< GUM_SCALAR >::get__(), gum::DiGraph::hasDirectedPath(), gum::learning::genericBNLearner::learnDAG__(), gum::DAGmodel::moralizedAncestralGraph(), gum::prm::StructuredInference< GUM_SCALAR >::removeNode__(), and gum::NodeGraphPartIterator::setPos_().

292  {
293  return existsNode(node);
294  }
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
+ Here is the caller graph for this function:

◆ existsArc() [1/2]

INLINE bool gum::ArcGraphPart::existsArc ( const Arc arc) const
inherited

indicates whether a given arc exists

Parameters
arcthe arc we test whether or not it belongs to the ArcGraphPart

Definition at line 41 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::arcs__, and gum::Set< Key, Alloc >::contains().

Referenced by gum::DAGCycleDetector::addArc(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::AorR__(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::AR__(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::connect__(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::directedPath__(), gum::ArcGraphPart::eraseArc(), gum::DAGCycleDetector::eraseArc(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), gum::prm::gspan::Pattern::exists(), gum::DAGmodel::existsArc(), gum::learning::Miic::existsDirectedPath__(), gum::prm::LayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::jump_multi__(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::jump_poly__(), gum::MarkovBlanket::MarkovBlanket(), gum::prm::gspan::Pattern::not_rec__(), gum::learning::Miic::orientation_3off2_(), gum::learning::Miic::orientation_latents_(), gum::learning::Miic::orientation_miic_(), gum::prm::gspan::Pattern::rec__(), and gum::learning::Miic::updateProbaTriples_().

41  {
42  return arcs__.contains(arc);
43  }
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
Definition: set_tpl.h:581
Set< Arc > arcs__
the set of all the arcs contained within the ArcGraphPart
Definition: arcGraphPart.h:269
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ existsArc() [2/2]

INLINE bool gum::ArcGraphPart::existsArc ( const NodeId  tail,
const NodeId  head 
) const
inherited

indicates whether a given arc exists

Parameters
tailthe tail of the arc we test the existence in the ArcGraphPart
headthe head of the arc we test the existence in the ArcGraphPart

Definition at line 45 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::parents__.

45  {
46  return parents__.exists(head) && parents__[head]->exists(tail);
47  }
NodeProperty< NodeSet *> parents__
for each arc, the sets of its parents
Definition: arcGraphPart.h:272

◆ existsNode()

◆ hasDirectedPath()

bool gum::DiGraph::hasDirectedPath ( const NodeId  from,
const NodeId  to 
)
inherited

checks whether there exists a directed path from from to to

If from==to, this function checks if a directed cycle containing from exists.

Parameters
from
to
Returns
true if a directed path exists

Definition at line 137 of file diGraph.cpp.

References gum::ArcGraphPart::children(), gum::Set< Key, Alloc >::contains(), gum::List< Val, Alloc >::empty(), gum::NodeGraphPart::exists(), gum::List< Val, Alloc >::front(), gum::Set< Key, Alloc >::insert(), gum::List< Val, Alloc >::popFront(), and gum::List< Val, Alloc >::pushBack().

Referenced by addArc().

137  {
138  if (!exists(from)) return false;
139 
140  // not recursive version => use a FIFO for simulating the recursion
141  List< NodeId > nodeFIFO;
142  nodeFIFO.pushBack(from);
143 
144  NodeSet marked;
145  marked.insert(from);
146 
147  NodeId new_one;
148 
149  while (!nodeFIFO.empty()) {
150  new_one = nodeFIFO.front();
151  // std::cout<<new_one<<std::endl;
152  nodeFIFO.popFront();
153 
154  for (const auto chi: children(new_one)) {
155  if (chi == to) return true;
156 
157  if (!marked.contains(chi)) {
158  nodeFIFO.pushBack(chi);
159  marked.insert(chi);
160  }
161  }
162  }
163 
164  return false;
165  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
bool exists(const NodeId id) const
alias for existsNode
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
Size NodeId
Type for node ids.
Definition: graphElements.h:98
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:613
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listMapArcs()

template<typename VAL >
List< VAL > gum::ArcGraphPart::listMapArcs ( VAL(*)(const Arc &)  f) const
inherited

a method to create a list of VAL from a set of arcs (using for every arc, say x, the VAL f(x))

Parameters
fa function assigning a VAL to any arc

◆ listMapNodes()

template<typename VAL >
List< VAL > gum::NodeGraphPart::listMapNodes ( VAL(*)(const NodeId &)  f) const
inherited

a method to create a list of VAL from a set of nodes (using for every nodee, say x, the VAL f(x))

Parameters
fa function assigning a VAL to any node

◆ moralGraph()

UndiGraph gum::DAG::moralGraph ( ) const

Definition at line 52 of file DAG.cpp.

References gum::UndiGraph::addEdge(), gum::ArcGraphPart::arcs(), gum::NodeGraphPart::nodes(), gum::ArcGraphPart::parents(), and gum::NodeGraphPart::populateNodes().

52  {
53  UndiGraph moralgraph;
54  moralgraph.populateNodes(*this);
55  // transform the arcs into edges
56  for (const auto& arc: arcs())
57  moralgraph.addEdge(arc.first(), arc.second());
58 
59  // marry the parents
60  for (const auto node: nodes()) {
61  const auto& par = parents(node);
62 
63  for (auto it1 = par.begin(); it1 != par.end(); ++it1) {
64  auto it2 = it1;
65 
66  for (++it2; it2 != par.end(); ++it2) {
67  // will automatically check if this edge already exists
68  moralgraph.addEdge(*it1, *it2);
69  }
70  }
71  }
72  return moralgraph;
73  }
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
const ArcSet & arcs() const
returns the set of arcs stored within the ArcGraphPart
+ Here is the call graph for this function:

◆ nextNodeId()

INLINE NodeId gum::NodeGraphPart::nextNodeId ( ) const
inherited

returns a new node id, not yet used by any node

Warning
a code like
id=nextNodeId();addNode(id);
is basically not thread safe !!
Returns
a node id not yet used by any node within the NodeGraphPart

Definition at line 226 of file nodeGraphPart_inl.h.

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::addNode_().

226  {
227  NodeId next = 0;
228 
229  // return the first hole if holes exist
230  if (holes__ && (!holes__->empty()))
231  next = *(holes__->begin());
232  else // in other case
233  next = boundVal__;
234 
235  return next;
236  }
bool empty() const noexcept
Indicates whether the set is the empty set.
Definition: set_tpl.h:707
iterator begin() const
The usual unsafe begin iterator to parse the set.
Definition: set_tpl.h:517
NodeSet * holes__
the set of nodes not contained in the NodeGraphPart in the interval 1..max__
NodeId boundVal__
the id below which NodeIds may belong to the NodeGraphPart
Size NodeId
Type for node ids.
Definition: graphElements.h:98
+ Here is the caller graph for this function:

◆ nodes()

INLINE const NodeGraphPart & gum::NodeGraphPart::nodes ( ) const
inherited

return *this as a NodeGraphPart

Definition at line 373 of file nodeGraphPart_inl.h.

Referenced by gum::MarkovBlanket::buildMarkovBlanket__(), gum::prm::StructuredInference< GUM_SCALAR >::CData::CData(), gum::SpanningForestPrim::compute__(), gum::StaticTriangulation::computeMaxPrimeJunctionTree__(), gum::StaticTriangulation::fillIns(), gum::prm::LayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph(), gum::prm::gspan::DFSTree< GUM_SCALAR >::growPattern(), gum::UndiGraph::hasUndirectedCycle(), gum::MarkovBlanket::MarkovBlanket(), moralGraph(), gum::InfluenceDiagram< GUM_SCALAR >::moralGraph_(), gum::MarkovBlanket::nodes(), gum::EssentialGraph::nodes(), gum::prm::gspan::Pattern::nodes(), gum::InfluenceDiagram< GUM_SCALAR >::removeTables_(), gum::prm::GSpan< GUM_SCALAR >::sortPatterns__(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::threadUpdate__(), gum::MarkovBlanket::toDot(), gum::EssentialGraph::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::UndiGraph::toDot(), gum::DiGraph::toDot(), and gum::MixedGraph::toDot().

373  {
374  return *(static_cast< const NodeGraphPart* >(this));
375  }
NodeGraphPart(Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true)
default constructor
+ Here is the caller graph for this function:

◆ nodesProperty() [1/2]

template<typename VAL >
NodeProperty< VAL > gum::NodeGraphPart::nodesProperty ( VAL(*)(const NodeId &)  f,
Size  size = 0 
) const
inherited

a method to create a HashTable with key:NodeId and value:VAL

VAL are computed from the nodes using for all node x, VAL f(x). This method is a wrapper of the same method in HashTable.

See also
HashTable::map.
Parameters
fa function assigning a VAL to any node
sizean optional parameter enabling to fine-tune the returned Property. Roughly speaking, it is a good practice to have a size equal to half the number of nodes. If you do not specify this parameter, the method will assign it for you.

Referenced by gum::BarrenNodesFinder::barrenNodes(), gum::BinaryJoinTreeConverterDefault::convert(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::InfluenceDiagram< GUM_SCALAR >::getChildrenDecision_(), and gum::UndiGraph::hasUndirectedCycle().

+ Here is the caller graph for this function:

◆ nodesProperty() [2/2]

template<typename VAL >
NodeProperty< VAL > gum::NodeGraphPart::nodesProperty ( const VAL &  a,
Size  size = 0 
) const
inherited

a method to create a hashMap with key:NodeId and value:VAL

for all nodes, the value stored is a. This method is a wrapper of the same method in HashTable.

See also
HashTable::map.
Parameters
athe default value assigned to each edge in the returned Property
sizean optional parameter enabling to fine-tune the returned Property. Roughly speaking, it is a good practice to have a size equal to half the number of nodes. If you do not specify this parameter, the method will assign it for you.

◆ operator!=() [1/3]

INLINE bool gum::ArcGraphPart::operator!= ( const ArcGraphPart p) const
inherited

tests whether two ArcGraphParts contain different arcs

Parameters
pthe ArcGraphPart that we compare with this

Definition at line 157 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::arcs__.

157  {
158  return arcs__ != p.arcs__;
159  }
Set< Arc > arcs__
the set of all the arcs contained within the ArcGraphPart
Definition: arcGraphPart.h:269

◆ operator!=() [2/3]

INLINE bool gum::DiGraph::operator!= ( const DiGraph g) const
inherited

tests whether two DiGraphs are different

Parameters
gthe DiGraph with which "this" is compared

Definition at line 83 of file diGraph_inl.h.

References gum::DiGraph::operator==().

83  {
84  return !operator==(p);
85  }
bool operator==(const DiGraph &g) const
tests whether two DiGraphs are identical (same nodes, same arcs)
Definition: diGraph_inl.h:79
+ Here is the call graph for this function:

◆ operator!=() [3/3]

INLINE bool gum::NodeGraphPart::operator!= ( const NodeGraphPart p) const
inherited

check whether two NodeGraphParts contain different nodes

Parameters
pthe NodeGraphPart to be compared with "this"

Definition at line 357 of file nodeGraphPart_inl.h.

References gum::NodeGraphPartIterator::operator==().

357  {
358  return !operator==(p);
359  }
bool operator==(const NodeGraphPart &p) const
check whether two NodeGraphParts contain the same nodes
+ Here is the call graph for this function:

◆ operator=()

INLINE DAG & gum::DAG::operator= ( const DAG g)

copy operator

Parameters
gthe DAG to copy

Definition at line 36 of file DAG_inl.h.

References gum::DiGraph::operator=().

36  {
37  // avoid self assignment
38  if (this != &g) { DiGraph::operator=(g); }
39 
40  return *this;
41  }
DiGraph & operator=(const DiGraph &g)
copy operator
Definition: diGraph_inl.h:48
+ Here is the call graph for this function:

◆ operator==() [1/3]

INLINE bool gum::ArcGraphPart::operator== ( const ArcGraphPart p) const
inherited

tests whether two ArcGraphParts contain the same arcs

Parameters
pthe ArcGraphPart that we compare with this

Definition at line 153 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::arcs__.

Referenced by gum::DiGraph::operator==(), and gum::MixedGraph::operator==().

153  {
154  return arcs__ == p.arcs__;
155  }
Set< Arc > arcs__
the set of all the arcs contained within the ArcGraphPart
Definition: arcGraphPart.h:269
+ Here is the caller graph for this function:

◆ operator==() [2/3]

INLINE bool gum::DiGraph::operator== ( const DiGraph g) const
inherited

tests whether two DiGraphs are identical (same nodes, same arcs)

Parameters
gthe DiGraph with which "this" is compared

Definition at line 79 of file diGraph_inl.h.

References gum::ArcGraphPart::operator==(), and gum::NodeGraphPart::operator==().

Referenced by gum::DiGraph::operator!=().

79  {
81  }
bool operator==(const NodeGraphPart &p) const
check whether two NodeGraphParts contain the same nodes
bool operator==(const ArcGraphPart &p) const
tests whether two ArcGraphParts contain the same arcs
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator==() [3/3]

INLINE bool gum::NodeGraphPart::operator== ( const NodeGraphPart p) const
inherited

check whether two NodeGraphParts contain the same nodes

Parameters
pthe NodeGraphPart to be compared with "this"

Definition at line 343 of file nodeGraphPart_inl.h.

References gum::NodeGraphPart::boundVal__, and gum::NodeGraphPart::holes__.

Referenced by gum::UndiGraph::operator==(), gum::DiGraph::operator==(), and gum::MixedGraph::operator==().

343  {
344  if (boundVal__ != p.boundVal__) return false;
345 
346  if (holes__)
347  if (p.holes__)
348  return (*holes__ == *p.holes__);
349  else
350  return false;
351  else if (p.holes__)
352  return false;
353 
354  return true;
355  }
NodeSet * holes__
the set of nodes not contained in the NodeGraphPart in the interval 1..max__
NodeId boundVal__
the id below which NodeIds may belong to the NodeGraphPart
+ Here is the caller graph for this function:

◆ parents()

INLINE const NodeSet & gum::ArcGraphPart::parents ( const NodeId  id) const
inherited

returns the set of nodes with arc ingoing to a given node

Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.

Parameters
idthe node toward which the arcs returned are pointing

Definition at line 57 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::checkParents__(), and gum::ArcGraphPart::parents__.

Referenced by gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::AR__(), gum::BarrenNodesFinder::barrenNodes(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::connect__(), gum::InfluenceDiagram< GUM_SCALAR >::copyTables_(), gum::ArcGraphPart::directedPath(), gum::ArcGraphPart::directedUnorientedPath(), gum::learning::BNDatabaseGenerator< GUM_SCALAR >::drawSamples(), gum::ArcGraphPart::eraseParents(), gum::learning::Miic::existsDirectedPath__(), gum::prm::gspan::Pattern::expandCodeIsMinimal__(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::generateClass__(), gum::prm::LayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::generateClassDag__(), gum::prm::LayerGenerator< GUM_SCALAR >::generateClasses__(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::generateCluster__(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::initialize_(), gum::prm::gspan::Pattern::isMinimal(), gum::learning::Miic::learnStructure(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_(), gum::MixedGraph::mixedOrientedPath(), gum::MixedGraph::mixedUnorientedPath(), moralGraph(), gum::InfluenceDiagram< GUM_SCALAR >::moralGraph_(), gum::prm::gspan::Pattern::not_rec__(), gum::learning::Miic::orientation_miic_(), gum::prm::gspan::DFSTree< GUM_SCALAR >::parent(), gum::MarkovBlanket::parents(), gum::EssentialGraph::parents(), gum::DAGmodel::parents(), gum::learning::Miic::propagatesHead_(), gum::prm::gspan::Pattern::rec__(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::prm::gspan::Pattern::remove(), gum::BayesBall::requisiteNodes(), gum::dSeparation::requisiteNodes(), gum::prm::gspan::Pattern::rightmostPath(), gum::EssentialGraph::strongly_protected__(), and gum::ArcGraphPart::unvirtualizedEraseParents().

57  {
58  checkParents__(id);
59  return *(parents__[id]);
60  }
void checkParents__(const NodeId id) const
when the ArcGraphPart contains no arc ingoing into a given node, this function adds an empty set entr...
NodeProperty< NodeSet *> parents__
for each arc, the sets of its parents
Definition: arcGraphPart.h:272
+ Here is the call graph for this function:

◆ populateNodes()

void gum::NodeGraphPart::populateNodes ( const NodeGraphPart s)
inherited

populateNodes clears *this and fills it with the same nodes as "s"

populateNodes should basically be the preferred way to insert nodes with IDs not selected by the internal idFactory.

Parameters
sthe NodeGraphPart to be copied

Definition at line 64 of file nodeGraphPart.cpp.

References gum::NodeGraphPart::boundVal__, gum::NodeGraphPart::clear(), gum::NodeGraphPart::holes__, gum::NodeGraphPart::holes_resize_policy__, gum::NodeGraphPart::holes_size__, and gum::NodeGraphPart::updateEndIteratorSafe__().

Referenced by moralGraph(), and gum::DAGmodel::moralGraph__().

64  {
65  clear(); // "virtual" flush of the nodes set
66  holes_size__ = s.holes_size__;
67  holes_resize_policy__ = s.holes_resize_policy__;
68 
69  if (s.holes__) holes__ = new NodeSet(*s.holes__);
70 
71  boundVal__ = s.boundVal__;
72 
74  }
bool holes_resize_policy__
value for holes__ configuration
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
NodeSet * holes__
the set of nodes not contained in the NodeGraphPart in the interval 1..max__
virtual void clear()
alias for clearNodes
NodeId boundVal__
the id below which NodeIds may belong to the NodeGraphPart
void updateEndIteratorSafe__()
updating endIterator (always at max__+1)
Size holes_size__
value for holes__ configuration
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populateNodesFromProperty()

template<typename T >
void gum::NodeGraphPart::populateNodesFromProperty ( const NodeProperty< T > &  h)
inherited

populateNodesFromProperty clears *this and fills it with the keys of "h"

populateNodes should basically be the preferred way to insert nodes with IDs not selected by the internal idFactory.

◆ size()

◆ sizeArcs()

INLINE Size gum::ArcGraphPart::sizeArcs ( ) const
inherited

indicates the number of arcs stored within the ArcGraphPart

Definition at line 37 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::arcs__, and gum::Set< Key, Alloc >::size().

Referenced by gum::MarkovBlanket::sizeArcs(), gum::EssentialGraph::sizeArcs(), gum::DAGmodel::sizeArcs(), gum::prm::gspan::Pattern::sizeArcs(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().

37 { return arcs__.size(); }
Set< Arc > arcs__
the set of all the arcs contained within the ArcGraphPart
Definition: arcGraphPart.h:269
Size size() const noexcept
Returns the number of elements in the set.
Definition: set_tpl.h:701
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sizeNodes()

INLINE Size gum::NodeGraphPart::sizeNodes ( ) const
inherited

returns the number of nodes in the NodeGraphPart

Definition at line 280 of file nodeGraphPart_inl.h.

Referenced by gum::BarrenNodesFinder::barrenNodes(), gum::BinaryJoinTreeConverterDefault::convert(), gum::BinaryJoinTreeConverterDefault::markConnectedComponent__(), gum::EliminationSequenceStrategy::setGraph(), gum::MarkovBlanket::sizeNodes(), and gum::EssentialGraph::sizeNodes().

280  {
281  return (holes__) ? (boundVal__ - holes__->size()) : boundVal__;
282  }
NodeSet * holes__
the set of nodes not contained in the NodeGraphPart in the interval 1..max__
NodeId boundVal__
the id below which NodeIds may belong to the NodeGraphPart
Size size() const noexcept
Returns the number of elements in the set.
Definition: set_tpl.h:701
+ Here is the caller graph for this function:

◆ toDot()

const std::string gum::DiGraph::toDot ( ) const
virtualinherited

to friendly display the content of the graph in the DOT syntax

Parameters
nameThe graph name in the dot syntax. Default is G.
Returns
Returns a string describing the graph in the dot syntax

Reimplemented in gum::MixedGraph.

Definition at line 68 of file diGraph.cpp.

References gum::ArcGraphPart::arcs(), and gum::NodeGraphPart::nodes().

68  {
69  std::stringstream strBuff;
70  std::string tab = " ";
71  strBuff << "digraph {" << std::endl;
72 
73  for (const auto node: nodes())
74  strBuff << tab << node << ";" << std::endl;
75 
76  strBuff << std::endl;
77 
78  for (const auto& arc: arcs())
79  strBuff << tab << arc.tail() << " -> " << arc.head() << ";" << std::endl;
80 
81  strBuff << "}" << std::endl << std::endl;
82  return strBuff.str();
83  }
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
const ArcSet & arcs() const
returns the set of arcs stored within the ArcGraphPart
+ Here is the call graph for this function:

◆ topologicalOrder()

const Sequence< NodeId > & gum::DiGraph::topologicalOrder ( bool  clear = true) const
inherited

The topological order stays the same as long as no variable or arcs are added or erased src the topology.

Parameters
clearIf false returns the previously created topology.
Exceptions
InvalidDirectedCycleRaised if this DiGraph contains cycles.

Definition at line 91 of file diGraph.cpp.

References gum::SequenceImplementation< Key, Alloc, Gen >::clear(), gum::DiGraph::mutableTopologicalOrder__, and gum::DiGraph::topologicalOrder__().

Referenced by gum::learning::Miic::learnStructure(), gum::prm::o3prm::O3ClassFactory< GUM_SCALAR >::setO3ClassCreationOrder__(), gum::prm::o3prm::O3InterfaceFactory< GUM_SCALAR >::setO3InterfaceCreationOrder__(), gum::prm::o3prm::O3TypeFactory< GUM_SCALAR >::setO3TypeCreationOrder__(), and gum::DAGmodel::topologicalOrder().

91  {
92  if (clear
94  == nullptr)) { // we have to call topologicalOrder_
95  if (mutableTopologicalOrder__ == nullptr) {
97  } else {
98  // clear is True
100  }
101 
103  }
104 
106  }
void topologicalOrder__() const
Returns a topological order of this DAGModel.
Definition: diGraph.cpp:108
void clear()
Clear the sequence.
Definition: sequence_tpl.h:271
Sequence< NodeId > * mutableTopologicalOrder__
The topology sequence of this Directed Graphical Model.
Definition: diGraph.h:210
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toString()

const std::string gum::DiGraph::toString ( ) const
virtualinherited

to friendly display the content of the graph

Reimplemented in gum::MixedGraph.

Definition at line 61 of file diGraph.cpp.

References gum::ArcGraphPart::toString(), and gum::NodeGraphPart::toString().

Referenced by gum::operator<<().

61  {
62  std::string s = NodeGraphPart::toString();
63  s += " , ";
65  return s;
66  }
const std::string toString() const
to friendly display the content of the ArcGraphPart
std::string toString() const
a function to display the set of nodes
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unvirtualizedEraseChildren()

INLINE void gum::ArcGraphPart::unvirtualizedEraseChildren ( const NodeId  id)
inherited

same function as eraseChildren but without any virtual call to an erase

Parameters
idthe node whose outgoing arcs will be removed

Definition at line 141 of file arcGraphPart_inl.h.

References gum::Set< Key, Alloc >::beginSafe(), gum::ArcGraphPart::children(), gum::ArcGraphPart::children__, gum::Set< Key, Alloc >::endSafe(), and gum::ArcGraphPart::eraseArc().

Referenced by gum::DiGraph::eraseNode(), and gum::MixedGraph::eraseNode().

141  {
142  if (children__.exists(id)) {
143  NodeSet& children = *(children__[id]);
144 
145  for (auto iter = children.beginSafe(); // safe iterator needed here
146  iter != children.endSafe();
147  ++iter) {
148  ArcGraphPart::eraseArc(Arc(id, *iter));
149  }
150  }
151  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
NodeProperty< NodeSet *> children__
for each arc, the set of its children
Definition: arcGraphPart.h:275
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unvirtualizedEraseParents()

INLINE void gum::ArcGraphPart::unvirtualizedEraseParents ( const NodeId  id)
inherited

same function as eraseParents but without any virtual call to an erase

Parameters
idthe node whose ingoing arcs will be removed

Definition at line 129 of file arcGraphPart_inl.h.

References gum::Set< Key, Alloc >::beginSafe(), gum::Set< Key, Alloc >::endSafe(), gum::ArcGraphPart::eraseArc(), gum::ArcGraphPart::parents(), and gum::ArcGraphPart::parents__.

Referenced by gum::DiGraph::eraseNode(), and gum::MixedGraph::eraseNode().

129  {
130  if (parents__.exists(id)) {
131  NodeSet& parents = *(parents__[id]);
132 
133  for (auto iter = parents.beginSafe(); // safe iterator needed here
134  iter != parents.endSafe();
135  ++iter) {
136  ArcGraphPart::eraseArc(Arc(*iter, id));
137  }
138  }
139  }
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
NodeProperty< NodeSet *> parents__
for each arc, the sets of its parents
Definition: arcGraphPart.h:272
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unvirtualizedEraseSetOfArcs_()

INLINE void gum::ArcGraphPart::unvirtualizedEraseSetOfArcs_ ( const ArcSet set)
protectedinherited

similar to eraseSetOfArcs_ except that it is unvirtualized

Warning
this function uses ArcGraphPart::eraseArc, hence, as compared with eraseSetOfArcs_, it removes the arcs without calling a virtual eraseArc

Definition at line 124 of file arcGraphPart_inl.h.

References gum::ArcGraphPart::eraseArc().

124  {
125  for (const auto& arc: set)
127  }
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
+ Here is the call graph for this function:

Member Data Documentation

◆ onArcAdded

Signaler2< NodeId, NodeId > gum::ArcGraphPart::onArcAdded
inherited

◆ onArcDeleted

Signaler2< NodeId, NodeId > gum::ArcGraphPart::onArcDeleted
inherited

Definition at line 84 of file arcGraphPart.h.

Referenced by gum::ArcGraphPart::clearArcs(), and gum::ArcGraphPart::eraseArc().

◆ onNodeAdded

Signaler1< NodeId > gum::NodeGraphPart::onNodeAdded
inherited

Definition at line 272 of file nodeGraphPart.h.

Referenced by gum::NodeGraphPart::addNodeWithId().

◆ onNodeDeleted

Signaler1< NodeId > gum::NodeGraphPart::onNodeDeleted
inherited

Definition at line 273 of file nodeGraphPart.h.

Referenced by gum::NodeGraphPart::clearNodes__().


The documentation for this class was generated from the following files: