iduedu.UrbanGraph

class iduedu.UrbanGraph(nodes_gdf, edges_gdf, is_multigraph, is_directed, *, edge_direction_column=None, adjacency_weight='time_min', crs=None, graph_type=None, routes=None)[source]

Tabular representation of an urban transport graph.

UrbanGraph stores nodes and edges as pandas-compatible tables and builds SciPy CSR adjacency matrices for shortest-path and OD-matrix calculations. Spatial graphs use GeoDataFrame tables: nodes are points, edges are lines, and both tables share the graph CRS.

Parameters:
  • nodes_gdf (GeoDataFrame | DataFrame) – Node table. Its index is the node id and must be unique. Spatial graphs should use point geometries.

  • edges_gdf (GeoDataFrame | DataFrame) – Edge table. Required columns are u, v, geometry, length_meter and time_min. Multigraphs also require k. Edge endpoint columns reference nodes_gdf.index.

  • is_multigraph (bool) – Whether multiple edges may exist between the same node pair. If true, (u, v, k) uniquely identifies an edge.

  • is_directed (bool) – Whether edge direction is respected by adjacency-based algorithms.

  • edge_direction_column (str | None) – Optional boolean edge column. True means movement is allowed only from u to v; False means both directions are allowed.

  • adjacency_weight (str) – Default edge column used when building weighted adjacency matrices.

  • crs (Any | None) – Optional graph CRS. If omitted, it is inferred from GeoDataFrames when possible.

  • graph_type (str | None) – Optional semantic graph type such as "drive", "walk" or "intermodal".

  • routes (DataFrame | None) – Optional table of public-transport routes, one row per route variant, indexed by route_key (see iduedu.graph.routes). Edges refer to it by their route_key column; rows no edge refers to are dropped, so clipping or cutting a graph drops the routes it loses. Street graphs have none (None).

Raises:
  • TypeError – If node or edge tables use unsupported types.

  • ValueError – If graph table contracts are violated.

Methods

add_elevation

Return a copy of the graph with node heights and edge grades.

aggregate_objects

Count objects and sum their values within a travel cost of every origin.

alternative_paths

Return up to k distinct routes by the penalty method.

apply_grade_speed

Return a copy of the graph with travel times that depend on the grade.

centrality

Centralities of the nodes within travel-cost thresholds.

clip

Clip the graph by geometry and keep only nodes inside it.

connected_components

Return connected components for an undirected graph.

consolidate_intersections

Merge groups of nearby nodes, such as the nodes of one junction, into one node.

copy

Return an independent copy of the graph and cached adjacency state.

dijkstra_parallel

Run independent source searches.

diversity

Diversity of object categories within a travel cost of every origin.

edge_betweenness

Betweenness of the edges within travel-cost thresholds.

edge_stats

Edge counts, lengths and speeds for every value of an edge column.

empty

Create an empty graph with the requested topology metadata.

from_nx_graph

Create an UrbanGraph from a NetworkX graph.

graph_stats

Measures of size, density, shape and connectivity of the street network.

iter_od_matrix

Yield OD origin-row blocks.

join

Join this graph with another compatible UrbanGraph.

k_shortest_paths

Return up to k shortest loopless paths.

keep_largest_connected_component

Keep only the largest graph component.

largest_component

Return the largest component according to the selected mode.

local_stats

Network measures around every node, within a travel cost along the network.

multi_source_dijkstra

Search from the nearest source.

multi_source_dijkstra_nearest_source

Find the nearest source node and distance for each reachable graph node.

nearest_edges

Return the nearest graph edge for each object, with the distance and the position along it.

nearest_nodes

Return nearest graph node ids for object geometries.

nearest_objects

Find the k nearest objects of every origin along the network.

od_matrix

Calculate an OD matrix of shortest paths on this graph.

path_to_edges

Convert an ordered node path to ordered graph edges.

project_objects

Project objects onto nearest graph edges and add them to the graph.

read

Read an UrbanGraph from an .urbangraph archive.

relabel

Relabel graph nodes to a dense RangeIndex.

route_directness

Ratio of network to straight distance between origins and destinations.

route_edges

Travel edges of one route in the order of travel.

route_stops

Stop nodes of one route in calling order.

routes_in_area

Routes with an edge or a stop in an area.

shortest_path

Return the cost and node route of one shortest path.

simplify_multiedges

Collapse a multigraph to a simple graph.

