aGrUM 3.3.2
a C++ library for (probabilistic) graphical models
gum::NodeGraphPart Class Reference

Class for node sets in graph. More...

#include <nodeGraphPart.h>

Inheritance diagram for gum::NodeGraphPart:
[legend]
Collaboration diagram for gum::NodeGraphPart:
[legend]

Public Types

using NodeIterator = NodeGraphPartIterator
using NodeConstIterator = NodeGraphPartIterator
using NodeIteratorSafe = NodeGraphPartIteratorSafe
using NodeConstIteratorSafe = NodeGraphPartIteratorSafe
using node_iterator = NodeGraphPartIterator
 types for STL compliance
using node_const_iterator = NodeGraphPartIterator
 types for STL compliance
using node_iterator_safe = NodeGraphPartIteratorSafe
 types for STL compliance
using node_const_iterator_safe = NodeGraphPartIteratorSafe
 types for STL compliance

Public Member Functions

Constructors / Destructors
 NodeGraphPart (Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true)
 default constructor
 NodeGraphPart (const NodeGraphPart &s)
 copy constructor
 NodeGraphPart (NodeGraphPart &&s)
 move constructor
virtual ~NodeGraphPart ()
 destructor
Operators
NodeGraphPart & operator= (const NodeGraphPart &p)
 copy operator
NodeGraphPart & operator= (NodeGraphPart &&p)
 move assignment operator
bool operator== (const NodeGraphPart &p) const
 check whether two NodeGraphParts contain the same nodes
Accessors/Modifiers
void populateNodes (const NodeGraphPart &s)
 populateNodes clears *this and fills it with the same nodes as "s"
template<typename T>
void populateNodesFromProperty (const NodeProperty< T > &h)
 populateNodesFromProperty clears *this and fills it with the keys of "h"
NodeId nextNodeId () const
 returns a new node id, not yet used by any node
virtual NodeId addNode ()
 insert a new node and return its id
std::vector< NodeId > addNodes (Size n)
 insert n nodes
virtual void addNodeWithId (const NodeId id)
 try to insert a node with the given id
virtual void eraseNode (const NodeId id)
 erase the node with the given id
bool existsNode (const NodeId id) const
 returns true iff the NodeGraphPart contains the given nodeId
bool exists (const NodeId id) const
 alias for existsNode
bool emptyNodes () const
 indicates whether there exists nodes in the NodeGraphPart
bool empty () const
 alias for emptyNodes
virtual void clearNodes ()
 remove all the nodes from the NodeGraphPart
virtual void clear ()
 alias for clearNodes
Size sizeNodes () const
 returns the number of nodes in the NodeGraphPart
Size size () const
 alias for sizeNodes
NodeId bound () const
 returns a number n such that all node ids are strictly lower than n
NodeSet asNodeSet () const
 returns a copy of the set of nodes represented by the NodeGraphPart
const NodeGraphPart & nodes () const
 return *this as a NodeGraphPart
node_iterator_safe beginSafe () const
 a begin iterator to parse the set of nodes contained in the NodeGraphPart
const node_iterator_safe & endSafe () const noexcept
 the end iterator to parse the set of nodes contained in the NodeGraphPart
node_iterator begin () const noexcept
 a begin iterator to parse the set of nodes contained in the NodeGraphPart
const node_iterator & end () const noexcept
 the end iterator to parse the set of nodes contained in the NodeGraphPart
virtual std::string toString () const
 a function to display the set of nodes
std::string nameFromId (NodeId id) const
 returns the name of node id, or "<id>" if no name is set
std::optional< NodeId > idFromName (const std::string &name) const
 returns the id of the node with the given name, or std::nullopt
void setName (NodeId id, const std::string &name)
 sets the name of node id
bool hasName (NodeId id) const
 returns true iff node id has an explicit name
template<typename VAL>
NodeProperty< VAL > nodesPropertyFromFunction (VAL(*f)(const NodeId &), Size size=0) const
 a method to create a HashTable with key:NodeId and value:VAL
template<typename VAL>
NodeProperty< VAL > nodesPropertyFromVal (const VAL &a, Size size=0) const
 a method to create a hashMap with key:NodeId and value:VAL
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))

Public Attributes

Signaler< NodeId > onNodeAdded
Signaler< NodeId > onNodeDeleted

Protected Member Functions

std::string dotNodeText (NodeId id) const
 the label of a node in a graph drawn with graphviz : "(id) name", or "" if the node has no name
void writeDotNode (dot::DotWriter &writer, const dot::DotStyle &style, const dot::DotOptions &options, NodeId id) const
 writes a node in the dot language, with the label "(id) name" if it is named and the colors given by the options
void writeDotNodes (dot::DotWriter &writer, const dot::DotStyle &style, const dot::DotOptions &options) const
 writes the nodes in the dot language, see writeDotNode()

Private Member Functions

void _updateEndIteratorSafe_ ()
 updating endIterator (always at max+1)
void _clearNodes_ ()
 code for clearing nodes (called twice)
void _eraseHole_ (NodeId id)
 to delete hole.
void _addHole_ (NodeId id)
 to add a hole.
std::unique_ptr< Bijection< NodeId, std::string > > _cloneNames_ () const
 clone the names bijection (returns nullptr when no name has been set)
Introspection
bool _inHoles_ (NodeId id) const
Size _sizeHoles_ () const

Private Attributes

NodeSet * _holes_
 the set of nodes not contained in the NodeGraphPart in the interval 1.
std::unique_ptr< Bijection< NodeId, std::string > > _names_
 optional node names — null when no name has been set
Size _holes_size_
 value for holes configuration
bool _holes_resize_policy_
 value for holes configuration
NodeGraphPartIteratorSafe _endIteratorSafe_
 the end iterator (used to speed-up parsings of the NodeGraphPart)
