-
-
Notifications
You must be signed in to change notification settings - Fork 206
feat: add error if adding a vertices results in duplicated names attribute #1932
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
base: main
Are you sure you want to change the base?
Conversation
re #60 and the Cons: Might be annoying for quick prototyping |
Should also look at #1250 |
R/attributes.R
Outdated
if (is.null(current_names)) { | ||
current_names <- rep(NA_character_, vcount(graph)) | ||
} | ||
idx_numeric <- as.numeric(index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed? (genuine question)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the graph has no name attribute but we add a vertex with a name, we need to set all other names to NA (this is consistent with most of igraph but not really a good solution. Needs to be addressed elsewhere)
h <- make_full_graph(3)
set_vertex_attr(h, "name", 2, "B")
#>IGRAPH 4d3e0a7 UN-- 3 3 -- Full graph
#>+ attr: name (g/c), loops (g/l), name (v/c)
#>+ edges from 4d3e0a7 (vertex names):
#>[1] NA--B NA--NA B --NA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was more curious about the as.numeric()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah sorry. That was actually not needed and my mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please resolve conversations, happy to review in a second iteration. The code looks complex.
Co-authored-by: Maëlle Salmon <[email protected]>
Co-authored-by: Maëlle Salmon <[email protected]>
Co-authored-by: Maëlle Salmon <[email protected]>
Co-authored-by: Maëlle Salmon <[email protected]>
all comments addressed and I think I made it a bit simpler |
Does this affect only disjoint_union? There are other ways to create duplicate names. |
Yes there should be more places. The question is, what should happen in this case. I think we reached a form of consensus last week, but I can't remember what we thought was the best way to deal with it. I think it might have been to throw an error if a named and unnamed object are combined |
Ok I realise I talked about combining unnamed and named objects only. The pr is about erroring for duplicated vertex names. I think this covers all places where this can happen or do I see any other place? |
Fix #46 (check if #60 could be addressed)
Should this be an error now?
rigraph/R/operators.R
Lines 264 to 266 in 0386a24
also need a strategy for this
Created on 2025-07-03 with reprex v2.1.1