single_source_dijkstra

Search once for distances and/or routes.

single_source_dijkstra_path

Return one shortest path as an ordered list of graph node ids.

streets_per_node

Number of streets that meet at every node.

strongly_connected_components

Return strongly connected components.

subgraph_by_nodes

Return the node-induced subgraph for nodes.

to_csr

Build a CSR adjacency matrix without changing graph state.

to_directed

Return a directed version of the graph with an edge direction column.

to_nx_graph

Convert this graph to a NetworkX graph.

to_undirected

Return an undirected version of the graph.

transport_stats

Stops, routes and stop spacing of every public-transport mode.

unique_segments

Return the straight segments of the edge geometries, each physical segment once.

update_adjacency_matrix

Rebuild and store the graph adjacency matrix.

validate

Validate node, edge, topology and CRS contracts of the graph.

weakly_connected_components

Return weakly connected components, ignoring edge direction.

write

Write the graph to an .urbangraph archive.

classmethod empty(*, crs=None, is_multigraph=True, is_directed=False, edge_direction_column=None, adjacency_weight='time_min', graph_type=None, routes=None)[source]

Create an empty graph with the requested topology metadata.

Return type:

UrbanGraph

Parameters:
  • crs (Any | None)

  • is_multigraph (bool)

  • is_directed (bool)

  • edge_direction_column (str | None)

  • adjacency_weight (str)

  • graph_type (str | None)

  • routes (DataFrame | None)

validate()[source]

Validate node, edge, topology and CRS contracts of the graph.

Raises:
  • TypeError – If graph tables use unsupported types.

  • ValueError – If graph table contracts are violated.

Return type:

None

copy()[source]

Return an independent copy of the graph and cached adjacency state.

Return type:

UrbanGraph

write(path, *, include_adjacency=False)[source]

Write the graph to an .urbangraph archive.

Parameters:
  • path (str | Path) – Destination path with the .urbangraph suffix.

  • include_adjacency (bool) – Whether to persist the cached adjacency matrix.

Return type:

Path

Returns:

Path to the written archive.

classmethod read(path, *, validate=True)[source]

Read an UrbanGraph from an .urbangraph archive.

Parameters:
  • path (str | Path) – Source path with the .urbangraph suffix.

  • validate (bool) – Whether to validate the graph after reading.

Return type:

UrbanGraph

Returns:

Restored graph instance.

update_adjacency_matrix(*, nodelist=None, weight=None, multigraph_rule='min')[source]

Rebuild and store the graph adjacency matrix.

Parameters:
  • nodelist (Optional[Iterable[Any]]) – Node ids to include in matrix order. If omitted, all graph nodes are used.

  • weight (str | None) – Edge weight column. If omitted, adjacency_weight is used.

  • multigraph_rule (Literal['min', 'max']) – Aggregation rule for parallel edges.

Return type:

csr_matrix

Returns:

Built SciPy CSR adjacency matrix.

Raises:
  • KeyError – If weight is not present in edges_gdf.

  • ValueError – If edge weights are invalid.

to_csr(*, nodelist=None, weight=None, multigraph_rule='min')[source]

Build a CSR adjacency matrix without changing graph state.

Parameters:
  • nodelist (Optional[Iterable[Any]]) – Node ids to include in matrix order. If omitted, all graph nodes are used.

  • weight (str | None) – Edge weight column. If omitted, adjacency_weight is used.

  • multigraph_rule (Literal['min', 'max']) – Aggregation rule for parallel edges.

Return type:

csr_matrix

Returns:

Built SciPy CSR adjacency matrix.

connected_components()[source]

Return connected components for an undirected graph.

Return type:

list[set[Any]]

weakly_connected_components()[source]

Return weakly connected components, ignoring edge direction.

Return type:

list[set[Any]]

strongly_connected_components()[source]

Return strongly connected components.

Return type:

list[set[Any]]

largest_component(*, mode='auto')[source]

Return the largest component according to the selected mode.

Return type:

set[Any]

Parameters:

mode (Literal['auto', 'connected', 'weak', 'strong'])

subgraph_by_nodes(nodes)[source]

Return the node-induced subgraph for nodes.

Return type:

UrbanGraph

Parameters:

nodes (Iterable[Any])

route_edges(route_key)[source]

Travel edges of one route in the order of travel. See iduedu.route_edges().

Return type:

GeoDataFrame

Parameters:

