experimental.to_networkx

experimental.to_networkx(res, graph_type='MultiDiGraph')

Convert a Res1D object to a networkx Graph.

Nodes become nodes, reaches become edges. Gridpoints ignored.

See mikeio1d.network.Network.open, whose graph keeps the gridpoints, the reach lengths and the timeseries. The two builders should become one, once it is settled whether a network graph is directed (issue #214).

Parameters

Name Type Description Default
res Res1D The Res1D object required
graph_type ('MultiDiGraph', 'DiGraph', 'MultiGraph', 'Graph') The type of networkx graph to return. Defaults to “MultiDiGraph”. "MultiDiGraph"

Returns

Name Type Description
nx.Graph / nx.DiGraph / nx.MultiGraph / nx.MultiDiGraph The networkx Graph object.

Examples

>>> from mikeio1d.experimental import to_networkx
>>> G = to_networkx(res, graph_type="MultiDiGraph")