I am using this code snippet from here after modifying it to fit with the rest of my python script, I think I have done this modification not the right way.
positions = list_points
# Where list_points(np.array) = [[3.7440e+01 5.4121e+02] [6.1218e+02 4.9432e+02]...[3.8130e+01 3.5315e+02]]
x_sol = np.asarray(t)
# Where t = [(0.9481610257893822, 37.44, 541.21), ..., (0.9313909810893908, 49.92, 541.44)]
fig, ax = plt.subplots(2, figsize = (10,10), sharex=True, sharey=True) # Prepare 2 plots
ax[0].set_title('Raw nodes')
ax[1].set_title('Optimized tour')
ax[0].scatter(positions[:, 0], positions[:, 1]) # plot A
ax[1].scatter(positions[:, 0], positions[:, 1]) # plot B
start_node = 0
for i in range(N):
start_pos = positions[start_node]
next_node = np.argmax(x_sol[start_node])
end_pos = positions[next_node]
ax[1].annotate("",
xy=start_pos, xycoords='data',
xytext=end_pos, textcoords='data',
arrowprops=dict(arrowstyle="->",
connectionstyle="arc3"))
start_node = next_node
plt.tight_layout()
plt.show()
Because instead of a complete connected tour, where arrows link all the cities in the tour, when It plots it gives:
Just the first one is connected, While It was supposed to give something like this:
Any help would be really appreciated.