route_key (str)

route_stops(route_key)[source]

Stop nodes of one route in calling order. See iduedu.route_stops().

Return type:

GeoDataFrame

Parameters:

route_key (str)

routes_in_area(area)[source]

Routes with an edge or a stop in an area. See iduedu.routes_in_area().

Return type:

DataFrame

keep_largest_connected_component(*, mode='auto', inplace=False)[source]

Keep only the largest graph component.

Return type:

UrbanGraph

Parameters:
  • mode (Literal['auto', 'connected', 'weak', 'strong'])

  • inplace (bool)

single_source_dijkstra(source_node, *, target_nodes=None, weight='time_min', cutoff=None, reverse=False, output='both', path_storage='eager', dtype=<class 'numpy.float32'>, distance_format='frame')[source]

Search once for distances and/or routes. See iduedu.single_source_dijkstra().

Return type:

Series | ShortestPathResult | ndarray

Parameters:
  • source_node (Any)

  • target_nodes (Iterable[Any] | None)

  • weight (Literal['length_meter', 'time_min'])

  • cutoff (float | None)

  • reverse (bool)

  • output (Literal['distances', 'paths', 'both'])

  • path_storage (Literal['eager', 'lazy'])

  • dtype (dtype)

  • distance_format (Literal['frame', 'dense', 'sparse'])

multi_source_dijkstra(*, source_nodes=None, gdf_sources=None, graph_node_column='graph_node_id', target_nodes=None, weight='time_min', cutoff=None, reverse=False, output='both', path_storage='eager', dtype=<class 'numpy.float32'>, distance_format='frame')[source]

Search from the nearest source. See iduedu.multi_source_dijkstra().

Return type:

Series | ShortestPathResult | ndarray

Parameters:
dijkstra_parallel(*, source_nodes=None, gdf_sources=None, graph_node_column='graph_node_id', target_nodes=None, weight='time_min', cutoff=None, reverse=False, output='both', path_storage='eager', dtype=<class 'numpy.float32'>, max_workers=None, batch_size=None, distance_format='frame')[source]

Run independent source searches. See iduedu.dijkstra_parallel().

Return type:

DataFrame | ShortestPathResult | ndarray | csr_array

Parameters:
  • source_nodes (Iterable[Any] | None)

  • gdf_sources (DataFrame | None)

  • graph_node_column (str)

  • target_nodes (Iterable[Any] | None)

  • weight (Literal['length_meter', 'time_min'])

  • cutoff (float | None)

  • reverse (bool)

  • output (Literal['distances', 'paths', 'both'])

  • path_storage (Literal['eager', 'lazy'])

  • dtype (dtype)

  • max_workers (int | None)

  • batch_size (int | None)

  • distance_format (Literal['frame', 'dense', 'sparse'])

single_source_dijkstra_path(source_node, target_node, *, weight='time_min', cutoff=None, reverse=False)[source]

Return one shortest path as an ordered list of graph node ids.

Return type:

list[Any]

Parameters:
  • source_node (Any)

  • target_node (Any)

  • weight (Literal['length_meter', 'time_min'])

  • cutoff (float | None)

  • reverse (bool)

shortest_path(source_node, target_node, *, weight='time_min', cutoff=None, method='bidirectional')[source]

Return the cost and node route of one shortest path. See iduedu.shortest_path().

Return type:

tuple[float, list[Any]]

Parameters:
  • source_node (Any)

  • target_node (Any)

  • weight (Literal['length_meter', 'time_min'])

  • cutoff (float | None)

  • method (Literal['bidirectional', 'astar', 'alt', 'dijkstra'])

k_shortest_paths(source_node, target_node, k, *, weight='time_min', cutoff=None, max_workers=None)[source]

Return up to k shortest loopless paths. See iduedu.k_shortest_paths().

Return type:

DataFrame

Parameters:
  • source_node (Any)

  • target_node (Any)

  • k (int)

  • weight (Literal['length_meter', 'time_min'])

  • cutoff (float | None)

  • max_workers (int | None)

alternative_paths(source_node, target_node, k=3, *, weight='time_min', penalty=1.5, max_overlap=0.7, max_cost_ratio=1.4, cutoff=None)[source]

Return up to k distinct routes by the penalty method. See iduedu.alternative_paths().

Return type:

DataFrame

