-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Topological metrics #74
Conversation
-Update and test KStest
-Update and test KStest -Add and test flow/flooding for a 'dominant' outlet
update to merge with `metric_format`
revert kstest_betweenness
try and make the diff tidier
Revert kstest test
refactor
move utiltiies up
keep ks betweenness the same
proper subgraph values->to_numpy
avoid intersects
Very nice comparison! Perhaps, you can compute and compare these metrics for the GRIP and OSM datasets, for the same bounding box. |
For one of my projects, I wrote this function for computing BC in parallel, it can speed up the computations by a factor of 3 or 4 depending on the complexity of the network: import joblib
import networkx as nx
import cytoolz.curried as tlz
from collections import defaultdict
def edge_betweenness_centrality(G: nx.Graph, normalized: bool = True, weight: str = "weight", njobs: int = -1):
"""Parallel betweenness centrality function"""
njobs = joblib.cpu_count(True) if njobs == -1 else njobs
node_chunks = tlz.partition_all(G.order() // njobs, G.nodes())
bt_func = tlz.partial(nx.edge_betweenness_centrality_subset, G=G, normalized=normalized, weight=weight)
bt_sc = joblib.Parallel(n_jobs=njobs)(
joblib.delayed(bt_func)(sources=nodes, targets=G.nodes()) for nodes in node_chunks
)
# Merge the betweenness centrality results
bt_c = defaultdict(float)
for bt in bt_sc:
for n, v in bt.items():
bt_c[n] += v
return bt_c Also, there's this library called In one of my tests, the BC computation with |
OK I will make an issue, #80, for |
@cheginit Oh I think I have used |
Note that this is for edge BC, for node BC, you need to change the function, so you should compare it with |
Yep yep! |
-Use taher's new function for edge betweenness -introduce new metric for edge betweenness (in contrast to node betweenness) -update requirements
Description
Place to implement topological metrics
Fixes #50
Summary of changes:
metric_utilities
.debug_topology
to study whether these metrics are behaving sensibly.Summary of
debug_topology
:prepare_data.py/download_street
), a slightly larger street network which contains the small graph, and a slightly larger one again which contains that, finally another larger street network graph which does not overlap the first three.Observations:
nc_laplacian_dist
,nc_laplacian_norm_dist
,nc_adjacency_dist
, andkstest_betweenness
the large and separate graphs are very close - not good! Additionally these four seem to be somewhat behaving similarly.nc_deltacon0
andnc_resistance_distance
seem to be behaving similarly.nc_vertex_edge_distance
seems to have very large values in general, but I would say qualitatively seems closer to thelaplacian
-type results.Thus, provided we are happy that these are implemented properly - I think this covers quite well different measures of topological distance. In my tests these metrics are quick to calculate, but if they become prohibitive, we have evidence here to select maybe only 2 or 3 to cover the broad categories of behaviour.