spacenet.node_metrics.degree#

spacenet.node_metrics.degree(spatial_network, nodes=None, edge_weight_name='Distance', add_as_node_label=False, node_label_name='degree')#

Computes the weighted degree for the nodes in the spatial network.

Parameters:
spatial_networkNetworkX graph

The spatial network for which to calculate the degree.

nodeslist or np.ndarray, optional

The set of nodes to compute the degree. Default is ‘None’, computing for all nodes.

edge_weight_namestr, optional

The name of the edge attribute in the graph that corresponds to the distance between nodes. Default is ‘Distance’. For unweighted degree, set this to None.

add_as_node_labelbool, optional

Whether to add the computed degree values as a node attribute in the spatial network. Default is False.

node_label_namestr, optional

The name of the node attribute to which to add the computed degree values if add_as_node_label is True. Default is ‘degree’.

Returns:
degree_valuesnp.ndarray

An array of degree values for the specified nodes in the spatial network. The order of the values corresponds to the order of the nodes in the ‘nodes’ parameter.

nodesnp.ndarray

An array of the node ids for which the degree values were computed. The order of the nodes corresponds to the order of the values in the ‘degree_values’ array.