Skip to main content
`Ctrl`+`K`

# generate_adjlist

generate_adjlist(G, delimiter=' ')

  Generate a single line of the graph G in adjacency list format.

  Parameters:
    G NetworkX graph
    delimiter string, optional

      Separator for node labels

  Returns:
    lines string

      Lines of data in adjlist format.

  See also

  `write_adjlist`, `read_adjlist`

  Notes

  The default `delimiter=" "` will result in unexpected results if node names contain whitespace characters. To avoid this problem, specify an alternate delimiter when spaces are valid in node names.

  NB: This option is not available for data that isn’t user-generated.

  Examples

      >>> G = nx.lollipop_graph(4, 3)
      >>> for line in nx.generate_adjlist(G):
      ...     print(line)
      0 1 2 3
      1 2 3
      2 3
      3 4
      4 5
      5 6
      6