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

Implicit graph helper struct #32

Open
pnevyk opened this issue Dec 25, 2022 · 1 comment
Open

Implicit graph helper struct #32

pnevyk opened this issue Dec 25, 2022 · 1 comment

Comments

@pnevyk
Copy link
Owner

pnevyk commented Dec 25, 2022

Inspired by pathfinding crate, it would be nice to have a possibility to specify a structure of an implicit graph just by providing a function to get the neighbors of a vertex. Currently, it is necessary to implement several traits (Neighbors and *Weak traits).

There could be a struct Implicit that would be a wrapper over a generic F that would represent a function implementing the Neighbors::neighbors_directed. The rest of Neighbors trait plus all *Weak traits would be implemented by the wrapper.

The implementation of Neighbors::neighbors will be probably a bit tricky, it needs to correctly handle undirected and directed graphs. And the type of Neighbors::NeighborsIter will need to be something like Box<dyn Iterator> so that the implementation of Neighbors::neighbors can chain outgoing and incoming edges.

@pnevyk
Copy link
Owner Author

pnevyk commented Oct 30, 2023

And alternative or complement might be to implement all the mentioned traits for any appropriate F: Fn(...) -> ..., so that a function or closure could be sent directly in place of graph G.

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

1 participant