anvaka / ngraph.graph

Graph data structure in JavaScript
BSD 3-Clause "New" or "Revised" License
520 stars 66 forks source link

`Node.links === null` when there are no links, inconsistent with type definition #35

Closed nemosmithasf closed 3 years ago

nemosmithasf commented 3 years ago

Type definition for Node.links seems to suggest that we return an empty array when there's no links.

The actual behaviour is returning Node.links === null.

anvaka commented 3 years ago

yes! That's a good catch. We don't create links until truly necessary, as this can causes significant increase of memory usage for the graphs with many isolated nodes.

anvaka commented 3 years ago

btw, this was fixed a while back: https://github.com/anvaka/ngraph.graph/blob/1659251bb3d7811e7c377ba4361b60039fd6c24d/index.d.ts#L56