0
votes

I have a graph with weighted paths I need to get the path from nodes to each other with the cumulative weight. The graph for adjacent nodes and the weights to them is below {"hop":{"S3":1,"S4":2,"S2":2},"S4":{"pop":1},"S1":{"hop":1},"S2":{"S1":2,"S4":10},"pop":{"S1":1,"S3":8},"S3":{}}

For eg: The result for a Path from S1 to S3 would be S1 -> hop -> S3 = 2.

Look at the Depth First Search or Breadth First Search to find path, then traverse and sum weights. - K.Mat
Stack Overflow will not do your homework for you. We will help you, but you have to make some sort of effort on your own, first. - Frank Yellin