Skip to main content
. Author manuscript; available in PMC: 2017 Jul 21.
Published in final edited form as: Cell Syst. 2016 Jul 21;3(1):54–61. doi: 10.1016/j.cels.2016.04.013
Algorithm 1: Calculates the neighbor distance
Require: y; μi; c
Ensure: Returns the neighbor distance, di(c).
Let i1, …, in be a permutation on 1, …, n such that, if
   ur=max{μi,ir(1yir),μi,ir(0yir)}
then u1u2 ≥ ⋯ ≥ un.
Let j1, …, jn be a permutation on 1, …, n such that, if
   lr=min{μi,jr(1yjr),μi,jr(0yjr)}
then l1l2 ≤ ⋯ ≤ ln.
Let Ur=j=1k uj and Lr=j=1k lj for k = 1, ⋯, n
Return r such that cμi · y ∈ [Lr+1, Lr) ∪ (Ur, Ur+1]