Add more advanced ways of iterating nodes and links
- Dominant language
- JavaScript
- Stars
- 580
- Forks
- 72
- PR merge metrics
- No merged PRs in 30d
Description
Hi @anvaka!
Thank you for your huge work on the `ngraph` packages family. It is cool, except there is a vital thing not implemented yet - so is a convenient and universal way to iterate through nodes/links. The existing way of iteration via callback provided to internal foreach cycle is not enough, as:
1. The `ngraph.graph` package controls the iteration and one cannot suspend execution somewhere in the middle of the cycle.
1. It requires an intermediate array to write graph elements to if one wants to pass them anywhere else.
#1 is a pretty similar issue, @ZigGreen probably wanted the same thing - a convenient way to iterate through elements.
**I suppose** adding methods that will return ECMAScript 6 iterators a cool way to deal with this problem. An iterator is a simple object so it is completely compatible with vanilla JavaScript.
Everyone who is happy to afford using ECMAScript 6 features can then use `for..of` and `*yield` syntax with the returned iterator. For everybody else we could create a simple `ngraph.iteration` package with common functional methods, such as `map`/`filter`/`forEach`, written on vanilla JS.
Another benefit of this approach is that the internal `nodes` object won't be able to be changed by user.
The only possible problem may be a concurrency issue... or not?
What do you think about it?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the existing callback-based node and link iteration in ngraph.graph. Define the iterator and concurrency requirements before identifying an implementation scope; the issue is done only when the API and its supported iteration behavior are agreed and implemented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100