aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
gum::ArcGraphPart Class Reference

Classes for directed edge sets. More...

#include <arcGraphPart.h>

Inheritance diagram for gum::ArcGraphPart:
Collaboration diagram for gum::ArcGraphPart:

Public Types

using ArcIterator = ArcSetIterator

Public Member Functions

Constructors / Destructors
 ArcGraphPart (Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
 default constructor
 ArcGraphPart (const ArcGraphPart &s)
 copy constructor
 ArcGraphPart (ArcGraphPart &&s)
 move constructor
virtual ~ArcGraphPart ()
 destructor
Operators
ArcGraphPartoperator= (const ArcGraphPart &s)
 copy operator
ArcGraphPartoperator= (ArcGraphPart &&s)
 move assignment operator
bool operator== (const ArcGraphPart &p) const
 tests whether two ArcGraphParts contain the same arcs
Accessors/Modifiers
virtual void addArc (NodeId tail, NodeId head)
 insert a new arc into the ArcGraphPart
virtual void eraseArc (const Arc &arc)
 removes an arc from the ArcGraphPart
bool existsArc (const Arc &arc) const
 indicates whether a given arc exists
bool existsArc (NodeId tail, NodeId head) const
 indicates whether a given arc exists
bool emptyArcs () const
 indicates wether the ArcGraphPart contains any arc
void clearArcs ()
 removes all the arcs from the ArcGraphPart
Size sizeArcs () const
 indicates the number of arcs stored within the ArcGraphPart
const ArcSetarcs () const
 returns the set of arcs stored within the ArcGraphPart
const NodeSetparents (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 set of nodes
NodeSet parents (const NodeSet &ids) const
 returns the set of parents of a set of nodes
const NodeSetchildren (NodeId id) const
 returns the set of nodes with arc outgoing from a given node
void eraseParents (NodeId id)
 erase all the parents of a given node
void unvirtualizedEraseParents (NodeId id)
 same function as eraseParents but without any virtual call to an erase
void eraseChildren (NodeId id)
 removes all the children of a given node
void unvirtualizedEraseChildren (NodeId id)
 same function as eraseChildren but without any virtual call to an erase
std::string toString () const
 to friendly display the content of the ArcGraphPart
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))
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)
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))

Public Attributes

Signaler< NodeId, NodeIdonArcAdded
Signaler< NodeId, NodeIdonArcDeleted

Protected Member Functions

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

Private Member Functions

void _checkParents_ (NodeId id)
 when the ArcGraphPart contains no arc ingoing into a given node, this function adds an empty set entry to parents[id]
void _checkChildren_ (NodeId id)
 when the ArcGraphPart contains no arc outgoing from a given node, this function adds an empty set entry to children[id]

Private Attributes

Set< Arc_arcs_
 the set of all the arcs contained within the ArcGraphPart
NodeProperty< NodeSet * > _parents_
 for each arc, the sets of its parents
NodeProperty< NodeSet * > _children_
 for each arc, the set of its children

Detailed Description

Classes for directed edge sets.

