[[0, 78, 126, 27, 79, 65, 48, 127, 75, 96, 34, 0],
[0, 54, 57, 102, 133, 82, 59, 124, 66, 67, 2, 45, 56, 0],
[0, 60, 80, 83, 101, 52, 98, 61, 87, 81, 35, 0],
[0, 71, 37, 49, 51, 50, 15, 30, 29, 31, 33, 28, 32, 38, 0],
[0, 131, 74, 16, 3, 95, 44, 73, 90, 22, 23, 0],
[0, 105, 8, 14, 63, 40, 41, 7, 130, 58, 92, 24, 0],
[0, 36, 114, 113, 18, 94, 10, 11, 108, 89, 86, 19, 55, 0],
[0, 111, 6, 43, 88, 109, 39, 53, 1, 9, 97, 64, 12, 0],
[0, 106, 99, 125, 20, 104, 129, 132, 119, 62, 68, 72, 13, 110, 0],
[0, 4, 46, 47, 122, 21, 117, 118, 93, 121, 25, 107, 0]]
This is my list that consists of multiple lists. Every list in the list is a route and every number represents a location. 0 is the headquarter so every list starts and ends with a 0. I have a distance matrix to determine the distances between the locations. So I made this list of tuples to calculate the distances with the distances dataframe like distance_matrix[i][j] gives the distance between location i and j.
[[(0, 78), (78, 126), (126, 27), (27, 79), (79, 65), (65, 48), (48, 127), (127, 75), (75, 96), (96, 34), (34, 0)],
[(0, 54),(54, 57),(57, 102),(102, 133),(133, 82),(82, 59),(59, 124),(124, 66),(66, 67),(67, 2),(2, 45),(45, 56),(56, 0)],
[(0, 60),(60, 80),(80, 83),(83, 101),(101, 52),(52, 98),(98, 61),(61, 87),(87, 81),(81, 35),(35, 0)],
[(0, 71),(71, 37),(37, 49),(49, 51),(51, 50),(50, 15),(15, 30),(30, 29),(29, 31),(31, 33),(33, 28),(28, 32),(32, 38),(38, 0)]]
This is a subsample of my list that consists of multiple lists with tuples in it, to determine the distances.
Now every tuple is a location in a distance matrix so for example (0,78) gives 96km it is the distance between location 0 and location 78.
Now I need the cumsum of distances for every route (so every list in the list). Because when I cannot keep the routes separate.
Can someone help me out?