Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #2271
| From | Julian Francis <julian.w.francis@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Strange result with FindShortestPath and Tuple |
| Date | 2011-05-10 12:32 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <iqbb9i$jne$1@smc.vnet.net> (permalink) |
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.
Thanks,
Julian Francis.
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Strange result with FindShortestPath and Tuple Julian Francis <julian.w.francis@gmail.com> - 2011-05-10 12:32 +0000 Re: Strange result with FindShortestPath and Tuple Szabolcs Horvát <szhorvat@gmail.com> - 2011-05-11 08:25 +0000
csiph-web