Author
Pierre-Henri WUILLEMIN(_at_LIP6) & Christophe GONZALES(_at_AMU)
Usage example:
ArcGraphPart arcs1,arcs2,arcs3;
// insert elements into arcs1
arcs1.addArc( 2,3 );
arcs1.addArc( 5,3 );
// copy arcs1 into arcs2
arcs2=arcs1;
// remove some elements from arcs1
arcs1.eraseArc( Arc( 5,3 ) );
arcs1.eraseArc( arc );
if ( arcs1.empty() ) std::cerr<<" arcs1 is empty"<<std::endl;
// checks whether a given arc exists
if ( arcs2.existArc( arc ) )
cerr << "set contains " << arc << endl;
if ( arcs2.existArc( 5,3 ) )
cerr << "set contains " << arc << endl;
std::cerr<<arcs2.toString()<<std::endl;
std::cerr<<arcs2.parents( 3 )<<std::endl;
std::cerr<<arcs2.children( 2 )<<std::endl;
std::cerr<<std::endl<<std::endl;
std::cerr<<std::endl<<std::endl;
virtual void addArc(NodeId tail, NodeId head)
insert a new arc into the ArcGraphPart
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
ArcGraphPart(Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
std::string toString() const
to friendly display the content of the ArcGraphPart
The base class for all directed edges.

Definition at line 98 of file arcGraphPart.h.

Member Typedef Documentation

◆ ArcIterator

Definition at line 100 of file arcGraphPart.h.

Constructor & Destructor Documentation

◆ ArcGraphPart() [1/3]

gum::ArcGraphPart::ArcGraphPart ( Size arcs_size = HashTableConst::default_size,
bool arcs_resize_policy = true )
explicit

default constructor

Parameters
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 58 of file arcGraphPart.cpp.

58 :
59 _arcs_(arcs_size, arcs_resize_policy) {
60 GUM_CONSTRUCTOR(ArcGraphPart);
61 }
Set< Arc > _arcs_
the set of all the arcs contained within the ArcGraphPart

References ArcGraphPart(), and _arcs_.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ArcGraphPart() [2/3]

gum::ArcGraphPart::ArcGraphPart ( const ArcGraphPart & s)

copy constructor

Parameters
sthe ArcGraphPart to copy

Definition at line 69 of file arcGraphPart.cpp.

69 : _arcs_(s._arcs_) {
70 GUM_CONS_CPY(ArcGraphPart);
71
72 // copy the sets of parents
73 const NodeProperty< NodeSet* >& pars = s._parents_;
74 _parents_.resize(pars.capacity());
75
76 for (const auto& [key, nodeset]: pars) {
77 NodeSet* newpar = new NodeSet(*nodeset);
78 _parents_.insert(key, newpar);
79 }
80
81 // copy the sets of children
82 const NodeProperty< NodeSet* >& children = s._children_;
83 _children_.resize(children.capacity());
84
85 for (const auto& [key, nodeset]: children) {
86 NodeSet* newchildren = new NodeSet(*nodeset);
87 _children_.insert(key, newchildren);
88 }
89
90 // send signals to indicate that there are new arcs
91 if (onArcAdded.hasListener()) {
92 for (const auto& arc: _arcs_) {
93 GUM_EMIT2(onArcAdded, arc.tail(), arc.head());
94 }
95 }
96 }
NodeProperty< NodeSet * > _children_
for each arc, the set of its children
Signaler< NodeId, NodeId > onArcAdded
NodeProperty< NodeSet * > _parents_
for each arc, the sets of its parents
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
#define GUM_EMIT2(signal, arg1, arg2)
Definition signaler.h:290

References ArcGraphPart(), _arcs_, _children_, _parents_, gum::HashTable< Key, Val >::capacity(), children(), GUM_EMIT2, and onArcAdded.

Here is the call graph for this function:

◆ ArcGraphPart() [3/3]

gum::ArcGraphPart::ArcGraphPart ( ArcGraphPart && s)

move constructor

Definition at line 63 of file arcGraphPart.cpp.

63 :
64 _arcs_(std::move(s._arcs_)), _parents_(std::move(s._parents_)),
65 _children_(std::move(s._children_)) {
66 GUM_CONS_MOV(ArcGraphPart);
67 }

References ArcGraphPart(), _arcs_, _children_, and _parents_.

Here is the call graph for this function:

◆ ~ArcGraphPart()

gum::ArcGraphPart::~ArcGraphPart ( )
virtual

destructor

Definition at line 98 of file arcGraphPart.cpp.

98 {
99 GUM_DESTRUCTOR(ArcGraphPart);
100 // be sure to deallocate all the parents and children sets
101 clearArcs();
102 }
void clearArcs()
removes all the arcs from the ArcGraphPart

References ArcGraphPart(), and clearArcs().

Here is the call graph for this function:

Member Function Documentation

◆ _checkChildren_()

INLINE void gum::ArcGraphPart::_checkChildren_ ( NodeId id)
private

when the ArcGraphPart contains no arc outgoing from a given node, this function adds an empty set entry to children[id]

Parameters
idthe node whose children[id] is checked

Definition at line 72 of file arcGraphPart_inl.h.

72 {
73 if (!_children_.exists(id)) { _children_.insert(id, new NodeSet); }
74 }

References _children_.

Referenced by addArc().

Here is the caller graph for this function:

◆ _checkParents_()

INLINE void gum::ArcGraphPart::_checkParents_ ( NodeId id)
private

when the ArcGraphPart contains no arc ingoing into a given node, this function adds an empty set entry to parents[id]

Parameters
idthe node whose parents[id] is checked

Definition at line 68 of file arcGraphPart_inl.h.

68 {
69 if (!_parents_.exists(id)) { _parents_.insert(id, new NodeSet); }
70 }

References _parents_.

Referenced by addArc().

Here is the caller graph for this function:

◆ addArc()

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

insert a new arc into the ArcGraphPart

Parameters
tailthe id of the tail of the new arc to be inserted
headthe id of the head of the new arc to be inserted
Warning
if the arc already exists, nothing is done. In particular, no exception is raised.

Reimplemented in gum::DAG, gum::DiGraph, gum::PDAG, and gum::prm::gspan::Pattern.

Definition at line 102 of file arcGraphPart_inl.h.

102 {
103 Arc arc(tail, head);
104
105 _arcs_.insert(arc);
106 _checkParents_(head);
107 _checkChildren_(tail);
108 _parents_[head]->insert(tail);
109 _children_[tail]->insert(head);
110
111 GUM_EMIT2(onArcAdded, tail, head);
112 }
void _checkParents_(NodeId id)
when the ArcGraphPart contains no arc ingoing into a given node, this function adds an empty set entr...
void _checkChildren_(NodeId id)
when the ArcGraphPart contains no arc outgoing from a given node, this function adds an empty set ent...

References _arcs_, _checkChildren_(), _checkParents_(), _children_, _parents_, GUM_EMIT2, and onArcAdded.

Referenced by gum::DiGraph::addArc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ arcs()

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

returns the set of arcs stored within the ArcGraphPart

Definition at line 60 of file arcGraphPart_inl.h.

60{ return _arcs_; }

References _arcs_.

Referenced by gum::EssentialGraph::_buildEssentialGraph_(), gum::prm::PRMClass< GUM_SCALAR >::_inheritClass_(), gum::prm::ClassBayesNet< GUM_SCALAR >::_init_(), gum::prm::gspan::Pattern::arcs(), gum::learning::FCI::learnPAG(), gum::learning::SimpleMiic::learnStructure(), and gum::DiGraph::toDot().

Here is the caller graph for this function:

◆ arcsProperty() [1/2]

template<typename VAL>
ArcProperty< VAL > gum::ArcGraphPart::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)

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.

