code: def to_edgelist(G, nodelist=None):
      """Returns a list of edges in the graph.
  
      Parameters
      ----------
      G : graph
         A NetworkX graph
  
      nodelist : list
         Use only nodes specified in nodelist
  
      """
      if nodelist is None:
          return G.edges(data=True)
      return G.edges(nodelist, data=True)
  
file_path: networkx/networkx/convert.py
imports: import warnings
  from collections.abc import Collection, Generator, Iterator
  import networkx
label_desc: Use image node_id 6 for calling a global function with example usage: to_edgelist(G, nodelist) and returns: G, G