Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6430fe9
refactor: Rename `index` to `vertices`/`edges` in the attribute acces…
schochastics Oct 15, 2026
aea8b61
Merge remote-tracking branch 'origin/main' into claude/issue-2788-sub…
krlmlr Oct 18, 2026
cc0436b
chore: Auto-update from GitHub Actions
krlmlr Oct 18, 2026
6fc95bb
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 2, 2026
1640ebf
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 2, 2026
4f73152
test: Use `vertices` in the `V<-` protocol test
schochastics Dec 2, 2026
699985d
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 2, 2026
ac82684
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 2, 2026
fd0737a
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 2, 2026
c9bafcb
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 2, 2026
5896843
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 2, 2026
87f3197
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
f66b444
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
d09603e
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
b63b49d
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
a4a3c8f
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
c9d3535
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
1510ef1
chore: Auto-update from GitHub Actions
schochastics Dec 3, 2026
b197802
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
18309bc
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
c057c92
test: Drop the duplicated inbound-edges snapshot
schochastics Dec 3, 2026
5be4794
test: Drop a stray blank line from the structural-properties snapshots
schochastics Dec 3, 2026
f20ad01
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
d1a2aa3
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
9ca0c03
refactor: Let the generator own the remaining renames that positional…
schochastics Dec 3, 2026
a2ec8ff
Merge branch 'claude/issue-2788-subagents-faw1t1-7' into claude/issue…
schochastics Dec 3, 2026
2ecb143
Merge remote-tracking branch 'origin/claude/issue-2788-subagents-faw1…
schochastics Dec 3, 2026
41713c9
Merge remote-tracking branch 'origin/claude/issue-2788-subagents-faw1…
schochastics Dec 3, 2026
b001775
Merge remote-tracking branch 'origin/claude/issue-2788-subagents-faw1…
schochastics Dec 3, 2026
64e4550
chore: Auto-update from GitHub Actions
schochastics Dec 3, 2026
bd22768
chore: Trigger CI after the formatting update
schochastics Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
311 changes: 260 additions & 51 deletions R/attributes.R

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions man/edge_attr-set.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/edge_attr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/get.edge.attribute.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions man/get.vertex.attribute.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/set.edge.attribute.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/set.vertex.attribute.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man/set_edge_attr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man/set_vertex_attr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions man/set_vertex_attrs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man/vertex_attr-set.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/vertex_attr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions tests/testthat/_snaps/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,21 @@
Error in `set_vertex_attrs()`:
! All arguments in `...` must be named.

# attribute accessors with `index = ` are deprecated but still work

Code
res <- vertex_attr(g, "name", index = 2:3)
Condition
Warning:
The `index` argument of `vertex_attr()` is deprecated as of igraph 3.0.0.
i Please use the `vertices` argument instead.

---

Code
vertex_attr(g, "name", vertices = 1, index = 2)
Condition
Error in `vertex_attr()`:
! Argument `vertices` of `vertex_attr()` was supplied more than once.
i It was also supplied via its legacy name `index`.