Parameters:
multi_source_dijkstra_nearest_source(*, source_nodes=None, gdf_sources=None, graph_node_column='graph_node_id', weight='time_min', cutoff=None, reverse=False, dtype=<class 'numpy.float32'>)[source]

Find the nearest source node and distance for each reachable graph node.

Return type:

DataFrame

Parameters:
od_matrix(*, gdf_origins=None, gdf_destinations=None, origins_nodes=None, destination_nodes=None, graph_node_column='graph_node_id', weight='time_min', dtype=<class 'numpy.float32'>, threshold=None, max_workers=None, cutoff=None, output='distances', path_storage='eager', mode='all_to_all', batch_size=None, method='auto', distance_format='frame')[source]

Calculate an OD matrix of shortest paths on this graph.

Return type:

DataFrame | ShortestPathResult | ndarray | csr_array

Parameters:
  • gdf_origins (DataFrame | None)

  • gdf_destinations (DataFrame | None)

  • origins_nodes (Iterable[Any] | None)

  • destination_nodes (Iterable[Any] | None)

  • graph_node_column (str)

  • weight (Literal['length_meter', 'time_min'])

  • dtype (dtype)

  • threshold (float | None)

  • max_workers (int | None)

  • cutoff (float | None)

  • output (Literal['distances', 'paths', 'both'])

  • path_storage (Literal['eager', 'lazy'])

  • mode (Literal['all_to_all', 'pairwise'])

  • batch_size (int | None)

  • method (Literal['auto', 'bidirectional', 'astar', 'dijkstra'])

  • distance_format (Literal['frame', 'dense', 'sparse'])

iter_od_matrix(*, gdf_origins=None, gdf_destinations=None, origins_nodes=None, destination_nodes=None, graph_node_column='graph_node_id', weight='time_min', dtype=<class 'numpy.float32'>, threshold=None, max_workers=None, cutoff=None, output='distances', path_storage='eager', mode='all_to_all', batch_size=256, method='auto', distance_format='frame')[source]

Yield OD origin-row blocks. See iduedu.iter_od_matrix().

Return type:

Iterator[DataFrame | ShortestPathResult | ndarray | csr_array]

Parameters:
  • gdf_origins (DataFrame | None)

  • gdf_destinations (DataFrame | None)

  • origins_nodes (Iterable[Any] | None)

  • destination_nodes (Iterable[Any] | None)

  • graph_node_column (str)

  • weight (Literal['length_meter', 'time_min'])

  • dtype (dtype)

  • threshold (float | None)

  • max_workers (int | None)

  • cutoff (float | None)

  • output (Literal['distances', 'paths', 'both'])

  • path_storage (Literal['eager', 'lazy'])

  • mode (Literal['all_to_all', 'pairwise'])

  • batch_size (int)

  • method (Literal['auto', 'bidirectional', 'astar', 'dijkstra'])

  • distance_format (Literal['frame', 'dense', 'sparse'])

path_to_edges(path, *, weight='time_min')[source]

Convert an ordered node path to ordered graph edges.

Return type:

GeoDataFrame

Parameters:
classmethod from_nx_graph(nx_graph, restore_edge_geom=False, *, check_oneway=True, oneway_column='oneway')[source]

Create an UrbanGraph from a NetworkX graph.

This constructor is useful for graphs received from external libraries when they already contain node coordinates, CRS metadata and edge attributes such as length_meter and time_min. The conversion itself is performed by iduedu.nx_graph2urban_graph().

Parameters:
  • nx_graph – NetworkX graph, directed graph, multigraph or multidigraph.

  • restore_edge_geom (bool) – If True, empty edge geometries are restored as straight segments between endpoint nodes.

  • check_oneway (bool) – If True and oneway_column exists on edges, that column is used as the edge direction column.

  • oneway_column (str) – Boolean edge attribute that marks one-way movement.

Return type:

UrbanGraph

Returns:

Converted UrbanGraph instance.

to_nx_graph()[source]

Convert this graph to a NetworkX graph.

The method delegates to iduedu.urban_graph2nx_graph() and preserves node and edge attributes where possible.

Returns:

NetworkX graph type matching this graph topology.

simplify_multiedges(*, weight='time_min', rule='min', inplace=False)[source]

Collapse a multigraph to a simple graph.

For each node pair, one edge is selected by the weight column. rule="min" keeps the smallest weight and rule="max" keeps the largest weight. Functional equivalent: iduedu.simplify_multiedges().

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

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

  • inplace (bool) – If True, replace this object with the simplified graph.

