![]() |
aGrUM
0.21.0
a C++ library for (probabilistic) graphical models
|
Class for node sets in graph. More...
#include <nodeGraphPart.h>
Public Attributes | |
Signaler1< NodeId > | onNodeAdded |
Signaler1< NodeId > | onNodeDeleted |
Public Member Functions | |
Constructors / Destructors | |
NodeGraphPart (Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true) | |
default constructor More... | |
NodeGraphPart (const NodeGraphPart &s) | |
copy constructor More... | |
virtual | ~NodeGraphPart () |
destructor More... | |
Operators | |
NodeGraphPart & | operator= (const NodeGraphPart &p) |
copy operator More... | |
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... | |
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< NodeId > | addNodes (Size n) |
insert n nodes More... | |
virtual void | addNodeWithId (const NodeId id) |
try to insert a node with the given id More... | |
virtual void | eraseNode (const NodeId id) |
erase the 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... | |
virtual void | clear () |
alias for clearNodes 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 NodeGraphPart & | nodes () 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_safe & | endSafe () 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_iterator & | end () const noexcept |
the end iterator to parse the set of nodes contained in the NodeGraphPart More... | |
virtual std::string | toString () const |
a function to display the set of nodes 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... | |
Public Types | |
typedef NodeGraphPartIterator | NodeIterator |
typedef NodeGraphPartIterator | NodeConstIterator |
typedef NodeGraphPartIteratorSafe | NodeIteratorSafe |
typedef NodeGraphPartIteratorSafe | NodeConstIteratorSafe |
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... | |
Friends | |
class | NodeGraphPartIterator |
class | NodeGraphPartIteratorSafe |
class | gum_tests::NodeGraphPartTestSuite |
to enable testunits to use check More... | |
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.
Definition at line 253 of file nodeGraphPart.h.
types for STL compliance
Definition at line 258 of file nodeGraphPart.h.
types for STL compliance
Definition at line 260 of file nodeGraphPart.h.
types for STL compliance
Definition at line 257 of file nodeGraphPart.h.
types for STL compliance
Definition at line 259 of file nodeGraphPart.h.
Definition at line 267 of file nodeGraphPart.h.
Definition at line 269 of file nodeGraphPart.h.
Definition at line 266 of file nodeGraphPart.h.
Definition at line 268 of file nodeGraphPart.h.
|
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.
holes_size | the size of the hash table used to store all holes |
holes_resize_policy | the resizing policy of this hash table |
Definition at line 37 of file nodeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
gum::NodeGraphPart::NodeGraphPart | ( | const NodeGraphPart & | s | ) |
copy constructor
s | the NodeGraphPart to be copied |
Definition at line 45 of file nodeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
destructor
Definition at line 57 of file nodeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
private |
to add a hole.
Definition at line 76 of file nodeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
private |
code for clearing nodes (called twice)
Definition at line 154 of file nodeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
private |
to delete hole.
Definition at line 224 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
Definition at line 356 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Definition at line 359 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
updating endIterator (always at max+1)
Definition at line 308 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
insert a new node and return its id
Reimplemented in gum::CliqueGraph.
Definition at line 238 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
insert n nodes
n | the number of nodes to add |
Definition at line 256 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
try to insert a node with the given id
DuplicateElement | exception if the id already exists |
Definition at line 131 of file nodeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
INLINE NodeSet gum::NodeGraphPart::asNodeSet | ( | ) | const |
returns a copy of the set of nodes represented by the NodeGraphPart
Definition at line 340 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
a begin iterator to parse the set of nodes contained in the NodeGraphPart
Definition at line 314 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE NodeGraphPartIteratorSafe gum::NodeGraphPart::beginSafe | ( | ) | const |
a begin iterator to parse the set of nodes contained in the NodeGraphPart
Definition at line 302 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE NodeId gum::NodeGraphPart::bound | ( | ) | const |
returns a number n such that all node ids are strictly lower than n
Definition at line 291 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
alias for clearNodes
Reimplemented in gum::MixedGraph, gum::DiGraph, gum::UndiGraph, and gum::CliqueGraph.
Definition at line 300 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
remove all the nodes from the NodeGraphPart
Definition at line 293 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE bool gum::NodeGraphPart::empty | ( | ) | const |
alias for emptyNodes
Definition at line 289 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE bool gum::NodeGraphPart::emptyNodes | ( | ) | const |
indicates whether there exists nodes in the NodeGraphPart
Definition at line 287 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
the end iterator to parse the set of nodes contained in the NodeGraphPart
Definition at line 320 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
noexcept |
the end iterator to parse the set of nodes contained in the NodeGraphPart
Definition at line 310 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
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::MixedGraph, gum::DiGraph, gum::UndiGraph, and gum::CliqueGraph.
Definition at line 279 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
alias for existsNode
Definition at line 277 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
returns true iff the NodeGraphPart contains the given nodeId
Definition at line 271 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
List< VAL > gum::NodeGraphPart::listMapNodes | ( | VAL(*)(const NodeId &) | f | ) | const |
a method to create a list of VAL from a set of nodes (using for every nodee, say x, the VAL f(x))
f | a function assigning a VAL to any node |
INLINE NodeId gum::NodeGraphPart::nextNodeId | ( | ) | const |
returns a new node id, not yet used by any node
Definition at line 211 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE const NodeGraphPart & gum::NodeGraphPart::nodes | ( | ) | const |
return *this as a NodeGraphPart
Definition at line 352 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
NodeProperty< VAL > gum::NodeGraphPart::nodesProperty | ( | VAL(*)(const NodeId &) | f, |
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.
f | a function assigning a VAL to any node |
size | an 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. |
NodeProperty< VAL > gum::NodeGraphPart::nodesProperty | ( | 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.
a | the default value assigned to each edge in the returned Property |
size | an 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. |
INLINE bool gum::NodeGraphPart::operator!= | ( | const NodeGraphPart & | p | ) | const |
check whether two NodeGraphParts contain different nodes
p | the NodeGraphPart to be compared with "this" |
Definition at line 338 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE NodeGraphPart & gum::NodeGraphPart::operator= | ( | const NodeGraphPart & | p | ) |
copy operator
p | the NodeGraphPart to be copied |
Definition at line 204 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE bool gum::NodeGraphPart::operator== | ( | const NodeGraphPart & | p | ) | const |
check whether two NodeGraphParts contain the same nodes
p | the NodeGraphPart to be compared with "this" |
Definition at line 324 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
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.
s | the NodeGraphPart to be copied |
Definition at line 63 of file nodeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
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.
INLINE Size gum::NodeGraphPart::size | ( | ) | const |
alias for sizeNodes
Definition at line 269 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE Size gum::NodeGraphPart::sizeNodes | ( | ) | const |
returns the number of nodes in the NodeGraphPart
Definition at line 265 of file nodeGraphPart_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
a function to display the set of nodes
Reimplemented in gum::MixedGraph, gum::CliqueGraph, gum::DiGraph, and gum::UndiGraph.
Definition at line 104 of file nodeGraphPart.cpp.
References gum::Set< Key, Alloc >::emplace().
|
friend |
to enable testunits to use check
Definition at line 467 of file nodeGraphPart.h.
|
friend |
Definition at line 462 of file nodeGraphPart.h.
|
friend |
Definition at line 463 of file nodeGraphPart.h.
|
private |
the id below which NodeIds may belong to the NodeGraphPart
Definition at line 511 of file nodeGraphPart.h.
|
private |
the end iterator (used to speed-up parsings of the NodeGraphPart)
Definition at line 508 of file nodeGraphPart.h.
|
private |
the set of nodes not contained in the NodeGraphPart in the interval 1.
. max
Definition at line 499 of file nodeGraphPart.h.
|
private |
value for holes configuration
Definition at line 505 of file nodeGraphPart.h.
|
private |
value for holes configuration
Definition at line 502 of file nodeGraphPart.h.
Signaler1< NodeId > gum::NodeGraphPart::onNodeAdded |
Definition at line 271 of file nodeGraphPart.h.
Signaler1< NodeId > gum::NodeGraphPart::onNodeDeleted |
Definition at line 272 of file nodeGraphPart.h.