From e4d86723227dc3694bf502dfd492e8c2b1887c2c Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 19 Oct 2022 17:27:59 +0200 Subject: Ran clang-format. --- hungarian.cpp | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) (limited to 'hungarian.cpp') diff --git a/hungarian.cpp b/hungarian.cpp index b8cb7ab..8c01a78 100644 --- a/hungarian.cpp +++ b/hungarian.cpp @@ -1,14 +1,14 @@ -#include #include #include -#include -#include +#include #include #include +#include #include +#include -#include "randutils/randutils.hpp" #include "pcg-cpp/include/pcg_random.hpp" +#include "randutils/randutils.hpp" using Rng = randutils::random_generator; @@ -22,11 +22,9 @@ public: std::vector> neighbors; std::array coordinate; - Vertex() : y(0), inZ(false) {}; + Vertex() : y(0), inZ(false){}; - void addEdge(Edge& e) { - neighbors.push_back(e); - } + void addEdge(Edge& e) { neighbors.push_back(e); } bool inMatching() const; }; @@ -39,14 +37,14 @@ public: double weight; bool inPath; - Edge() : orientation(false) {}; + Edge() : orientation(false){}; void setVertices(Vertex& red, Vertex& blue) { s = &red; t = &blue; red.addEdge(*this); blue.addEdge(*this); } - Vertex& tail() { + Vertex& tail() { if (orientation) { return *t; } else { @@ -74,9 +72,7 @@ public: return *t; } } - bool isTight() const { - return std::abs(s->y + t->y - weight) < 1e-13; - } + bool isTight() const { return std::abs(s->y + t->y - weight) < 1e-13; } }; bool Vertex::inMatching() const { @@ -112,11 +108,11 @@ public: void hungarian() { std::queue> q; - for (Vertex &v : T) { + for (Vertex& v : T) { v.inZ = false; } - for (Vertex &v : S) { + for (Vertex& v : S) { v.inZ = false; if (!v.inMatching()) { @@ -141,7 +137,9 @@ public: for (Vertex& v : T) { if (v.inZ && !v.inMatching()) { - std::stack>::iterator, std::vector>::iterator, unsigned>> path; + std::stack>::iterator, + std::vector>::iterator, unsigned>> + path; for (Edge& e : E) { e.inPath = false; @@ -167,7 +165,7 @@ public: if (!e.tail().inMatching()) { break; } else { - e.inPath= true; + e.inPath = true; path.push({e.tail().neighbors.begin(), e.tail().neighbors.end(), e.tail().index}); } } else { @@ -209,25 +207,23 @@ public: v.y -= Δ; } } - } } bool isPerfect() const { for (const Vertex& v : S) { if (!v.inMatching()) { - return false; + return false; } } for (const Vertex& v : T) { if (!v.inMatching()) { - return false; + return false; } } return true; } - }; int main(int argc, char* argv[]) { @@ -265,11 +261,8 @@ int main(int argc, char* argv[]) { for (const Edge& e : G.E) { if (e.orientation) { - std::cout - << e.tail().coordinate[0] << " " - << e.tail().coordinate[1] << " " - << e.head().coordinate[0] << " " - << e.head().coordinate[1] << std::endl; + std::cout << e.tail().coordinate[0] << " " << e.tail().coordinate[1] << " " + << e.head().coordinate[0] << " " << e.head().coordinate[1] << std::endl; } } -- cgit v1.2.3-70-g09d2