gboeing / osmnx

OSMnx is a Python package to easily download, model, analyze, and visualize street networks and other geospatial features from OpenStreetMap.
https://osmnx.readthedocs.io
MIT License
4.88k stars 827 forks source link

not implemented for multigraph type #247

Closed omrakn closed 5 years ago

omrakn commented 5 years ago

When running eigenvector centrality by nx.eigenvector_centrality following error is produced: NetworkXNotImplemented: not implemented for multigraph type.

Closeness and betweenness centrality modules are working without any problem.

I've already checked #178, #8 and #157 but they didn't help. I'm using osmnx version 0.8.2, networkx 2.2 and python 3.6.6

# name, network and whichresult are the inputs from interface
    G = ox.graph_from_place(name, network_type=str(network), which_result=int(whichresult)) 
    G_proj = ox.project_graph(G)    

    eigen_centrality = nx.eigenvector_centrality(G_proj)
gboeing commented 5 years ago

This is a networkx question, as it is their implementation of eigenvector centrality that is causing your error. OSMnx itself seems to be producing your MultiDiGraph object properly. Networkx appears not to implement their eigenvector centrality algorithm for MultiDiGraph objects, so you'd have to convert your object like:

G2 = nx.DiGraph(G)
eigen_centrality = nx.eigenvector_centrality(G2, max_iter=1000)
davidfoutch42 commented 1 year ago

First, when I run the code using: sources = list(zip(edges)[0]) targets = list(zip(edges)[1]) I get a subscript error...which I believe I have corrected using: sources = list(zip(edges)) targets = list(zip(edges)) sources = sources[0] targets = targets[1]

However, I have no clue how to correct this error NameError: name 'visJS_module' is not defined

Any help would be appreciated.