Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2298
| From | Oliver Ruebenkoenig <ruebenko@wolfram.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Strange result with FindShortestPath and Tuple |
| Date | 2011-05-12 08:33 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <iqg5vs$d2p$1@smc.vnet.net> (permalink) |
On Wed, 11 May 2011, Szabolcs Horv=E1t wrote:
> On 2011.05.10. 14:32, Julian Francis wrote:
>> 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
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Strange result with FindShortestPath and Tuple Oliver Ruebenkoenig <ruebenko@wolfram.com> - 2011-05-12 08:33 +0000 Re: Strange result with FindShortestPath and Tuple Julian Francis <julian.w.francis@gmail.com> - 2011-05-31 11:54 +0000
csiph-web