dynetworkx.IntervalGraph.load_from_txt¶
-
static
IntervalGraph.
load_from_txt
(path, delimiter=' ', nodetype=None, intervaltype=<class 'float'>, comments='#')¶ - Read interval graph in from path.
- Every line in the file must be an edge in the following format: “node node begin end”. Both interval times must be integers or floats. Nodes can be any hashable objects.
Parameters: - path (string or file) – Filename to read.
- nodetype (Python type, optional) – Convert nodes to this type.
- intervaltype (Python type, optional (default= float)) –
- interval begin and end to this type. (Convert) –
- must be an orderable type, ideally int or float. Other orderable types have not been fully tested. (This) –
- comments (string, optional) – Marker for comment lines
- delimiter (string, optional) – Separator for node labels. The default is whitespace.
Returns: G – The graph corresponding to the lines in edge list.
Return type: Examples
>>> G=dnx.IntervalGraph.load_from_txt("my_dygraph.txt")
The optional nodetype is a function to convert node strings to nodetype.
For example
>>> G=dnx.IntervalGraph.load_from_txt("my_dygraph.txt", nodetype=int)
will attempt to convert all nodes to integer type.
Since nodes must be hashable, the function nodetype must return hashable types (e.g. int, float, str, frozenset - or tuples of those, etc.)