Return type:

UrbanGraph

Returns:

Simplified UrbanGraph.

relabel(*, inplace=False)[source]

Relabel graph nodes to a dense RangeIndex.

Functional equivalent: iduedu.relabel_urban_graph().

Parameters:

inplace (bool) – If True, replace this object with the relabeled graph.

Return type:

UrbanGraph

Returns:

UrbanGraph with updated node indexes and edge endpoints.

clip(polygon, *, inplace=False)[source]

Clip the graph by geometry and keep only nodes inside it.

Edges are retained only when both endpoints remain in the graph. Node ids are preserved; call relabel() if dense labels are needed. Functional equivalent: iduedu.clip_urban_graph().

Parameters:
  • polygon – Shapely geometry in EPSG:4326 (as territory of the graph builders), or a GeoSeries / GeoDataFrame in any CRS.

  • inplace (bool) – If True, replace this object with the clipped graph.

Return type:

UrbanGraph

Returns:

Clipped UrbanGraph.

join(other, *, graph_type=None, node_conflict='left', inplace=False)[source]

Join this graph with another compatible UrbanGraph.

Shared node indexes are allowed and resolved with node_conflict. Duplicate edge keys are treated as conflicts.

Parameters:
  • other (UrbanGraph) – Graph to append.

  • graph_type (str | None) – Optional graph type for the result. If None, keep this graph type.

  • node_conflict (str) – Which side wins when node indexes overlap: "left" or "right".

  • inplace (bool) – If True, replace this object with the joined graph.

Return type:

UrbanGraph

Returns:

Joined UrbanGraph.

to_directed(*, edge_direction_column='oneway', default_direction_value=False, inplace=False)[source]

Return a directed version of the graph with an edge direction column.

Functional equivalent: iduedu.to_directed().

Parameters:
  • edge_direction_column (str) – Name of the boolean one-way edge column.

  • default_direction_value (bool) – Value used for edges where the column is missing or null.

  • inplace (bool) – If True, replace this object with the directed graph.

Return type:

UrbanGraph

Returns:

Directed UrbanGraph.

to_undirected(*, inplace=False)[source]

Return an undirected version of the graph.

Functional equivalent: iduedu.to_undirected().

Parameters:

inplace (bool) – If True, replace this object with the undirected graph.

Return type:

UrbanGraph

Returns:

Undirected UrbanGraph.

nearest_nodes(objects_gdf, *, graph_node_column='graph_node_id')[source]

Return nearest graph node ids for object geometries.

Functional equivalent: iduedu.nearest_nodes().

Parameters:
  • objects_gdf (GeoDataFrame) – GeoDataFrame with geometries to match to graph nodes.

  • graph_node_column (str) – Name assigned to the returned Series.

Return type:

Series

Returns:

Series indexed like objects_gdf with nearest node ids as values.

nearest_edges(objects_gdf, *, max_dist=None)[source]

Return the nearest graph edge for each object, with the distance and the position along it.

Functional equivalent: iduedu.nearest_edges().

Return type:

DataFrame

Parameters:
unique_segments(*, precision=0.01)[source]

Return the straight segments of the edge geometries, each physical segment once.

Functional equivalent: iduedu.unique_segments().

Return type:

GeoDataFrame

Parameters:

precision (float)

consolidate_intersections(tolerance=10.0, *, max_span=None, return_mapping=False)[source]

Merge groups of nearby nodes, such as the nodes of one junction, into one node.

Functional equivalent: iduedu.consolidate_intersections().

Parameters:
project_objects(objects_gdf, speed_m_per_min, *, max_dist=None, add_link_edge=True, inplace=False)[source]

Project objects onto nearest graph edges and add them to the graph.

The method creates graph nodes for objects, projects their representative points onto nearest edges, splits those edges when needed and adds connector edges. It is convenient for in-memory preparation of buildings, services or other objects before OD-matrix calculations. For backend workflows where graph changes should be persisted separately, use iduedu.project_objects2urban_graph().

Parameters:
  • objects_gdf (GeoDataFrame) – Objects with a unique index and geometry. The index becomes the object2node_map index.

  • speed_m_per_min (float) – Movement speed on connector edges, in meters per minute. For 5 km/h use 5 * 1000 / 60.

  • max_dist (float | None) – Optional maximum distance to the nearest edge. If None, no distance limit is applied.

  • add_link_edge (bool) – If True, create a dedicated object node and connector edge. If False, map objects to projection nodes on the graph.

  • inplace (bool) – If True, apply changes to this graph.

