def dijkstra_single_path_length(G, start, end):
    """
    Compute shortest path length between satrt
    and end for a weight graph. return -> (length, [path])
    """
    if start not in G.vertices:
        raise GraphInsertError("Vertex %s doesn't exist." % (start,))
    if end not in G.vertices:
        raise GraphInsertError("Vertex %s doesn't exist." % (end,))
    dijkstra_data = dijkstra(G, start)
    length = dijkstra_data[0][end]
    path = [end]
    current = end
    while current is not start:
        for vertex in dijkstra_data[1]:
            if vertex is current:
                path.append(dijkstra_data[1][vertex])
                current = dijkstra_data[1][vertex]
                break
    return length, path
def dijkstra_single_path_length ( G , start , end ) : if start not in G . vertices : raise GraphInsertError ( "Vertex %s doesn't exist." % ( start , ) ) if end not in G . vertices : raise GraphInsertError ( "Vertex %s doesn't exist." % ( end , ) ) dijkstra_data = dijkstra ( G , start ) length = dijkstra_data [ 0 ] [ end ] path = [ end ] current = end while current is not start : for vertex in dijkstra_data [ 1 ] : if vertex is current : path . append ( dijkstra_data [ 1 ] [ vertex ] ) current = dijkstra_data [ 1 ] [ vertex ] break return length , path
Compute shortest path length between satrt
    and end for a weight graph. return -> (length, [path])