summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rbmp.cpp26
1 files 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<pcg32>;
+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<double, std::exponential_distribution>(1);
+ edges[i].halfedges[0].oldX = r.variate<double, std::normal_distribution>(0, 1);
+ edges[i].halfedges[1].oldX = r.variate<double, std::normal_distribution>(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;
}
}