Re: Strange result with FindShortestPath and Tuple
- To: mathgroup at smc.vnet.net
- Subject: [mg119357] Re: Strange result with FindShortestPath and Tuple
- From: Julian Francis <julian.w.francis at gmail.com>
- Date: Tue, 31 May 2011 07:53:51 -0400 (EDT)
- References: <iqg5vs$d2p$1@smc.vnet.net>
Dear Oliver & Szabolcs, Thanks for both of your replies. Let's hope it gets fixed in the next Mathematica release. Thanks & kind regards, Julian. On May 12, 9:33 am, Oliver Ruebenkoenig <ruebe... at wolfram.com> wrote: > On Wed, 11 May 2011, Szabolcs Horv=E1t wrote: > > On 2011.05.10. 14:32, JulianFranciswrote: > >> Dear all, > > >> I am getting a very confusing result when using Tuple to build a list > >> of vertices to be used as input to Graph (and eventually > >> FindShortestPath). However, when I use Table to build the list of > >> vertices, it all works fine. But the output of Tuple and Table produce > >> identical expressions, so why would one work and not the other? A > >> simple example may illustrate what I mean more clearly: > > >> In[1]:= vertices1 = Tuples[{Range[2], Range[2]}] > > >> Out[1]= {{1, 1}, {1, 2}, {2, 1}, {2, 2}} > > >> In[2]:= vertices2 = Flatten[Table[{x, y}, {x, 1, 2}, {y, 1, 2}], 1= ] > > >> Out[2]= {{1, 1}, {1, 2}, {2, 1}, {2, 2}} > > >> In[3]:= vertices1 === vertices2 > > >> Out[3]= True > > >> In[8]:= FindShortestPath[ > >> Graph[vertices1, {{1, 1} \[DirectedEdge] {2, 1}}, > >> VertexLabels -> "Name"], {1, 1}, {2, 1}] > > >> Out[8]= {1, 1} > > >> In[9]:= FindShortestPath[ > >> Graph[vertices2, {{1, 1} \[DirectedEdge] {2, 1}}, > >> VertexLabels -> "Name"], {1, 1}, {2, 1}] > > >> Out[9]= {{1, 1}, {2, 1}} > > >> I was expecting the last two expressions to be the same (with the last > >> one being the correct one). Why the difference? > > >> Any help would be greatly appreciated. > > > I believe this is a bug. > > > I'm replying just to mention that the difference between vertices1 and > > vertices2 is that vertices1 is a packed array: > > > Developer`PackedArrayQ[vertices1] > > > gives True. > > I reported it as bug. Thanks. > > Oliver