diff options
Diffstat (limited to 'order.cpp')
-rw-r--r-- | order.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/order.cpp b/order.cpp new file mode 100644 index 0000000..3ca57af --- /dev/null +++ b/order.cpp @@ -0,0 +1,55 @@ +#include <iostream> +#include <random> + +#include "rbmp.hpp" + +int main(int argc, char* argv[]) { + unsigned n = 100; + unsigned m = 100; + + int opt; + + while ((opt = getopt(argc, argv, "n:m:")) != -1) { + switch (opt) { + case 'n': + n = atoi(optarg); + break; + case 'm': + m = atoi(optarg); + break; + default: + exit(1); + } + } + + Rng r; + Graph G(n, r); + + std::vector<Coordinate> data(G.vertices.size() / 2); + + for (unsigned i = 0; i < m; i++) { + PerfectMatching pm(G.vertices.size(), G.edges.size()); + + for (const Edge& e : G.edges) { + pm.AddEdge(e.halfedges[0].getHead().index, e.halfedges[0].getTail().index, r.variate<double, std::exponential_distribution>(1)); + } + + pm.options.verbose = false; + pm.Solve(); + + for (unsigned i = 0; i < G.vertices.size() / 2; i++) { + unsigned j = pm.GetMatch(i); + + data[i] += G.vertices[i].coordinate; + data[i] -= G.vertices[j].coordinate; + } + } + + std::cout << n << std::endl; + + for (unsigned i = 0; i < G.vertices.size() / 2; i++) { + std::cout << data[i][0] << " " << data[i][1] << std::endl; + } + + return 0; +} |