anvaka / ngraph.graph

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

multigraphs and uniqueLinkId, deprecated or misdocumented? #34

Closed nemosmithasf closed 3 years ago

nemosmithasf commented 3 years ago

I see that when multigraph = true, we use the createUniqueLink method. However, there's currently a TODO comment that says createUniqueLink should be removed.

Does that mean the multigraph option is deprecated? If so, what is the advised alternative? Thanks.

https://github.com/anvaka/ngraph.graph/blob/75d5679c1ac228040a4226701201c80dc0adff4a/index.js#L373

anvaka commented 3 years ago

Sorry for confusion. Multigraphs are not going anywhere, it's just that I don't like an implementation of createUniqueLink method, because it is 18% slower than non-multigraph options.

I updated the TODO comment to be more specific: // TODO: Find a better/faster way to store multigraphs

nemosmithasf commented 3 years ago

I see, thanks for the heads-up.

As a side-note for working with multigraphs; perhaps you can consider the ability to provide a "differentiator" ID to make sibling links unique in a way thats less fragile than using insert order.

One example would be if a list of link-IDs is saved externally; if the insert order changes, the saved list would become invalidated.