NodeId _boundVal_
 the id below which NodeIds may belong to the NodeGraphPart

Friends

class NodeGraphPartIterator
class NodeGraphPartIteratorSafe

Detailed Description

Class for node sets in graph.

NodeGraphPart represents the set of nodes of all the graphs. It is built to be as light as possible and it implements its own NodeId factory. The set of NodeId is 0 ... ( bound-1) minus the NodeIds in holes.

Author
Pierre-Henri WUILLEMIN(_at_LIP6) & Christophe GONZALES(_at_AMU)
Usage example:
// create an empty node list
// add 2 elements
NodeId id_a=nodes1.addNode( );
NodeId id_b=nodes1.addNode( );
// checks if there exists a node with ID = 6
if ( !nodes1.exists( 6 ) ) std::cerr << "no node with ID 6" << std::endl;
// check if the set of nodes is empty
if ( !nodes1.empty() || ( nodes1.size() != 0 ) )
std::cerr << "nodes1 is not empty" << std::endl;
// copy a set of nodes
NodeGraphPart nodes2 = nodes1, nodes3;
nodes3 = nodes1;
// remove elements from list3
nodes3.eraseNode( id_a );
nodes3.eraseNode( id_b );
// remove all the elements from the list
nodes1.clear();
for ( NodeGraphPart::iterator it=nodes2.beginNodes();
it!=nodes2.endNodes();++it ) {
std::cerr<<*it<<" ";
}
std::cerr<<"list : "<<nodes2.listMapNodes(getDouble)<<std::endl;
std::cerr<<"hashmap : "<<nodes2.hashMapNodes(getDouble)<<std::endl;
Size size() const
alias for sizeNodes
virtual void clear()
alias for clearNodes
virtual void eraseNode(const NodeId id)
erase the node with the given id
bool exists(const NodeId id) const
alias for existsNode
bool empty() const
alias for emptyNodes
virtual NodeId addNode()
insert a new node and return its id
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,...
NodeGraphPart(Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true)
default constructor
Size NodeId
Type for node ids.

Definition at line 271 of file nodeGraphPart.h.

Member Typedef Documentation

◆ node_const_iterator

types for STL compliance

Definition at line 276 of file nodeGraphPart.h.

◆ node_const_iterator_safe

types for STL compliance

Definition at line 278 of file nodeGraphPart.h.

◆ node_iterator

types for STL compliance

Definition at line 275 of file nodeGraphPart.h.

◆ node_iterator_safe

types for STL compliance

Definition at line 277 of file nodeGraphPart.h.

◆ NodeConstIterator

◆ NodeConstIteratorSafe

◆ NodeIterator

◆ NodeIteratorSafe

Constructor & Destructor Documentation

◆ NodeGraphPart() [1/3]

gum::NodeGraphPart::NodeGraphPart ( Size holes_size = HashTableConst::default_size,
bool holes_resize_policy = true )
explicit

default constructor

A NodeGrphPart does not store all its nodes. To be lighter in terms of memory consumption, it store its maximal NodeId and the set of NodeIds between 0 and this maximum that do not actually belong to the set of its nodes (the so-called set of holes). In practice, it turns out that the set of holes is most often very small.

Parameters
holes_sizethe size of the hash table used to store all holes
holes_resize_policythe resizing policy of this hash table

Definition at line 58 of file nodeGraphPart.cpp.

58 :
59 _holes_size_(holes_size), _holes_resize_policy_(holes_resize_policy),
60 _endIteratorSafe_(*this), _boundVal_(0) {
61 _holes_ = nullptr;
62 GUM_CONSTRUCTOR(NodeGraphPart);
64 }
NodeGraphPartIteratorSafe _endIteratorSafe_
the end iterator (used to speed-up parsings of the NodeGraphPart)
void _updateEndIteratorSafe_()
updating endIterator (always at max+1)
Size _holes_size_
value for holes configuration
bool _holes_resize_policy_
value for holes configuration
NodeSet * _holes_
the set of nodes not contained in the NodeGraphPart in the interval 1.
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart

References NodeGraphPart(), _boundVal_, _endIteratorSafe_, _holes_, _holes_resize_policy_, _holes_size_, and _updateEndIteratorSafe_().

Referenced by gum::DiGraph::DiGraph(), gum::DiGraph::DiGraph(), gum::DiGraph::DiGraph(), NodeGraphPart(), NodeGraphPart(), NodeGraphPart(), gum::UndiGraph::UndiGraph(), gum::UndiGraph::UndiGraph(), gum::UndiGraph::UndiGraph(), ~NodeGraphPart(), nodes(), gum::prm::gspan::Pattern::nodes(), operator=(), operator=(), operator==(), populateNodes(), and populateNodesFromProperty().

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

◆ NodeGraphPart() [2/3]

gum::NodeGraphPart::NodeGraphPart ( const NodeGraphPart & s)

copy constructor

Parameters
sthe NodeGraphPart to be copied

Definition at line 66 of file nodeGraphPart.cpp.

66 :
67 _holes_size_(s._holes_size_), _holes_resize_policy_(s._holes_resize_policy_),
68 _endIteratorSafe_(*this), _boundVal_(s._boundVal_) {
69 _holes_ = nullptr;
70
71 if (s._holes_) _holes_ = new NodeSet(*s._holes_);
72
73 _names_ = s._cloneNames_();
74
76
77 GUM_CONS_CPY(NodeGraphPart);
78 }
std::unique_ptr< Bijection< NodeId, std::string > > _names_
optional node names — null when no name has been set
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...

References NodeGraphPart(), _boundVal_, _cloneNames_(), _endIteratorSafe_, _holes_, _holes_resize_policy_, _holes_size_, _names_, and _updateEndIteratorSafe_().

Here is the call graph for this function:

◆ NodeGraphPart() [3/3]

