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

add_vertex! should return the added vertex. #122

Open
chelate opened this issue Apr 29, 2022 · 3 comments
Open

add_vertex! should return the added vertex. #122

chelate opened this issue Apr 29, 2022 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@chelate
Copy link

chelate commented Apr 29, 2022

So I often write code like

add_vertex!(tree) # returns "true" for some reason ???
v = last(vertices(tree))
...

wouldn't it be great if add_vertex! returned something useful, and guaranteed to be the fresh vertex added, instead of a boolean that I can't imagine a use for? PROPOSAL

v = add_vertex!(tree) #new vertex is the return value!

Let me know if I'm missing something. If people love that boolean (Why???) we can always pass it as the first argument but on the whole this would just be way better.

@etiennedeg
Copy link
Member

I agree that returning the created vertex would be great, but that would be a big breaking change... Maybe we can consider it for a 2.0 release ?

@simonschoelly
Copy link
Contributor

That would indeed be a breaking change, but it is also very useful, as the current behavior always assumes that the added vertex has the identifier nv(g). In the meantime we could change the functions to something like:

add_vertex!(g; return_added_vertices=false)
add_vertices!(g; return_added_vertices=false)

and if return_added_vertices is true, we would return the added vertices.

@gdalle
Copy link
Member

gdalle commented May 13, 2022

How about starting a roadmap for 2.0 with big breaking changes we would like to see happen? I have a few of my own, eg. #77

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

No branches or pull requests

4 participants