I am going to listen to SQL. Although in reality it was not my first choice for working with TSP - it can still easily do such things - assuming, of course, that the data model is optimal for your efforts.
The first task will be to define a data model that contains the information your algorithm needs, and then fills in some sample data, and then processes the query, which can retrieve arrays as needed.
Finally, you can decide whether any simple SQL will work in this query, or perhaps an extension in the form of a stored procedure.
Finally, you can choose to pull it into your alternative language of choice.
Randy source share