gum::NodeGraphPart::NodeGraphPart ( NodeGraphPart && s)

move constructor

Definition at line 80 of file nodeGraphPart.cpp.

80 :
81 _holes_(s._holes_), _names_(std::move(s._names_)), _holes_size_(s._holes_size_),
82 _holes_resize_policy_(s._holes_resize_policy_), _endIteratorSafe_(*this),
83 _boundVal_(s._boundVal_) {
84 s._holes_ = nullptr;
85 s._boundVal_ = 0;
86
88
89 GUM_CONS_MOV(NodeGraphPart);
90 }

References NodeGraphPart(), _boundVal_, _endIteratorSafe_, _holes_, _holes_resize_policy_, _holes_size_, _names_, and _updateEndIteratorSafe_().

Here is the call graph for this function:

◆ ~NodeGraphPart()

gum::NodeGraphPart::~NodeGraphPart ( )
virtual

destructor

Definition at line 92 of file nodeGraphPart.cpp.

92 {
93 if (_holes_) delete _holes_;
94
95 GUM_DESTRUCTOR(NodeGraphPart);
96 }

References NodeGraphPart(), and _holes_.

Here is the call graph for this function:

Member Function Documentation

◆ _addHole_()

void gum::NodeGraphPart::_addHole_ ( NodeId id)
private

to add a hole.

Warning
id is assumed not to be already a hole

Definition at line 113 of file nodeGraphPart.cpp.

113 {
114 // we assume that the node exists
115 if (node + 1 == _boundVal_) {
116 // we remove the max : no new hole and maybe a bunch of holes to remove
117 --_boundVal_;
118
119 if (_holes_) {
120 while (_holes_->contains(_boundVal_ - 1)) {
121 // a bunch of holes to remove. We do not use inHoles for optimisation
122 // :
123 // not to repeat the test if ( _holes_) each time
125 }
126
127 if (_holes_->empty()) {
128 delete _holes_;
129 _holes_ = nullptr;
130 }
131 }
132
134 } else {
136
137 _holes_->insert(node);
138 }
139 }
bool contains(const Key &k) const
Indicates whether a given elements belong to the set.
Definition set_tpl.h:468
bool empty() const noexcept
Indicates whether the set is the empty set.
Definition set_tpl.h:613
void insert(const Key &k)
Inserts a new element into the set.
Definition set_tpl.h:510
void erase(const Key &k)
Erases an element from the set.
Definition set_tpl.h:553

References _boundVal_, _holes_, _holes_resize_policy_, _holes_size_, _updateEndIteratorSafe_(), gum::Set< Key >::contains(), gum::Set< Key >::empty(), gum::Set< Key >::erase(), and gum::Set< Key >::insert().

Referenced by eraseNode(), and NodeGraphPartIteratorSafe.

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

◆ _clearNodes_()

void gum::NodeGraphPart::_clearNodes_ ( )
private

code for clearing nodes (called twice)

Definition at line 236 of file nodeGraphPart.cpp.

236 {
238 _boundVal_ = 0;
239
241 for (NodeId n = 0; n < bound; ++n) {
242 if (!_inHoles_(n)) GUM_EMIT1(onNodeDeleted, n);
243 }
244 }
245
247
248 delete (_holes_);
249 _holes_ = nullptr;
250 _names_.reset();
251 }
Signaler< NodeId > onNodeDeleted
NodeId bound() const
returns a number n such that all node ids are strictly lower than n
bool _inHoles_(NodeId id) const
#define GUM_EMIT1(signal, arg1)
Definition signaler.h:289

References _boundVal_, _holes_, _inHoles_(), _names_, _updateEndIteratorSafe_(), bound(), GUM_EMIT1, gum::__sig__::BasicSignaler< Args... >::hasListener(), and onNodeDeleted.

Referenced by clear(), clearNodes(), and NodeGraphPartIteratorSafe.

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

◆ _cloneNames_()

INLINE std::unique_ptr< Bijection< NodeId, std::string > > gum::NodeGraphPart::_cloneNames_ ( ) const
private

clone the names bijection (returns nullptr when no name has been set)

Definition at line 389 of file nodeGraphPart_inl.h.

389 {
390 return _names_ ? std::make_unique< Bijection< NodeId, std::string > >(*_names_) : nullptr;
391 }

References _names_.

Referenced by NodeGraphPart(), and populateNodes().

Here is the caller graph for this function:

◆ _eraseHole_()

INLINE void gum::NodeGraphPart::_eraseHole_ ( NodeId id)
private

to delete hole.

Warning
the hole is assumed to be existing.

Definition at line 255 of file nodeGraphPart_inl.h.

255 {
256 _holes_->erase(id);
257
258 if (_holes_->empty()) {
259 delete _holes_;
260 _holes_ = nullptr;
261 }
262 }

References _holes_, gum::Set< Key >::empty(), and gum::Set< Key >::erase().

Referenced by addNode(), addNodeWithId(), and NodeGraphPartIteratorSafe.

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

◆ _inHoles_()

INLINE bool gum::NodeGraphPart::_inHoles_ ( NodeId id) const
private
Returns
true if id is part of holes

Definition at line 383 of file nodeGraphPart_inl.h.

383{ return _holes_ && _holes_->contains(id); }

References _holes_, and gum::Set< Key >::contains().

Referenced by _clearNodes_(), addNodeWithId(), asNodeSet(), existsNode(), NodeGraphPartIteratorSafe, toString(), and gum::NodeGraphPartIterator::validate_().

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

◆ _sizeHoles_()

INLINE Size gum::NodeGraphPart::_sizeHoles_ ( ) const
private
Returns
the size of holes

Definition at line 386 of file nodeGraphPart_inl.h.

386{ return _holes_ ? _holes_->size() : (Size)0; }
Size size() const noexcept
Returns the number of elements in the set.
Definition set_tpl.h:607
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74

