diff -r bc571f16e1e9 -r 3feba0ea1bda test/vf2_test.cc --- a/test/vf2_test.cc Tue Sep 19 15:23:43 2017 +0200 +++ b/test/vf2_test.cc Tue Sep 19 14:08:20 2017 +0200 @@ -2,7 +2,7 @@ * * This file is a part of LEMON, a generic C++ optimization library. * - * Copyright (C) 2015 + * Copyright (C) 2015-2017 * EMAXA Kutato-fejleszto Kft. (EMAXA Research Ltd.) * * Permission to use, modify and distribute this software is granted @@ -183,18 +183,21 @@ class EqComparable { public: - bool operator==(const EqComparable&) { return false; } + bool operator==(const EqComparable&) { + return false; + } }; template class EqClass { public: - bool operator()(A, B) { return false; } + bool operator()(A, B){ + return false; + } }; template -void checkVf2Compile() -{ +void checkVf2Compile() { G1 g; G2 h; concepts::ReadWriteMap r; @@ -205,8 +208,15 @@ succ = vf2(g,h).induced().run(); succ = vf2(g,h).iso().run(); succ = vf2(g,h).mapping(r).run(); + + Vf2, + EqClass > + myVf2(g,h,r,EqClass()); + myVf2.find(); + succ = vf2(g,h).induced().mapping(r).run(); succ = vf2(g,h).iso().mapping(r).run(); + concepts::ReadMap l1; concepts::ReadMap l2; succ = vf2(g,h).nodeLabels(l1,l2).mapping(r).run(); @@ -214,24 +224,21 @@ .mapping(r).run(); } -void justCompile() -{ +void justCompile() { checkVf2Compile(); checkVf2Compile(); checkVf2Compile(); } template -void checkSub(const G1 &g1, const G2 &g2, const I &i) -{ +void checkSub(const G1 &g1, const G2 &g2, const I &i) { { std::set image; - for(typename G1::NodeIt n(g1);n!=INVALID;++n) - { - check(i[n]!=INVALID, "Wrong isomorphism: incomplete mapping."); - check(image.count(i[n])==0,"Wrong isomorphism: not injective."); - image.insert(i[n]); - } + for(typename G1::NodeIt n(g1);n!=INVALID;++n){ + check(i[n]!=INVALID, "Wrong isomorphism: incomplete mapping."); + check(image.count(i[n])==0,"Wrong isomorphism: not injective."); + image.insert(i[n]); + } } for(typename G1::EdgeIt e(g1);e!=INVALID;++e) check(findEdge(g2,i[g1.u(e)],i[g1.v(e)])!=INVALID, @@ -239,87 +246,78 @@ } template -void checkInd(const G1 &g1, const G2 &g2, const I &i) - { +void checkInd(const G1 &g1, const G2 &g2, const I &i) { std::set image; - for(typename G1::NodeIt n(g1);n!=INVALID;++n) - { + for(typename G1::NodeIt n(g1);n!=INVALID;++n) { check(i[n]!=INVALID, "Wrong isomorphism: incomplete mapping."); check(image.count(i[n])==0,"Wrong isomorphism: not injective."); image.insert(i[n]); - } + } for(typename G1::NodeIt n(g1); n!=INVALID; ++n) for(typename G1::NodeIt m(g1); m!=INVALID; ++m) - if((findEdge(g1,n,m)==INVALID) != (findEdge(g2,i[n],i[m])==INVALID)) - { + if((findEdge(g1,n,m)==INVALID) != (findEdge(g2,i[n],i[m])==INVALID)) { std::cout << "Wrong isomorphism: edge mismatch"; exit(1); - } - } - -template -int checkSub(const G1 &g1, const G2 &g2) -{ - typename G1:: template NodeMap iso(g1,INVALID); - if(vf2(g1,g2).mapping(iso).run()) - { - checkSub(g1,g2,iso); - return true; - } - else return false; + } } template -int checkInd(const G1 &g1, const G2 &g2) -{ +int checkSub(const G1 &g1, const G2 &g2) { typename G1:: template NodeMap iso(g1,INVALID); - if(vf2(g1,g2).induced().mapping(iso).run()) - { - checkInd(g1,g2,iso); - return true; - } - else return false; + if(vf2(g1,g2).mapping(iso).run()) { + checkSub(g1,g2,iso); + return true; + } + else + return false; } template -int checkIso(const G1 &g1, const G2 &g2) -{ +int checkInd(const G1 &g1, const G2 &g2) { typename G1:: template NodeMap iso(g1,INVALID); - if(vf2(g1,g2).iso().mapping(iso).run()) - { - check(countNodes(g1)==countNodes(g2), - "Wrong iso alg.: they are not isomophic."); - checkInd(g1,g2,iso); - return true; - } - else return false; + if(vf2(g1,g2).induced().mapping(iso).run()) { + checkInd(g1,g2,iso); + return true; + } + else + return false; +} + +template +int checkIso(const G1 &g1, const G2 &g2) { + typename G1:: template NodeMap iso(g1,INVALID); + if(vf2(g1,g2).iso().mapping(iso).run()) { + check(countNodes(g1)==countNodes(g2), + "Wrong iso alg.: they are not isomophic."); + checkInd(g1,g2,iso); + return true; + } + else + return false; } template void checkLabel(const G1 &g1, const G2 &, - const L1 &l1, const L2 &l2,const I &i) -{ + const L1 &l1, const L2 &l2,const I &i) { for(typename G1::NodeIt n(g1);n!=INVALID;++n) - { - check(l1[n]==l2[i[n]],"Wrong isomorphism: label mismatch."); - } + check(l1[n]==l2[i[n]],"Wrong isomorphism: label mismatch."); } template -int checkSub(const G1 &g1, const G2 &g2, const L1 &l1, const L2 &l2) -{ +int checkSub(const G1 &g1, const G2 &g2, const L1 &l1, const L2 &l2) { typename G1:: template NodeMap iso(g1,INVALID); - if(vf2(g1,g2).nodeLabels(l1,l2).mapping(iso).run()) - { - checkSub(g1,g2,iso); - checkLabel(g1,g2,l1,l2,iso); - return true; - } - else return false; + if(vf2(g1,g2).nodeLabels(l1,l2).mapping(iso).run()){ + checkSub(g1,g2,iso); + checkLabel(g1,g2,l1,l2,iso); + return true; + } + else + return false; } int main() { make_graphs(); + // justCompile(); check(checkSub(c5,petersen), "There should exist a C5->Petersen mapping."); check(!checkSub(c7,petersen), "There should not exist a C7->Petersen mapping.");