graph

Graph data structures and utilities for network analysis.

NodePayload

Payload for a network node.

NodePayload

NodePayload
( )

validate

validate
(
self
/
)

Validates the payload. Returns Ok(()) if valid, Err(PyValueError) otherwise.

EdgePayload

Payload for a network edge.

EdgePayload

EdgePayload
( )

validate

validate
(
self
/
)

Validates the payload. Returns Ok(()) if valid, Err(PyValueError) otherwise.

NetworkStructure

Main network structure.

NetworkStructure

NetworkStructure
( )

dijkstra_tree_shortest

dijkstra_tree_shortest
(
self
/
src_idx
max_seconds
speed_m_s
)

The type of the None singleton.

poll_reach_hits

poll_reach_hits
(
self
/
src_idxs
distances
speed_m_s
)

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

dijkstra_tree_simplest
(
self
/
src_idx
max_seconds
speed_m_s
)

The type of the None singleton.

centrality_shortest

centrality_shortest
(
self
/
distances=None
minutes=None
closeness_exprs=None
betweenness_exprs=None
compute_cycles=None
speed_m_s=None
tolerance=None
sample_probability=None
sampling_weights=None
random_seed=None
pbar_disabled=None
)

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

centrality_simplest
(
self
/
distances=None
minutes=None
closeness_exprs=None
betweenness_exprs=None
speed_m_s=None
tolerance=None
sample_probability=None
sampling_weights=None
random_seed=None
pbar_disabled=None
)

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

betweenness_od_shortest
(
self
/
od_matrix
distances=None
minutes=None
betweenness_exprs=None
speed_m_s=None
tolerance=None
pbar_disabled=None
)

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

betweenness_demand_shortest
(
self
/
origins
destinations
decay_fn
distances=None
minutes=None
closest_destination=False
metric_name=None
speed_m_s=None
tolerance=None
pbar_disabled=None
)

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.

progress_init

progress_init
(
self
/
)

The type of the None singleton.

progress

progress
(
self
/
)

The type of the None singleton.

set_is_dual

set_is_dual
(
self
/
is_dual
)

The type of the None singleton.

set_is_directed

set_is_directed
(
self
/
is_directed
)

The type of the None singleton.

add_street_node

add_street_node
(
self
/
node_key
x
y
live
weight
z=None
)

The type of the None singleton.

add_transport_node

add_transport_node
(
self
/
node_key
x
y
linking_radius=None
z=None
)

The type of the None singleton.

get_node_payload_py

get_node_payload_py
(
self
/
node_idx
)

The type of the None singleton.

get_node_weight

get_node_weight
(
self
/
node_idx
)

The type of the None singleton.

set_node_weight

set_node_weight
(
self
/
node_idx
weight
)

Set the weight of a node.

is_node_live

is_node_live
(
self
/
node_idx
)

The type of the None singleton.

set_node_live

set_node_live
(
self
/
node_idx
live
)

Set the live status of a node (e.g. based on a boundary polygon).

node_count

node_count
(
self
/
)

Returns the total count of all nodes (street and transport).

node_bound

node_bound
(
self
/
)

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

edge_bound
(
self
/
)

Returns an upper bound on edge indices (all valid indices are < edge_bound).

street_node_count

street_node_count
(
self
/
)

Returns the count of non-transport (street) nodes.

node_indices

node_indices
(
self
/
)

Returns a list of indices for all nodes (street and transport).

node_keys_py

node_keys_py
(
self
/
)

Returns a list of original keys for all nodes (street and transport).

street_node_indices

street_node_indices
(
self
/
)

Returns a list of indices for non-transport (street) nodes.

add_street_edge

add_street_edge
(
self
/
start_nd_idx
end_nd_idx
edge_idx
start_nd_key_py
end_nd_key_py
geom_wkt
imp_factor=None
shared_primal_node_key=None
)

Adds a street edge with geometry. Calculates length, bearings, and angle sum from WKT. Sets seconds to NaN.

remove_street_node

remove_street_node
(
self
/
node_idx
)

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_street_edge
(
self
/
start_nd_idx
end_nd_idx
edge_idx
)

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

add_transport_edge
(
self
/
start_nd_idx
end_nd_idx
edge_idx
start_nd_key_py
end_nd_key_py
seconds
imp_factor=None
)

Adds an abstract transport edge defined by travel time (seconds). Length is set to NaN. Geometry-related fields are NaN/None.

edge_references

edge_references
(
self
/
)

The type of the None singleton.

get_edge_payload_py

get_edge_payload_py
(
self
/
start_nd_idx
end_nd_idx
edge_idx
)

The type of the None singleton.

get_edge_length

get_edge_length
(
self
/
start_nd_idx
end_nd_idx
edge_idx
)

The type of the None singleton.

get_edge_impedance

get_edge_impedance
(
self
/
start_nd_idx
end_nd_idx
edge_idx
)

The type of the None singleton.

validate

validate
(
self
/
)

The type of the None singleton.

build_edge_rtree

build_edge_rtree
(
self
/
)

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

set_barriers
(
self
/
barriers_wkt
)

Sets barrier geometries from WKT strings and builds the R-tree. Replaces any existing barriers.

unset_barriers

unset_barriers
(
self
/
)

Removes all barrier geometries and the associated R-tree.

street_node_lives

node_ys

node_xs

node_xyzs

node_zs

node_xys