MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

GraphPath With Edge Weights

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126646] GraphPath With Edge Weights
  • From: Ben <benp84 at gmail.com>
  • Date: Mon, 28 May 2012 05:12:02 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

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.



  • Prev by Date: Print TraditionalForm
  • Next by Date: Re: Sqrt of complex number
  • Previous by thread: Re: Print TraditionalForm
  • Next by thread: Re: GraphPath With Edge Weights