Write graph as a list of edges.
Parameters: | G : graph
path : file or string
comments : string, optional
delimiter : string, optional
data : bool or list, 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.
Examples
>>> G=nx.path_graph(4)
>>> nx.write_edgelist(G, "test.edgelist")
>>> G=nx.path_graph(4)
>>> fh=open("test.edgelist",'w')
>>> nx.write_edgelist(G, fh)
>>> nx.write_edgelist(G, "test.edgelist.gz")
>>> nx.write_edgelist(G, "test.edgelist.gz", data=False)
>>> import sys
>>> G=nx.Graph()
>>> G.add_edge(1,2,weight=7,color='red')
>>> nx.write_edgelist(G,sys.stdout,data=False)
1 2
>>> nx.write_edgelist(G,sys.stdout,data=['color'])
1 2 red
>>> nx.write_edgelist(G,sys.stdout,data=['color','weight'])
1 2 red 7