Searching for indices of rows in a matrix with 10 million rows

1 view (last 30 days)
I have a matrix with few million unique rows (let's call the number of rows n) and 7 columns. Each row respresents an ID and is (directionally) related to another ~ 10 rows. The relation is specified through some known operation on the row. I want to end up with a matrix with two columns where each row contains the indices of the rows in the original matrix which are related. However, this needs ~(n x 10) lookups in a matrix of size n which makes things pretty slow. I tried using hashmaps (quite uninitiated there) but MATLAB won't let me create a cell of size n which I intend to use as a set of keys. Is there a way to do this? Below is a representative example showing the input and desired output.
Input matrix:
[ 1 1 0;
0 1 1;
0 0 2;
1 0 1]
and let's assume (1 1 0) is related to (0 1 1) and (0 1 1), (0 1 1) to (0 0 2), (0 0 2) to (1 1 0) and (1 0 1) to (0 0 2).
The output then should be
[1 2;
1 3;
2 3;
3 4;
4 1]
  2 Comments
Luna
Luna on 7 Feb 2019
What is the relation? How did you decide (1 1 0) is related to (0 1 1) and (0 1 1) ?
I recommend you to read about: Tall Arrays
Sounak Kar
Sounak Kar on 7 Feb 2019
Thanks for the link, Luna. I think this is relevant but I'm particularly looking for efficient row search in tall arrays.
The relation is determined by a given rule. In this case, I just know that (i, j, k) is related to (i-1, j, k+1) and (i, j-1, k+1) when i>0 and j>0. But I would say I'm more concerned with searching for a row in a tall array.

Sign in to comment.

Answers (0)

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!