make jump-ratio and jumphalf take wraparound into account.
diff --git a/sim.py b/sim.py
--- a/sim.py
+++ b/sim.py
@@ -275,6 +275,13 @@ def checkjumphalf(target, prev, net):
:param targetdeviation: deviation of the link distribution at the
target from a small world distribution."""
conns = net[prev][:]
+ wrap = dist(target, prev) + 1.e-9 < abs(target - prev)
+ if wrap and prev < target:
+ target = ((prev + (target-1))/2)%1
+ elif wrap and prev > target:
+ target = (((prev-1) + (target))/2)%1
+ else:
+ target = (prev + (target))/2
target = (prev+target)/2
old = distances(prev, conns)
new = distances(target, conns)
@@ -291,7 +298,14 @@ def checkjumpratio(target, prev, net, ra
:param targetdeviation: deviation of the link distribution at the
target from a small world distribution."""
conns = net[prev][:]
- target = prev * (1-ratio) + target * ratio
+ # if the distance through the edge is shorter, go that way
+ wrap = dist(target, prev) + 1.e-9 < abs(target - prev)
+ if wrap and prev < target:
+ target = (prev * (1-ratio) + (target-1) * ratio)%1
+ elif wrap and prev > target:
+ target = ((prev-1) * (1-ratio) + target * ratio)%1
+ else:
+ target = prev * (1-ratio) + target * ratio
old = distances(prev, conns)
new = distances(target, conns)
newdev = deviationfromsmallworld(new)