def shortest_edge_paths(graph, edge_index, position=0.5):
    """Find the shortest path from the edge given
    by `edge_index`.  If we have no lengths, then each edge has length 1.
    This could be achieved by using the "derived graph", but our use will also
    require knowing the _vertex_ degree of the path.

    We use a simple modification of Dijkstra's algorithm whereby the initial
    distance to 
    
    :param graph: :class:`Graph` to use
    :param edge_index: The edge to start on
    :param position: `0 <= t <= 1` along the edge to start at.  Defaults
      to the midpoint.

    :return: `(lengths, prevs)` where `lengths` is a dictionary from key
        to length.  If a key is not present, it means that vertex is not
        connected to `vertex_key`.  `prevs` is a dictionary from key to key,
        giving for each vertex the previous vertex in the path from
        `vertex_key` to that vertex.  Working backwards, you can hence
        construct all shortest paths.  These paths will end at either vertex
        of the initial edge.
    """
    shortest_length = dict()
    v1, v2 = graph.edges[edge_index]
    shortest_length[v1] = graph.length(edge_index) * position
    shortest_length[v2] = graph.length(edge_index) * (1 - position)
    candidates = {v1, v2}
    done = set()
    prevs = {v1:v1, v2:v2}
    while len(candidates) > 0:
        next_vertex, min_dist = None, -1
        for v in candidates:
            dist = shortest_length[v]
            if min_dist == -1 or dist < min_dist:
                min_dist = dist
                next_vertex = v
        candidates.discard(next_vertex)
        done.add(next_vertex)

        for v in graph.neighbours(next_vertex):
            edge_index, _ = graph.find_edge(next_vertex, v)
            dist = min_dist + graph.length(edge_index)
            if v not in shortest_length or shortest_length[v] > dist:
                shortest_length[v] = dist
                prevs[v] = next_vertex
            if v not in done:
                candidates.add(v)

    return shortest_length, prevs