View source: R/10-grafos-TSP.R
neigh_index | R Documentation |
Previous, current, and next positions of a given index in a cycle.
neigh_index(i, n)
i |
Position in a cycle |
n |
Lenght of the cycle |
Given some position i in a n-lenght cycle, this function returns the triple c(i-1,i,i+1) taking into account that the next position of i=n is 1 and the previous position of i=1 is n. It is used to perform a 4-exchange in a cycle.
A three component vector c(previous, current, next)
Cesar Asensio
neigh_index(6, 9) # 5 6 7
neigh_index(9, 9) # 8 9 1
neigh_index(1, 9) # 9 1 2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.