ngraph.graph icon indicating copy to clipboard operation
ngraph.graph copied to clipboard

Adds oriented version of getLink and allow people to set default orientatidness

Open FelixMo42 opened this issue 6 years ago • 2 comments

I added an oriented param to getLink so that you can get links pointing either direction easier and makes it easier to see if two links are connected in either direction. Even if they are connected in both direction it will only return one.

Allow people to set the default oriented parameter for using getLink and forEachLinkedNode by doing createGraph({oriented: true}).

I made some unit-testing for it.

FelixMo42 avatar Nov 11 '19 03:11 FelixMo42

There is an option in forEachLinkedNode() method, which allows to do oriented/non oriented traversal. Does it work for your use case?

By default getLink is oriented, and I'm somewhat reluctant to extend its API without proper use case. Very often this method lies on a hot path, and adding a few more arguments/checks while seem innocent on the surface may cause higher price for CPU intensive algorithms. If there is a general need for getting non-oriented link via getLink we can discuss it, and it seem to be well suited for the scope of https://github.com/anvaka/ngraph.graph/issues/13

What do you think?

anvaka avatar Nov 12 '19 05:11 anvaka

Currently, there is no fast way to figure out if to nodes are connected in either direction. You have to call hasLink(from, to) and hasLink(to, from).

FelixMo42 avatar Nov 12 '19 15:11 FelixMo42