graph
Graph data structures and utilities for network analysis.
NetworkStructure
Main network structure.
dijkstra_tree_shortest
The type of the None singleton.
poll_reach_hits
Per-node hit counts from bounded Dijkstra traversals over the given sources. For each distance threshold, counts how many of the sources reach each node within that metric distance (one traversal per source, to the largest threshold). Backs the sampling pilot (cityseer.sampling.estimate_polled_reach): on an undirected network a node’s hit count is binomial in its reach, so hits / m * n estimates reach at every threshold from one traversal set. Returns one Vec of length node_bound() per distance, indexed by raw node index.
dijkstra_tree_simplest
The type of the None singleton.
centrality_shortest
Compute node centrality using shortest paths with a single Dijkstra per source. Closeness and betweenness metrics are specified as lists of (name, expression) pairs. Expressions use variables c (metric distance) and p (normalised progress = c / threshold). Each expression is parsed once per thread via meval and evaluated per reached node (closeness) or per shortest path (betweenness).
When sample_probability is set, Bernoulli sampling with inverse-probability weighting (IPW) is used.
centrality_simplest
Compute node centrality using simplest (angular) paths on the dual graph. Angular routing is evaluated on two directed states per segment. Each source segment seeds both orientations into a single Brandes traversal.
Expressions use c (angular cost) and p (normalised time progress = agg_seconds / max_seconds).
betweenness_od_shortest
Compute OD-weighted betweenness centrality using shortest paths. Uses Brandes multi-predecessor Dijkstra from each source that has outbound OD trips. Betweenness expressions use c (metric distance) and p (normalised progress = c / threshold).
betweenness_demand_shortest
Demand-weighted (flow) betweenness from a singly / origin-constrained spatial interaction model. Each origin distributes its full weight across reachable destinations in proportion to W_d * decay(c), where decay is the supplied expression evaluated on c (metric cost) and p (normalised progress to the threshold) — the gravity model is one instance of this spatial interaction form. The allocated origin-destination flows are then routed along shortest paths via Brandes back-propagation, accumulating flow betweenness at intermediate nodes. Origins and destinations are each aggregated by node first, so several snapped points sharing a node contribute their summed weight (and a node only triggers one Dijkstra). When closest_destination is true, an origin routes its full weight to its single nearest reachable destination instead of allocating across all of them.
add_street_node
The type of the None singleton.
add_transport_node
The type of the None singleton.
set_node_live
Set the live status of a node (e.g. based on a boundary polygon).
node_bound
Returns an upper bound on node indices (all valid indices are < node_bound). Use this instead of node_count() when allocating index-addressed vectors, because StableGraph may have gaps after node removal.
edge_bound
Returns an upper bound on edge indices (all valid indices are < edge_bound).
node_indices
Returns a list of indices for all nodes (street and transport).
node_keys_py
Returns a list of original keys for all nodes (street and transport).
street_node_indices
Returns a list of indices for non-transport (street) nodes.
add_street_edge
Adds a street edge with geometry. Calculates length, bearings, and angle sum from WKT. Sets seconds to NaN.
remove_street_node
Remove a street node and all its connected edges from the StableGraph. StableGraph::remove_node() cascades to all edges connected to the node, and preserves existing indices for other nodes (no swap-and-compact). This means node indices held externally (e.g. by the QGIS plugin’s node_idx dict) remain valid after removal.
Returns an error if the node does not exist or is a transport node.
remove_street_edge
Remove a specific directed edge identified by its start/end node indices and edge_idx. Other edge indices remain stable after removal (StableGraph guarantee).
add_transport_edge
Adds an abstract transport edge defined by travel time (seconds). Length is set to NaN. Geometry-related fields are NaN/None.
get_edge_payload_py
The type of the None singleton.
get_edge_length
The type of the None singleton.
get_edge_impedance
The type of the None singleton.
build_edge_rtree
Builds the R-tree for street edge geometries using their bounding boxes. Deduplicates edges based on sorted node pairs and geometric equality. Stores (start_node_idx, end_node_idx, start_node_point, end_node_point, edge_geom) in the R-tree data payload.
set_barriers
Sets barrier geometries from WKT strings and builds the R-tree. Replaces any existing barriers.
street_node_lives
node_ys
node_xs
node_xyzs
node_zs
node_xys