Efficient way to connect based on n x 2 array
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Cam Salzberger
2019-3-14
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!