Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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 comentario
John BG
John BG el 31 de Mayo de 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.

Iniciar sesión para comentar.

Respuestas (1)

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

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by