Very urgent Help needed..Regarding Pseudo code for graph related work

Hi everyone!

I would appreciate if I can be given some help to solve thus riddle (my project task) to find out the solution. I really need the pseudo code for this which fully solve this problem. I am really dying to solve this problem as I have been working for last two months to solve this but can't get the answer to this.

Assuming you have a graph G whose edges are labeled with the distance between each pair of vertices they connect. Given two vertices a and b in G, and a distance n as input, write an algorithm in pseudo-code to find out if there is a path from a to b with cumulative distance less than n.

I will be very much thankful for any help in this regards

Thanks in advance


  • Start at A. Label A with 0A. Go to B, label B with 0B. Keep a list of current labels in A and labels in B.

    Go to the A labels. Visit each neighbour and label distance from A, A, and preceding node in the path to A. Go to the B labels and do the same. If the neighbour is already labelled with the other tag, sum the distances. If they are below N, there's your answer.

    Terminate paths when distances go above N, or when you hit an already labelled node with a distance less than your distance.

    Read my books
    [link=] MiniBasic how to write a script interpreter [/link]
    [link=] Basic Algorithms (in C) [/link]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion