spacenet.utils.spatial_network_from_adjacency#

spacenet.utils.spatial_network_from_adjacency(points, adjacency_matrix, inverse_distance_function=None, node_ids=None)#

Generates a spatial network from a given adjacency matrix and node coordinates. The function creates a NetworkX graph object, adds nodes and edges, and computes inverse distances for the edges based on the provided or default inverse distance function. Edge weights for ‘Distance’ and ‘Inverse Distance’ will be added to the network. Node indices correspond to the indices of the input points array. Nodes will have a ‘position’ attribute corresponding to their spatial coordinates from the input points array.

Parameters:
pointsnumpy.ndarray

An array of shape (n, 2) representing the coordinates of the nodes in the network. Points should be ordered in ascending order of node ids in the adjacency matrix.

adjacency_matrixnp.ndarray or csr_array

A weighted adjacency array where non-zero entries represent edges in the spatial network. The values will be considered as the distances between nodes.

inverse_distance_functioncallable, optional

A function that takes a distance as an argument and returns an inverse distance value.

node_idsarray-like, optional

An array of custom node identifiers corresponding to the input points. If None, enumerated node indices will be used as identifiers. Default is None.

Returns:
Gnetworkx.Graph

A NetworkX graph object representing the spatial network, with nodes and edges added.