References _holes_, and gum::Set< Key >::size().

Referenced by NodeGraphPartIteratorSafe.

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

◆ _updateEndIteratorSafe_()

INLINE void gum::NodeGraphPart::_updateEndIteratorSafe_ ( )
private

updating endIterator (always at max+1)

Definition at line 340 of file nodeGraphPart_inl.h.

void setPos_(NodeId id) noexcept
this function is used by NodeGraphPart to update

References _boundVal_, _endIteratorSafe_, and gum::NodeGraphPartIterator::setPos_().

Referenced by NodeGraphPart(), NodeGraphPart(), NodeGraphPart(), _addHole_(), _clearNodes_(), addNode(), addNodeWithId(), NodeGraphPartIteratorSafe, operator=(), and populateNodes().

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

◆ addNode()

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

insert a new node and return its id

Returns
the id chosen by the internal idFactory

Reimplemented in gum::CliqueGraph.

Definition at line 269 of file nodeGraphPart_inl.h.

269 {
270 NodeId newNode;
271
272 // fill the first hole if holes exist
273 if (_holes_ && (!_holes_->empty())) {
274 newNode = *(_holes_->begin());
275 _eraseHole_(newNode);
276 } else {
277 newNode = _boundVal_;
278 ++_boundVal_;
280 }
281
282 GUM_EMIT1(onNodeAdded, newNode);
283
284 return newNode;
285 }
void _eraseHole_(NodeId id)
to delete hole.
Signaler< NodeId > onNodeAdded
iterator begin() const
The usual unsafe begin iterator to parse the set.
Definition set_tpl.h:409

References _boundVal_, _eraseHole_(), _holes_, _updateEndIteratorSafe_(), gum::Set< Key >::begin(), gum::Set< Key >::empty(), GUM_EMIT1, and onNodeAdded.

Referenced by gum::IncrementalGraphLearner< AttributeSelection, isScalar >::IncrementalGraphLearner(), gum::MultiDimFunctionGraph< GUM_ELEMENT, TerminalNodePolicy >::MultiDimFunctionGraph(), gum::prm::gspan::DFSTree< GUM_SCALAR >::_addChild_(), gum::prm::StructuredInference< GUM_SCALAR >::_addEdgesInReducedGraph_(), gum::prm::gspan::StrictSearch< GUM_SCALAR >::_buildPatternGraph_(), gum::prm::StructuredInference< GUM_SCALAR >::_buildPatternGraph_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::gspan::DFSTree< GUM_SCALAR >::_initialiaze_root_(), gum::prm::gspan::DFSTree< GUM_SCALAR >::addRoot(), populateNodesFromProperty(), and gum::LeafAggregator::update().

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

◆ addNodes()

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

insert n nodes

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

Definition at line 287 of file nodeGraphPart_inl.h.

287 {
288 std::vector< NodeId > v;
289 v.reserve(N);
290 for (Idx i = 0; i < N; i++)
291 v.push_back(this->addNode());
292 return v;
293 }
Size Idx
Type for indexes.
Definition types.h:79

Referenced by gum::DiGraph::completeGraph(), gum::UndiGraph::completeGraph(), and populateNodesFromProperty().

Here is the caller graph for this function:

◆ addNodeWithId()

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

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

Reimplemented in gum::CliqueGraph.

Definition at line 213 of file nodeGraphPart.cpp.

213 {
214 if (id >= _boundVal_) {
215 if (id > _boundVal_) { // we have to add holes
217
218 for (NodeId i = _boundVal_; i < id; ++i)
219 _holes_->insert(i);
220 }
221
222 _boundVal_ = id + 1;
223
225 } else {
226 if (_inHoles_(id)) { // we fill a hole
227 _eraseHole_(id);
228 } else {
229 GUM_ERROR(DuplicateElement, "Id " << id << " is already used")
230 }
231 }
232
234 }
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

References _boundVal_, _eraseHole_(), _holes_, _holes_resize_policy_, _holes_size_, _inHoles_(), _updateEndIteratorSafe_(), GUM_EMIT1, GUM_ERROR, gum::Set< Key >::insert(), and onNodeAdded.

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::CData::CData(), gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::InterfaceGraph(), gum::EssentialGraph::_buildEssentialGraph_(), gum::SpanningForestPrim::_computeInAComponent_(), gum::prm::GSpan< GUM_SCALAR >::_sortPatterns_(), gum::prm::gspan::Pattern::addNodeWithLabel(), gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph(), gum::CausalModel< GUM_ELEMENT >::inducedCausalSubModel(), gum::Separation::isForwardSeparated(), gum::learning::IBNLearner::learnDag_(), gum::learning::FCI::learnPAG(), gum::learning::KTBNLearner< GUM_SCALAR >::learnParameters(), gum::graph::markovBlanket(), gum::UndiGraph::partialUndiGraph(), populateNodesFromProperty(), gum::learning::IBNLearner::prepareFCI_(), gum::learning::IBNLearner::prepareMiic_(), gum::learning::IBNLearner::preparePC_(), gum::MeekRules::propagateToCPDAG(), gum::MeekRules::propagateToDAG(), gum::learning::StructuralConstraintDAG::setGraphAlone(), gum::EssentialGraph::skeleton(), and gum::PAG::toMixedGraph().

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

◆ asNodeSet()

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

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())
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
rather than
for(const auto n : asNodeSet())
NodeSet asNodeSet() const
returns a copy of the set of nodes represented by the NodeGraphPart
as this is faster and consumes much less memory.

Definition at line 367 of file nodeGraphPart_inl.h.

367 {
368 NodeSet son(sizeNodes());
369
370 if (!empty()) {
371 for (NodeId n = 0; n < _boundVal_; ++n) {
372 if (!_inHoles_(n)) son.insert(n);
373 }
374 }
375
376 return son;
377 }
Size sizeNodes() const
returns the number of nodes in the NodeGraphPart

