Author: mrogers
Date: 2006-10-08 20:49:08 +0000 (Sun, 08 Oct 2006)
New Revision: 10652
Modified:
trunk/apps/load-balancing-sims/phase6/Sim.java
Log:
Kleinberg shortcuts chosen randomly with replacement
Modified: trunk/apps/load-balancing-sims/phase6/Sim.java
===================================================================
--- trunk/apps/load-balancing-sims/phase6/Sim.java 2006-10-08 20:45:38 UTC
(rev 10651)
+++ trunk/apps/load-balancing-sims/phase6/Sim.java 2006-10-08 20:49:08 UTC
(rev 10652)
@@ -47,10 +47,12 @@
norm += 1.0 / latticeDistance (0, i);
// Add DEGREE shortcuts per node, randomly with replacement
+ double outDegree = DEGREE * 0.5;
for (int i = 0; i < NODES; i++) {
- for (int j = 0; j < i; j++) {
+ for (int j = 0; j < NODES; j++) {
+ if (i == j) continue;
double p = 1.0 / latticeDistance (i, j) / norm;
- for (int k = 0; k < DEGREE; k++) {
+ for (int k = 0; k < outDegree; k++) {
if (Math.random() < p) {
nodes[i].connectBothWays
(nodes[j], LATENCY);