GraphPath With Edge Weights

  • Follow


I can't figure out how to compute a shortest path using GraphPath with
edge weights. I first define a graph as follows.

graph = Graph[{UndirectedEdge[1,2], UndirectedEdge[2,3],
UndirectedEdge[3,1]}, EdgeWeight->{1, 2, 9}]

After loading GraphUtilities I compute GraphDistance[graph, 1, 3] and
it correctly returns the shortest path distance of 3 corresponding to
the path {1, 2, 3}.  But if I compute GraphPath[graph, 1, 3] it
returns the unweighted shortest path {1, 3}. Even if I use
GraphPath[graph, 1, 3, Weighted->True] it still returns the same
answer of {1, 3}. (Weighted is supposed be True by default anyway.)
What am I doing wrong?

Thanks.

0
Reply benp84 (6) 5/28/2012 9:14:05 AM


0 Replies
29 Views

(page loaded in 0.247 seconds)


Reply: