-
Notifications
You must be signed in to change notification settings - Fork 21
Throw a BoundsError when setting an attribute for a vertex that doesn't exist #2
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
Comments
I modeled this behavior on |
Given that |
One thing that I like about the Also, I find it a little weird that if I want to add a new vertex with no metadata, I have to do this: g[:a] = nothing (and likewise for adding edges with no metadata). EDIT: |
I'm not a big fan of
? |
Yeah, that seems reasonable. |
The current behavior is that
g[:a] = "hello"
sets the vertex attribute for vertex:a
to"hello"
and it creates a new vertex with the index:a
if it doesn't exist already. This syntax looks convenient, but I think it's a bit dangerous. Normally in Julia if you try to set a value at an index that doesn't exist, you get aBoundsError
. I think it would be best to stick with that convention here. So if you want to add a vertex you have to explicitly add it viaadd_vertex!(g, :a, "hello")
.The text was updated successfully, but these errors were encountered: