- We’ll create a matrix to represent the grid, where each cell represents a node.
- Initialize the first row and first column with 1 (since there’s only one way to reach any cell in the first row or column).
- For each cell (except the first row and first column), the number of ways to reach it is the sum of the ways to reach the cell above it and the cell to its left.
- Finally, the value in the last cell (B) will give you the total number of paths from A to B.
- We can then backtrack to find all the paths.
find all pathbetween 2 node under constraint
2 ビュー (過去 30 日間)
古いコメントを表示
hey
i want to find all path between A to B ( start from left buttom)
i have tryed to use meshgrid and allpath command without succses
the constraint are the i can go right or up only
also, i need to write code that calculates the probability on each node to go up or right if given that all route is equal probability
i will appreciate hint how to write my code and which commands to use
here is the mesh
0 件のコメント
回答 (1 件)
Pratik
2024 年 6 月 11 日
Hi Shalom,
From what I can understand, we need to find all possible upward or rightward paths from the bottom-left corner to the top-right corner of a grid, and to calculate the probability of choosing to move right or up at any node, assuming each path is equally likely.
The problem can be approached using dynamic programming,
I hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および 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!