Hello!
I am using CellListMap to generate a neighbour list of the type:
ListOfPairs =
(1,4,0.04)
(1,3,0.02)
(1,8,0.09)
(2,1,0.01)
(2,4,0.05)
Where first index is “i”, second index is “j” and third index is the euclidean distance between “i” and “j”. My questions is then, how do I go in the fastest way from an vector of pairs to vector of indices:
ListOfIndices=
[1 4 3 8]
[2 1 4]
Where the array “[1 4 3 8]” would be understood as “particle with index 1 has neighbours 4 3 8” and the second array as “particle with index 2 has neighbours 1 4”
For now I can live with “losing” the information about euclidean distance, I just want to extract the indices in the second format. Currenly the code I use in a slightly pseudo code format:
i == 1
ListOfIndices_ = list[map(x->x[1]==i || x[2]==i,ListOfPairs)]
ListOfIndices[i] = [i;unique([getfield.(l,1);getfield.(l,2)])]
Which for a ListOfPairs of ~17000 elements roughly takes 0.10 seconds. I wish to get it down further.
@lmiq sorry if not okay to tag you. Since you are the developer of the package I imagined you might already have such a function - and thank you for making the package, it really helps me out
Kind regards