parse_edgelist(lines, comments='#', delimiter=None, create_using=None, nodetype=None, data=True)
Input data in edgelist format
Marker for comment lines. Default is :None:None:`'#'`
. To specify that no character should be treated as a comment, use comments=None
.
Separator for node labels. Default is :None:None:`None`
, meaning any whitespace.
Graph type to create. If graph instance, then cleared before populated.
Convert nodes to this type. Default is :None:None:`None`
, meaning no conversion is performed.
If :None:None:`False`
generate no edge data or if :None:None:`True`
use a dictionary representation of edge data or a list tuples specifying dictionary key names and types for edge data.
The graph corresponding to lines
Parse lines of an edge list representation of a graph.
Edgelist with no data:
>>> lines = ["1 2", "2 3", "3 4"]
... G = nx.parse_edgelist(lines, nodetype=int)
... list(G) [1, 2, 3, 4]
>>> list(G.edges()) [(1, 2), (2, 3), (3, 4)]
Edgelist with data in Python dictionary representation:
>>> lines = ["1 2 {'weight': 3}", "2 3 {'weight': 27}", "3 4 {'weight': 3.0}"]
... G = nx.parse_edgelist(lines, nodetype=int)
... list(G) [1, 2, 3, 4]
>>> list(G.edges(data=True)) [(1, 2, {'weight': 3}), (2, 3, {'weight': 27}), (3, 4, {'weight': 3.0})]
Edgelist with data in a list:
>>> lines = ["1 2 3", "2 3 27", "3 4 3.0"]
... G = nx.parse_edgelist(lines, nodetype=int, data=(("weight", float),))
... list(G) [1, 2, 3, 4]
>>> list(G.edges(data=True)) [(1, 2, {'weight': 3.0}), (2, 3, {'weight': 27.0}), (3, 4, {'weight': 3.0})]See :
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.readwrite.edgelist.parse_edgelist
networkx.readwrite.edgelist.read_edgelist
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them