summaryrefslogtreecommitdiff
path: root/lib/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/graph.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/lib/src/graph.cpp b/lib/src/graph.cpp
index c6f0ba6..b42aa78 100644
--- a/lib/src/graph.cpp
+++ b/lib/src/graph.cpp
@@ -7,11 +7,11 @@ graph_t::graph_t(D_t D, L_t L, lattice_t lat) {
nv = pow(L, D);
ne = D * nv;
- v_adj.resize(nv);
+ adj.resize(nv);
coordinate.resize(nv);
- for (std::vector<v_t> v_adj_i : v_adj) {
- v_adj_i.reserve(2 * D);
+ for (std::vector<v_t> adj_i : adj) {
+ adj_i.reserve(2 * D);
}
for (v_t i = 0; i < nv; i++) {
@@ -19,21 +19,21 @@ graph_t::graph_t(D_t D, L_t L, lattice_t lat) {
for (D_t j = 0; j < D; j++) {
coordinate[i][j] = (i / (v_t)pow(L, D - j - 1)) % L;
- v_adj[i].push_back(pow(L, j + 1) * (i / ((v_t)pow(L, j + 1))) + fmod(i + pow(L, j), pow(L, j + 1)));
- v_adj[i].push_back(pow(L, j + 1) * (i / ((v_t)pow(L, j + 1))) + fmod(pow(L, j+1) + i - pow(L, j), pow(L, j + 1)));
+ adj[i].push_back(pow(L, j + 1) * (i / ((v_t)pow(L, j + 1))) + fmod(i + pow(L, j), pow(L, j + 1)));
+ adj[i].push_back(pow(L, j + 1) * (i / ((v_t)pow(L, j + 1))) + fmod(pow(L, j+1) + i - pow(L, j), pow(L, j + 1)));
}
}
break;
}
case DIAGONAL_LATTICE: {
nv = D * pow(L, D);
- ne = D * nv;
+ ne = 2 * nv;
- v_adj.resize(nv);
+ adj.resize(nv);
coordinate.resize(nv);
- for (std::vector<v_t> v_adj_i : v_adj) {
- v_adj_i.reserve(4 * (D - 1));
+ for (std::vector<v_t> adj_i : adj) {
+ adj_i.reserve(4 * (D - 1));
}
for (D_t i = 0; i < D; i++) {
@@ -42,10 +42,10 @@ graph_t::graph_t(D_t D, L_t L, lattice_t lat) {
for (v_t j = 0; j < pow(L, D); j++) {
v_t vc = sb + j;
- v_adj[vc].push_back(((i + 1) % D) * pow(L, D) + j);
- v_adj[vc].push_back(((i + 1) % D) * pow(L, D) + pow(L, D - 1) * (j / (v_t)pow(L, D - 1)) + (j + 1 - 2 * (i % 2)) % L);
- v_adj[vc].push_back(((i + 1) % D) * pow(L, D) + pow(L, D - 1) * ((L + (j/ (v_t)pow(L, D - 1)) - 1 + 2 * (i % 2)) % L) + (j - i) % L);
- v_adj[vc].push_back(((i + 1) % D) * pow(L, D) + pow(L, D - 1) * ((L + (j/ (v_t)pow(L, D - 1)) - 1 + 2 * (i % 2)) % L) + (j + 1 - i) % L);
+ adj[vc].push_back(((i + 1) % D) * pow(L, D) + j);
+ adj[vc].push_back(((i + 1) % D) * pow(L, D) + pow(L, D - 1) * (j / (v_t)pow(L, D - 1)) + (j + 1 - 2 * (i % 2)) % L);
+ adj[vc].push_back(((i + 1) % D) * pow(L, D) + pow(L, D - 1) * ((L + (j/ (v_t)pow(L, D - 1)) - 1 + 2 * (i % 2)) % L) + (j - i) % L);
+ adj[vc].push_back(((i + 1) % D) * pow(L, D) + pow(L, D - 1) * ((L + (j/ (v_t)pow(L, D - 1)) - 1 + 2 * (i % 2)) % L) + (j + 1 - i) % L);
}
}
break;
@@ -54,16 +54,16 @@ graph_t::graph_t(D_t D, L_t L, lattice_t lat) {
}
void graph_t::add_ext() {
- for (std::vector<v_t>& v_adj_i : v_adj) {
- v_adj_i.push_back(nv);
+ for (std::vector<v_t>& adj_i : adj) {
+ adj_i.push_back(nv);
}
- v_adj.resize(nv + 1);
+ adj.resize(nv + 1);
coordinate.resize(nv + 1);
- v_adj[nv].reserve(nv);
+ adj[nv].reserve(nv);
for (v_t i = 0; i < nv; i++) {
- v_adj[nv].push_back(i);
+ adj[nv].push_back(i);
}
coordinate[nv].resize(coordinate[0].size());