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에서 Directed Graphs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!