Return type:

tuple[UrbanGraph, Series]

Returns:

Pair (graph, object2node_map). object2node_map is indexed by the original object index and contains graph node ids.

graph_stats(*, area=None, zones=None, edge_types=None, boundary_buffer=1.0, precision=0.01)[source]

Measures of size, density, shape and connectivity of the street network.

Functional equivalent: iduedu.graph_stats().

Return type:

Series | DataFrame

Parameters:
edge_stats(by='type', *, area=None, precision=0.01)[source]

Edge counts, lengths and speeds for every value of an edge column.

Functional equivalent: iduedu.edge_stats().

Return type:

DataFrame

Parameters:
transport_stats(*, modes=None)[source]

Stops, routes and stop spacing of every public-transport mode.

Functional equivalent: iduedu.transport_stats().

Return type:

DataFrame

Parameters:

modes (Iterable[str] | None)

local_stats(radius, *, weight='length_meter', nodes=None, edge_types=None, max_workers=None)[source]

Network measures around every node, within a travel cost along the network.

Functional equivalent: iduedu.local_stats().

Return type:

DataFrame

Parameters:
streets_per_node(*, edge_types=None)[source]

Number of streets that meet at every node.

Functional equivalent: iduedu.streets_per_node().

Return type:

Series

Parameters:

edge_types (Iterable[str] | None)

route_directness(*, origins_nodes=None, destination_nodes=None, gdf_origins=None, gdf_destinations=None, graph_node_column='graph_node_id', sample=200, seed=0, max_workers=None)[source]

Ratio of network to straight distance between origins and destinations.

Functional equivalent: iduedu.route_directness().

Return type:

DataFrame

Parameters:
nearest_objects(*, gdf_origins=None, gdf_objects=None, origins_nodes=None, object_nodes=None, k=1, cutoff=None, weight='time_min', direction='from', graph_node_column='graph_node_id', max_workers=None)[source]

Find the k nearest objects of every origin along the network.

Functional equivalent: iduedu.nearest_objects().

Return type:

DataFrame

Parameters:
aggregate_objects(cutoff, *, gdf_origins=None, gdf_objects=None, origins_nodes=None, object_nodes=None, columns=None, weight='time_min', decay=None, beta=None, direction='from', graph_node_column='graph_node_id', max_workers=None)[source]

Count objects and sum their values within a travel cost of every origin.

Functional equivalent: iduedu.aggregate_objects().

Return type:

DataFrame

Parameters:
diversity(cutoff, category, *, gdf_objects, gdf_origins=None, origins_nodes=None, values=None, hill_order=2.0, weight='time_min', decay=None, beta=None, direction='from', graph_node_column='graph_node_id', max_workers=None)[source]

Diversity of object categories within a travel cost of every origin.

Functional equivalent: iduedu.diversity().

Return type:

DataFrame

Parameters:
centrality(measures=('reach', 'harmonic', 'gravity'), *, cutoffs=None, weight='length_meter', beta=None, node_weights=None, direction='from', area=None, sample=None, seed=0, max_workers=None)[source]

Centralities of the nodes within travel-cost thresholds.

Functional equivalent: iduedu.centrality().

Return type:

DataFrame

Parameters:
edge_betweenness(*, cutoffs=None, weight='length_meter', node_weights=None, sample=None, seed=0, max_workers=None)[source]

Betweenness of the edges within travel-cost thresholds.

Functional equivalent: iduedu.edge_betweenness().

Return type:

DataFrame

Parameters:
add_elevation(elevation, *, column='elevation', method='linear', sample_distance=20.0, structure_columns=('bridge', 'tunnel'), band=1)[source]

Return a copy of the graph with node heights and edge grades.

Functional equivalent: iduedu.add_elevation().

Return type:

UrbanGraph

Parameters:
apply_grade_speed(model='tobler', *, edge_types=None)[source]

Return a copy of the graph with travel times that depend on the grade.

Functional equivalent: iduedu.apply_grade_speed().

Return type:

UrbanGraph

Parameters:
  • model (Literal['tobler', 'cycling'] | ~typing.Callable[[~numpy.ndarray], ~numpy.ndarray])

  • edge_types (Iterable[str] | None)