Calculating all paths from a given node in a digraph
이전 댓글 표시
Hey all,
I am using the digraph function and trying to find all paths from a given source node, i was wondering if there already exist a object function to do this such as the shortest path object functions.
As an example:

The output i would like:
[1 2 4]
[1 2 5]
[1 2 6]
[1 3 7 9]
[1 3 7 8]
댓글 수: 2
Can Chen
2020년 6월 5일
Hi Niels, I work at MathWorks on graphs. If you have a few minutes, I would very much appreciate hearing more about your workflow using paths. Would you please contact me directly? Thanks.
채택된 답변
추가 답변 (2개)
Walter Roberson
2018년 9월 4일
0 개 추천
Mathworks does not provide any function for that purpose. Perhaps the graph theory toolbox in the File Exchange?
Your text asks for "all paths", and your example is a digraph that happens to have "in degree" 1 for all nodes. In the special case of a digraph with "in degree" 1 for all nodes, then "all paths" becomes the same as all shortest path tree https://www.mathworks.com/help/matlab/ref/graph.shortestpathtree.html .
This routine will not work for cases where the in degree is more than 1, such as if node 3 also pointed to node 9: in that case the "shortest" path choices in the routine would prune out some of the paths.
댓글 수: 3
Niels de Vries
2018년 9월 4일
Walter Roberson
2018년 9월 4일
The task is more difficult if loops are possible.
Niels de Vries
2018년 9월 4일
편집: Niels de Vries
2018년 9월 4일
Pierre Harouimi
2021년 12월 29일
0 개 추천
카테고리
도움말 센터 및 File Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!