Skip to main content
`Ctrl`+`K`

# parse_multiline_adjlist

parse_multiline_adjlist(lines, comments='#', delimiter=None, create_using=None, nodetype=None, edgetype=None)

  Parse lines of a multiline adjacency list representation of a graph.

  Parameters:
    lines list or iterator of strings

      Input data in multiline adjlist format

    create_using NetworkX graph constructor, optional (default=nx.Graph)

      Graph type to create. If graph instance, then cleared before populated.

    nodetype Python type, optional

      Convert nodes to this type.

    edgetype Python type, optional

      Convert edges to this type.

    comments string, optional

      Marker for comment lines

    delimiter string, optional

      Separator for node labels. The default is whitespace.

  Returns:
    G: NetworkX graph

      The graph corresponding to the lines in multiline adjacency list format.

  Examples

      >>> lines = [
      ...     "1 2",
      ...     "2 {'weight':3, 'name': 'Frodo'}",
      ...     "3 {}",
      ...     "2 1",
      ...     "5 {'weight':6, 'name': 'Saruman'}",
      ... ]
      >>> G = nx.parse_multiline_adjlist(iter(lines), nodetype=int)
      >>> list(G)
      [1, 2, 3, 5]