I have a image in
here i want to find the shorted path between 2 nodes ,say node 1 and node 4,there are twopaths
1-5-4 and 1-5-3-4
can anyone tell how to find these two paths and find the shortest among them
[dist,path,pred] = graphshortestpath(UG,1,3,'directed',false);
it gives only one path i.e shortest path,i need all paths from node 1 to 4
No products are associated with this question.
you can use graphshortestpath http://www.mathworks.com/help/bioinfo/ref/graphshortestpath.html
Follow the procedure I indicated in that other thread, as many times as necessary, each time getting one step closer to the destination.
There are two different ways you can proceed:
The first option, predicting the complete path and having each node required to follow it, runs the risk that a node will become unavailable, leaving it undefined how the packet should continue. The second option, continually predicting the path along the way, runs the risk that based on the path information as known to the receiving node, the packet will be sent to a node that has already handled it in the trip (possibly right back to the node that just send it here), potentially resulting in an infinite loop for the packet.
Both of these are classic routing problems in networking, and there is no solution that guarantees delivery or shortest delivery. There have been a number of routing protocols invented to work with these problems, with trade-offs necessarily taken. You need to investigate routing protocols and decide which one you are going to use.
Play games and win prizes!Learn more