Edge List¶
Edge Lists¶
Read and write NetworkX graphs as edge lists.
The multiline adjacency list format is useful for graphs with nodes that can be meaningfully represented as strings. With the edgelist format simple edge data can be stored but node or graph data is not. There is no way of representing isolated nodes unless the node has a selfloop edge.
Format¶
You can read or write three formats of edge lists with these functions.
Node pairs with no data:
1 2
Python dictionary as data:
1 2 {'weight':7, 'color':'green'}
Arbitrary data:
1 2 7 green

Read a graph from a list of edges. 

Write graph as a list of edges. 

Read a graph as list of edges with numeric weights. 

Write graph G as a list of edges with numeric weights. 

Generate a single line of the graph G in edge list format. 

Parse lines of an edge list representation of a graph. 