Read a graph from a list of edges.
Parameters: | path : file or string
comments : string, optional
delimiter : string, optional
create_using : Graph container, optional,
nodetype : int, float, str, Python type, optional
data : bool or list of (label,type) tuples
edgetype : int, float, str, Python type, optional OBSOLETE
encoding: string, optional :
|
---|---|
Returns: | G : graph
|
See also
Notes
Since nodes must be hashable, the function nodetype must return hashable types (e.g. int, float, str, frozenset - or tuples of those, etc.)
Examples
>>> nx.write_edgelist(nx.path_graph(4), "test.edgelist")
>>> G=nx.read_edgelist("test.edgelist")
>>> fh=open("test.edgelist", 'rb')
>>> G=nx.read_edgelist(fh)
>>> G=nx.read_edgelist("test.edgelist", nodetype=int)
>>> G=nx.read_edgelist("test.edgelist",create_using=nx.DiGraph())
See parse_edgelist() for more examples of formatting.