def get_cost(ss, a, dist_mat, C, n):
    """Determines the cost of an airline route network from a sampleset.

    Args:
        - ss: Sampleset dictionary. One solution returned from the hybrid solver.
        - a: Float in [0.0, 1.0]. Discount allowed for hub-hub legs.
        - dist_mat: Numpy matrix providing distance between cities i and j.
        - C: Numpy matrix. Represents airline leg cost.
        - n: Int. Number of cities in play.

    Returns:
        - cost: Cost of provided route network.
    """

    cost = 0
    for i in range(n):
        for j in range(i+1, n):
            cost += dist_mat[i][j]*(C[i][ss[i]] + C[j][ss[j]] + a*C[ss[i]][ss[j]])

    return cost