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: Plots the current graph in 2D
  
  Parameters
  ----------
  X : None or array of shape (self.V, 2)
      a set of coordinates that can be used to embed the vertices in 2D.
      If X.shape[1]>2, a svd reduces X for display. By default, the graph
      is presented on a circle
  ax: None or int, optional
      ax handle
  
  Returns
  -------
  ax: axis handle
  
  Notes
  -----
  This should be used only for small graphs.
docstr_tok: ["Plots","the","current","graph","in","2D","Parameters","--","--","--","--","--","X",":","None","or","array","of","shape","(","self.V",",","2",")","a","set","of","coordinates","that","can","be","used","to","embed","the","vertices","in","2D",".","If","X.shape","[","1","]",">","2",",","a","svd","reduces","X","for","display",".","By","default",",","the","graph","is","presented","on","a","circle","ax",":","None","or","int",",","optional","ax","handle","Returns","--","--","--","-","ax",":","axis","handle","Notes","--","--","-","This","should","be","used","only","for","small","graphs","."]
code: def show(self, X=None, ax=None):
      """Plots the current graph in 2D
  
      Parameters
      ----------
      X : None or array of shape (self.V, 2)
          a set of coordinates that can be used to embed the vertices in 2D.
          If X.shape[1]>2, a svd reduces X for display. By default, the graph
          is presented on a circle
      ax: None or int, optional
          ax handle
  
      Returns
      -------
      ax: axis handle
  
      Notes
      -----
      This should be used only for small graphs.
      """
      if np.size(self.weights) == 0:
          return Graph.show()
  
      wm = self.weights.max()
      import matplotlib.pyplot as plt
  
      if ax is None:
          plt.figure()
          ax = plt.subplot(1, 1, 1)
  
      ml = 5.0
      if X is None:
          for e in range(self.E):
              A = (self.edges[e, 0] * 2 * np.pi) / self.V
              B = (self.edges[e, 1] * 2 * np.pi) / self.V
              C = max(1, int(self.weights[e] * ml / wm))
              plt.plot(
                  [np.cos(A), np.cos(B)],
                  [np.sin(A), np.sin(B)],
                  "k",
                  linewidth=C,
              )
              t = (2 * np.pi * np.arange(self.V)) / self.V
          plt.plot(np.cos(t), np.sin(t), "o", linewidth=ml)
          plt.axis([-1.1, 1.1, -1.1, 1.1])
          return ax
  
      if X.shape[0] != self.V:
          raise ValueError("X.shape(0)!=self.V")
      if np.size(X) == self.V:
          X = np.reshape(X, (self.V, 1))
      if X.shape[1] == 1:
          # plot the graph on a circle
          x = np.pi * (X - X.min()) / (X.max() - X.min())
          for e in range(self.E):
              A = x[self.edges[e, 0]]
              B = x[self.edges[e, 1]]
              C = max(1, int(self.weights[e] * ml / wm))
              plt.plot(
                  [np.cos(A), np.cos(B)],
                  [np.sin(A), np.sin(B)],
                  "k",
                  linewidth=C,
              )
  
          plt.plot(np.cos(x), np.sin(x), "o", linewidth=ml)
          plt.axis([-1.1, 1.1, -0.1, 1.1])
  
      if X.shape[1] > 2:
          Y = X.copy()
          from numpy.linalg import svd
  
          M1, M2, M3 = svd(Y, 0)
          Y = np.dot(M1, np.diag(M2))
          Y = Y[:, :1]
      if X.shape[1] < 3:
          Y = X
  
      if Y.shape[1] == 2:
          for e in range(self.E):
              A = self.edges[e, 0]
              B = self.edges[e, 1]
              C = max(1, int(self.weights[e] * ml / wm))
              plt.plot(
                  [Y[A, 0], Y[B, 0]],
                  [Y[A, 1], Y[B, 1]],
                  "k",
                  linewidth=C,
              )
  
          plt.plot(Y[:, 0], Y[:, 1], "o", linewidth=ml)
          xmin, xmax = Y[:, 0].min(), Y[:, 0].max()
          ymin, ymax = Y[:, 1].min(), Y[:, 1].max()
          xmin = 1.1 * xmin - 0.1 * xmax
          xmax = 1.1 * xmax - 0.1 * xmin
          ymin = 1.1 * ymin - 0.1 * ymax
          ymax = 1.1 * ymax - 0.1 * ymin
          plt.axis([xmin, xmax, ymin, ymax])
  
      return ax
  
imports: import numpy
  from scipy.sparse import coo_matrix
label_desc: Use image node_id 20 for calling the WeightedGraph obj's underlying member method code with example usage: obj.show(X, ax) and returns: ax, Graph, ax