class_docstr: Basic weighted, directed graph class
  
  Member variables:
  
  * V (int): the number of vertices
  * E (int): the number of edges
  
  Methods
  
  * vertices (list, type=int, shape=(V,)): vertices id
  * edges (list, type=int, shape=(E,2)): edges as vertices id tuples
  * weights (list, type=int, shape=(E,)): weights / lengths
    of the graph's edges
class_docstr_tok: ["Basic","weighted",",","directed","graph","class","Member","variables",":","*","V","(","int",")",":","the","number","of","vertices","*","E","(","int",")",":","the","number","of","edges","Methods","*","vertices","(","list",",","type=int",",","shape=","(","V",",",")",")",":","vertices","id","*","edges","(","list",",","type=int",",","shape=","(","E,2",")",")",":","edges","as","vertices","id","tuples","*","weights","(","list",",","type=int",",","shape=","(","E",",",")",")",":","weights","\/","lengths","of","the","graph","'s","edges"]
docstr: Returns all the [graph] geodesic distances starting from seed
  x
          Parameters
          ----------
          seed (int, >-1, <self.V) or array of shape(p)
               edge(s) from which the distances are computed
  
          Returns
          -------
          dg: array of shape (self.V),
              the graph distance dg from ant vertex to the nearest seed
  
          Notes
          -----
          It is mandatory that the graph weights are non-negative
          
docstr_tok: ["Returns","all","the","[","graph","]","geodesic","distances","starting","from","seed","x","Parameters","--","--","--","--","--","seed","(","int",",",">","-1",",","<","self.V",")","or","array","of","shape","(","p",")","edge","(","s",")","from","which","the","distances","are","computed","Returns","--","--","--","-","dg",":","array","of","shape","(","self.V",")",",","the","graph","distance","dg","from","ant","vertex","to","the","nearest","seed","Notes","--","--","-","It","is","mandatory","that","the","graph","weights","are","non-negative"]
code: def dijkstra(self, seed=0):
      """Returns all the [graph] geodesic distances starting from seed
      x
              Parameters
              ----------
              seed (int, >-1, <self.V) or array of shape(p)
                   edge(s) from which the distances are computed
  
              Returns
              -------
              dg: array of shape (self.V),
                  the graph distance dg from ant vertex to the nearest seed
  
              Notes
              -----
              It is mandatory that the graph weights are non-negative
      """
      import heapq
  
      if hasattr(seed, "__iter__") == False:
          seed = [seed]
      try:
          if (self.weights < 0).any():
              raise ValueError("some weights are non-positive")
      except:
          raise ValueError("undefined weights")
      dist, active = np.inf * np.ones(self.V), np.ones(self.V)
      idx, neighb, weight = self.compact_neighb()
      dist[seed] = 0
      dg = list(zip(np.zeros_like(seed), seed))
      heapq.heapify(dg)
      for j in range(self.V):
          end = False
          while True:
              if len(dg) == 0:
                  end = True
                  break
              node = heapq.heappop(dg)
              if active[node[1]]:
                  break
          if end:
              break
          dwin, win = node
          active[win] = False
          # the following loop might be vectorized
          l = neighb[idx[win] : idx[win + 1]]
          newdist = dwin + weight[idx[win] : idx[win + 1]]
          who = newdist < dist[l]
          for z in zip(newdist[who], l[who]):
              heapq.heappush(dg, z)
          dist[l[who]] = newdist[who]
      return dist
  
imports: import numpy
  from scipy.sparse import coo_matrix
label_desc: Use image node_id 6 for calling the WeightedGraph obj's underlying member method code with example usage: obj.dijkstra(seed) and returns: dist