diff --git a/group-connectivity.h b/group-connectivity.h index 110faf4a264ed04f50726bb43d732e7e5dbf3847..eac1fd05ec784ed033c4bf22265cc690cb18ded3 100644 --- a/group-connectivity.h +++ b/group-connectivity.h @@ -140,32 +140,30 @@ struct Tester : public AbstractTester { #endif virtual bool run() { +# if SAVE_MEMORY +# define INC(a) a = true +# else +# define INC(a) a++ +# endif + Mapping forb(edges); - -#if USE_NEXT_FORB - for (size_t i = 0; i < edges; i++) - forb.assign(i, 1); - do { - Mapping copy(forb); -#if SAVE_MEMORY - classes[pack(cannonize(copy))] = true; -#else - classes[pack(cannonize(copy))]++; -#endif - } while (nextForb(forb)); -#else // ! USE_NEXT_FORB - for (size_t i = 0; i < numForb; i++) -#if SAVE_MEMORY - classes[pack(cannonize(unpack(i, forb)))] = true; -#else - classes[pack(cannonize(unpack(i, forb)))]++; -#endif -#endif +# if USE_NEXT_FORB + for (size_t i = 0; i < edges; i++) forb.assign(i, 1); + + do { + Mapping copy(forb); + INC(classes[pack(cannonize(copy))]); + } while (nextForb(forb)); +# else + for (size_t i = 0; i < numForb; i++) + INC(classes[pack(cannonize(unpack(i, forb)))]); +# endif for (const auto &c : classes) if (!c) return (isConnected = false); return (isConnected = true); +# undef INC } virtual ~Tester() {}