momepy.
local_closeness_centrality
(graph, radius=5, name='closeness', distance=None, weight=None)[source]¶Calculates local closeness for each node based on the defined distance.
Subgraph is generated around each node within set radius. If distance=None, radius will define topological distance, otherwise it uses values in distance attribute. Based on networkx.closeness_centrality.
Local closeness centrality of a node u is the reciprocal of the average shortest path distance to u over all n-1 nodes within subgraph.
where d(v, u) is the shortest-path distance between v and u, and n is the number of nodes that can reach u.
Graph representing street network.
Ideally genereated from GeoDataFrame using momepy.gdf_to_nx()
number of topological steps defining the extent of subgraph
calculated attribute name
Use specified edge data key as distance. For example, setting distance=’weight’ will use the edge weight to measure the distance from the node n during ego_graph generation.
Use the specified edge attribute as the edge distance in shortest path calculations in closeness centrality algorithm
networkx.Graph
References
Porta S, Crucitti P and Latora V (2006) The network analysis of urban streets: A primal approach. Environment and Planning B: Planning and Design 33(5): 705–725.
Examples
>>> network_graph = mm.local_closeness_centrality(network_graph, radius=400, distance='edge_length')