SetIteratorEncodingValue *conflictIt = ev->notequals.iterator();
while (conflictIt->hasNext()) {
EncodingValue *conflict = conflictIt->next();
- ASSERT(conflict->value != ev->value);
if (conflict->assigned) {
encodingArray.setExpand(conflict->encoding, true);
}
return newSize;
}
+double EncodingSubGraph::measureSimilarity(EncodingNode *node) {
+ uint common = 0;
+ Hashset64Int intSet;
+ SetIteratorEncodingNode *nit = nodes.iterator();
+ while (nit->hasNext()) {
+ EncodingNode *en = nit->next();
+ for(uint i=0; i < en->getSize(); i++){
+ intSet.add(en->getIndex(i));
+ }
+ }
+ for(uint i=0; i < node->getSize(); i++){
+ if(intSet.contains( node->getIndex(i) )){
+ common++;
+ }
+ }
+// model_print("measureSimilarity:139: common=%u\t GraphSize=%u\tnodeSize=%u\tGraphSim=%f\tnodeSim=%f\n", common, intSet.getSize(), node->getSize(), 1.0*common/intSet.getSize(), 1.0*common/node->getSize());
+ delete nit;
+ return common*1.0/intSet.getSize() + common*1.0/node->getSize();
+}
+
+double EncodingSubGraph::measureSimilarity(EncodingSubGraph *sg) {
+ uint common = 0;
+ Hashset64Int set1;
+ Hashset64Int set2;
+ SetIteratorEncodingNode *nit = nodes.iterator();
+ while (nit->hasNext()) {
+ EncodingNode *en = nit->next();
+ for(uint i=0; i < en->getSize(); i++){
+ set1.add(en->getIndex(i));
+ }
+ }
+ delete nit;
+ nit = sg->nodes.iterator();
+ while (nit->hasNext()) {
+ EncodingNode *en = nit->next();
+ for(uint i=0; i < en->getSize(); i++){
+ set2.add(en->getIndex(i));
+ }
+ }
+ delete nit;
+ SetIterator64Int *setIter1 = set1.iterator();
+ while(setIter1->hasNext()){
+ uint64_t item1 = setIter1->next();
+ if( set2.contains(item1)){
+ common++;
+ }
+ }
+ delete setIter1;
+// model_print("measureSimilarity:139: common=%u\tGraphSize1=%u\tGraphSize2=%u\tGraphSize1=%f\tGraphSize2=%f\n", common, set1.getSize(), set2.getSize(), 1.0*common/set1.getSize(), 1.0*common/set2.getSize());
+ return common*1.0/set1.getSize() + common*1.0/set2.getSize();
+}
+
uint EncodingSubGraph::estimateNewSize(EncodingNode *n) {
SetIteratorEncodingEdge *eeit = n->edges.iterator();
uint newsize = n->getSize();
NodeValuePair nvp2(right, rVal);
EncodingValue *rev = map.get(&nvp2);
if (lev != rev) {
- ASSERT(lVal != rVal);
if (lev->inComparison && rev->inComparison) {
//Need to assign during comparison stage...
//Thus promote to comparison
while (tovisit.getSize() != 0) {
EncodingNode *n = tovisit.last();tovisit.pop();
//Add encoding node to structures
- NodeValuePair *nvp = new NodeValuePair(n, value);
- if(map.contains(nvp))
- continue;
ecv->nodes.add(n);
+ NodeValuePair *nvp = new NodeValuePair(n, value);
map.put(nvp, ecv);
- ASSERT(node != NULL);
SetIteratorEncodingEdge *edgeit = n->edges.iterator();
while (edgeit->hasNext()) {
EncodingEdge *ee = edgeit->next();
if (!discovered.contains(ee->left) && nodes.contains(ee->left) && ee->left->s->exists(value)) {
tovisit.push(ee->left);
discovered.add(ee->left);
- ASSERT(discovered.contains(ee->left));
}
if (!discovered.contains(ee->right) && nodes.contains(ee->right) && ee->right->s->exists(value)) {
tovisit.push(ee->right);
discovered.add(ee->right);
- ASSERT(discovered.contains(ee->right));
}
}
delete edgeit;