iduedu.nx_graph2urban_graph¶
- iduedu.nx_graph2urban_graph(nx_graph, restore_edge_geom=True, *, check_oneway=True, oneway_column='oneway')[source]¶
Convert a NetworkX graph to an
UrbanGraph.This helper is intended for compatibility with libraries that still produce NetworkX graphs. Nodes must contain
xandycoordinates, the graph must expose acrsattribute, and edges are expected to carrygeometry,length_meterandtime_minattributes.- Parameters:
nx_graph (
Any) – NetworkX graph, directed graph, multigraph or multidigraph. Directed graphs are accepted for compatibility, but a warning is emitted because stable behavior for directed NetworkX inputs is not guaranteed.restore_edge_geom (
bool) – IfTrue, empty edge geometries are restored as straight lines between endpoint nodes. IfFalse, edges with empty geometries are removed.check_oneway (
bool) – IfTrueandoneway_columnexists on edges, that column is used as the UrbanGraph edge direction column.oneway_column (
str) – Boolean edge attribute that marks one-way movement.
- Return type:
- Returns:
Converted
UrbanGraphinstance.- Raises:
TypeError – If
nx_graphis not a NetworkX graph.ValueError – If required CRS, node or edge data is missing or invalid.