diff --git a/compileTimeOptions.h b/compileTimeOptions.h index 526e6ec2611f3897ca3c7e148c6c7109d985f1ad..ee4aee3604d22123a0adefe9472f2d80f58fa9ee 100644 --- a/compileTimeOptions.h +++ b/compileTimeOptions.h @@ -20,6 +20,6 @@ REQUIRES(EXPLICIT_NORMAL_EDGES, USE_NEXT_FORB) BOOL_OPTION(USE_TWO_CUTS, 1) REQUIRES(USE_TWO_CUTS, USE_NEXT_FORB && EXPLICIT_NORMAL_EDGES) -BOOL_OPTION(USE_DOUBLE_SUBDIVISIONS, 0) +BOOL_OPTION(USE_DOUBLE_SUBDIVISIONS, 1) REQUIRES(USE_DOUBLE_SUBDIVISIONS, USE_NEXT_FORB && EXPLICIT_NORMAL_EDGES) diff --git a/group-connectivity.h b/group-connectivity.h index ec326fbd21bbc324ba8af34e4ff1a0209efe4993..0199836d7abacb862f912e2058239b33962135da 100644 --- a/group-connectivity.h +++ b/group-connectivity.h @@ -57,6 +57,9 @@ struct Tester : public AbstractTester { # if USE_TWO_CUTS std::vector< TwoCutInt > twoCuts; # endif +# if USE_DOUBLE_SUBDIVISIONS + std::vector< EdgeId > doubleSubdividedEdges; +# endif virtual void init( int edges_, @@ -87,6 +90,16 @@ struct Tester : public AbstractTester { } } +# if USE_DOUBLE_SUBDIVISIONS + if (Ring::size == 4) { + for (const auto& i : dSub) { + for (auto e : i) edgeList[e - 1] = false; + classEdges.push_back(i[0] - 1); + doubleSubdividedEdges.push_back(i[0] - 1); + } + } +# endif + # if USE_TWO_CUTS for (auto cut : twoCuts_) { if (cut.first < 0) { @@ -227,6 +240,9 @@ struct Tester : public AbstractTester { # if USE_TWO_CUTS for (const auto& cut : twoCuts) cut.encode(forb, 0); # endif +# if USE_DOUBLE_SUBDIVISIONS + for (const auto& e : doubleSubdividedEdges) forb.assign(e, 0); +# endif do { Mapping copy(forb); diff --git a/groupConnectivity.pyx b/groupConnectivity.pyx index b70b9ed4f2b693ea69b1324d5c7121b07ba0622b..007c5deaee2ddd6f2ae1bdb3e39ce1f5b4057fad 100644 --- a/groupConnectivity.pyx +++ b/groupConnectivity.pyx @@ -39,7 +39,7 @@ def pathToEdges(G, path): def testGroupConnectivity(G, group = "Z4", getClasses = False, - useTwoCuts = True, useDoubleSubdivisions = False, + useTwoCuts = True, useDoubleSubdivisions = True, debug = False): cdef AbstractTester* tester = NULL if group == "Z4": @@ -59,19 +59,29 @@ def testGroupConnectivity(G, group = "Z4", getClasses = False, G.set_edge_label(u, v, i) i += 1 - spanningTree = Graph(G.min_spanning_tree()) + spanningTree = Graph(G.min_spanning_tree( + weight_function = lambda e: min(G.degree([e[0], e[1]])) + )) elemCycles = [ [ l ] + pathToEdges(G, spanningTree.shortest_path(u, v)) for (u, v, l) in set(G.edge_iterator()) - set(spanningTree.edge_iterator()) ] spanningTreeEdges = [ l for (_, _, l) in spanningTree.edge_iterator() ] + availableEdges = set(spanningTreeEdges) - + doubleSubdivisions = [] + if useDoubleSubdivisions: + for (u, v, l) in G.edges(): + if G.degree([u, v]) != [2, 2]: + continue + edges = set([ l for (_, _, l) in G.edges_incident([u, v]) ]) + if edges.issubset(availableEdges): + doubleSubdivisions.append(edges) + availableEdges -= edges twoCuts = [] if useTwoCuts: - availableEdges = set(spanningTreeEdges) for v in [ v for v in G.vertices() if G.degree(v) == 2 ]: e, f = G.edges_incident(v) el = e[2] @@ -98,8 +108,9 @@ def testGroupConnectivity(G, group = "Z4", getClasses = False, print "Spanning Tree: ", spanningTreeEdges print "Elementary cycles: ", elemCycles print "Two cuts: ", twoCuts + print "Double subdivided edges: ", doubleSubdivisions - tester.init(G.num_edges(), spanningTreeEdges, twoCuts, [], elemCycles) + tester.init(G.num_edges(), spanningTreeEdges, twoCuts, doubleSubdivisions, elemCycles) ret = tester.run() if getClasses: