summaryrefslogtreecommitdiff
path: root/lib/src/graph.cpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2019-09-23 23:19:13 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2019-09-23 23:19:13 -0400
commit3f7f20f21f583ca2de566bea08a87eac4b17ad29 (patch)
treeea55b8f42f797653ed2bac21ad0bf57bf95068f5 /lib/src/graph.cpp
parent9e3726c6c7762f6292333f85117546acc01f5568 (diff)
downloadfuse_networks-3f7f20f21f583ca2de566bea08a87eac4b17ad29.tar.gz
fuse_networks-3f7f20f21f583ca2de566bea08a87eac4b17ad29.tar.bz2
fuse_networks-3f7f20f21f583ca2de566bea08a87eac4b17ad29.zip
successfully implemented the backbone trimming with homespun graph algorithms, measurements have mostly been disabled and need to be migrated
Diffstat (limited to 'lib/src/graph.cpp')
-rw-r--r--lib/src/graph.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/src/graph.cpp b/lib/src/graph.cpp
index bfdb952..a5063de 100644
--- a/lib/src/graph.cpp
+++ b/lib/src/graph.cpp
@@ -44,7 +44,7 @@ graph::graph(unsigned Nx, unsigned Ny) {
dual_vertices[i].r.x = (double)((i / (Nx / 2)) % 2 + 2 * (i % (Nx / 2)));
dual_vertices[i].r.y = (double)(i / (Nx / 2));
- dual_vertices[i].nd = {i, (i + Nx / 2) % nv, Nx * (i / (Nx / 2)) + (i % (Nx / 2)), (nv + i - Nx / 2) % nv};
+ dual_vertices[i].nd = {i, (i + Nx / 2) % nv, Nx / 2 * (i / (Nx / 2)) + ((i + f) % (Nx / 2)), (nv + i - Nx / 2) % nv};
dual_vertices[i].polygon = {
{dual_vertices[i].r.x - 1.0, vertices[i].r.y},
{dual_vertices[i].r.x, vertices[i].r.y - 1.0},
@@ -93,6 +93,16 @@ graph::graph(unsigned Nx, unsigned Ny) {
}
}
+ for (vertex& v : dual_vertices) {
+ v.ne.reserve(v.nd.size());
+ }
+
+ for (unsigned i = 0; i < dual_edges.size(); i++) {
+ for (unsigned vi : dual_edges[i].v) {
+ dual_vertices[vi].ne.push_back(i);
+ }
+ }
+
}
class eulerException: public std::exception
@@ -411,6 +421,16 @@ void graph::helper(unsigned nv, std::mt19937& rng) {
}
}
+ for (vertex& v : dual_vertices) {
+ v.ne.reserve(v.nd.size());
+ }
+
+ for (unsigned i = 0; i < dual_edges.size(); i++) {
+ for (unsigned vi : dual_edges[i].v) {
+ dual_vertices[vi].ne.push_back(i);
+ }
+ }
+
jcv_diagram_free(&diagram);
}