Efficient way to connect based on n x 2 array

1 vue (au cours des 30 derniers jours)
Oliver Köhn
Oliver Köhn le 14 Mar 2019
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

Réponses (1)

Cam Salzberger
Cam Salzberger le 14 Mar 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

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by