References _boundVal_, _inHoles_(), empty(), gum::Set< Key >::insert(), and sizeNodes().

Referenced by gum::MarginalTargetedInference< GUM_SCALAR >::MarginalTargetedInference(), gum::MarginalTargetedMRFInference< GUM_SCALAR >::MarginalTargetedMRFInference(), gum::DoCalculus< GUM_SCALAR >::_ancestorsIn_(), gum::DoCalculus< GUM_SCALAR >::_cDecomposition_(), gum::DoCalculus< GUM_SCALAR >::_ID_(), gum::DoCalculus< GUM_SCALAR >::_topoObserved_(), populateNodesFromProperty(), and gum::ImportanceSampling< GUM_SCALAR >::unsharpenBN_().

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

◆ begin()

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

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

Definition at line 346 of file nodeGraphPart_inl.h.

346 {
347 NodeGraphPartIterator it(*this);
348 it.validate_(); // stop the iterator at the first not-in-holes
349 return it;
350 }
friend class NodeGraphPartIterator

References NodeGraphPartIterator, and gum::NodeGraphPartIterator::validate_().

Referenced by gum::Estimator< GUM_SCALAR >::Estimator(), gum::learning::ConstraintBasedLearning::initGraph_(), populateNodesFromProperty(), and gum::Estimator< GUM_SCALAR >::setFromBN().

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

◆ beginSafe()

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

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

Definition at line 334 of file nodeGraphPart_inl.h.

334 {
336 it.validate_(); // stop the iterator at the first not-in-holes
337 return it;
338 }
friend class NodeGraphPartIteratorSafe

References NodeGraphPartIteratorSafe, and gum::NodeGraphPartIterator::validate_().

Referenced by populateNodesFromProperty().

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

◆ bound()

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

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

Definition at line 323 of file nodeGraphPart_inl.h.

323{ return _boundVal_; }

References _boundVal_.

Referenced by _clearNodes_(), gum::StaticTriangulation::_computeEliminationTree_(), populateNodesFromProperty(), gum::NodeGraphPartIterator::validate_(), and gum::NodeGraphPartIteratorSafe::whenNodeDeleted().

Here is the caller graph for this function:

◆ clear()

INLINE void gum::NodeGraphPart::clear ( )
virtual

alias for clearNodes

Reimplemented in gum::CliqueGraph, gum::DiGraph, gum::MixedGraph, gum::PAG, and gum::UndiGraph.

Definition at line 332 of file nodeGraphPart_inl.h.

332{ _clearNodes_(); }
void _clearNodes_()
code for clearing nodes (called twice)

References _clearNodes_().

Referenced by populateNodes(), and populateNodesFromProperty().

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

◆ clearNodes()

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

remove all the nodes from the NodeGraphPart

Definition at line 325 of file nodeGraphPart_inl.h.

325{ _clearNodes_(); }

References _clearNodes_().

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

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

◆ dotNodeText()

std::string gum::NodeGraphPart::dotNodeText ( NodeId id) const
protected

the label of a node in a graph drawn with graphviz : "(id) name", or "" if the node has no name

Definition at line 189 of file nodeGraphPart.cpp.

189 {
190 if (!hasName(id)) return "";
191 return "(" + std::to_string(id) + ") " + _names_->second(id);
192 }
bool hasName(NodeId id) const
returns true iff node id has an explicit name

References _names_, and hasName().

Referenced by listMapNodes(), and writeDotNode().

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

◆ empty()

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

alias for emptyNodes

Definition at line 321 of file nodeGraphPart_inl.h.

321{ return emptyNodes(); }
bool emptyNodes() const
indicates whether there exists nodes in the NodeGraphPart

References emptyNodes().

Referenced by asNodeSet(), populateNodesFromProperty(), gum::prm::gspan::Pattern::remove(), and gum::PDAG::toDot().

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

◆ emptyNodes()

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

indicates whether there exists nodes in the NodeGraphPart

Definition at line 319 of file nodeGraphPart_inl.h.

319{ return (sizeNodes() == 0); }

References sizeNodes().

Referenced by empty(), and populateNodesFromProperty().

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

◆ end()

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

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

Definition at line 352 of file nodeGraphPart_inl.h.

352 {
353 return _endIteratorSafe_;
354 }

References _endIteratorSafe_, and NodeGraphPartIterator.

Referenced by gum::Estimator< GUM_SCALAR >::Estimator(), gum::learning::ConstraintBasedLearning::initGraph_(), populateNodesFromProperty(), and gum::Estimator< GUM_SCALAR >::setFromBN().

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

◆ endSafe()

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

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

Definition at line 342 of file nodeGraphPart_inl.h.

342 {
343 return _endIteratorSafe_;
344 }

References _endIteratorSafe_, and NodeGraphPartIteratorSafe.

Referenced by populateNodesFromProperty().

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

◆ eraseNode()

INLINE void gum::NodeGraphPart::eraseNode ( const NodeId id)
virtual

erase the node with the given id

If the NodeGraphPart does not contain the nodeId, then nothing is done. In particular, no exception is raised. However, the signal onNodeDeleted is fired only if a node is effectively removed.

Reimplemented in gum::CliqueGraph, gum::DiGraph, gum::MixedGraph, gum::PAG, and gum::UndiGraph.

Definition at line 309 of file nodeGraphPart_inl.h.

309 {
310 if (!existsNode(node)) return;
311
312 if (_names_ && _names_->existsFirst(node)) _names_->eraseFirst(node);
313
314 _addHole_(node);
315
317 }
void _addHole_(NodeId id)
to add a hole.
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId

References _addHole_(), _names_, existsNode(), GUM_EMIT1, and onNodeDeleted.

