Commit cf31a83f authored by Radek Hušek's avatar Radek Hušek Committed by Radek Hušek
Browse files

API changes for double-subdivision optimization

parent 94184620
......@@ -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)
......@@ -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_;
......
......@@ -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:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment