Crash when edges are not initialised with a weight attribute
See original GitHub issueI am seeing the following crash when creating a Node2Vec
object on a graph with no weights attribute on its edges:
Traceback (most recent call last):
File "~/dev/pyiextract/graph.py", line 65, in <module>
node2vec = Node2Vec(G, dimensions=64, walk_length=30, num_walks=200, workers=4)
File "~/dev/pyiextract/venv/lib/python3.9/site-packages/node2vec/node2vec.py", line 73, in __init__
self._precompute_probabilities()
File "~/dev/pyiextract/venv/lib/python3.9/site-packages/node2vec/node2vec.py", line 125, in _precompute_probabilities
ss_weight = weight * 1 / q
TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'
If I initialise the edges with a weights attribute of 0.0, it seems to work. I can make a PR to assume 0.0 as a weight attribute if none exists however I want to understand what the intention is here, perhaps if this is expected an explicit error could be sent as an exception instead?
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Weighted directed graph adding an edge not working
You are defining a local variable "adjacencyList" in the constructor with the same name as the class variable. The local variable overrides ...
Read more >Trouble with dynamic edge weights - Gephi forums
I have successfully created and filtered dynamic edge weights in a very simple made-up graph, but even then the program crashed when I...
Read more >Why does my model exists some negative weight edges? #59
Hi, After learn the BN model, I use the 'sm.egdes(data)' and then I find some negative weight edges in my model. What's the...
Read more >NEWS - The Comprehensive R Archive Network
layout_nicely() now ignores edge weights when there are non-positive edge weights ... Fixed a set.vertex/edge.attribute bug that changed both graph objects, ...
Read more >C/igraph 0.9.9
This release includes bug fixes and documentation improvements, ... only non-negative weights are accepted, and all vertices must have ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in 0.4.6 (out on PyPI)
Both would be preferrable, I have a graph where nodes can be connected to other nodes via a link which is defined mainly by the connection attribute. For example “YYZ” -> “located in” -> “Toronto” and “YYZ” -> airport of -> “Toronto”.