60 GUM_CONSTRUCTOR(DAGCycleDetector::Change);
65 _type_{from._type_}, _tail_{from._tail_}, _head_{from._head_} {
66 GUM_CONS_CPY(DAGCycleDetector::Change);
71 _type_{from._type_}, _tail_{from._tail_}, _head_{from._head_} {
72 GUM_CONS_MOV(DAGCycleDetector::Change);
128 std::move(from.tail()),
129 std::move(from.head())) {
171 std::move(from.tail()),
172 std::move(from.head())) {
214 std::move(from.tail()),
215 std::move(from.head())) {
278 _dag_ = std::move(from._dag_);
305 Size multiplier)
const {
306 for (
auto iter = set_to_add.
cbegin(); iter != set_to_add.
cend(); ++iter) {
307 if (nodeset.
exists(iter.key())) {
308 nodeset[iter.key()] += iter.val() * multiplier;
310 nodeset.
insert(iter.key(), iter.val() * multiplier);
319 Size multiplier)
const {
320 for (
auto iter = set_to_del.
cbegin(); iter != set_to_del.
cend(); ++iter) {
321 if (nodeset.
exists(iter.key())) {
322 Size& weight = nodeset[iter.key()];
323 weight -= iter.val() * multiplier;
325 if (!weight) { nodeset.
erase(iter.key()); }
335 const NodeSet& extremities)
const {
336 for (
auto iter = set_to_restrict.
cbegin(); iter != set_to_restrict.
cend(); ++iter) {
337 if (extremities.
exists(iter.key())) { result_set.
insert(iter.key(), iter.val()); }
the class to indicate that we wish to add a new arc
~ArcAdd() noexcept
destructor
ArcAdd & operator=(const ArcAdd &from) noexcept
copy operator
ArcAdd(NodeId tail, NodeId head) noexcept
default constructor
the class to indicate that we wish to remove an arc
~ArcDel() noexcept
destructor
ArcDel(NodeId tail, NodeId head) noexcept
default constructor
ArcDel & operator=(const ArcDel &from) noexcept
copy operator
the class to indicate that we wish to reverse an arc
ArcReverse & operator=(const ArcReverse &from) noexcept
copy operator
~ArcReverse() noexcept
destructor
ArcReverse(NodeId tail, NodeId head) noexcept
default constructor
the base class indicating the possible changes
ChangeType type() const noexcept
returns the type of the operation
NodeId tail() const noexcept
indicates the tail of the arc involved in the modification
NodeId _head_
the head of the arc to be modified
Change & operator=(const Change &from) noexcept
virtual ~Change() noexcept
ChangeType _type_
the type of modification
Change(ChangeType type, NodeId tail, NodeId head) noexcept
NodeId _tail_
the tail of the arc to be modified
NodeId head() const noexcept
indicates the head of the arc involved in the modification
DAGCycleDetector() noexcept
default constructor
bool hasCycleFromDeletion(NodeId x, NodeId y) const noexcept
indicates whether an arc deletion would create a cycle
~DAGCycleDetector()
destructor
NodeProperty< NodeProperty< Size > > _descendants_
the set of descendants of each node in the dag
void _addWeightedSet_(NodeProperty< Size > &nodeset, const NodeProperty< Size > &set_to_add, Size multiplier) const
adds a weighted nodeset to another (weights are added)
void addArc(NodeId x, NodeId y)
adds a new arc to the current DAG
bool hasCycleFromReversal(NodeId x, NodeId y) const noexcept
indicates wether an arc reversal would create a cycle
NodeProperty< NodeProperty< Size > > _ancestors_
the set of ancestors of each node in the dag
DAGCycleDetector & operator=(const DAGCycleDetector &from)
copy operator
void _delWeightedSet_(NodeProperty< Size > &nodeset, const NodeProperty< Size > &set_to_del, Size multiplier) const
removes a weighted nodeset from another (weights are subtracted)
bool operator!=(const DAGCycleDetector &from) const
check the inequality between two DAGCycleDetectors
void reverseArc(NodeId x, NodeId y)
reverses an arc from the DAG
void eraseArc(NodeId x, NodeId y)
removes an arc from the current DAG
DiGraph _dag_
the initial dag from which modifications are applied
bool operator==(const DAGCycleDetector &from) const
check the equality between two DAGCycleDetectors
void _restrictWeightedSet_(NodeProperty< Size > &result_set, const NodeProperty< Size > &set_to_restrict, const NodeSet &extrmities) const
put into a weighted nodeset the nodes of another weighted set that belong to a set of arc extremities
bool hasCycleFromAddition(NodeId x, NodeId y) const noexcept
indicates whether an arc addition would create a cycle
void erase(const Key &key)
Removes a given element from the hash table.
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
const_iterator cbegin() const
Returns an unsafe const_iterator pointing to the beginning of the hashtable.
const const_iterator & cend() const noexcept
Returns the unsafe const_iterator pointing to the end of the hashtable.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Exception : existence of a directed cycle in a graph.
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
#define GUM_ERROR(type, msg)
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