feat: add error if adding a vertices results in duplicated names attribute#1932
feat: add error if adding a vertices results in duplicated names attribute#1932schochastics wants to merge 9 commits intomainfrom
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.
why is this needed? (genuine question)
There was a problem hiding this comment.
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 --NAThere was a problem hiding this comment.
I was more curious about the as.numeric().
There was a problem hiding this comment.
ah sorry. That was actually not needed and my mistake
krlmlr
left a comment
There was a problem hiding this comment.
Please resolve conversations, happy to review in a second iteration. The code looks complex.
Co-authored-by: Maëlle Salmon <maelle.salmon@yahoo.se>
Co-authored-by: Maëlle Salmon <maelle.salmon@yahoo.se>
Co-authored-by: Maëlle Salmon <maelle.salmon@yahoo.se>
Co-authored-by: Maëlle Salmon <maelle.salmon@yahoo.se>
|
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