From cf31a83f42525c56e90a64914eca54c82ade8d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Hu=C5=A1ek?= <PitelVonSacek@gmail.com> Date: Thu, 10 Dec 2015 13:12:04 +0100 Subject: [PATCH] API changes for double-subdivision optimization --- compileTimeOptions.h | 3 +++ group-connectivity.h | 3 +++ groupConnectivity.pyx | 10 +++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/compileTimeOptions.h b/compileTimeOptions.h index 4b32d85..526e6ec 100644 --- a/compileTimeOptions.h +++ b/compileTimeOptions.h @@ -20,3 +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) +REQUIRES(USE_DOUBLE_SUBDIVISIONS, USE_NEXT_FORB && EXPLICIT_NORMAL_EDGES) + diff --git a/group-connectivity.h b/group-connectivity.h index 1ff1eb0..ec326fb 100644 --- a/group-connectivity.h +++ b/group-connectivity.h @@ -11,6 +11,7 @@ typedef int EdgeId; typedef int DirectedEdgeId; typedef std::pair<DirectedEdgeId, DirectedEdgeId> TwoCut; +typedef std::vector<EdgeId> DoubleSubdivision; struct AbstractTester { bool isConnected; @@ -25,6 +26,7 @@ struct AbstractTester { int edges, std::vector<EdgeId> spanningTree, std::vector<TwoCut> twoCuts, + std::vector<DoubleSubdivision> dSub, std::vector< std::vector<DirectedEdgeId> > elementaryCycles ) =0; virtual std::vector<size_t> getClasses() =0; @@ -60,6 +62,7 @@ struct Tester : public AbstractTester { int edges_, std::vector<EdgeId> spanningTree, std::vector<TwoCut> twoCuts_, + std::vector<DoubleSubdivision> dSub, std::vector< std::vector<DirectedEdgeId> > elementaryCycles ) { edges = edges_; diff --git a/groupConnectivity.pyx b/groupConnectivity.pyx index 356f3ed..b70b9ed 100644 --- a/groupConnectivity.pyx +++ b/groupConnectivity.pyx @@ -16,9 +16,10 @@ cdef extern from "group-connectivity.h": ctypedef int EdgeId ctypedef int DirectedEdgeId ctypedef pair[DirectedEdgeId, DirectedEdgeId] TwoCut + ctypedef vector[EdgeId] DoubleSubdivision cdef cppclass AbstractTester: - void init(int, vector[EdgeId], vector[TwoCut], vector[vector[DirectedEdgeId]]) + void init(int, vector[EdgeId], vector[TwoCut], vector[DoubleSubdivision], vector[vector[DirectedEdgeId]]) vector[size_t] getClasses() bool run() @@ -38,7 +39,8 @@ def pathToEdges(G, path): def testGroupConnectivity(G, group = "Z4", getClasses = False, - useTwoCuts = True, debug = False): + useTwoCuts = True, useDoubleSubdivisions = False, + debug = False): cdef AbstractTester* tester = NULL if group == "Z4": tester = new Tester[Z4[int]]() @@ -65,6 +67,8 @@ def testGroupConnectivity(G, group = "Z4", getClasses = False, spanningTreeEdges = [ l for (_, _, l) in spanningTree.edge_iterator() ] + + twoCuts = [] if useTwoCuts: availableEdges = set(spanningTreeEdges) @@ -95,7 +99,7 @@ def testGroupConnectivity(G, group = "Z4", getClasses = False, print "Elementary cycles: ", elemCycles print "Two cuts: ", twoCuts - tester.init(G.num_edges(), spanningTreeEdges, twoCuts, elemCycles) + tester.init(G.num_edges(), spanningTreeEdges, twoCuts, [], elemCycles) ret = tester.run() if getClasses: -- GitLab