order.length(dist, order)
dist
.The order corresponds to a path through a graph where each node is visited only once, i.e. a Hamilton path. The length of a path is defined as the sum of the edge weights, i.e. distances.
If order
is missing the identity order is used.
If order
is not unique NA
is returned.
If there are non-finite distance values NA
is returned.
d <- dist(matrix(runif(10),ncol=2))
order.length(d)
o <- sample(5,5) # random order
order.length(d, o)
Run the code above in your browser using DataLab