47#ifndef GUM_NODE_GRAPH_PART_H
48#define GUM_NODE_GRAPH_PART_H
298 bool holes_resize_policy =
true);
345 template <
typename T >
395 virtual void clear();
464 template < typename VAL >
478 template < typename VAL >
484 template < typename VAL >
Set of pairs of elements with fast search for both elements.
Set of pairs of elements with fast search for both elements.
Generic doubly linked lists.
Listener()
Class constructor.
~NodeGraphPartIteratorSafe() final
destructor
NodeGraphPartIteratorSafe & operator=(const NodeGraphPartIteratorSafe &it)
copy assignment operator
NodeId value_type
types for STL compliance
value_type & reference
types for STL compliance
std::ptrdiff_t difference_type
types for STL compliance
friend class NodeGraphPart
void whenNodeDeleted(const void *src, NodeId id)
called when a node is deleted in the iterated NodeGraphPart
NodeGraphPartIteratorSafe(const NodeGraphPart &nodes)
default constructor
const value_type * const_pointer
types for STL compliance
const value_type & const_reference
types for STL compliance
value_type * pointer
types for STL compliance
std::forward_iterator_tag iterator_category
types for STL compliance
bool operator==(const NodeGraphPartIterator &it) const noexcept
checks whether two iterators point toward the same node
std::ptrdiff_t difference_type
types for STL compliance
void setPos_(NodeId id) noexcept
this function is used by NodeGraphPart to update
const value_type & const_reference
types for STL compliance
const value_type * const_pointer
types for STL compliance
void validate_() noexcept
ensure that the nodeId is either end() either a valid NodeId
virtual ~NodeGraphPartIterator() noexcept
destructor
NodeGraphPartIterator(const NodeGraphPart &nodes) noexcept
Default constructor.
friend class NodeGraphPart
value_type & reference
types for STL compliance
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
NodeId pos_
the nodeid on which the iterator points currently
std::forward_iterator_tag iterator_category
types for STL compliance
NodeId value_type
types for STL compliance
value_type * pointer
types for STL compliance
Class for node sets in graph.
NodeGraphPartIteratorSafe _endIteratorSafe_
the end iterator (used to speed-up parsings of the NodeGraphPart)
Size size() const
alias for sizeNodes
void populateNodes(const NodeGraphPart &s)
populateNodes clears *this and fills it with the same nodes as "s"
Signaler< NodeId > onNodeDeleted
void _clearNodes_()
code for clearing nodes (called twice)
virtual void clear()
alias for clearNodes
Size sizeNodes() const
returns the number of nodes in the NodeGraphPart
std::unique_ptr< Bijection< NodeId, std::string > > _names_
optional node names — null when no name has been set
NodeId bound() const
returns a number n such that all node ids are strictly lower than n
NodeGraphPartIteratorSafe NodeIteratorSafe
bool hasName(NodeId id) const
returns true iff node id has an explicit name
void _eraseHole_(NodeId id)
to delete hole.
const NodeGraphPart & nodes() const
return *this as a NodeGraphPart
friend class NodeGraphPartIterator
NodeProperty< VAL > nodesPropertyFromFunction(VAL(*f)(const NodeId &), Size size=0) const
a method to create a HashTable with key:NodeId and value:VAL
NodeGraphPartIterator node_const_iterator
types for STL compliance
NodeGraphPartIteratorSafe node_const_iterator_safe
types for STL compliance
std::string nameFromId(NodeId id) const
returns the name of node id, or "<id>" if no name is set
void _updateEndIteratorSafe_()
updating endIterator (always at max+1)
void setName(NodeId id, const std::string &name)
sets the name of node id
virtual void eraseNode(const NodeId id)
erase the node with the given id
NodeGraphPartIterator node_iterator
types for STL compliance
Size _holes_size_
value for holes configuration
node_iterator_safe beginSafe() const
a begin iterator to parse the set of nodes contained in the NodeGraphPart
NodeSet asNodeSet() const
returns a copy of the set of nodes represented by the NodeGraphPart
virtual std::string toString() const
a function to display the set of nodes
bool exists(const NodeId id) const
alias for existsNode
bool emptyNodes() const
indicates whether there exists nodes in the NodeGraphPart
const node_iterator_safe & endSafe() const noexcept
the end iterator to parse the set of nodes contained in the NodeGraphPart
bool empty() const
alias for emptyNodes
std::string dotNodeLabel(NodeId id) const
returns " [label=\"...\"]" with DOT-escaped name, or "" if no name
NodeId nextNodeId() const
returns a new node id, not yet used by any node
bool _holes_resize_policy_
value for holes configuration
std::unique_ptr< Bijection< NodeId, std::string > > _cloneNames_() const
clone the names bijection (returns nullptr when no name has been set)
NodeSet * _holes_
the set of nodes not contained in the NodeGraphPart in the interval 1.
Signaler< NodeId > onNodeAdded
virtual void clearNodes()
remove all the nodes from the NodeGraphPart
friend class NodeGraphPartIteratorSafe
virtual NodeId addNode()
insert a new node and return its id
NodeProperty< VAL > nodesPropertyFromVal(const VAL &a, Size size=0) const
a method to create a hashMap with key:NodeId and value:VAL
NodeGraphPartIteratorSafe node_iterator_safe
types for STL compliance
node_iterator begin() const noexcept
a begin iterator to parse the set of nodes contained in the NodeGraphPart
NodeGraphPartIterator NodeIterator
NodeId _boundVal_
the id below which NodeIds may belong to the NodeGraphPart
std::optional< NodeId > idFromName(const std::string &name) const
returns the id of the node with the given name, or std::nullopt
NodeGraphPartIteratorSafe NodeConstIteratorSafe
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,...
NodeGraphPartIterator NodeConstIterator
NodeGraphPart(Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true)
default constructor
const node_iterator & end() const noexcept
the end iterator to parse the set of nodes contained in the NodeGraphPart
void _addHole_(NodeId id)
to add a hole.
void populateNodesFromProperty(const NodeProperty< T > &h)
populateNodesFromProperty clears *this and fills it with the keys of "h"
bool _inHoles_(NodeId id) const
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
std::vector< NodeId > addNodes(Size n)
insert n nodes
some utils for topology : NodeId, Edge, Arc and consorts ...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
gum is the global namespace for all aGrUM entities
Inline implementation of the base node set class for graphs.
Implementation of the NodeGraphPart.
Convenience header for the signal/listener pattern.
static constexpr Size default_size
The default number of slots in hashtables.