◆ arcsProperty() [2/2]

template<typename VAL>
ArcProperty< VAL > gum::ArcGraphPart::arcsProperty ( VAL(* )(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))

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.

◆ children() [1/2]

INLINE NodeSet gum::ArcGraphPart::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 set of nodes

returns the set of children of a set of nodes

Definition at line 82 of file arcGraphPart_inl.h.

82 {
83 NodeSet res;
84 for (const auto node: ids)
85 res += children(node);
86 return res;
87 }

References children().

Referenced by ArcGraphPart(), gum::prm::ClassDependencyGraph< GUM_SCALAR >::_addArcs_(), gum::EssentialGraph::_buildEssentialGraph_(), gum::DoorCriteria::_existsUnblockedDirectedPath_(), gum::prm::gspan::Pattern::_expandCodeIsMinimal_(), gum::prm::SVE< GUM_SCALAR >::_initElimOrder_(), gum::prm::SVED< GUM_SCALAR >::_initElimOrder_(), gum::prm::gspan::Pattern::_not_rec_(), gum::MeekRules::_propagatesOrientationInChainOfRemainingEdges_(), gum::prm::gspan::Pattern::_rec_(), gum::DoCalculus< GUM_SCALAR >::_removeInIntoDoing_outOfKnowing_(), gum::BarrenNodesFinder::barrenNodes(), children(), gum::DoorCriteria::enumerateFrontdoorSets(), eraseChildren(), gum::PDAG::hasMixedReallyOrientedPath(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::initialize_(), gum::Separation::isBackdoorSeparated(), gum::Separation::isForwardSeparated(), gum::prm::gspan::Pattern::isMinimal(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_(), operator<<(), gum::learning::SimpleMiic::propagatesOrientationInChainOfRemainingEdges_(), gum::rec_hasMixedReallyOrientedPath(), gum::BayesBall::relevantTensors(), gum::dSeparationAlgorithm::relevantTensors(), gum::prm::gspan::Pattern::remove(), gum::dSeparationAlgorithm::requisiteNodes(), gum::DAGCycleDetector::setDAG(), gum::MixedGraph::toDot(), gum::PDAG::toDot(), and unvirtualizedEraseChildren().

Here is the call graph for this function:

◆ children() [2/2]

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

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 97 of file arcGraphPart_inl.h.

97 {
98 if (_children_.exists(id)) return *_children_[id];
99 else return emptyNodeSet;
100 }
const NodeSet emptyNodeSet
Some typdefs and define for shortcuts ...

References _children_, and gum::emptyNodeSet.

◆ clearArcs()

void gum::ArcGraphPart::clearArcs ( )

removes all the arcs from the ArcGraphPart

Definition at line 104 of file arcGraphPart.cpp.

104 {
105 for (const auto& elt: _parents_)
106 delete elt.second;
107
108 _parents_.clear();
109
110 for (const auto& elt: _children_)
111 delete elt.second;
112
113 _children_.clear();
114
115 // we need this copy only if at least one onArcDeleted listener exists
116 if (onArcDeleted.hasListener()) {
117 ArcSet tmp = _arcs_;
118 _arcs_.clear();
119
120 for (const auto& arc: tmp)
121 GUM_EMIT2(onArcDeleted, arc.tail(), arc.head());
122 } else {
123 _arcs_.clear();
124 }
125 }
Signaler< NodeId, NodeId > onArcDeleted
Set< Arc > ArcSet
Some typdefs and define for shortcuts ...

References _arcs_, _children_, _parents_, GUM_EMIT2, and onArcDeleted.

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

Here is the caller graph for this function:

◆ emptyArcs()

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

indicates wether the ArcGraphPart contains any arc

Definition at line 56 of file arcGraphPart_inl.h.

56{ return _arcs_.empty(); }

References _arcs_.

◆ eraseArc()

INLINE void gum::ArcGraphPart::eraseArc ( const Arc & arc)
virtual

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 114 of file arcGraphPart_inl.h.

114 {
115 // ASSUMING tail and head exists in _parents_ anf _children_
116 // (if not, it is an error)
117 if (existsArc(arc)) {
118 NodeId tail = arc.tail();
119 NodeId head = arc.head();
120 _parents_[head]->erase(tail);
121 _children_[tail]->erase(head);
122 _arcs_.erase(arc);
123 GUM_EMIT2(onArcDeleted, tail, head);
124 }
125 }
bool existsArc(const Arc &arc) const
indicates whether a given arc exists
Size NodeId
Type for node ids.

References _arcs_, _children_, _parents_, existsArc(), GUM_EMIT2, gum::Arc::head(), onArcDeleted, and gum::Arc::tail().

Referenced by gum::EssentialGraph::_buildEssentialGraph_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::MeekRules::_orientDoubleHeadedArcs_(), gum::DoCalculus< GUM_SCALAR >::_removeIncomingInto_(), gum::DoCalculus< GUM_SCALAR >::_removeInIntoDoing_outOfKnowing_(), gum::BarrenNodesFinder::barrenNodes(), eraseChildren(), eraseParents(), eraseSetOfArcs_(), gum::Separation::isBackdoorSeparated(), gum::learning::IBNLearner::learnDag_(), gum::learning::SimpleMiic::learnStructure(), gum::learning::ConstraintBasedLearning::orientDoubleHeadedArcs_(), gum::prm::gspan::Pattern::pop_back(), gum::BayesNet< GUM_SCALAR >::reverseArc(), unvirtualizedEraseChildren(), unvirtualizedEraseParents(), and unvirtualizedEraseSetOfArcs_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eraseChildren()

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

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 146 of file arcGraphPart_inl.h.

146 {
147 if (_children_.exists(id)) {
148 const NodeSet& children = *(_children_[id]);
149
150 for (auto iter = children.beginSafe(); // safe iterator needed here
151 iter != children.endSafe();
152 ++iter) {
153 // warning: use this erase so that you actually use the virtualized
154 // arc removal function
155 eraseArc(Arc(id, *iter));
156 }
157 }
158 }

References _children_, children(), and eraseArc().

Here is the call graph for this function:

◆ eraseParents()

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

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 132 of file arcGraphPart_inl.h.

132 {
133 if (_parents_.exists(id)) {
134 const NodeSet& parents = *(_parents_[id]);
135
136 for (auto iter = parents.beginSafe(); // safe iterator needed here
137 iter != parents.endSafe();
138 ++iter) {
139 // warning: use this erase so that you actually use the virtualized
140 // arc removal function
141 eraseArc(Arc(*iter, id));
142 }
143 }
144 }

References _parents_, eraseArc(), and parents().

Here is the call graph for this function:

◆ eraseSetOfArcs_()

INLINE void gum::ArcGraphPart::eraseSetOfArcs_ ( const ArcSet & set)
protected

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 127 of file arcGraphPart_inl.h.

127 {
128 for (const auto& arc: set)
129 eraseArc(arc);
130 }

References eraseArc().

Here is the call graph for this function:

◆ existsArc() [1/2]

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

◆ existsArc() [2/2]

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

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 64 of file arcGraphPart_inl.h.

64 {
65 return _parents_.exists(head) && _parents_[head]->exists(tail);
66 }

References _parents_.

◆ listMapArcs()

template<typename VAL>
List< VAL > gum::ArcGraphPart::listMapArcs ( VAL(* )(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))

Parameters
fa function assigning a VAL to any arc

◆ operator=() [1/2]

ArcGraphPart & gum::ArcGraphPart::operator= ( ArcGraphPart && s)

move assignment operator

Definition at line 162 of file arcGraphPart.cpp.

162 {
163 if (this != &s) {
164 clearArcs();
165 _arcs_ = std::move(s._arcs_);
166 _parents_ = std::move(s._parents_);
167 _children_ = std::move(s._children_);
168 if (onArcAdded.hasListener()) {
169 for (const auto& arc: _arcs_) {
170 GUM_EMIT2(onArcAdded, arc.tail(), arc.head());
171 }
172 }
173 GUM_OP_MOV(ArcGraphPart);
174 }
175 return *this;
176 }

References ArcGraphPart(), _arcs_, _children_, _parents_, clearArcs(), GUM_EMIT2, and onArcAdded.

Here is the call graph for this function:

◆ operator=() [2/2]

ArcGraphPart & gum::ArcGraphPart::operator= ( const ArcGraphPart & s)

copy operator

Parameters
sthe ArcGraphPart to copy

Definition at line 127 of file arcGraphPart.cpp.

127 {
128 // avoid self assignment
129 if (this != &s) {
130 // copy the arcs
131 clearArcs();
132 _arcs_ = s._arcs_;
133
134 // copy the sets of parents
135 _parents_.resize(s._parents_.capacity());
136
137 for (const auto& [key, nodeset]: s._parents_) {
138 NodeSet* newpar = new NodeSet(*nodeset);
139 _parents_.insert(key, newpar);
140 }
141
142 // copy the sets of children
143 _children_.resize(s._children_.capacity());
144
145 for (const auto& [key, nodeset]: s._children_) {
146 NodeSet* newchildren = new NodeSet(*nodeset);
147 _children_.insert(key, newchildren);
148 }
149
150 if (onArcAdded.hasListener()) {
151 for (const auto& arc: _arcs_) {
152 GUM_EMIT2(onArcAdded, arc.tail(), arc.head());
153 }
154 }
155
156 GUM_OP_CPY(ArcGraphPart);
157 }
158
159 return *this;
160 }

References ArcGraphPart(), _arcs_, _children_, _parents_, clearArcs(), GUM_EMIT2, and onArcAdded.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator==()

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

tests whether two ArcGraphParts contain the same arcs

Parameters
pthe ArcGraphPart that we compare with this

Definition at line 189 of file arcGraphPart_inl.h.

189{ return _arcs_ == p._arcs_; }

References ArcGraphPart(), and _arcs_.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parents() [1/2]

INLINE NodeSet gum::ArcGraphPart::parents ( const NodeSet & ids) const

returns the set of parents of a set of nodes

Definition at line 90 of file arcGraphPart_inl.h.

90 {
91 NodeSet res;
92 for (const auto node: ids)
93 res += parents(node);
94 return res;
95 }

References parents().

Here is the call graph for this function:

◆ parents() [2/2]

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

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 76 of file arcGraphPart_inl.h.

76 {
77 if (_parents_.exists(id)) return *(_parents_[id]);
78 else return emptyNodeSet;
79 }

References _parents_, and gum::emptyNodeSet.

Referenced by gum::DoCalculus< GUM_SCALAR >::_ancestorsIn_(), gum::prm::gspan::Pattern::_expandCodeIsMinimal_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClass_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClasses_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateCluster_(), gum::prm::SVE< GUM_SCALAR >::_initElimOrder_(), gum::prm::SVED< GUM_SCALAR >::_initElimOrder_(), gum::prm::SVE< GUM_SCALAR >::_initLiftedNodes_(), gum::prm::SVED< GUM_SCALAR >::_initLiftedNodes_(), gum::prm::gspan::Pattern::_not_rec_(), gum::MeekRules::_orientDoubleHeadedArcs_(), gum::prm::gspan::Pattern::_rec_(), gum::DoCalculus< GUM_SCALAR >::_removeIncomingInto_(), gum::DoCalculus< GUM_SCALAR >::_removeInIntoDoing_outOfKnowing_(), gum::EssentialGraph::_strongly_protected_(), gum::DoorCriteria::backdoorReach(), gum::BarrenNodesFinder::barrenNodes(), gum::DoorCriteria::enumerateBackdoorSets(), gum::DoorCriteria::enumerateFrontdoorSets(), eraseParents(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::initialize_(), gum::prm::gspan::Pattern::isMinimal(), gum::learning::SimpleMiic::learnPDAG(), gum::learning::SimpleMiic::learnStructure(), gum::credal::CNLoopyPropagation< GUM_SCALAR >::makeInferenceNodeToNeighbours_(), operator<<(), gum::learning::ConstraintBasedLearning::orientDoubleHeadedArcs_(), gum::prm::gspan::DFSTree< GUM_SCALAR >::parent(), gum::prm::gspan::DFSTree< GUM_SCALAR >::parent(), parents(), gum::BayesBall::relevantTensors(), gum::dSeparationAlgorithm::relevantTensors(), gum::prm::gspan::Pattern::remove(), gum::dSeparationAlgorithm::requisiteNodes(), gum::prm::gspan::Pattern::rightmostPath(), gum::DAGCycleDetector::setDAG(), and unvirtualizedEraseParents().

◆ sizeArcs()

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

indicates the number of arcs stored within the ArcGraphPart

Definition at line 58 of file arcGraphPart_inl.h.

58{ return _arcs_.size(); }

References _arcs_.

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

Here is the caller graph for this function:

◆ toString()

std::string gum::ArcGraphPart::toString ( ) const

to friendly display the content of the ArcGraphPart

Definition at line 178 of file arcGraphPart.cpp.

178 {
179 std::stringstream s;
180 bool first = true;
181 s << "{";
182
183 for (const auto& arc: _arcs_) {
184 if (first) {
185 first = false;
186 } else {
187 s << ",";
188 }
189
190 s << arc;
191 }
192
193 s << "}";
194
195 return s.str();
196 }

References _arcs_.

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

Here is the caller graph for this function:

◆ unvirtualizedEraseChildren()

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

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

Parameters
idthe node whose outgoing arcs will be removed

Definition at line 177 of file arcGraphPart_inl.h.

177 {
178 if (_children_.exists(id)) {
179 const NodeSet& children = *(_children_[id]);
180
181 for (auto iter = children.beginSafe(); // safe iterator needed here
182 iter != children.endSafe();
183 ++iter) {
184 ArcGraphPart::eraseArc(Arc(id, *iter));
185 }
186 }
187 }

References _children_, children(), and eraseArc().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unvirtualizedEraseParents()

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

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

Parameters
idthe node whose ingoing arcs will be removed

Definition at line 165 of file arcGraphPart_inl.h.

165 {
166 if (_parents_.exists(id)) {
167 const NodeSet& parents = *(_parents_[id]);
168
169 for (auto iter = parents.beginSafe(); // safe iterator needed here
170 iter != parents.endSafe();
171 ++iter) {
172 ArcGraphPart::eraseArc(Arc(*iter, id));
173 }
174 }
175 }

References _parents_, eraseArc(), and parents().

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

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)
protected

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 160 of file arcGraphPart_inl.h.

160 {
161 for (const auto& arc: set)
163 }

References eraseArc().

Here is the call graph for this function:

Member Data Documentation

◆ _arcs_

Set< Arc > gum::ArcGraphPart::_arcs_
private

the set of all the arcs contained within the ArcGraphPart

Definition at line 281 of file arcGraphPart.h.

Referenced by ArcGraphPart(), ArcGraphPart(), ArcGraphPart(), addArc(), arcs(), clearArcs(), emptyArcs(), eraseArc(), existsArc(), operator=(), operator=(), operator==(), sizeArcs(), and toString().

◆ _children_

NodeProperty< NodeSet* > gum::ArcGraphPart::_children_
private

◆ _parents_

NodeProperty< NodeSet* > gum::ArcGraphPart::_parents_
private

◆ onArcAdded

Signaler< NodeId, NodeId > gum::ArcGraphPart::onArcAdded

Definition at line 102 of file arcGraphPart.h.

Referenced by ArcGraphPart(), addArc(), operator=(), and operator=().

◆ onArcDeleted

Signaler< NodeId, NodeId > gum::ArcGraphPart::onArcDeleted

Definition at line 103 of file arcGraphPart.h.

Referenced by clearArcs(), and eraseArc().


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