Referenced by gum::LeafAggregator::_removeContext_(), gum::DiGraph::eraseNode(), gum::MixedGraph::eraseNode(), gum::UndiGraph::eraseNode(), and populateNodesFromProperty().

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

◆ exists()

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

alias for existsNode

Definition at line 307 of file nodeGraphPart_inl.h.

307{ return existsNode(node); }

References existsNode().

Referenced by gum::DAGmodel::_checkNodeExists_(), gum::prm::StructuredInference< GUM_SCALAR >::_removeNode_(), gum::DiGraph::addArc(), gum::prm::gspan::Pattern::addArc(), gum::UndiGraph::addEdge(), gum::DAGmodel::exists(), gum::prm::gspan::Pattern::exists(), gum::UGmodel::exists(), gum::learning::IBNLearner::learnDag_(), and populateNodesFromProperty().

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

◆ existsNode()

INLINE bool gum::NodeGraphPart::existsNode ( const NodeId id) const

◆ hasName()

bool gum::NodeGraphPart::hasName ( NodeId id) const

returns true iff node id has an explicit name

Definition at line 187 of file nodeGraphPart.cpp.

187{ return _names_ && _names_->existsFirst(id); }

References _names_.

Referenced by dotNodeText(), and populateNodesFromProperty().

Here is the caller graph for this function:

◆ idFromName()

std::optional< NodeId > gum::NodeGraphPart::idFromName ( const std::string & name) const

returns the id of the node with the given name, or std::nullopt

Definition at line 166 of file nodeGraphPart.cpp.

166 {
167 if (_names_ && _names_->existsSecond(name)) return _names_->first(name);
168 return std::nullopt;
169 }

References _names_.

Referenced by populateNodesFromProperty().

Here is the caller graph for this function:

◆ listMapNodes()

template<typename VAL>
List< VAL > gum::NodeGraphPart::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))

Parameters
fa function assigning a VAL to any node

References dotNodeText(), listMapNodes(), writeDotNode(), and writeDotNodes().

Referenced by listMapNodes().

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

◆ nameFromId()

std::string gum::NodeGraphPart::nameFromId ( NodeId id) const

returns the name of node id, or "<id>" if no name is set

Definition at line 161 of file nodeGraphPart.cpp.

161 {
162 if (_names_ && _names_->existsFirst(id)) return _names_->second(id);
163 return std::to_string(id);
164 }

References _names_.

Referenced by populateNodesFromProperty().

Here is the caller graph for this function:

◆ nextNodeId()

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

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

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

Definition at line 243 of file nodeGraphPart_inl.h.

243 {
244 NodeId next = 0;
245
246 // return the first hole if holes exist
247 if (_holes_ && (!_holes_->empty())) next = *(_holes_->begin());
248 else // in other case
249 next = _boundVal_;
250
251 return next;
252 }

References _boundVal_, _holes_, gum::Set< Key >::begin(), and gum::Set< Key >::empty().

Referenced by populateNodesFromProperty().

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

◆ nodes()

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

return *this as a NodeGraphPart

Definition at line 379 of file nodeGraphPart_inl.h.

379 {
380 return *(static_cast< const NodeGraphPart* >(this));
381 }

References NodeGraphPart().

Referenced by gum::CausalModel< GUM_SCALAR >::CausalModel(), gum::prm::StructuredInference< GUM_SCALAR >::CData::CData(), gum::MarkovBlanket::MarkovBlanket(), gum::DoCalculus< GUM_SCALAR >::_ancestorsIn_(), gum::DoCalculus< GUM_SCALAR >::_cDecomposition_(), gum::KTBNInference< GUM_SCALAR >::_compileWindow_(), gum::SpanningForestPrim::_compute_(), gum::StaticTriangulation::_computeMaxPrimeJunctionTree_(), gum::KTBNInference< GUM_SCALAR >::_fillWindow_(), gum::prm::ClusteredLayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::prm::LayerGenerator< GUM_SCALAR >::_generateClassDag_(), gum::DoCalculus< GUM_SCALAR >::_ID_(), gum::prm::ClassBayesNet< GUM_SCALAR >::_init_(), gum::prm::SVE< GUM_SCALAR >::_initElimOrder_(), gum::prm::SVED< GUM_SCALAR >::_initElimOrder_(), gum::prm::SVE< GUM_SCALAR >::_initLiftedNodes_(), gum::MeekRules::_orientDoubleHeadedArcs_(), gum::prm::GSpan< GUM_SCALAR >::_sortPatterns_(), gum::DoCalculus< GUM_SCALAR >::_topoObserved_(), gum::prm::PRMFactory< GUM_SCALAR >::addAttribute(), gum::DoorCriteria::enumerateBackdoorSets(), gum::StaticTriangulation::fillIns(), gum::CausalModel< GUM_SCALAR >::inducedCausalSubModel(), gum::learning::ConstraintBasedLearning::initGraph_(), gum::junctionTreeRoots(), gum::learning::FCI::learnPAG(), gum::DAG::moralizedAncestralGraph(), gum::graph::moralizedAncestralGraph(), gum::PDAG::moralizedAncestralGraph(), gum::EssentialGraph::nodes(), gum::MarkovBlanket::nodes(), gum::prm::gspan::Pattern::nodes(), operator<<(), gum::learning::ConstraintBasedLearning::orientDoubleHeadedArcs_(), gum::UndiGraph::partialUndiGraph(), populateNodesFromProperty(), gum::learning::IBNLearner::prepareFCI_(), gum::learning::IBNLearner::prepareMiic_(), gum::learning::IBNLearner::preparePC_(), gum::learning::FCI::ruleR10_(), gum::learning::FCI::ruleR1_(), gum::learning::FCI::ruleR2_(), gum::learning::FCI::ruleR3_(), gum::learning::FCI::ruleR4_(), gum::learning::FCI::ruleR5_(), gum::learning::FCI::ruleR6_(), gum::learning::FCI::ruleR7_(), gum::learning::FCI::ruleR8_(), gum::learning::FCI::ruleR9_(), gum::EssentialGraph::toDot(), gum::MarkovBlanket::toDot(), gum::PDAG::toDot(), gum::PAG::toMixedGraph(), and writeDotNodes().

