-
Notifications
You must be signed in to change notification settings - Fork 92
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
Indexability of vertices
and neighbors
#282
Comments
See #270 |
Very good question, for the moment, the |
The One downside I already see is the |
This might be possible with something like Base.hasmethod - I am just always a bit careful with such reflection based methods, as I think I run into some world age issues when I had much less experience with Julia. But the julia standard library also seems to use it, so maybe it is indeed possible. |
Something like function collect_if_not_indexable(vs)
if Base.hasmethod(getindex, (typeof(vs), Integer))
return vs
else
return collect(vs)
end
end |
Either that or we wrap it inside a struct that does indexing by enumeration, and we pay non-constant indexing cost |
In the PRs done by @simonschoelly to test on generic graphs, he frequently ran into trouble because collections like
vertices(g)
orneighbors(g, v)
were not indexable. This explains the appearance of the functioncollect_if_not_vector
throughout the code.@etiennedeg what will this behavior look like in GraphsBase?
The text was updated successfully, but these errors were encountered: