Warning
This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
write_adjlist¶
-
write_adjlist
(G, path, comments='#', delimiter=' ', encoding='utf-8')[source]¶ Write graph G in single-line adjacency-list format to path.
Parameters: G : NetworkX graph
path : string or file
Filename or file handle for data output. Filenames ending in .gz or .bz2 will be compressed.
comments : string, optional
Marker for comment lines
delimiter : string, optional
Separator for node labels
encoding : string, optional
Text encoding.
See also
Notes
This format does not store graph, node, or edge data.
Examples
>>> G=nx.path_graph(4) >>> nx.write_adjlist(G,"test.adjlist")
The path can be a filehandle or a string with the name of the file. If a filehandle is provided, it has to be opened in ‘wb’ mode.
>>> fh=open("test.adjlist",'wb') >>> nx.write_adjlist(G, fh)