Here is the call graph for this function:

◆ nodesPropertyFromFunction()

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

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.

References nodesPropertyFromFunction(), and size().

Referenced by nodesPropertyFromFunction().

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

◆ nodesPropertyFromVal()

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

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.

References nodesPropertyFromVal(), and size().

Referenced by gum::BarrenNodesFinder::barrenNodes(), gum::BinaryJoinTreeConverterDefault::convert(), and nodesPropertyFromVal().

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

◆ operator=() [1/2]

INLINE NodeGraphPart & gum::NodeGraphPart::operator= ( const NodeGraphPart & p)

copy operator

Parameters
pthe NodeGraphPart to be copied

Definition at line 220 of file nodeGraphPart_inl.h.

220 {
221 // avoid self assignment
222 if (this != &p) { populateNodes(p); }
223
224 return *this;
225 }
void populateNodes(const NodeGraphPart &s)
populateNodes clears *this and fills it with the same nodes as "s"

References NodeGraphPart(), and populateNodes().

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

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

◆ operator=() [2/2]

INLINE NodeGraphPart & gum::NodeGraphPart::operator= ( NodeGraphPart && p)

move assignment operator

Definition at line 227 of file nodeGraphPart_inl.h.

227 {
228 if (this != &p) {
229 clearNodes();
230 _holes_ = p._holes_;
231 _holes_size_ = p._holes_size_;
232 _holes_resize_policy_ = p._holes_resize_policy_;
233 _boundVal_ = p._boundVal_;
234 _names_ = std::move(p._names_);
235 p._holes_ = nullptr;
236 p._boundVal_ = 0;
238 GUM_OP_MOV(NodeGraphPart);
239 }
240 return *this;
241 }
virtual void clearNodes()
remove all the nodes from the NodeGraphPart

References NodeGraphPart(), _boundVal_, _holes_, _holes_resize_policy_, _holes_size_, _names_, _updateEndIteratorSafe_(), and clearNodes().

Here is the call graph for this function:

◆ operator==()

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

check whether two NodeGraphParts contain the same nodes

Parameters
pthe NodeGraphPart to be compared with "this"

Definition at line 356 of file nodeGraphPart_inl.h.

356 {
357 if (_boundVal_ != p._boundVal_) return false;
358
359 if (_holes_)
360 if (p._holes_) return (*_holes_ == *p._holes_);
361 else return false;
362 else if (p._holes_) return false;
363
364 return true;
365 }

References NodeGraphPart(), _boundVal_, and _holes_.

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

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

◆ populateNodes()

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

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 98 of file nodeGraphPart.cpp.

98 {
99 clear(); // "virtual" flush of the nodes set
100 _holes_size_ = s._holes_size_;
101 _holes_resize_policy_ = s._holes_resize_policy_;
102
103 if (s._holes_) _holes_ = new NodeSet(*s._holes_);
104
105 _names_ = s._cloneNames_();
106
107 _boundVal_ = s._boundVal_;
108
110 }

References NodeGraphPart(), _boundVal_, _cloneNames_(), _holes_, _holes_resize_policy_, _holes_size_, _names_, _updateEndIteratorSafe_(), and clear().

Referenced by operator=().

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)

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.

References NodeGraphPart(), addNode(), addNodes(), addNodeWithId(), asNodeSet(), begin(), beginSafe(), bound(), clear(), clearNodes(), empty(), emptyNodes(), end(), endSafe(), eraseNode(), exists(), existsNode(), hasName(), idFromName(), nameFromId(), nextNodeId(), nodes(), setName(), size(), sizeNodes(), and toString().

Here is the call graph for this function:

◆ setName()

void gum::NodeGraphPart::setName ( NodeId id,
const std::string & name )

sets the name of node id

Exceptions
DuplicateElementif name is already used by another node

Definition at line 171 of file nodeGraphPart.cpp.

171 {
172 if (!existsNode(id)) GUM_ERROR(InvalidNode, "node " << id << " does not exist")
173 if (_names_) {
174 auto owner = _names_->tryFirst(name);
175 if (owner.has_value()) {
176 if (*owner != id)
177 GUM_ERROR(DuplicateElement, "name '" << name << "' already used by node " << *owner)
178 return;
179 }
180 if (_names_->existsFirst(id)) _names_->eraseFirst(id);
181 } else {
182 _names_ = std::make_unique< Bijection< NodeId, std::string > >();
183 }
184 _names_->insert(id, name);
185 }

References _names_, existsNode(), and GUM_ERROR.

Referenced by gum::GraphicalModel::_nameNodes_(), gum::CausalModel< GUM_SCALAR >::causalDAG(), gum::CausalModel< GUM_ELEMENT >::inducedCausalSubModel(), populateNodesFromProperty(), and gum::EssentialGraph::skeleton().

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

◆ size()

◆ sizeNodes()

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

returns the number of nodes in the NodeGraphPart

Definition at line 295 of file nodeGraphPart_inl.h.

295 {
296 return (_holes_) ? (_boundVal_ - _holes_->size()) : _boundVal_;
297 }

References _boundVal_, _holes_, and gum::Set< Key >::size().

Referenced by gum::BinaryJoinTreeConverterDefault::_markConnectedComponent_(), asNodeSet(), gum::BarrenNodesFinder::barrenNodes(), gum::BinaryJoinTreeConverterDefault::convert(), emptyNodes(), populateNodesFromProperty(), gum::EliminationSequenceStrategy::setGraph(), size(), gum::EssentialGraph::sizeNodes(), and gum::MarkovBlanket::sizeNodes().

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

