Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
45f476f
Initial plan
Copilot Jan 25, 2026
f560006
feat: Add BFS and DFS callback closures
Copilot Jan 25, 2026
64243d8
fix: Handle NULL callbacks in BFS closure
Copilot Jan 25, 2026
53fe489
feat: Incorporate safe eval from hand-rolled implementation
Copilot Jan 25, 2026
3c9e6e1
Revert
krlmlr Jan 25, 2026
7683ee7
Extra safety
krlmlr Jan 25, 2026
49c45f1
Catch interrupts
krlmlr Jan 25, 2026
a33fa7e
Move
krlmlr Jan 25, 2026
a35a5bc
chore: Auto-update from GitHub Actions
krlmlr Jan 25, 2026
1856cc4
fix: Unify callback return value interpretation to TRUE=continue, FAL…
Copilot Jan 25, 2026
34cdceb
fix: Change all callbacks to TRUE=stop, FALSE=continue
Copilot Jan 25, 2026
4842870
docs: Update callback documentation to reflect TRUE=stop convention
Copilot Jan 25, 2026
39f2a4f
Merge branch 'main' into copilot/autogenerate-callback-functions
krlmlr Jan 26, 2026
9089248
chore: Auto-update from GitHub Actions
krlmlr Jan 26, 2026
a1f8a0c
Tweak motif test
krlmlr Jan 26, 2026
fd0b187
Tweak motif tests
krlmlr Jan 26, 2026
572177c
Merge branch 'main' into copilot/autogenerate-callback-functions
krlmlr Jan 26, 2026
a751e1a
test: Fix callback return value logic in tests
Copilot Jan 26, 2026
031cbb7
Merge branch 'main' into copilot/autogenerate-callback-functions
krlmlr Jan 26, 2026
713bb50
fix: Improve NULL handling for OPTIONAL VERTEX_INDICES in Stimulus
Copilot Jan 26, 2026
80f6d39
Merge branch 'main' into copilot/autogenerate-callback-functions
Copilot Jan 26, 2026
1ae10d1
Merge branch 'main' into copilot/autogenerate-callback-functions
krlmlr Jan 26, 2026
0620352
Fix conflict resolution
krlmlr Jan 26, 2026
453d5c1
chore: Auto-update from GitHub Actions
krlmlr Jan 26, 2026
47adb5f
Fix callback usage
krlmlr Jan 26, 2026
5e180af
Fix callback usage
krlmlr Jan 26, 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
270 changes: 249 additions & 21 deletions R/aaa-auto.R

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions R/cliques.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ clique.number <- function(graph) {
#' @param ... These dots are for future extensions and must be empty.
#' @param callback Optional function to call for each clique found. If provided,
#' the function should accept one argument: `clique` (integer vector of vertex
#' IDs in the clique, 1-based indexing). The function should return `TRUE` to
#' continue the search or `FALSE` to stop it. If `NULL` (the default), all
#' IDs in the clique, 1-based indexing). The function should return `FALSE` to
#' continue the search or `TRUE` to stop it. If `NULL` (the default), all
#' cliques are collected and returned as a list.
#'
#' **Important limitation:** Callback functions must NOT call any igraph
Expand Down
8 changes: 4 additions & 4 deletions R/cycles.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ find_cycle <- function(graph, mode = c("out", "in", "all", "total")) {
#' @param callback Optional function to call for each cycle found. If provided,
#' the function should accept two arguments: `vertices` (integer vector of vertex
#' IDs in the cycle) and `edges` (integer vector of edge IDs
#' in the cycle). The function should return `TRUE` to continue
#' the search or `FALSE` to stop it. If `NULL` (the default), all cycles are
#' in the cycle). The function should return `FALSE` to continue
#' the search or `TRUE` to stop it. If `NULL` (the default), all cycles are
#' collected and returned as a list.
#'
#' **Important limitation:** Callback functions must NOT call any igraph
Expand All @@ -103,8 +103,8 @@ find_cycle <- function(graph, mode = c("out", "in", "all", "total")) {
#' @param callback Optional function to call for each cycle found. If provided,
#' the function should accept two arguments: `vertices` (integer vector of vertex
#' IDs in the cycle) and `edges` (integer vector of edge IDs
#' in the cycle). The function should return `TRUE` to continue
#' the search or `FALSE` to stop it. If `NULL` (the default), all cycles are
#' in the cycle). The function should return `FALSE` to continue
#' the search or `TRUE` to stop it. If `NULL` (the default), all cycles are
#' collected and returned as a list.
#'
#' **Important limitation:** Callback functions must NOT call any igraph
Expand Down
2 changes: 1 addition & 1 deletion R/motifs.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ dyad.census <- function(graph) {
#' @param callback Optional callback function to call for each motif found.
#' The function should accept two arguments: `vids` (integer vector of vertex IDs
#' in the motif) and `isoclass` (the isomorphism class of the motif).
#' The function should return `TRUE` to continue the search or `FALSE` to stop it.
#' The function should return `FALSE` to continue the search or `TRUE` to stop it.
#' If `NULL` (the default), motif counts are returned as a numeric vector.
#'
#' **Important limitation:** Callback functions must NOT call any igraph
Expand Down
3 changes: 2 additions & 1 deletion R/structural-properties.R
Original file line number Diff line number Diff line change
Expand Up @@ -2633,7 +2633,8 @@ count_loops <- function(graph) {
#' @param dist Logical scalar, whether to return the distance from the root of
#' the search tree.
#' @param callback If not `NULL`, then it must be callback function. This
#' is called whenever a vertex is visited. See details below.
#' is called whenever a vertex is visited. The callback function should
#' return `FALSE` to continue the search or `TRUE` to stop it. See details below.
#' @param extra Additional argument to supply to the callback function.
#' @param rho The environment in which the callback function is evaluated.
#' @param neimode `r lifecycle::badge("deprecated")` This argument is deprecated
Expand Down
4 changes: 2 additions & 2 deletions R/topology.R
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ graph.count.subisomorphisms.vf2 <- function(
#' If provided, the function should accept two arguments: `map12` (integer vector
#' mapping vertex IDs from graph1 to graph2, 1-based indexing) and `map21`
#' (integer vector mapping vertex IDs from graph2 to graph1, 1-based indexing).
#' The function should return `TRUE` to continue the search or `FALSE` to stop it.
#' The function should return `FALSE` to continue the search or `TRUE` to stop it.
#' If `NULL` (the default), all isomorphisms are collected and returned as a list.
#' Only supported for `method = "vf2"`.
#'
Expand Down Expand Up @@ -895,7 +895,7 @@ isomorphisms <- function(graph1, graph2, method = "vf2", ..., callback = NULL) {
#' If provided, the function should accept two arguments: `map12` (integer vector
#' mapping vertex IDs from pattern to target, 1-based indexing) and `map21`
#' (integer vector mapping vertex IDs from target to pattern, 1-based indexing).
#' The function should return `TRUE` to continue the search or `FALSE` to stop it.
#' The function should return `FALSE` to continue the search or `TRUE` to stop it.
#' If `NULL` (the default), all subisomorphisms are collected and returned as a list.
#' Only supported for `method = "vf2"`.
#'
Expand Down
3 changes: 2 additions & 1 deletion man/bfs.Rd

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

4 changes: 2 additions & 2 deletions man/cliques.Rd

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

3 changes: 2 additions & 1 deletion man/graph.bfs.Rd

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

2 changes: 1 addition & 1 deletion man/isomorphisms.Rd

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

2 changes: 1 addition & 1 deletion man/motifs.Rd

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

4 changes: 2 additions & 2 deletions man/simple_cycles.Rd

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

2 changes: 1 addition & 1 deletion man/subgraph_isomorphisms.Rd

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

4 changes: 4 additions & 0 deletions src/cpp11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extern SEXP R_igraph_barabasi_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEX
extern SEXP R_igraph_betweenness(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_betweenness_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_betweenness_subset(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_bfs_closure(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_bfs_simple(SEXP, SEXP, SEXP);
extern SEXP R_igraph_biadjacency(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_bibcoupling(SEXP, SEXP);
Expand Down Expand Up @@ -137,6 +138,7 @@ extern SEXP R_igraph_delete_vertices(SEXP, SEXP);
extern SEXP R_igraph_delete_vertices_idx(SEXP, SEXP);
extern SEXP R_igraph_density(SEXP, SEXP);
extern SEXP R_igraph_deterministic_optimal_imitation(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_dfs_closure(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_diameter(SEXP, SEXP, SEXP);
extern SEXP R_igraph_diameter_dijkstra(SEXP, SEXP, SEXP, SEXP);
extern SEXP R_igraph_difference(SEXP, SEXP);
Expand Down Expand Up @@ -657,6 +659,7 @@ static const R_CallMethodDef CallEntries[] = {
{"R_igraph_betweenness", (DL_FUNC) &R_igraph_betweenness, 4},
{"R_igraph_betweenness_cutoff", (DL_FUNC) &R_igraph_betweenness_cutoff, 5},
{"R_igraph_betweenness_subset", (DL_FUNC) &R_igraph_betweenness_subset, 6},
{"R_igraph_bfs_closure", (DL_FUNC) &R_igraph_bfs_closure, 7},
{"R_igraph_bfs_simple", (DL_FUNC) &R_igraph_bfs_simple, 3},
{"R_igraph_biadjacency", (DL_FUNC) &R_igraph_biadjacency, 4},
{"R_igraph_bibcoupling", (DL_FUNC) &R_igraph_bibcoupling, 2},
Expand Down Expand Up @@ -742,6 +745,7 @@ static const R_CallMethodDef CallEntries[] = {
{"R_igraph_delete_vertices_idx", (DL_FUNC) &R_igraph_delete_vertices_idx, 2},
{"R_igraph_density", (DL_FUNC) &R_igraph_density, 2},
{"R_igraph_deterministic_optimal_imitation", (DL_FUNC) &R_igraph_deterministic_optimal_imitation, 6},
{"R_igraph_dfs_closure", (DL_FUNC) &R_igraph_dfs_closure, 6},
{"R_igraph_diameter", (DL_FUNC) &R_igraph_diameter, 3},
{"R_igraph_diameter_dijkstra", (DL_FUNC) &R_igraph_diameter_dijkstra, 4},
{"R_igraph_difference", (DL_FUNC) &R_igraph_difference, 2},
Expand Down
Loading
Loading