jvkersch/pyconcorde

Set start node

Closed this issue · 1 comments

How do we specify the start vertex of the tour?

@Carpetfizz I do not know of a way to specify the start vertex. However, you can always apply a cyclic permutation to the tour to bring any desired vertex to the front:

>>> import numpy as np
>>> tour = np.arange(10)
>>> np.random.shuffle(tour)
>>> tour
array([1, 5, 7, 6, 0, 2, 9, 3, 8, 4])
>>> start = 7
>>> index = np.where(tour == start)[0][0]
>>> index
2
>>> np.hstack([tour[index:], tour[:index]])
array([7, 6, 0, 2, 9, 3, 8, 4, 1, 5])