FFrankyy / FINDER

FINDER - FInding key players in complex Networks through DEep Reinforcement learning (Nature Machine Intelligence)
MIT License
176 stars 46 forks source link

Working with nx.graph objects when there are disconnected nodes in the graph #13

Closed jernsting closed 3 years ago

jernsting commented 3 years ago

If you have a nx.graph object where a node is disconnected (or removed) from the graph, FINDER will fail to analyze this.

Code for reproduction:

>>> test = np.array([0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1], [1, 1, 1, 0]])
>>> g = nx.from_numpy_array(test)
>>> g.remove_node(2)
>>> 
>>> # some more detail:
>>> a, b = zip(*g.edges())
>>> a
(0, 1)
>>> b    # <<< Here is the error!
(3, 3)
>>> len(g.nodes())
3

I already created a pull request (#12) on this and I am only filing this issue for convenient issue tracking.