summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2024-12-11 11:36:54 +0100
committerJaron Kent-Dobias <jaron@kent-dobias.com>2024-12-11 11:36:54 +0100
commit0d20da01f1e6f3718dcc7f048a5b38a703d8fd8b (patch)
treea28a2ddad062663d46f5bce456210b3e9e9df3ab
parentbd4f181a67aec822d1e420db2b12a10812b371ae (diff)
downloadcode-0d20da01f1e6f3718dcc7f048a5b38a703d8fd8b.tar.gz
code-0d20da01f1e6f3718dcc7f048a5b38a703d8fd8b.tar.bz2
code-0d20da01f1e6f3718dcc7f048a5b38a703d8fd8b.zip
Measure also the probability of being in the same cluster.
-rw-r--r--percolation.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/percolation.cpp b/percolation.cpp
index f012b07..fac04ec 100644
--- a/percolation.cpp
+++ b/percolation.cpp
@@ -189,7 +189,8 @@ int main(int argc, char* argv[]) {
std::vector<Cluster> clusters = G.markClusters(activeEdges);
Matrix laplacian = G.laplacian(activeEdges);
- std::vector<Real> conductivities(L * L * D / 4);
+ std::vector<Real> conductivities((L * L * D) / 4);
+ std::vector<unsigned> probabilities((L * L * D) / 4);
for (const Cluster& c : clusters) {
std::vector<unsigned> inds;
@@ -212,6 +213,7 @@ int main(int argc, char* argv[]) {
double ΔV = std::abs(output(i) - output(j));
conductivities[G.squaredDistance(inds[i], inds[j]) - 1] += 1 / ΔV;
+ probabilities[G.squaredDistance(inds[i], inds[j]) - 1]++;
}
}
}
@@ -224,6 +226,14 @@ int main(int argc, char* argv[]) {
}
}
std::cout << std::endl;
+ for (unsigned i = 0; i < probabilities.size(); i++) {
+ if (G.multiplicities[i] != 0) {
+ std::cout << ((Real)probabilities[i]) / G.multiplicities[i] << " ";
+ } else {
+ std::cout << 0 << " ";
+ }
+ }
+ std::cout << std::endl;
}
return 0;