Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Finidin the nodes of the shortest path

Subject: Finidin the nodes of the shortest path

From: Jack

Date: 18 Jun, 2010 12:26:05

Message: 1 of 1

Hi all,

I am trying to find all possible shortest paths ( the path itself not the distance) for a undirected graph for which all weights are equal. The function
 "graphshortestpath" gives only one possible shortest path between any two nodes while there may be many. How can I find the rest??
For my data, I have 64-node undirected graph for which the shortest path between nodes 1 and 3:

[dist,path,pred] = graphshortestpath(UG,1,3,'directed',false);
path = 1 7 55 3

and funny enough if you try to exchange the nodes you get another possible root for the shortest path betwen nodes 1 and 3.

[dist,path,pred] = graphshortestpath(UG,3,1,'directed',false);
path = 3 13 61 1

I'll come back with a whole code if needed.
Any ideas please?
Many thanks

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us