Re: CostOfPath
- To: mathgroup at smc.vnet.net
- Subject: [mg62491] Re: [mg62481] CostOfPath
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sat, 26 Nov 2005 02:46:40 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 25 Nov 2005, at 16:25, Bart De Vylder wrote: > > > Can anybody explain the following? > > << DiscreteMath`Combinatorica`; > gr = FromOrderedPairs[{{2, 1}}]; > CostOfPath[gr, {2, 1}] > > Out[]= ° (infinity) > > I would expect 1 as answer. > CostOfPath seems to give correct answers only for undirected graphs. Thus gr = FromOrderedPairs[{{2, 1}},Type->Undirected]; CostOfPath[gr, {2, 1}] 1 It will give the same answer in the case of a "bi-directed" graph, e.g. hr = FromOrderedPairs[{{2, 1},{1,2}}]; CostOfPath[hr, {2, 1}] 1 It seems that edges with only one direction are counted as "impassable", and hence the answer Infinity. I don't have my copy of Pemmaraju and Skiena book within reach (it is currently on a different continent and my reach is not that long ;-)) so I can't guarantee that my explanation is completely correct, but I think it is not far off. Andrzej Kozlowski