# Errata: Data Structures and Algorithms Book!

**URL:** https://forum.kirupa.com/t/errata-data-structures-and-algorithms-book/663668
**Category:** programming
**Created:** [December 15, 2023, 3:54am UTC](https://forum.kirupa.com/t/errata-data-structures-and-algorithms-book/663668 "2023-12-15T03:54:20Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)
#### Post date: [March 11, 2025, 6:12pm UTC](https://forum.kirupa.com/t/errata-data-structures-and-algorithms-book/663668/13 "2025-03-11T18:12:08Z")

</div>

Hi @anlexN - you are right. It required me to sleep and wake up today and see it with a fresher perspective 😛

In what I had originally, instead of removing references to the deleted node, I’m removing self-references (which don’t exist anyway). It should be as you described earlier:

```auto
removeNode(nodeToRemove) {
  if (this.nodes.has(nodeToRemove)) {
    // Remove the node and its edges from the graph
    this.nodes.delete(nodeToRemove);

    // Remove any incident edges in other nodes
    for (const [node, adjacentNodes] of this.nodes) {
      adjacentNodes.delete(nodeToRemove); // Now properly removing nodeToRemove
    }
  }
}

```

Thanks for flagging this. I’ll update the errata to call this out.

---

_[View the full topic](https://forum.kirupa.com/t/errata-data-structures-and-algorithms-book/663668)._
