Efficient way to connect based on n x 2 array
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I have a vector of size n x 2 which is build up like
[a,b ; d,e ; b,f ; e,g ; ...]
what means that a is connected to b, d is connected to e, b is connected to f and so on. As a is connected to b and b is also connected to f, I want to find chains like (a,b,f,...).
As the length of the vector n is much larger than 1 million, I would like to do this in an efficient way, because just using find with loops works, but is taking a very long time. So if someone has an idea to speed it up I would be pretty happy.
BR Olli
0 comentarios
Respuestas (1)
Cam Salzberger
el 14 de Mzo. de 2019
Hello Olli,
Consider looking into various graph search algorithms, as that is exactly the field that explores "doing this efficiently". There are several functions for this built into MATLAB, and you would simply need to define the graph in the expected way.
-Cam
0 comentarios
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!