diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2022-10-04 12:37:14 +0200 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2022-10-04 12:37:14 +0200 |
commit | 352e1be1bf05de2ba75f93b8375ac52036c8203e (patch) | |
tree | 6248835124e372f75f36160547e6f58e37111318 /order.cpp | |
parent | 1b72f7ac0adb1b2ed007ad9cfaf4e7092679e4fa (diff) | |
download | code-352e1be1bf05de2ba75f93b8375ac52036c8203e.tar.gz code-352e1be1bf05de2ba75f93b8375ac52036c8203e.tar.bz2 code-352e1be1bf05de2ba75f93b8375ac52036c8203e.zip |
Refactored base code and added new utility to measure the order paremeter.
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; +} |