iduedu.relabel_urban_graph¶
- iduedu.relabel_urban_graph(graph_gdf, *, by='range', on_duplicate='raise')[source]¶
Relabel node ids and update edge endpoints.
The function does not mutate the source graph. For multigraphs,
kis recalculated after relabeling to keep['u', 'v', 'k']unique.- Parameters:
graph_gdf (
UrbanGraph) – Source graph.by (
Literal['range','coordinates']) –"range"numbers the nodes0 .. n - 1in their order."coordinates"packs the latitude and longitude of every node, rounded to 1e-7 degree (the precision of OpenStreetMap), into one int64 id. Such ids do not change when the graph is built again from newer data, and graphs of neighbouring territories get equal ids for their shared nodes (seecoordinate_node_ids()).on_duplicate (
Literal['raise','hash']) – Whatby="coordinates"does with nodes closer than 1e-7 degree (about 1 cm), which would get one id, such as the stops of several routes at one platform in a public transport graph."raise"raisesValueError."hash"gives each of them a negative id hashed from the coordinate id, the node attributes and the rank among nodes with equal attributes, so the ids stay stable when the graph is built again in the same way; the other nodes keep their coordinate ids.
- Raises:
ValueError – If
by="coordinates"and the graph has no CRS, or nodes share a coordinate id andon_duplicate="raise".- Return type: