code: def draw_networkx(
      G=None,
      pos=None,
      chart=None,
      nodelist=None,
      edgelist=None,
      node_size=300,
      node_color="red",
      node_label=None,
      font_color="black",
      font_size=15,
      alpha=1,
      cmap=None,
      linewidths=1.0,
      width=1,
      arrow_width=2,
      arrow_length=0.1,
      edge_color="black",
      arrow_color="black",
      node_tooltip=None,
      edge_tooltip=None,
      edge_cmap=None,
  ):
      """Draw the graph G using Altair.
  
      nodelist : list, optional (default G.nodes())
         Draw only specified nodes
  
      edgelist : list, optional (default=G.edges())
         Draw only specified edges
  
      node_size : scalar or array, optional (default=300)
         Size of nodes.  If an array is specified it must be the
         same length as nodelist.
  
      node_color : color string, or array of floats, (default='r')
         Node color. Can be a single color format string,
         or a  sequence of colors with the same length as nodelist.
         If numeric values are specified they will be mapped to
         colors using the cmap and vmin,vmax parameters.  See
         matplotlib.scatter for more details.
  
      font_size : scalar or string
         Size of nodes (default=15).  If an array is specified it must be the
         same length as nodelist.
  
      font_color : color string, or array of floats
         Node color. Can be a single color format string (default='r'),
         or a  sequence of colors with the same length as nodelist.
         If numeric values are specified they will be mapped to
         colors using the cmap and vmin,vmax parameters.  See
         matplotlib.scatter for more details.
  
      node_label : string
         The name of the node attribute to treat as a label.
  
      alpha : float, optional (default=1.0)
         The node and edge transparency
  
      cmap : Matplotlib colormap, optional (default=None)
         Colormap for mapping intensities of nodes
  
      width : float, optional (default=1.0)
         Line width of edges
  
      arrow_width : float, optional (default=2.0)
         The width of arrow portions of edges.
  
      arrow_length : float, optional (default=.1)
         The perportion of the line to be occupied by the arrow.
  
      edge_color : color string, or array of floats (default='r')
         Edge color. Can be a single color format string,
         or a sequence of colors with the same length as edgelist.
         If numeric values are specified they will be mapped to
         colors using the edge_cmap and edge_vmin,edge_vmax parameters.
  
      arrow_color : color string, or array of floats (default='r')
         Arrow color. Can be a single color format string,
         or a sequence of colors with the same length as edgelist.
         If numeric values are specified they will be mapped to
         colors using the edge_cmap and edge_vmin,edge_vmax parameters.
  
      edge_cmap : Matplotlib colormap, optional (default=None)
         Colormap for mapping intensities of edges
      """
      if not pos:
          pos = nx.drawing.layout.spring_layout(G)
  
      # Draw edges
      if len(G.edges()) > 0:
          edges = draw_networkx_edges(
              G,
              pos,
              edgelist=edgelist,
              alpha=alpha,
              width=width,
              edge_color=edge_color,
              edge_cmap=edge_cmap,
              tooltip=edge_tooltip,
          )
  
          if isinstance(G, nx.DiGraph):
              # Draw edges
              arrows = draw_networkx_arrows(
                  G,
                  pos,
                  edgelist=edgelist,
                  alpha=alpha,
                  arrow_width=arrow_width,
                  arrow_length=arrow_length,
                  edge_color=arrow_color,
                  edge_cmap=edge_cmap,
                  tooltip=edge_tooltip,
              )
  
      # Draw nodes
      if len(G.nodes()) > 0:
          nodes = draw_networkx_nodes(
              G,
              pos,
              nodelist=nodelist,
              node_size=node_size,
              node_color=node_color,
              alpha=alpha,
              linewidths=linewidths,
              cmap=cmap,
              tooltip=node_tooltip,
          )
  
          # Draw node labels:
          if node_label:
              labels = draw_networkx_labels(
                  G,
                  pos,
                  nodelist=nodelist,
                  font_size=font_size,
                  font_color=font_color,
                  node_label=node_label,
              )
  
      # Layer the chart
      viz = []
      if len(G.edges()):
          viz.append(edges)
          if isinstance(G, nx.DiGraph):
              viz.append(arrows)
  
      if len(G.nodes()):
          viz.append(nodes)
          if node_label:
              viz.append(labels)
  
      if viz:
          viz = alt.layer(*viz)
      else:
          raise ValueError("G does not contain any nodes or edges.")
  
      return viz
  
file_path: nx_altair/nx_altair/draw_altair.py
imports: import numpy
  import altair
  import networkx
  from .core import to_pandas_edges, to_pandas_edges_arrows, to_pandas_nodes
  from ._utils import is_arraylike
label_desc: Use image node_id 5 for calling a global function with example usage: draw_networkx(G, pos, chart, nodelist, edgelist, node_size, node_color, node_label, font_color, font_size, alpha, cmap, linewidths, width, arrow_width, arrow_length, edge_color, arrow_color, node_tooltip, edge_tooltip, edge_cmap) and returns: viz