code: def generate_edgelist(G, delimiter=" ", data=True):
      """Generate a single line of the graph G in edge list format.
  
      Parameters
      ----------
      G : NetworkX graph
  
      delimiter : string, optional
         Separator for node labels
  
      data : bool or list of keys
         If False generate no edge data.  If True use a dictionary
         representation of edge data.  If a list of keys use a list of data
         values corresponding to the keys.
  
      Returns
      -------
      lines : string
          Lines of data in adjlist format.
  
      Examples
      --------
      >>> G = nx.lollipop_graph(4, 3)
      >>> G[1][2]["weight"] = 3
      >>> G[3][4]["capacity"] = 12
      >>> for line in nx.generate_edgelist(G, data=False):
      ...     print(line)
      0 1
      0 2
      0 3
      1 2
      1 3
      2 3
      3 4
      4 5
      5 6
  
      >>> for line in nx.generate_edgelist(G):
      ...     print(line)
      0 1 {}
      0 2 {}
      0 3 {}
      1 2 {'weight': 3}
      1 3 {}
      2 3 {}
      3 4 {'capacity': 12}
      4 5 {}
      5 6 {}
  
      >>> for line in nx.generate_edgelist(G, data=["weight"]):
      ...     print(line)
      0 1
      0 2
      0 3
      1 2 3
      1 3
      2 3
      3 4
      4 5
      5 6
  
      See Also
      --------
      write_adjlist, read_adjlist
      """
      if data is True:
          for u, v, d in G.edges(data=True):
              e = u, v, dict(d)
              yield delimiter.join(map(str, e))
      elif data is False:
          for u, v in G.edges(data=False):
              e = u, v
              yield delimiter.join(map(str, e))
      else:
          for u, v, d in G.edges(data=True):
              e = [u, v]
              try:
                  e.extend(d[k] for k in data)
              except KeyError:
                  pass  # missing data for this edge, should warn?
              yield delimiter.join(map(str, e))
  
file_path: networkx/networkx/readwrite/edgelist.py
imports: import networkx
  from networkx.utils import open_file
label_desc: Use image node_id 1 for calling a global function with example usage: generate_edgelist(G, delimiter, data) without return types