aditya-grover / node2vec

http://snap.stanford.edu/node2vec/
MIT License
2.61k stars 912 forks source link

random ZeroDivisionError: float division by zero #17

Open Mrliuzhengming opened 7 years ago

Mrliuzhengming commented 7 years ago

hi, i run node2vec with a graph created by nx.read_adjlist(), but sometimes i have this problem. it's not always show up,when i adjust parameters like p,q,walk_length,number_walks.. how can slove this problem?

////////////////////////////////////////////////////// \node2vec.py", line 80, in get_alias_edge normalized_probs = [float(u_prob)/norm_const for u_prob in unnormalized_pro
bs] ZeroDivisionError: float division by zero //////////////////////////////////////////////////////

the dataset is DBLP,there are some nodes don't have edge..

TobiasSkovgaardJepsen commented 7 years ago

Hi

This issue occurs if you have a node with all outgoing edges with weight 0. Disconnected nodes does not cause this error, since the zero division only occurs if there are neighbors to iterate over.