Skip to contents

Returns the best hamiltonian

Usage

order_best(d, maxexact=9,nsamples=50000,path_weight=sum,
cycle=FALSE,path_dir = path_cor,...)

Arguments

d

A dist, used to provide edge weights.

maxexact

If the sequence length is <= maxexact, find the overall best hamiltonian, otherwise compares nsamples randomly generated permutations.

nsamples

If the sequence length is <= maxexact, finds the best of nsamples randomly generated permutations .

cycle

If TRUE, finds the shortest cycle, otherwise the shortest open path.

path_weight

Combines edge weights into a single path/cycle weight.

path_dir

If a function is provided, used to re-orient the cycle/path. Default function is path_cor.

...

Ignored.

Value

A vector containing a permutation of 1..n

Details

Requires package gtools. Currently it is possible to find the best hamiltonian by complete enumeration for up to 10 nodes. When path_dir is non NULL, the returned hamiltonian is also optimally oriented using best_orientation, which compares orientations via path_dir.

References

see overview

Author

C.B. Hurley and R.W. Oldford

See also

Examples

require(PairViz)
order_best(eurodist)
#>  [1]  9 12 14  2  6 11  4  3  7 20 17  1 21 16 19 13 15 10  8 18  5