◆ toString()

std::string gum::NodeGraphPart::toString ( ) const
virtual

a function to display the set of nodes

Reimplemented in gum::CliqueGraph, gum::DiGraph, gum::MixedGraph, gum::PAG, and gum::UndiGraph.

Definition at line 141 of file nodeGraphPart.cpp.

141 {
142 std::string s = "{";
143 bool first = true;
144
145 const bool hasNames = (_names_ != nullptr);
146 for (NodeId id = 0; id < _boundVal_; ++id) {
147 if (_inHoles_(id)) continue;
148
149 if (!first) s += ",";
150 first = false;
151
152 if (hasNames && _names_->existsFirst(id)) s += std::format("{}<{}>", id, _names_->second(id));
153 else s += std::format("{}", id);
154 }
155
156 s += "}";
157
158 return s;
159 }

References _boundVal_, _inHoles_(), and _names_.

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

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

◆ writeDotNode()

void gum::NodeGraphPart::writeDotNode ( dot::DotWriter & writer,
const dot::DotStyle & style,
const dot::DotOptions & options,
NodeId id ) const
protected

writes a node in the dot language, with the label "(id) name" if it is named and the colors given by the options

Definition at line 194 of file nodeGraphPart.cpp.

197 {
198 writer.node(id, dot::nodeAttributes(style, options.node(id), dotNodeText(id)));
199 }
std::string dotNodeText(NodeId id) const
the label of a node in a graph drawn with graphviz : "(id) name", or "" if the node has no name
DotAttributes nodeAttributes(const DotStyle &style, const DotNodeOptions *options, std::string_view defaultLabel, std::string_view defaultTooltip)
The attributes of a node : its label and tooltip, and its colors if the options give some.

References dotNodeText(), gum::dot::DotOptions::node(), gum::dot::DotWriter::node(), and gum::dot::nodeAttributes().

Referenced by listMapNodes(), gum::PDAG::toDot(), and writeDotNodes().

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

◆ writeDotNodes()

void gum::NodeGraphPart::writeDotNodes ( dot::DotWriter & writer,
const dot::DotStyle & style,
const dot::DotOptions & options ) const
protected

writes the nodes in the dot language, see writeDotNode()

Definition at line 201 of file nodeGraphPart.cpp.

203 {
204 for (const auto node: nodes())
205 writeDotNode(writer, style, options, node);
206 }
void writeDotNode(dot::DotWriter &writer, const dot::DotStyle &style, const dot::DotOptions &options, NodeId id) const
writes a node in the dot language, with the label "(id) name" if it is named and the colors given by ...

References nodes(), and writeDotNode().

Referenced by listMapNodes(), gum::DiGraph::toDot(), gum::MixedGraph::toDot(), gum::PAG::toDot(), and gum::UndiGraph::toDot().

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

◆ NodeGraphPartIterator

friend class NodeGraphPartIterator
friend

Definition at line 512 of file nodeGraphPart.h.

References NodeGraphPartIterator.

Referenced by begin(), end(), and NodeGraphPartIterator.

◆ NodeGraphPartIteratorSafe

friend class NodeGraphPartIteratorSafe
friend

Member Data Documentation

◆ _boundVal_

◆ _endIteratorSafe_

NodeGraphPartIteratorSafe gum::NodeGraphPart::_endIteratorSafe_
private

the end iterator (used to speed-up parsings of the NodeGraphPart)

Definition at line 559 of file nodeGraphPart.h.

Referenced by NodeGraphPart(), NodeGraphPart(), NodeGraphPart(), _updateEndIteratorSafe_(), end(), and endSafe().

◆ _holes_

NodeSet* gum::NodeGraphPart::_holes_
private

the set of nodes not contained in the NodeGraphPart in the interval 1.

. max

Warning
holes may be nullptr.

Definition at line 545 of file nodeGraphPart.h.

Referenced by NodeGraphPart(), NodeGraphPart(), NodeGraphPart(), ~NodeGraphPart(), _addHole_(), _clearNodes_(), _eraseHole_(), _inHoles_(), _sizeHoles_(), addNode(), addNodeWithId(), nextNodeId(), operator=(), operator==(), populateNodes(), and sizeNodes().

◆ _holes_resize_policy_

bool gum::NodeGraphPart::_holes_resize_policy_
private

value for holes configuration

Definition at line 556 of file nodeGraphPart.h.

Referenced by NodeGraphPart(), NodeGraphPart(), NodeGraphPart(), _addHole_(), addNodeWithId(), operator=(), and populateNodes().

◆ _holes_size_

Size gum::NodeGraphPart::_holes_size_
private

value for holes configuration

Definition at line 553 of file nodeGraphPart.h.

Referenced by NodeGraphPart(), NodeGraphPart(), NodeGraphPart(), _addHole_(), addNodeWithId(), operator=(), and populateNodes().

◆ _names_

std::unique_ptr< Bijection< NodeId, std::string > > gum::NodeGraphPart::_names_
private

optional node names — null when no name has been set

Definition at line 548 of file nodeGraphPart.h.

Referenced by NodeGraphPart(), NodeGraphPart(), _clearNodes_(), _cloneNames_(), dotNodeText(), eraseNode(), hasName(), idFromName(), nameFromId(), operator=(), populateNodes(), setName(), and toString().

◆ onNodeAdded

Signaler< NodeId > gum::NodeGraphPart::onNodeAdded

Definition at line 289 of file nodeGraphPart.h.

Referenced by addNode(), and addNodeWithId().

◆ onNodeDeleted

Signaler< NodeId > gum::NodeGraphPart::onNodeDeleted

Definition at line 290 of file nodeGraphPart.h.

Referenced by _clearNodes_(), and eraseNode().


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