iduedu.simplify_multiedges

iduedu.simplify_multiedges(graph, *, weight='time_min', rule='min')[source]

Collapse a multigraph UrbanGraph into a simple graph.

For each node pair, one edge is selected according to weight and rule. rule="min" keeps the edge with the smallest weight, while rule="max" keeps the edge with the largest weight.

Parameters:
  • graph (UrbanGraph) – Source urban graph.

  • weight (str) – Edge column used to choose the representative edge.

  • rule (Literal['min', 'max']) – Selection rule, either "min" or "max".

Return type:

UrbanGraph

Returns:

New UrbanGraph with is_multigraph=False.

Raises:
  • TypeError – If graph is not an UrbanGraph.

  • KeyError – If weight is absent from edges_gdf.

  • ValueError – If weights contain NaN or rule is unsupported.