필터 지우기
필터 지우기

Rewriting graphtraverse using bfsearch/dfsearch

조회 수: 5 (최근 30일)
Dmitrii
Dmitrii 2022년 9월 28일
답변: Ayush 2023년 9월 8일
Hi, I am having trouble with rewriting graphtraverse (now deprecated) using bfsearch.
In particular, I want to make this line work with R2022b:
[D,P]=graphtraverse(G,n);
Where G is graph and n is node of interest. As I understand, function returns D -- indices of discovered nodes, and P -- indices of predecessor nodes. Ideally, i want to replace this line of code using bfsearch instead of graphtraverse so it returns same outputs.
It looks like bfsearch doesn't return predecessor indices, only discoverd nodes, judging by documentation.
Would you kindly help me to navigate this issue?
  댓글 수: 2
Lara
Lara 2022년 12월 8일
Hey, I am struggling to do the same. Have you found a solution?
Dmitrii
Dmitrii 2022년 12월 12일
Hi Lara,
Unfortunately, no. I have ended up using another solution for my project.

댓글을 달려면 로그인하십시오.

답변 (1개)

Ayush
Ayush 2023년 9월 8일
I understand that you want a list of predecessors to search a node which you want using bfssearch.
As mentioned in the following documentation https://www.mathworks.com/help/releases/R2022b/matlab/ref/graph.bfsearch.html#buofmch-1-events you can use the events to get a table of all the data like "edgetonew" using the following command
[T,E] = bfsearch(G,s,"edgetonew")
Once you get the the table "T" and Edge indices "E" you can use those to find the predecessor.
Hope this helps!
Thank you.

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by