if minimum distance is specified, ensure node is not too close to other nodes;
778875
def nodes_minimum_distance_validation(self):
    
    if self.layer and self.layer.nodes_minimum_distance:
        minimum_distance = self.layer.nodes_minimum_distance
        # TODO - lower priority: do this check only when coordinates are changing
        near_nodes = Node.objects.exclude(pk=self.id).filter(geometry__distance_lte=(self.geometry, D(m=minimum_distance))).count()
        if near_nodes > 0:
            raise ValidationError(_('Distance between nodes cannot be less than %s meters') % minimum_distance)
1174769
function(node, l, b, r, t)
{
    return (max(node.bb_r, r) - min(node.bb_l, l))*(max(node.bb_t, t) - min(node.bb_b, b));
}
734285
function closest (el, sel) {
  if (!el) return
  if (matches(el, sel)) {
    return el
  } else {
    return closest(el.parentNode, sel)
  }
}
985647
def prune_if_smaller_than(self, small_size, a_or_u):
        ""
        if self._prune_all_if_small(small_size, a_or_u):
            return

        for node in self._nodes:
            node.prune_if_smaller_than(small_size, a_or_u)

        self._prune_some_if_small(small_size, a_or_u)
667478
def _in_bounds(prop, instance, value):
    """"""
    if (
            (prop.min is not None and value < prop.min) or
            (prop.max is not None and value > prop.max)
    ):
        prop.error(instance, value, extra='Not within allowed range.')
844819
@Override
	public void findNeighbor(P target, int searchN, FastQueue<KdTreeResult> results) {
		if( searchN <= 0 )
			throw new IllegalArgumentException("I'm sorry, but I refuse to search for less than or equal to 0 neighbors.");

		if( tree.root == null )
			return;

		this.searchN = searchN;
		this.target = target;
		this.mostDistantNeighborSq = maxDistanceSq;

		stepClosest(tree.root,results);
	}
685209
function getCoefedDistance(box1, box2) {
            var xMin, xMax, yMin, yMax, xDist, yDist, dist, cx, cy;
            xMin = min(box1.left, box2.left);
            xMax = max(box1.right, box2.right);
            yMin = min(box1.top, box2.top);
            yMax = max(box1.bottom, box2.bottom);

            xDist = xMax - xMin - box1.width - box2.width;
            yDist = yMax - yMin - box1.height - box2.height;

            if (xDist < 0) dist = yDist;
            else if (yDist < 0) dist = xDist;
            else dist = sqrt(xDist * xDist + yDist * yDist);

            var node1 = box1.node;
            var node2 = box2.node;

            // sibling
            if (node1.parent == node2.parent) {
                dist /= 10;
            }
            // parent
            if (node2.parent == node1) {
                dist /= 5;
            }

            return dist;
        }
1341039
def distance_to(self, other):
        """"""
        return np.linalg.norm(self.position-other.position)
1221502
function lub(tree, node, key, comp, high) {
    if (node === tree.z) {
        return high;
    }
    else if (comp(key, node.key) <= 0) {
        // The node key is a valid upper bound, but may not be the least.
        return minNode(node, lub(tree, node.l, key, comp, high), comp);
    }
    else {
        // Take the right link in search of bigger keys.
        return lub(tree, node.r, key, comp, high);
    }
}
150372
def collapse_nodes(self, min_dist=1e-6, min_support=0):
        
        nself = self.copy()
        for node in nself.treenode.traverse():
            if not node.is_leaf():
                if (node.dist <= min_dist) | (node.support < min_support):
                    node.delete()
        nself._coords.update()
        return nself
615877
function(){

            this._distanceConstraints = Physics.util.shuffle( this._distanceConstraints );
            this._angleConstraints = Physics.util.shuffle( this._angleConstraints );
        }
1038797
public static void limitDistance(DenseMatrix64F p0, DenseMatrix64F pr, double min, double max)
    {
        double x0 = p0.data[0];
        double y0 = p0.data[1];
        double xr = pr.data[0];
        double yr = pr.data[1];
        double dx = xr-x0;
        double dy = yr-y0;
        double r = Math.sqrt(dx*dx+dy*dy);
        if (r < min || r > max)
        {
            if (r < min)
            {
                r = min;
            }
            else
            {
                r = max;
            }
            double m = dy/dx;
            if (Double.isInfinite(m))
            {
                if (m > 0)
                {
                    pr.data[1] = y0 +  r;
                }
                else
                {
                    pr.data[1] = y0 -  r;
                }
            }
            else
            {
                double x = Math.sqrt((r*r)/(m*m+1));
                double y = m*x;
                pr.data[0] = x0 +  x;
                pr.data[1] = y0 +  y;
            }
        }
    }
748614
def surrounding_nodes(self, position):
        

        n_node_index, n_node_position, n_node_error = self.nearest_node(position)

        if n_node_error == 0.0:

            index_mod = []

            for i in range(len(n_node_index)):

                new_point = np.asarray(n_node_position)
                new_point[i] += 1.e-5*np.abs(new_point[i])

                try:
                    self.nearest_node(tuple(new_point))
                    index_mod.append(-1)
                except ValueError:
                    index_mod.append(1)

        else:
            # Check if node_position is larger or smaller in resp. axes than position

            index_mod = []

            for i in range(len(n_node_index)):
                if n_node_position[i] > position[i]:
                    index_mod.append(-1)
                else:
                    index_mod.append(1)

        return tuple(n_node_index), tuple(index_mod)
301946
def in_constraint(self, node1, node2):
        """"""
        constraint = constraint_table[node2]
        if constraint == 0b0:
            return False

        try:
            value = self.el2bv[node1]
        except KeyError:
            return False

        return constraint & value != 0
585453
def neighbors(self, node_id):
        """"""
        node = self.get_node(node_id)
        flattened_nodes_list = []
        for a, b in [self.get_edge(edge_id)['vertices'] for edge_id in node['edges']]:
            flattened_nodes_list.append(a)
            flattened_nodes_list.append(b)
        node_set = set(flattened_nodes_list)
        if node_id in node_set:
            node_set.remove(node_id)
        return [nid for nid in node_set]
1122494
def __distance_valid(self, g0, g1, p):
        
        dist = np.sqrt((g1.x - g0.x) ** 2 +
                    (g1.y - g0.y) ** 2)
        return dist >= p.min_separation
806590
private void markNeighbor( TriangulationPoint p1, 
                               TriangulationPoint p2, 
                               DelaunayTriangle t )
    {
        if( ( p1 == points[2] && p2 == points[1] ) || ( p1 == points[1] && p2 == points[2] ) )
        {
            neighbors[0] = t;
        }
        else if( ( p1 == points[0] && p2 == points[2] ) || ( p1 == points[2] && p2 == points[0] ) )
        {
            neighbors[1] = t;
        }
        else if( ( p1 == points[0] && p2 == points[1] ) || ( p1 == points[1] && p2 == points[0] ) )
        {
            neighbors[2] = t;
        }
        else
        {
            logger.error( "Neighbor error, please report!" );
            // throw new Exception("Neighbor error, please report!");
        }
    }