Questions tagged [neighbours]

166 questions
27
votes
5 answers

Connected Component Labeling - Implementation

I have asked a similar question some days ago, but I have yet to find an efficient way of solving my problem. I'm developing a simple console game, and I have a 2D array like this: 1,0,0,0,1 1,1,0,1,1 0,1,0,0,1 1,1,1,1,0 0,0,0,1,0 I am trying to…
user1981497
21
votes
5 answers

Spatial Data Structures for moving objects?

I was wondering what is the best data structure to deal with a lot of moving objects(spheres, triangles, boxes, points, etc)? I'm trying to answer two questions, Nearest Neighbor and Collsion detection. I do realize that traditionally, data…
esiegel
  • 1,773
  • 2
  • 19
  • 31
11
votes
4 answers

Average neighbours inside a vector

My data : data <- c(1,5,11,15,24,31,32,65) There are 2 neighbours: 31 and 32. I wish to remove them and keep only the mean value (e.g. 31.5), in such a way data would be : data <- c(1,5,11,15,24,31.5,65) It seems simple, but I wish to do it…
Loulou
  • 703
  • 5
  • 17
10
votes
7 answers

Generating 'neighbours' for users based on rating

I'm looking for techniques to generate 'neighbours' (people with similar taste) for users on a site I am working on; something similar to the way last.fm works. Currently, I have a compatibilty function for users which could come into play. It ranks…
Austin Platt
  • 119
  • 5
8
votes
4 answers

How to check efficiently if two characters are neighbours on the keyboard?

I want to develop a soft keyboard for Android and already got a autocorrect algorithm which makes suggestions based on the fact if the input character and the character of a word from the dictionary are neighbours on the keyboard. This works in…
Philipp
  • 711
  • 5
  • 15
6
votes
2 answers

Determine adjacent regions in numpy array

I am looking for the following. I have a numpy array which is labeled as regions. The numpy array represents a segmented image. A region is a number of adjacent cells with the same value. Each region has its own unique value. A simplified version…
cf2
  • 581
  • 1
  • 7
  • 17
5
votes
1 answer

Find optimal unique neighbour pairs based on closest distance

General problem First let's explain the problem more generally. I have a collection of points with x,y coordinates and want to find the optimal unique neighbour pairs such that the distance between the neighbours in all pairs is minimised, but…
crazjo
  • 485
  • 1
  • 8
  • 20
5
votes
2 answers

CakePHP: find neighbors, order on 'name' or 'order'

I have a list of ordered items, ordered according to the int field order. I'm creating a gallery in CakePHP 1.2 that has a prev and next button and those should link to the previous and next item according to their ordering, not according to their…
Bart Gloudemans
  • 1,201
  • 12
  • 27
5
votes
2 answers

quickest way to calculate neighbourhood of pixels

I have a matrix which consists of positive and negative values. I need to do these things. Let u(i,j) denote the pixels of the matrix u. Calculate the zero crossing pixels. These are the pixels in the grid if u(i-1,j) and u(i+1,j) are of opposite…
roni
  • 1,443
  • 3
  • 28
  • 49
4
votes
3 answers

R gis: add polygon attribute based on neighbors value?

I have a set of forest stands (SpatialPolygonDataFrame) distributed randomly over the landscape, i.e. dispersed and aggregated. For each polygon, I want to decide if it has an open edge or not. Polygon has open edge if: has no neighbors has no…
maycca
  • 3,848
  • 5
  • 36
  • 67
4
votes
4 answers

numpy sliding 2d window calculations

I'm trying to learn a way to use numpy to efficiently solve problems that involve a sliding window in a variety of circumstances. Here is an example illustrating the type of problem I'm interested in: I have a large 2d matrix, and I'd like to…
Andrew Hundt
  • 2,551
  • 2
  • 32
  • 64
4
votes
2 answers

neighbors function in igraph package in R

First of all I want to say that I already read answers for the question: "issues with R “igraph” package neighbor function" and I tried to solve my problem but I couldn't. I tried to ask my question as follow up comment but because of low level of…
tolou
  • 53
  • 2
  • 6
4
votes
2 answers

Calculate the neighbourhood inside or outside of a region

I have a problem in MATLAB as follows: Suppose I have a matrix like given below. What I want to do is calculate the average values of the pixels given in yellow. (ans is 108) This will be calculated if the option given is outside. On the other hand…
roni
  • 1,443
  • 3
  • 28
  • 49
3
votes
2 answers

Python - Networkx: Neighbours with certain weight

This question setting is python 2.7 using the package networkx: https://networkx.github.io/documentation/stable/reference/classes/generated/networkx.Graph.neighbors.html I'm looking for a way to use the function "networkx.Graph.neighbors" which…
Tim D
  • 111
  • 1
  • 2
  • 7
3
votes
0 answers

Collecting neighbors in Spark Graphframes

I have an un-directed graph. Is there any efficient function to collect direct neighbors of specific vertex Id using Spark Graphframes? (This feature is available in GraphX [link]) If yes, how can we achieve neighbors of level 2, 3 and ... (It means…
MohsenIT
  • 304
  • 4
  • 10
1
2 3
11 12