43 __tail{tail}, __head{head} {
50 __type{from.__type}, __tail{from.__tail}, __head{from.__head} {
57 __type{from.__type}, __tail{from.__tail}, __head{from.__head} {
120 std::move(from.type()), std::move(from.tail()), std::move(from.head())) {
167 std::move(from.type()), std::move(from.tail()), std::move(from.head())) {
215 std::move(from.type()), std::move(from.tail()), std::move(from.head())) {
283 __dag = std::move(from.__dag);
313 Size multiplier)
const {
314 for (
auto iter = set_to_add.
cbegin(); iter != set_to_add.
cend(); ++iter) {
315 if (nodeset.
exists(iter.key())) {
316 nodeset[iter.key()] += iter.val() * multiplier;
318 nodeset.
insert(iter.key(), iter.val() * multiplier);
327 Size multiplier)
const {
328 for (
auto iter = set_to_del.
cbegin(); iter != set_to_del.
cend(); ++iter) {
329 if (nodeset.
exists(iter.key())) {
330 Size& weight = nodeset[iter.key()];
331 weight -= iter.val() * multiplier;
333 if (!weight) { nodeset.
erase(iter.key()); }
344 const NodeSet& extremities)
const {
345 for (
auto iter = set_to_restrict.
cbegin(); iter != set_to_restrict.
cend();
347 if (extremities.
exists(iter.key())) {
348 result_set.
insert(iter.key(), iter.val());
357 "the arc would create a directed into a DAG");
A class for detecting directed cycles in DAGs when trying to apply many changes to the graph...
~DAGCycleDetector()
destructor
DiGraph __dag
the initial dag from which modifications are applied
the base class indicating the possible changes
~ArcDel() noexcept
destructor
NodeId tail() const noexcept
indicates the tail of the arc involved in the modification
ArcAdd & operator=(const ArcAdd &from) noexcept
copy operator
void erase(const Key &key)
Removes a given element from the hash table.
void eraseArc(NodeId x, NodeId y)
removes an arc from the current DAG
void __addWeightedSet(NodeProperty< Size > &nodeset, const NodeProperty< Size > &set_to_add, Size multiplier) const
adds a weighted nodeset to another (weights are added)
ArcDel(NodeId tail, NodeId head) noexcept
default constructor
virtual ~Change() noexcept
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
void addArc(NodeId x, NodeId y)
adds a new arc to the current DAG
void __delWeightedSet(NodeProperty< Size > &nodeset, const NodeProperty< Size > &set_to_del, Size multiplier) const
removes a weighted nodeset from another (weights are subtracted)
ChangeType type() const noexcept
returns the type of the operation
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...
ArcReverse(NodeId tail, NodeId head) noexcept
default constructor
ChangeType __type
the type of modification
the class to indicate that we wish to reverse an arc
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Change & operator=(const Change &from) noexcept
The class for generic Hash Tables.
~ArcReverse() noexcept
destructor
DAGCycleDetector & operator=(const DAGCycleDetector &from)
copy operator
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
NodeId head() const noexcept
indicates the head of the arc involved in the modification
const const_iterator & cend() const noexcept
Returns the unsafe const_iterator pointing to the end of the hashtable.
the class to indicate that we wish to add a new arc
Change(ChangeType type, NodeId tail, NodeId head) noexcept
const_iterator cbegin() const
Returns an unsafe const_iterator pointing to the beginning of the hashtable.
ArcReverse & operator=(const ArcReverse &from) noexcept
copy operator
NodeId __head
the head of the arc to be modified
~ArcAdd() noexcept
destructor
bool operator!=(const DAGCycleDetector &from) const
check the inequality between two DAGCycleDetectors
bool hasCycleFromAddition(NodeId x, NodeId y) const noexcept
indicates whether an arc addition would create a cycle
NodeId __tail
the tail of the arc to be modified
NodeProperty< NodeProperty< Size > > __descendants
the set of descendants of each node in the dag
NodeProperty< NodeProperty< Size > > __ancestors
the set of ancestors of each node in the dag
bool hasCycleFromReversal(NodeId x, NodeId y) const noexcept
indicates wether an arc reversal would create a cycle
bool hasCycleFromDeletion(NodeId x, NodeId y) const noexcept
indicates whether an arc deletion would create a cycle
std::size_t Size
In aGrUM, hashed values are unsigned long int.
ArcDel & operator=(const ArcDel &from) noexcept
copy operator
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
DAGCycleDetector() noexcept
default constructor
the class to indicate that we wish to remove an arc
bool operator==(const DAGCycleDetector &from) const
check the equality between two DAGCycleDetectors
Size NodeId
Type for node ids.
ArcAdd(NodeId tail, NodeId head) noexcept
default constructor
#define GUM_ERROR(type, msg)
void reverseArc(NodeId x, NodeId y)
reverses an arc from the DAG