57 changes: 55 additions & 2 deletions tests/testthat/test-attributes.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ test_that("we can set all attributes on some vertices/edges", {

g2 <- make_graph(c(2, 1, 3, 1, 4, 1, 2, 5, 3, 6))

vertex_attr(g2, index = c(1, 2, 4, 5)) <- vertex_attr(g)
vertex_attr(g2, vertices = c(1, 2, 4, 5)) <- vertex_attr(g)
expect_equal(
vertex_attr(g2),
list(
Expand All @@ -179,7 +179,7 @@ test_that("we can set all attributes on some vertices/edges", {
)
)

edge_attr(g2, index = c(1, 3, 5)) <- edge_attr(g)
edge_attr(g2, edges = c(1, 3, 5)) <- edge_attr(g)
expect_equal(
edge_attr(g2),
list(
Expand Down Expand Up @@ -570,6 +570,59 @@ test_that("set_vertex_attrs() works", {
expect_equal(V(g)$gender, rep("F", vcount(g)))
})

test_that("attribute accessors with `index = ` are deprecated but still work", {
rlang::local_options(lifecycle_verbosity = "warning")
g <- make_ring(5)
V(g)$name <- letters[1:5]
E(g)$weight <- 1:5

expect_snapshot_igraph(res <- vertex_attr(g, "name", index = 2:3))
expect_equal(res, vertex_attr(g, "name", vertices = 2:3))
lifecycle::expect_deprecated(res <- edge_attr(g, "weight", index = 2:3))
expect_equal(res, edge_attr(g, "weight", edges = 2:3))

lifecycle::expect_deprecated(
g2 <- set_vertex_attr(g, "x", index = 1:2, value = 1)
)
expect_identical_graphs(
g2,
set_vertex_attr(g, "x", vertices = 1:2, value = 1)
)
lifecycle::expect_deprecated(
g2 <- set_edge_attr(g, "x", index = 1:2, value = 1)
)
expect_identical_graphs(g2, set_edge_attr(g, "x", edges = 1:2, value = 1))
lifecycle::expect_deprecated(g2 <- set_vertex_attrs(g, x = 1, index = 1:2))
expect_identical_graphs(g2, set_vertex_attrs(g, x = 1, vertices = 1:2))

g2 <- g
lifecycle::expect_deprecated(vertex_attr(g2, "x", index = 1:2) <- 1)
g3 <- g
vertex_attr(g3, "x", vertices = 1:2) <- 1
expect_identical_graphs(g2, g3)

g2 <- g
lifecycle::expect_deprecated(edge_attr(g2, "x", index = 1:2) <- 1)
g3 <- g
edge_attr(g3, "x", edges = 1:2) <- 1
expect_identical_graphs(g2, g3)

expect_snapshot_igraph_error(vertex_attr(g, "name", vertices = 1, index = 2))
})

test_that("attribute accessors keep positional selectors", {
g <- make_ring(5)
V(g)$name <- letters[1:5]
expect_equal(vertex_attr(g, "name", 2:3), c("b", "c"))
g2 <- set_vertex_attr(g, "x", 1:2, value = 1)
expect_equal(V(g2)$x, c(1, 1, NA, NA, NA))
# `value` also stays positional
g2 <- set_vertex_attr(g, "x", 1:2, 1)
expect_equal(V(g2)$x, c(1, 1, NA, NA, NA))
g2 <- set_edge_attr(g, "x", 1:2, 1)
expect_equal(E(g2)$x, c(1, 1, NA, NA, NA))
})

test_that("querying one attribute without an index returns it for all vertices/edges", {
g <- make_ring(5)
V(g)$name <- letters[1:5]
Expand Down
7 changes: 5 additions & 2 deletions tests/testthat/test-constant-defaults.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ test_that("NULL selector defaults of round-2 functions select the full set", {
expect_identical_graphs(reverse_edges(g, edges = NULL), reverse_edges(g))

V(g)$name <- letters[1:5]
expect_identical(vertex_attr(g, "name", index = NULL), vertex_attr(g, "name"))
expect_identical(
vertex_attr(g, "name", vertices = NULL),
vertex_attr(g, "name")
)
expect_identical(vertex.attributes(g, index = NULL), vertex.attributes(g))
g2 <- set_vertex_attr(g, "x", index = NULL, value = 1)
g2 <- set_vertex_attr(g, "x", vertices = NULL, value = 1)
expect_identical(vertex_attr(g2, "x"), rep(1, 5))
})

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-iterators.R
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ test_that("custom replacement functions following the `V<-` protocol work", {
set_vertex_attr(
x,
attr(value, "name"),
index = value,
vertices = value,
value = attr(value, "value")
)
}
Expand Down
41 changes: 41 additions & 0 deletions tools/migrations/attributes.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Argument-signature migrations: attributes
# Schema: see tools/migrations/README.md. Regenerate with:
# Rscript tools/generate-migrations.R

migrations <- list(
# `index` became `vertices`/`edges` in its slot. A legacy call naming
# `index` and passing the value positionally,
# `set_vertex_attr(g, "x", index = i, v)`, keeps giving `v` to `value`.
set_vertex_attr = list(
old = function(graph, name, index, value) {},
new = function(
graph,
name,
vertices = NULL,
value,
index = deprecated()
) {},
when = "3.0.0"
),
set_edge_attr = list(
old = function(graph, name, index, value) {},
new = function(graph, name, edges = NULL, value, index = deprecated()) {},
when = "3.0.0"
),
`vertex_attr<-` = list(
old = function(graph, name, index, value) {},
new = function(
graph,
name,
vertices = NULL,
index = deprecated(),
value
) {},
when = "3.0.0"
),
`edge_attr<-` = list(
old = function(graph, name, index, value) {},
new = function(graph, name, edges = NULL, index = deprecated(), value) {},
when = "3.0.0"
)
)
Loading