ngraph.graph v20.0.0 Release Notes

  • The changelog is introduced. Justification for it is that there is a breaking change in the library, and I wanted to call it out here.

    getLink(fromId, toId) / getLinks(nodeId)

    graph.getLinks(nodeId) now returns a Set object. Previous version of the method returned an Array.

    ๐ŸŽ Pre v20.0.0 library versions, getLink(fromId, toId) operation had O(deg(fromId)) time performance.

    ๐ŸŽ In v20.0.0 the links are manged via sets, driving the getLink() performance down to O(1).

    โšก๏ธ How to update?

    If your library used graph.getLinks(fromId).length constructs, you'll need to change that to graph.getLinks(fromId).size

    โž• addLink(fromId, toId, data)

    For non-multigraphs, this method will now act similar to addNode(nodeId, data). If link is already present in the graph it will replace old with new data. Otherwise a new link will be created.

    Prior versions of the library always create a new link and clients were required to check link presence to avoid duplicates.

    // this code is no longer necessary:
    if (graph.hasLink(fromId, toId) || graph.hasLink(toId, fromId)) {
      graph.addLink(fromId, toId, 42);
    // In version v20.0.0 it is equivalent to:
    graph.addLink(fromId, toId, 42);

    For multigraphs this method will act the same way as before - a new link will always be created.