Parse lines of a multiline adjacency list representation of a graph.
Parameters : | lines : list or iterator of strings
create_using: NetworkX graph container :
nodetype : Python type, optional
comments : string, optional
delimiter : string, optional
create_using: NetworkX graph container :
|
---|---|
Returns : | G: NetworkX graph :
|
Examples
>>> lines = ['1 2',
... "2 {'weight':3, 'name': 'Frodo'}",
... "3 {}",
... "2 1",
... "5 {'weight':6, 'name': 'Saruman'}"]
>>> G = nx.parse_multiline_adjlist(iter(lines), nodetype = int)
>>> G.nodes()
[1, 2, 3, 5]
>>> G.edges(data = True)
[(1, 2, {'name': 'Frodo', 'weight': 3}), (1, 3, {}), (2, 5, {'name': 'Saruman', 'weight': 6})]