How to find all possible paths between two nodes in a 246 nodes system.

4 vues (au cours des 30 derniers jours)
raj singh
raj singh le 31 Mai 2016
Commenté : Walter Roberson le 31 Mai 2016
ld=[1 2 2; 1 3 2; 1 4 3; 2 3 3; 3 4 2; 4 5 4; 4 6 4; 5 6 3];
first two column represent edge (node connectivity) of graph and third column represent distance between that line. For example: I want to know all paths from 3 to 4.
My answer will be :
[3 4]
[3 1 4]
[3 2 1 4]
Please help me to solve this. I already use Dijkstra algorithm but Dijkstra algorithm is in xy plane or xyz plane, which is not like my problem.
  1 commentaire
John BG
John BG le 31 Mai 2016
the column on the right is distance, so for the matrix example you can check whether there is a path defined between 3 and 4 with:
intersect(find(A(:,1)==3),find(A(:,1)==4))
Empty matrix: 0-by-1
If you allow the matrix to have multiple hops between start and stop nodes, then you may want to use a cell instead of a array of integers, because while a line may have just 2 nodes, the start and stop, next line may have for instance 20 hops between start and stop.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 31 Mai 2016
  2 commentaires
raj singh
raj singh le 31 Mai 2016
There is no solution as given in your link.........
Walter Roberson
Walter Roberson le 31 Mai 2016
Incorrect. That code has no built-in limits other than those imposed by MATLAB and the amount of memory you have available.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by