diff --git a/cpp/switchchain.hpp b/cpp/switchchain.hpp index 34e511d1c602394689504f56908bb64795eec7a8..49849d43f591842b92196b374857f4677b1c65aa 100644 --- a/cpp/switchchain.hpp +++ b/cpp/switchchain.hpp @@ -21,16 +21,18 @@ class SwitchChain { } ~SwitchChain() {} - bool initialize(const Graph& gstart) { + bool initialize(const Graph& gstart, bool trackTriangles = false) { if (gstart.edgeCount() == 0) return false; g = gstart; edgeDistribution.param( std::uniform_int_distribution<>::param_type(0, g.edgeCount() - 1)); + if (trackTriangles) + g.getTrackedTriangles() = g.countTriangles(); return true; } - bool doMove() { + bool doMove(bool trackTriangles = false) { int e1index, e2index; int timeout = 0; // Keep regenerating while conflicting edges @@ -48,7 +50,7 @@ class SwitchChain { // 2) e1.u - e2.u and e1.v - e2.v // 3) e1.u - e2.v and e1.v - e2.u bool switchType = permutationDistribution(mt); - return g.exchangeEdges(e1index, e2index, switchType); + return g.exchangeEdges(e1index, e2index, switchType, trackTriangles); } Graph g;