Shortest path via two intermediate points
The key reasons for the poor performance are:


Representing queue as a list. This is slow because popping an item off the beginning of a list takes time proportional to the length of the list.

What you need here is a collections.deque.
Computing shortest distances many times over. The shortest distance from a to clinique is computed again for every clinique2, even though it will be the same each time. Similarly, the shortest distance from clinique2 to b is computed again for every clinique.

What you need here is to compute these distances once and remember them.

If the number of cliniques is large compared with the number of cities, you should use the Floyd–Warshall algorithm to compute distances between all pairs of cities in one go (instead of using Dijkstra's algorithm many times, as in the posted code).


If I were implementing this, I'd use scipy.sparse.csgraph.floyd_warshall and write:

import numpy as np
from scipy.sparse.csgraph import floyd_warshall

def shortest_distance_via(graph, a, b, c1, c2):
    """Return the shortest distance in graph from a to b via C1 and C2 (in
    that order), where C1 and C2 are nodes in c1 and c2 respectively.

    Arguments:
    graph -- NxN array of distances between nodes.
    a, b -- nodes in the graph.
    c1, c2 -- arrays of nodes in the graph.

    """
    d = floyd_warshall(graph)
    ab = d[a, c1, np.newaxis] + d[np.meshgrid(c1, c2)] + d[np.newaxis, c2, b]
    return ab.min()