docs: def dijkstra(graph, start, end=None):
      """
      Dijkstra's algorithm for shortest paths
  
      `David Eppstein, UC Irvine, 4 April 2002 <http://www.ics.uci.edu/~eppstein/161/python/>`_
  
      `Python Cookbook Recipe <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/119466>`_
  
      Find shortest paths from the  start node to all nodes nearer than or equal to the end node.
  
      Dijkstra's algorithm is only guaranteed to work correctly when all edge lengths are positive.
      This code does not verify this property for all edges (only the edges examined until the end
      vertex is reached), but will correctly compute shortest paths even for some graphs with negative
      edges, and will raise an exception if it discovers that a negative edge has caused it to make a mistake.
  
      *Adapted to altgraph by Istvan Albert, Pennsylvania State University - June, 9 2004*
  
      """
      D = {}    # dictionary of final distances
      P = {}    # dictionary of predecessors
      Q = _priorityDictionary()    # estimated distances of non-final vertices
      Q[start] = 0
  
      for v in Q:
          D[v] = Q[v]
          if v == end: break
  
          for w in graph.out_nbrs(v):
              edge_id  = graph.edge_by_node(v,w)
              vwLength = D[v] + graph.edge_data(edge_id)
              if w in D:
                  if vwLength < D[w]:
                      raise GraphError("Dijkstra: found better path to already-final vertex")
              elif w not in Q or vwLength < Q[w]:
                  Q[w] = vwLength
                  P[w] = v
  
      return (D,P)