VHRanger / nodevectors

Fastest network node embeddings in the west
MIT License
534 stars 60 forks source link

TypeError: 'method' object is not iterable #1

Closed dvarelas closed 4 years ago

dvarelas commented 5 years ago

I am getting this error when trying to run the unit tests.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-b3bd86b0b5de> in <module>()
      1 # Fit embedding model to graph
      2 g2v = Node2Vec()
----> 3 g2v.fit(G)

/home/dionysis/Documents/git_repos/graph2vec/graph2vec/graph.py in fit(self, nxGraph, verbose)
    356             Whether to print output while working
    357         """
--> 358         node_names = list(nxGraph.nodes)
    359         if type(node_names[0]) not in [int, str, np.int32, np.int64]:
    360             raise ValueError("Graph node names must be int or str!")

TypeError: 'method' object is not iterable

Do you think this line: https://github.com/VHRanger/graph2vec/blob/8474f7ccf5d9b34d82fbf5ac16f04bcc37143cd6/graph2vec/graph.py#L358

Should change to this:

 node_names = list(nxGraph.nodes())
cthoyt commented 5 years ago

Because networkx graphs are actually iterables of their nodes, you could also do this to avoid any possible discrepancies between networkx 1.X and 2.X:

node_names = list(nxGraph)

VHRanger commented 4 years ago

Fixed as per @cthoyt resolved

Sorry for lateness, I forgot to watch this repo when I made it