Write graph as a list of edges.
Parameters: | G : graph
path : file or string
comments : string, optional
delimiter : string, optional
|
---|
See also
Notes
The file will use the default text encoding on your system. It is possible to write files in other encodings by opening the file with the codecs module. See doc/examples/unicode.py for hints.
>>> import codecs
>>> fh=codecs.open("test.edgelist",'w',encoding='utf=8') # utf-8 encoding
>>> nx.write_edgelist(G,fh)
Examples
>>> G=nx.path_graph(4)
>>> nx.write_edgelist(G, "test.edgelist")
>>> fh=open("test.edgelist",'w')
>>> nx.write_edgelist(G,fh)
>>> nx.write_edgelist(G, "test.edgelist.gz")