from typing import List


def get_total_distance(
    routes: dict, matrix: List[List[float]], include_origin: bool = True
):
    """
    Calulate total distance on a route.

    :routes:          dict of vehicle routes with ordered stop indicies
    :matrix:          list of lists of travel distances between nodes (includes origin)
    :include_origin:  include travel distance from and to origins in calculation

    return float
    """
    total_distance = 0
    for vehicle in routes:
        for i in range(len(routes[vehicle]) - 1):
            total_distance += matrix[routes[vehicle][i] + 1][routes[vehicle][i + 1] + 1]

        if include_origin:
            total_distance += matrix[0][routes[vehicle][0]]
            total_distance += matrix[routes[vehicle][-1]][0]

    return total_distance