Returns the number of live neighbours.
172896
def liveNeighbours(self, z, y, x):
        """"""
        count = 0

        for oz, oy, ox in self.offsets:
            cz, cy, cx = z + oz, y + oy, x + ox
            if cz >= self.depth:
                cz = 0
            if cy >= self.height:
                cy = 0
            if cx >= self.width:
                cx = 0
            count += self.table[cz][cy][cx]

        # if self.toroidal:
        #     if y == 0:
        #         if self.table[self.height - 1][x]:
        #             count = count + 1
        #     if y == self.height - 1:
        #         if self.table[0][x]:
        #             count = count + 1
        #     if x == 0:
        #         if self.table[y][self.width - 1]:
        #             count = count + 1
        #     if x == self.width - 1:
        #         if self.table[y][0]:
        #             count = count + 1

        return count
144639
def count_relations(graph) -> Counter:
    
    return Counter(
        data[RELATION]
        for _, _, data in graph.edges(data=True)
    )
1263445
def remove_neighbours(self):
        
        time_delta = 1 << (2*(IntervalSet.HPY_MAX_ORDER - self.max_order))

        intervals_arr = self._interval_set._intervals
        intervals_arr[:, 0] = np.minimum(intervals_arr[:, 0] + time_delta, (1 << 58) - 1)
        intervals_arr[:, 1] = np.maximum(intervals_arr[:, 1] - time_delta, 0)

        good_intervals = intervals_arr[:, 1] > intervals_arr[:, 0]

        self._interval_set = IntervalSet(intervals_arr[good_intervals])
163837
public int countForeignHosts() {
        int retval = 0;
        for (ForeignHost host : m_foreignHosts.values()) {
            if ((host != null) && (host.isUp())) {
                retval++;
            }
        }
        return retval;
    }
394167
def update_cell(self, row, col):
        
        # compute number of living neighbors
        neighbors = self.eight_neighbors(row, col)
        living_neighbors = 0
        for neighbor in neighbors:
            if not self.is_empty(neighbor[0], neighbor[1]):
                living_neighbors += 1
            
        # logic for Game of life        
        if (living_neighbors == 3) or (living_neighbors == 2 and not self.is_empty(row, col)):
            return mod_grid.FULL
        else:
            return mod_grid.EMPTY
1172687
def find_neighbors(self, grid, node, diagonal_movement=None):
        '''
        
        '''
        if not diagonal_movement:
            diagonal_movement = self.diagonal_movement
        return grid.neighbors(node, diagonal_movement=diagonal_movement)
95988
def count(self):
        
        return functools.reduce(lambda x, y: x * y, (x.count for x in self.bounds))
169387
def neighbors(self):
        '''
        
        '''
        if len(self._sentence) == 1:
            return {
                'left': None,
                'right': None
            }
        else:
            p = self._position
            if -1 < p < len(self._sentence):
                if 0 == self._position:
                    return {
                        'left': None,
                        'right': self._sentence.word(p+1)
                    }
                elif 0 < self._position < len(self._sentence) - 1:
                    return {
                        'left':  self._sentence.word(p-1),
                        'right': self._sentence.word(p+1)
                    }
                else:
                    return {
                        'left': self._sentence.word(p-1),
                        'right': None
                    }
            else:
                raise IndexError()
1026345
def neighbors(self, obj):
        
        neighbors = set([])
        
        for e in self.node_links[obj]:
            neighbors.update(set(self.edge_links[e]))
        
        return list(neighbors - set([obj]))
223278
def neighbors(self, subid, params=None):
        ''' 
        '''
        params = update_params(params, {'SUBID': subid})
        return self.request('/v1/server/neighbors', params, 'GET')
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]
679933
def _get_connected_subgraphs(vertices, vertices_neighbours):
    
    remaining_vertices = set(vertices)
    subgraphs = []
    while remaining_vertices:
        subgraph = set(_dfs(remaining_vertices.pop(), vertices_neighbours))
        remaining_vertices.difference_update(subgraph)
        subgraphs.append(subgraph)

    return subgraphs
264968
def get_listener_count(self):
        """"""

        if hasattr(self, "listener_count"):
            return self.listener_count
        else:
            self.listener_count = _number(
                _extract(self._request(self.ws_prefix + ".getInfo", True), "listeners")
            )
            return self.listener_count
483214
def count(self):
        ""
        return self.rpc_model.search_count(
            self.domain, context=self.context
        )
648900
def count(self):
        
        actions = self._actionGroup.actions()
        if len(actions) == 1 and actions[0].objectName() == 'place_holder':
            return 0
        
        return len(actions)
933648
int[][] findNeighborIndices() {

		// looking at a typical protein case, number of neighbours are from ~10 to ~50, with an average of ~30
		int initialCapacity = 60;

		int[][] nbsIndices = new int[atomCoords.length][];

		for (int k=0; k<atomCoords.length; k++) {
			double radius = radii[k] + probe + probe;

			List<Integer> thisNbIndices = new ArrayList<>(initialCapacity);

			for (int i = 0; i < atomCoords.length; i++) {
				if (i == k) continue;

				double dist = atomCoords[i].distance(atomCoords[k]);

				if (dist < radius + radii[i]) {
					thisNbIndices.add(i);
				}
			}

			int[] indicesArray = new int[thisNbIndices.size()];
			for (int i=0;i<thisNbIndices.size();i++) indicesArray[i] = thisNbIndices.get(i);
			nbsIndices[k] = indicesArray;
		}
		return nbsIndices;
	}
928796
public final int getLiveSegmentCount() {
        int num = 0;

        for (int i = 0; i < _segList.size(); i++) {
            if (_segList.get(i) != null)
                num++;
        }

        return num;
    }