spacenet.centrality.degree_centrality#
- spacenet.centrality.degree_centrality(spatial_network, nodes=None, edge_weight_name='Distance', add_as_node_label=False, node_label_name='degree')#
Computes the degree centrality for the nodes in the spatial network. The degree centrality of a node is defined as the sum of the weights of the edges connected to that node, normalized by the total volume of the network.
- Parameters:
- spatial_networkNetworkX graph
The spatial network for which to calculate the degree centrality.
- nodeslist or np.ndarray, optional
The set of nodes to compute the centrality. 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’.
- add_as_node_labelbool, optional
Whether to add the computed centrality 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 centrality values if add_as_node_label is True. Default is ‘degree’.
- Returns:
- degree_valuesnp.ndarray
An array of degree centrality 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 centrality values were computed. The order of the nodes corresponds to the order of the values in the ‘degree_values’ array.