Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General findPath function #27

Open
adamjanicki2 opened this issue Mar 21, 2024 · 5 comments
Open

General findPath function #27

adamjanicki2 opened this issue Mar 21, 2024 · 5 comments

Comments

@adamjanicki2
Copy link
Contributor

One of our use cases is a general findPath function, so I wanted to make an issue to discuss design before diving into implementing it. My thoughts are it should be a function like follows

function findPath(start, end) { ... }

which returns a path of type Array<string | number> to get from start to end. The function should attempt to use parent pointers to climb from end to start, but do a BFS/DFS if no parents are set. Before implementing this, we will need to resolve #26 because in a situation like this where parents aren't necessary but helpful, it would be nice to do a console.warn about it (see end of #26)

@LeaVerou
Copy link
Member

I don't think #26 is a blocker. But if this function ends up walking, it should definitely set parent pointers as it goes!

@LeaVerou
Copy link
Member

One issue is: you'd expect this function to stop once it finds the requested node. But currently, we assume that if a node has a parent pointer, its descendants also have parent pointers.

@adamjanicki2
Copy link
Contributor Author

One issue is: you'd expect this function to stop once it finds the requested node. But currently, we assume that if a node has a parent pointer, its descendants also have parent pointers.

Yeah, maybe we should wait on setting parent pointers here

@LeaVerou
Copy link
Member

Not sure. When we really care we do tend to use force. Maybe we should invert force and make it be the default behavior of updateParents().

@karger
Copy link

karger commented Mar 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants