Skip to content

why is enumerate_paths not returning an iterator? #217

@henrik-wolf

Description

@henrik-wolf

Currently, the enumerate_paths function returns a vector which contains a bunch of things, depending on the type of state you put into it. Especially when looking at all shortest paths (for example from floyd_warshall_shortest_paths) of a graph with n nodes, this allocates a vector of length n which contains vectors of length n which in turn contain vectors of various lengths, containing the paths.

I feel like iterating over all paths is the main use case for this function, so it would make sense to me to return an iterator which runs over all paths, rather than to allocate a vector of paths. Is there some reason why this approach has not been considered?

Changing the behaviour of enumerate_paths would probably be breaking, so maybe, if there are no huge problems I missed, I propose we add this to the "Graphs 2.0" wishlist under issue #146.
If you think something like this would be a good addition, I might give it a go and build an iterate_paths function, once I find the time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions