41 double similarityThreshold) :
42 __leavesCpt(idSource),
43 __similarityThreshold(similarityThreshold) {
62 pairIter != leafIter.val()->endSafe();
66 leafIter.val()->erase(curPair);
69 delete leafIter.val();
98 (leafIter.val())->insert(p);
122 if ((*fusIter)->leaf()->contains((*pairIter)->secondLeaf()->id())) {
127 if ((*fusIter)->addPair(*pairIter))
__removeContext(fusIter.pos() + 1);
132 bag << (*fusIter)->leafAssociatedPair(l);
149 (*pairIter)->updateLikelyhood();
160 if ((*fusIter)->leaf()->contains(curLeaf->
id())) {
162 if ((*fusIter)->updateAllAssociatedLeaves())
164 bag = (*fusIter)->associatedPairs();
165 curLeaf = (*fusIter)->leaf();
172 if ((*fusIter)->leaf()->contains((*pairIter)->secondLeaf()->id())
173 || (*fusIter)->leaf()->contains((*pairIter)->firstLeaf()->id())) {
178 if ((*fusIter)->updatePair(*pairIter))
__removeContext(fusIter.pos() + 1);
180 if ((*fusIter)->updateAssociatedLeaf(curLeaf))
182 bag << (*fusIter)->leafAssociatedPair(curLeaf);
200 (*
__leaf2Pair[(*pairIter)->otherLeaf(l)]) >> *pairIter;
213 if ((*fusIter)->leaf()->contains((*pairIter)->secondLeaf()->id())
214 || (*fusIter)->leaf()->contains((*pairIter)->firstLeaf()->id())) {
219 if ((*fusIter)->removePair(*pairIter)) {
224 bag << (*fusIter)->leafAssociatedPair(l);
225 toBeDeleted << (*fusIter)->leafAssociatedPair(l);
227 if ((*fusIter)->deassociateLeaf(l)) {
__removeContext(fusIter.pos() + 1); }
231 pairIter != toBeDeleted.
endSafe();
264 for (
pair_iterator pairIter = pb; pairIter != pe; ++pairIter) {
265 if (!newLeaf->
contains(pairIter.key()->firstLeaf()->id())
266 && !newLeaf->
contains(pairIter.key()->secondLeaf()->id()))
267 newContext->
addPair(pairIter.key());
268 if (!newLeaf->
contains(pairIter.key()->firstLeaf()->id())
271 if (!newLeaf->
contains(pairIter.key()->secondLeaf()->id())
291 bool alreadyIn =
false;
296 if (mapIter.val()->contains((*fusIter)->leaf()->id())) {
300 if (!alreadyIn) retMap.
insert((*fusIter)->leaf()->id(), (*fusIter)->leaf());
311 if (mapIter.val()->contains(leafIter.key()->id())) {
312 retMap.
insert(leafIter.key()->id(), mapIter.val());
315 if (!retMap.
exists(leafIter.key()->id()))
316 retMap.
insert(leafIter.key()->id(), leafIter.key());
324 std::stringstream ss;
325 ss <<
"################\nTas Initial : " << std::endl
330 ss <<
"################\nTas " << fusIter.pos() <<
" : " << std::endl
331 << (*fusIter)->toString();
virtual bool contains(NodeId testedId) const
Returns true if abstractleaf has leaf in it.
Safe iterators for Sequence.
void __removeInitialPair(LeafPair *)
AbstractLeaf * convert2Leaf(NodeId leafId) const
Returns a leaf matching data and having given id as id.
const iterator_safe & endSafe() noexcept
Returns the safe iterator pointing to the end of the hashtable.
Safe iterators for the Set classDevelopers may consider using Set<x>::iterator_safe instead of SetIte...
<agrum/FMDP/learning/FunctionGraph/leafAggregator.h>
bool removePair(LeafPair *p)
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
Safe Const Iterators for hashtables.
<agrum/FMDP/learning/datastructure/leaves/leafPair.h>
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
NodeGraphPart * __leavesCpt
void __addInitialPair(LeafPair *)
Safe Iterators for hashtables.
gum is the global namespace for all aGrUM entities
virtual NodeId addNode()
insert a new node and return its id
The class for generic Hash Tables.
Representation of a setA Set is a structure that contains arbitrary elements.
const iterator_safe & endSafe() const noexcept
The usual safe end iterator to parse the set.
~LeafAggregator()
Default destructor.
Sequence< FusionContext< false > *> __fusionSeq
AbstractLeaf * otherLeaf(AbstractLeaf *l) const
LeafAggregator(NodeGraphPart *idSource, double similarityThreshold)
Default constructor.
Class for node sets in graph.
bool addPair(LeafPair *p)
HashTable< NodeId, AbstractLeaf *> leavesMap()
FusionContext< true > * __initialContext
HashTable< AbstractLeaf *, Set< LeafPair *> *> __leaf2Pair
iterator_safe beginSafe()
Returns the safe iterator pointing to the beginning of the hashtable.
iterator_safe beginSafe() const
The usual safe begin iterator to parse the set.
bool containsAssociatedLeaf(AbstractLeaf *l)
Size Idx
Type for indexes.
void removeLeaf(AbstractLeaf *)
void clear()
Removes all the elements, if any, from the set.
bool associateLeaf(AbstractLeaf *l)
double __similarityThreshold
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
bool updateLeaf(AbstractLeaf *)
void __removeContext(Idx)
double likelyhood()
Updates GStatistic.
void addLeaf(AbstractLeaf *)
void insert(const Key &k)
Inserts a new element into the set.
Headers of the Leaf Aggregator class.
bool updatePair(LeafPair *p)
void updateLikelyhood()
Updates GStatistic.
pair_iterator beginPairs()
virtual void eraseNode(const NodeId id)
erase the node with the given id
void __updateInitialPair(LeafPair *)