write_multiline_adjlist#
- write_multiline_adjlist(G, path, delimiter=' ', comments='#', encoding='utf-8')[source]#
Write the graph G in multiline adjacency list format to path
- Parameters:
- GNetworkX graph
- pathstring or file
Filename or file handle to write to. Filenames ending in .gz or .bz2 will be compressed.
- commentsstring, optional
Marker for comment lines
- delimiterstring, optional
Separator for node labels
- encodingstring, optional
Text encoding.
See also
Examples
>>> G = nx.path_graph(4) >>> nx.write_multiline_adjlist(G, "test.adjlist")
The path can be a file handle or a string with the name of the file. If a file handle is provided, it has to be opened in ‘wb’ mode.
>>> fh = open("test.adjlist", "wb") >>> nx.write_multiline_adjlist(G, fh)
Filenames ending in .gz or .bz2 will be compressed.
>>> nx.write_multiline_adjlist(G, "test.adjlist.gz")