Commits

Anonymous committed d529aac

make jump-ratio and jumphalf take wraparound into account.

Comments (0)

Files changed (1)

     :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)
     :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)