generate_edgelist¶
-
generate_edgelist
(G, delimiter=' ', data=True)[source]¶ Generate a single line of the graph G in edge list format.
Parameters: Returns: lines – Lines of data in adjlist format.
Return type: Examples
>>> G = nx.lollipop_graph(4, 3) >>> G[1][2]['weight'] = 3 >>> G[3][4]['capacity'] = 12 >>> for line in nx.generate_edgelist(G, data=False): ... print(line) 0 1 0 2 0 3 1 2 1 3 2 3 3 4 4 5 5 6
>>> for line in nx.generate_edgelist(G): ... print(line) 0 1 {} 0 2 {} 0 3 {} 1 2 {'weight': 3} 1 3 {} 2 3 {} 3 4 {'capacity': 12} 4 5 {} 5 6 {}
>>> for line in nx.generate_edgelist(G,data=['weight']): ... print(line) 0 1 0 2 0 3 1 2 3 1 3 2 3 3 4 4 5 5 6
See also
write_adjlist()
,read_adjlist()