summaryrefslogtreecommitdiff
path: root/lib/src/network.cpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-12-20 12:20:19 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-12-20 12:20:19 -0500
commit09200a607661f739782a966807d31345485e2c41 (patch)
treeb459bd995c986c87959ffd7ae99c68f9939e2009 /lib/src/network.cpp
parentb1b18ae49b0d22d3fbd5146eb6416c8b9e4dd62c (diff)
downloadfuse_networks-09200a607661f739782a966807d31345485e2c41.tar.gz
fuse_networks-09200a607661f739782a966807d31345485e2c41.tar.bz2
fuse_networks-09200a607661f739782a966807d31345485e2c41.zip
added animation example, and did many fixes to the voronoi system
Diffstat (limited to 'lib/src/network.cpp')
-rw-r--r--lib/src/network.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/src/network.cpp b/lib/src/network.cpp
index 9cb1007..4d4ed2d 100644
--- a/lib/src/network.cpp
+++ b/lib/src/network.cpp
@@ -4,14 +4,14 @@
network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.size(), false), thresholds(G.edges.size(), 1) {
b = CHOL_F(zeros)(G.vertices.size(), 1, CHOLMOD_REAL, c);
for (unsigned int i = 0; i < G.edges.size(); i++) {
- double v0y = G.vertices[G.edges[i][0]].r.y;
- double v1y = G.vertices[G.edges[i][1]].r.y;
+ double v0y = G.vertices[G.edges[i].v[0]].r.y;
+ double v1y = G.vertices[G.edges[i].v[1]].r.y;
if (fabs(v0y - v1y) > G.L.y / 2) {
bool ind = v0y < v1y ? 0 : 1;
- ((double *)b->x)[G.edges[i][ind]] += 1.0;
- ((double *)b->x)[G.edges[i][!ind]] -= 1.0;
+ ((double *)b->x)[G.edges[i].v[ind]] += 1.0;
+ ((double *)b->x)[G.edges[i].v[!ind]] -= 1.0;
}
}
@@ -30,8 +30,8 @@ network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.
unsigned int terms = G.vertices.size();
for (unsigned int i = 0; i < G.edges.size(); i++) {
- unsigned int v0 = G.edges[i][0];
- unsigned int v1 = G.edges[i][1];
+ unsigned int v0 = G.edges[i].v[0];
+ unsigned int v1 = G.edges[i].v[1];
unsigned int s0 = v0 < v1 ? v0 : v1;
unsigned int s1 = v0 < v1 ? v1 : v0;
@@ -60,11 +60,11 @@ network::network(const graph& G, cholmod_common *c) : c(c), G(G), fuses(G.edges.
for (unsigned int i = 0; i < G.edges.size(); i++) {
((CHOL_INT *)t->i)[2 * i] = i;
- ((CHOL_INT *)t->j)[2 * i] = G.edges[i][0];
+ ((CHOL_INT *)t->j)[2 * i] = G.edges[i].v[0];
((double *)t->x)[2 * i] = 1.0;
((CHOL_INT *)t->i)[2 * i + 1] = i;
- ((CHOL_INT *)t->j)[2 * i + 1] = G.edges[i][1];
+ ((CHOL_INT *)t->j)[2 * i + 1] = G.edges[i].v[1];
((double *)t->x)[2 * i + 1] = -1.0;
}
@@ -99,8 +99,8 @@ void network::set_thresholds(double beta, std::mt19937& rng) {
void network::break_edge(unsigned int e, bool unbreak) {
fuses[e] = !unbreak;
- unsigned int v0 = G.edges[e][0];
- unsigned int v1 = G.edges[e][1];
+ unsigned int v0 = G.edges[e].v[0];
+ unsigned int v1 = G.edges[e].v[1];
unsigned int n = factor->n;
@@ -141,8 +141,8 @@ void network::break_edge(unsigned int e, bool unbreak) {
if (fabs(v0y - v1y) > G.L.y / 2) {
bool ind = v0y < v1y ? unbreak : !unbreak;
- ((double *)b->x)[G.edges[e][ind]] -= 1.0;
- ((double *)b->x)[G.edges[e][!ind]] += 1.0;
+ ((double *)b->x)[G.edges[e].v[ind]] -= 1.0;
+ ((double *)b->x)[G.edges[e].v[!ind]] += 1.0;
}
}
@@ -169,8 +169,8 @@ current_info network::get_current_info() {
} else {
currents[i] = ((double *)y->x)[i];
- double v0y = G.vertices[G.edges[i][0]].r.y;
- double v1y = G.vertices[G.edges[i][1]].r.y;
+ double v0y = G.vertices[G.edges[i].v[0]].r.y;
+ double v1y = G.vertices[G.edges[i].v[1]].r.y;
if (fabs(v0y - v1y) > G.L.y / 2) {
if (v0y > v1y) {