144 const bool hasNames = (
_names_ !=
nullptr);
148 if (!first) s +=
",";
151 if (hasNames &&
_names_->existsFirst(
id)) s += std::format(
"{}<{}>",
id,
_names_->second(
id));
152 else s += std::format(
"{}",
id);
162 return std::to_string(
id);
173 auto owner =
_names_->tryFirst(name);
174 if (owner.has_value()) {
181 _names_ = std::make_unique< Bijection< NodeId, std::string > >();
190 const std::string& name =
_names_->second(
id);
192 result.reserve(name.size() * 2 + 24);
193 result =
" [label=\"(";
194 result += std::to_string(
id);
196 for (
const char c: name) {
198 case '"' : result +=
"\\\"";
break;
199 case '\\' : result +=
"\\\\";
break;
200 case '\n' : result +=
"\\n";
break;
201 case '\r' : result +=
"\\r";
break;
202 default : result += c;
Exception : a similar element already exists.
Exception : node does not exist.
void whenNodeDeleted(const void *src, NodeId id)
called when a node is deleted in the iterated NodeGraphPart
const NodeGraphPart * nodes_
the nodegraphpart on which points the iterator
NodeId pos_
the nodeid on which the iterator points currently
Class for node sets in graph.
NodeGraphPartIteratorSafe _endIteratorSafe_
the end iterator (used to speed-up parsings of the NodeGraphPart)
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
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
bool hasName(NodeId id) const
returns true iff node id has an explicit name
void _eraseHole_(NodeId id)
to delete hole.
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
Size _holes_size_
value for holes configuration
virtual std::string toString() const
a function to display the set of nodes
std::string dotNodeLabel(NodeId id) const
returns " [label=\"...\"]" with DOT-escaped name, or "" if no name
bool _holes_resize_policy_
value for holes configuration
virtual ~NodeGraphPart()
destructor
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
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
NodeGraphPart(Size holes_size=HashTableConst::default_size, bool holes_resize_policy=true)
default constructor
void _addHole_(NodeId id)
to add a hole.
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
#define GUM_ERROR(type, msg)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...
gum is the global namespace for all aGrUM entities
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree
Base node set class for graphs.
Inline implementation of the base node set class for graphs.
#define GUM_EMIT1(signal, arg1)