code: def draw_networkx_edges(
      G=None,
      pos=None,
      chart=None,
      layer=None,
      edgelist=None,
      width=1,
      alpha=1.0,
      edge_color="black",
      edge_cmap=None,
      tooltip=None,
      legend=False,
      **kwargs,
  ):
      """Draw the edges of the graph G.
  
      This draws only the edges of the graph G.
  
      Parameters
      ----------
      G : graph
         A networkx graph
  
      pos : dictionary
         A dictionary with nodes as keys and positions as values.
         Positions should be sequences of length 2.
  
      chart:
  
      edgelist : collection of edge tuples
         Draw only specified edges(default=G.edges())
  
      width : float, or array of floats
         Line width of edges (default=1.0)
  
      edge_color : color string, or array of floats
         Edge color. Can be a single color format string (default='r'),
         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.
  
      alpha : float
         The edge transparency (default=1.0)
  
      edge_cmap : Matplotlib colormap
         Colormap for mapping intensities of edges (default=None)
  
      Returns
      -------
      viz: ``altair.Chart`` object
      """
      if chart is None:
          # Pandas dataframe of edges
          df_edges = to_pandas_edges(G, pos)
  
          # Build a chart
          edge_chart = alt.Chart(df_edges)
      else:
          df_edges = chart.layer[0].data
          edge_chart = chart.layer[0]
  
      marker_attrs = {}
      encoded_attrs = {}
  
      # ---------- Handle arguments ------------
  
      ###### node list argument
      if isinstance(edgelist, list):
          # Subset dataframe.
          df_edges = df_edges.loc[df_edges["pair"].isin(edgelist)]
  
      elif edgelist is not None:
          raise Exception("nodelist must be a list or None.")
  
      ###### Node size
      if isinstance(width, str):
          encoded_attrs["size"] = alt.Size(width, legend=None)
  
      elif isinstance(width, float) or isinstance(width, int):
          marker_attrs["strokeWidth"] = width
  
      else:
          raise Exception("width must be a string or int.")
  
      ###### node_color
      if not isinstance(edge_color, str):
          raise Exception("edge_color must be a string.")
  
      elif edge_color in df_edges.columns:
          encoded_attrs["color"] = alt.Color(edge_color, legend=None)
  
      else:
          marker_attrs["color"] = edge_color
  
      ##### alpha
      if isinstance(alpha, str):
          encoded_attrs["opacity"] = alpha
  
      elif isinstance(alpha, int) or isinstance(alpha, float):
          marker_attrs["opacity"] = alpha
  
      elif alpha is not None:
          raise Exception("alpha must be a string or None.")
  
      ##### alpha
      if isinstance(edge_cmap, str):
          encoded_attrs["color"] = alt.Color(
              edge_color,
              scale=alt.Scale(scheme=edge_cmap, legend=None),
              legend=None,
          )
  
      elif edge_cmap is not None:
          raise Exception(
              "edge_cmap must be a string (colormap name) or None."
          )
  
      if tooltip is not None:
          encoded_attrs["tooltip"] = tooltip
  
      # ---------- Construct visualization ------------
  
      # Draw edges
      edge_chart = edge_chart.mark_line(**marker_attrs).encode(
          x=alt.X(
              "x",
              axis=alt.Axis(
                  title="", grid=False, labels=False, ticks=False
              ),
          ),
          y=alt.Y(
              "y",
              axis=alt.Axis(
                  title="", grid=False, labels=False, ticks=False
              ),
          ),
          detail="edge",
          **encoded_attrs,
      )
  
      if chart is not None:
          chart.layer[0] = edge_chart
  
      return edge_chart
  
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 1 for calling a global function with example usage: draw_networkx_edges(G, pos, chart, layer, edgelist, width, alpha, edge_color, edge_cmap, tooltip, legend) and returns: edge_chart