Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with edge_index #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

fjwong
Copy link

@fjwong fjwong commented Mar 31, 2020

This fixes a bug when creating the induced graph, in which the first edge of the induced graph (with index 0) can end up being duplicated instead of having its weight updated.

@fjwong
Copy link
Author

fjwong commented Mar 31, 2020

By the way, thank you for making this library.
I've been using it a lot in one of my projects.

graph.edges.push(edge);
edge_index[edge.source + '_' + edge.target] = graph.edges.length - 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand why you think this is wrong? Indexes shouldn't go up to length; otherwise the other changes look fine :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this logic is not wrong at all. It's just that subtracting 1 seemed a bit redundant since we can get the same value from graph.edges.length prior to adding the edge to graph.edges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants