From 8964a534e576c62221e8ca2e9b1445f43292735e Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 14 Sep 2022 15:30:29 +0200 Subject: Small fixes. --- rbmp.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/rbmp.cpp b/rbmp.cpp index 3c8833a..1c30528 100644 --- a/rbmp.cpp +++ b/rbmp.cpp @@ -10,6 +10,7 @@ using Rng = randutils::random_generator; +class Edge; class HalfEdge; class Vertex { @@ -23,8 +24,6 @@ public: } }; -class Edge; - class HalfEdge { private: Vertex* tail; @@ -35,10 +34,7 @@ public: double oldX; double X; - HalfEdge(const Edge& e) : edge(e) { - X = 0; - oldX = X; - } + HalfEdge(const Edge& e) : edge(e) {} void setVertices(Vertex& vt, Vertex& vh) { tail = &vt; head = &vh; @@ -89,6 +85,8 @@ public: Vertex& blueVertex = vertices[M + (i % (2 * n)) / 2 + n * (((i + 2 * n) / 4) / n)]; edges[i].setVertices(redVertex, blueVertex); edges[i].weight = r.variate(1); + edges[i].halfedges[0].oldX = r.variate(0, 1); + edges[i].halfedges[1].oldX = r.variate(0, 1); } } @@ -118,8 +116,8 @@ public: int main() { unsigned n = 100; - unsigned maxSteps = 1e7; - double beliefThreshold = 0.1; + unsigned maxSteps = 1e8; + double beliefThreshold = 1; Rng r; Graph G(n, r); @@ -132,13 +130,13 @@ int main() { steps++; } - for (unsigned i = 0; i < G.edges.size(); i++) { - if (G.edges[i].active()) { + for (const Edge& e : G.edges) { + if (e.active()) { std::cout - << G.edges[i].halfedges[0].getTail().coordinate[0] << " " - << G.edges[i].halfedges[0].getTail().coordinate[1] << " " - << G.edges[i].halfedges[0].getHead().coordinate[0] << " " - << G.edges[i].halfedges[0].getHead().coordinate[1] << std::endl; + << e.halfedges[0].getTail().coordinate[0] << " " + << e.halfedges[0].getTail().coordinate[1] << " " + << e.halfedges[0].getHead().coordinate[0] << " " + << e.halfedges[0].getHead().coordinate[1] << std::endl; } } -- cgit v1.2.3-70-g09d2