Skip to content

Fix update link - #44

Open
parweb wants to merge 6 commits into
anvaka:mainfrom
parweb:fix-update-link
Open

Fix update link#44
parweb wants to merge 6 commits into
anvaka:mainfrom
parweb:fix-update-link

Conversation

@parweb

@parweb parweb commented Jun 16, 2022

Copy link
Copy Markdown

No description provided.

@parweb

parweb commented Jul 25, 2026

Copy link
Copy Markdown
Author

Re-checked this against current main (v20.1.2) before asking for anything — I think this PR is now obsolete and you may want to just close it.

The bug it was written for (stale Link references left in node.links after a link update, so removeLink would not clean the node side) no longer reproduces. createSingleLink now returns the existing link and mutates data in place, so the reference in node.links stays valid:

const g = createGraph();
g.addLink(1, 2, {w: 1});
g.addLink(1, 2, {w: 2});   // update
g.removeLink(g.getLink(1, 2));
// graph links: 0, node1.links.size: 0   ✅

Same result for multigraphs and self-loops.

What is left in the diff is the node.links Set -> Map change, which is a public API break — test/construction.js > add link adds link fails on it, since Array.from(node.links)[0] then yields [id, link] instead of the link. Not something worth landing to fix a bug that is already gone.

I have not touched the branch. Happy for you to close it — flagging rather than leaving it sitting in your queue.

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.

1 participant