Searching for indices of rows in a matrix with 10 million rows
1 view (last 30 days)
Show older comments
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
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
Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!