question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash when edges are not initialised with a weight attribute

See original GitHub issue

I 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:closed
  • Created a year ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
eliorccommented, Aug 1, 2022

Fixed in 0.4.6 (out on PyPI)

0reactions
8W9aGcommented, Jul 28, 2022

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”.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found