inputs: Solve in Python:
The professional Russian, Dmitri, from the popular youtube channel FPSRussia has hired you to help him move his arms cache between locations without detection by the authorities.  Your job is to write a Shortest Path First (SPF) algorithm that will provide a route with the shortest possible travel time between waypoints, which will minimize the chances of detection.  One exception is that you can't travel through the same waypoint twice.  Once you've been seen there is a higher chance of detection if you travel through that waypoint a second time.

Your function shortestPath will take three inputs, a topology/map of the environment, along with a starting point, and an ending point.  The topology will be a dictionary with the keys being the different waypoints.  The values of each entry will be another dictionary with the keys being the adjacent waypoints, and the values being the time it takes to travel to that waypoint.

Take the following topology as an example:

     topology = {'a' : {'b': 10, 'c': 20},
                 'b' : {'a': 10, 'c': 20},
                 'c' : {'a': 10, 'b': 20} }

In this example, waypoint 'a' has two adjacent waypoints, 'b' and 'c'.  And the time it takes to travel from 'a' to 'b' is 10 minutes, and from 'a' to 'c' is 20 minutes.  It's important to note that the time between these waypoints is one way travel time and can be different in opposite directions.  This is highlighted in the example above where a->c takes 20 minutes, but c->a takes 10 minutes.

The starting and ending points will passed to your function as single character strings such as 'a' or 'b', which will match a key in your topology.

The return value should be in the form of a list of lists of waypoints that make up the shortest travel time.  If there multiple paths that have equal travel time, then you should choose the path with the least number of waypoints.  If there are still multiple paths with equal travel time and number of waypoints, then you should return a list of lists with the multiple options. For...
targets: def shortestPath(topology, startPoint, endPoint):
    graph = {}
    for key, value in topology.items():
        values=[]
        for k, v in value.items():
            values.append(k)
        graph[key]=values
            
    paths=find_all_paths(graph, startPoint, endPoint)
    if len(paths)==0:
        return []
    pathsAndDistances=[]
    for path in paths:
        distance=0
        for i,waypoint in enumerate(path):
            if i < len(path)-1:
                distance += topology[waypoint][path[i+1]]
        pathsAndDistances.append((distance,path))
    pathsAndDistances=[t for t in pathsAndDistances if t[0]==min(pathsAndDistances)[0]]
    length=1000
    for p in pathsAndDistances:
        if len(p[1])<length:
            length=len(p[1])
    answer=[]
    for p in pathsAndDistances:
        if len(p[1])==length:
            answer.append(p[1])
    return answer
    
def find_all_paths(graph, start, end, path=[]):
        path = path + [start]
        if start == end:
            return [path]
        if start not in graph:
            return []
        paths = []
        for node in graph[start]:
            if node not in path:
                newpaths = find_all_paths(graph, node, end, path)
                for newpath in newpaths:
                    paths.append(newpath)
        return paths