From 352e1be1bf05de2ba75f93b8375ac52036c8203e Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 4 Oct 2022 12:37:14 +0200 Subject: Refactored base code and added new utility to measure the order paremeter. --- order.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 order.cpp (limited to 'order.cpp') 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 +#include + +#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 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(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; +} -- cgit v1.2.3-54-g00ecf