diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index ed3263e344a..b5bccb8346d 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -76,7 +76,7 @@ jobs: ref: ${{ inputs.ref }} - name: Update status for rcc - if: github.actor != 'github-copilot[bot]' + if: github.actor != 'Copilot' # FIXME: Wrap into action env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -182,7 +182,7 @@ jobs: - name: Update status for rcc # FIXME: Wrap into action - if: always() && (github.actor != 'github-copilot[bot]') + if: always() && (github.actor != 'Copilot') env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -219,12 +219,16 @@ jobs: - name: Update status for rcc (Copilot) # Update status directly when triggered by Copilot or bots, since they can't dispatch workflows - if: always() && (github.actor == 'github-copilot[bot]') + if: always() && (github.actor == 'Copilot') env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - # Check status of this workflow - state="pending" + # Set status to success if job succeeded, failure otherwise + if [ "${{ job.status }}" == "success" ]; then + state="success" + else + state="failure" + fi sha=${{ inputs.ref }} if [ -z "${sha}" ]; then sha=${{ github.sha }} diff --git a/.github/workflows/vendor.yaml b/.github/workflows/vendor.yaml index 7f578d3ccec..e7f37a08933 100644 --- a/.github/workflows/vendor.yaml +++ b/.github/workflows/vendor.yaml @@ -7,7 +7,7 @@ on: - "vendor-one.sh" workflow_dispatch: schedule: - - cron: "0 * * * *" + - cron: "* 0 * * *" concurrency: group: ${{ github.workflow }} diff --git a/.gitignore b/.gitignore index dd12d586c35..85e2c445848 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,6 @@ cran /rchk /src/*.d /src/symbols.rds +/tests/testthat/testthat-problems.rds /covr +/.vscode/launch.json diff --git a/AGENTS.md b/AGENTS.md index fd56874ab77..6356d1d21fc 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -31,15 +31,16 @@ pak::pak(dependencies = "Config/Needs/build") - When run on GitHub Actions, assume that R, the package in its current state and all dependencies are installed. - Only install new packages when needed for implementing new features or tests. -- Run `R -q -e 'testthat::test_local(reporter = "check")'` to execute tests as a final step. +- Run `R -q -e 'devtools::check()'` to execute all checks as a final step. ### Building and Testing - Load package for development: `pkgload::load_all()` - Run tests: `testthat::test_local(reporter = "check")` +- Run tests for a single file `test-foo.R`: `testthat::test_local(filter = "foo", reporter = "check")` - Build package: `devtools::build()` - Check package: `devtools::check()` -- Update documentation: `devtools::document()` +- Update `.Rd` documentation: `devtools::document()` - Format code: `air format .` ## Code Style and Documentation @@ -54,21 +55,24 @@ pak::pak(dependencies = "Config/Needs/build") - Prefer expressive code over comments where possible - Add comments to utility functions that cannot be made immediately obvious - Focus comments on explaining the "why" and "how", the "what" should be clear from the code itself -- Use line breaks after each sentence in multi-sentence comments +- Use line breaks after each sentence ### R Code Conventions -- Follow the [tidyverse style guide](https://style.tidyverse.org) +- Follow the [tidyverse style guide](https://style.tidyverse.org) and the [tidyverse design guide](https://design.tidyverse.org) - Use `snake_case` for new functions - Use explicit package prefixes (e.g., `withr::local_db_connection()`) for clarity - Maintain consistent indentation (2 spaces) and spacing patterns - Use meaningful variable names that reflect context - Run `air format .` before committing changes to ensure consistent formatting +- Never change deprecated functions ### Documentation - Use roxygen2 with Markdown syntax for all function documentation +- Use math notation for formulas: `\eqn{...}` for inline, `\deqn{...}` for display equations - Keep each sentence on its own line in roxygen2 comments for better readability +- Document all arguments and return values - Document internal functions using devtag (work in progress) - Link to C documentation using `@cdocs` tag: `#' @cdocs igraph_function_name` - Always run `devtools::document()` after updating documentation @@ -77,6 +81,25 @@ pak::pak(dependencies = "Config/Needs/build") - Use `max` for maximal (graph theory term: a vertex is maximal if no other vertex dominates it) and `largest` for maximum (the biggest value in a set) +### New functions + +All new functions must include: + +- Examples +- Tests +- Proper documentation, including arguments and return values +- A concept so that it exists in the pkgdown reference index +- An "experimental" badge via `r lifecycle::badge("experimental")` +- All arguments in `snake_case`, with documentation and suitable defaults +- An ellipsis guarded with `check_dots_empty()` separating mandatory and optional arguments +- Argument validation using built-in `check_*()` functions or `igraph_arg_match()` + +If exporting a new function from the C library: + +- Ensure it is autogenerated +- Add tests for the `_impl` function +- Name all arguments in all calls to the `_impl` function + ## File Structure and Organization ### Test Files @@ -95,9 +118,19 @@ Update them using: `make -f Makefile-cigraph src/rinterface.c R/aaa-auto.R` See `tools/README.md` for guidelines on code generation using the Stimulus framework. +### Build Artifacts + +Do not commit: `*.d`, `*.o`, `*.so` files in `src/`, and `tests/testthat/testthat-problems.rds`. +These are build artifacts that are regenerated automatically (see `src/README.md` for details on dependency tracking). + +Careful with changes to `*.dd`, keep system headers out, only expect changes if new source files are added or their local dependencies change. + ## Testing - Add test cases for all new functionality - For newly created autogenerated functions, always add a test to `test-aaa-auto.R` - Test file naming should mirror source file naming +- Implement both structured and snapshot tests. For the latter, ensure stability by setting a random seed and calling `local_igraph_options(print.id = FALSE)` if graph IDs are involved. +- When testing error behavior, prefer snapshot tests. - Run tests frequently during development and at the end: `testthat::test_local(reporter = "check")` +- Run `devtools::check()` as a final step to ensure all checks pass. diff --git a/DESCRIPTION b/DESCRIPTION index eb028b7ff11..3a694d5b571 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: igraph Title: Network Analysis and Visualization -Version: 2.2.1.9000 +Version: 2.2.1.9003 Authors@R: c( person("Gábor", "Csárdi", , "csardi.gabor@gmail.com", role = "aut", comment = c(ORCID = "0000-0001-7098-9676")), diff --git a/NAMESPACE b/NAMESPACE index 95be07fb203..d69b94b23d8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -222,6 +222,7 @@ export(centralize) export(centralize.scores) export(chordal_ring) export(chung_lu) +export(circulant) export(cit_cit_types) export(cit_types) export(cited.type.game) @@ -272,9 +273,11 @@ export(count.multiple) export(count_automorphisms) export(count_components) export(count_isomorphisms) +export(count_loops) export(count_max_cliques) export(count_motifs) export(count_multiple) +export(count_reachable) export(count_subgraph_isomorphisms) export(count_triangles) export(create.communities) @@ -366,6 +369,7 @@ export(from_prufer) export(full_bipartite_graph) export(full_citation_graph) export(full_graph) +export(full_multipartite) export(get.adjacency) export(get.adjedgelist) export(get.adjlist) @@ -529,6 +533,7 @@ export(induced_subgraph) export(infomap.community) export(interconnected.islands.game) export(intersection) +export(invalidate_cache) export(is.bipartite) export(is.chordal) export(is.connected) @@ -648,6 +653,7 @@ export(local_scan) export(make_) export(make_bipartite_graph) export(make_chordal_ring) +export(make_circulant) export(make_clusters) export(make_de_bruijn_graph) export(make_directed_graph) @@ -657,6 +663,7 @@ export(make_from_prufer) export(make_full_bipartite_graph) export(make_full_citation_graph) export(make_full_graph) +export(make_full_multipartite) export(make_graph) export(make_kautz_graph) export(make_lattice) @@ -665,6 +672,8 @@ export(make_neighborhood_graph) export(make_ring) export(make_star) export(make_tree) +export(make_tri_lattice) +export(make_turan) export(make_undirected_graph) export(match_vertices) export(max_bipartite_match) @@ -681,6 +690,7 @@ export(maximal.independent.vertex.sets) export(maximal_ivs) export(maximum.bipartite.matching) export(maximum.cardinality.search) +export(mean_degree) export(mean_distance) export(membership) export(merge_coords) @@ -865,11 +875,14 @@ export(topo_sort) export(topological.sort) export(traits) export(traits_callaway) +export(transitive_closure) export(transitivity) export(tree) +export(tri_lattice) export(triad.census) export(triad_census) export(triangles) +export(turan) export(undirected_graph) export(unfold.tree) export(unfold_tree) diff --git a/NEWS.md b/NEWS.md index 89c6ad8caad..47db062864d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,144 @@ +# igraph 2.2.1.9003 + +## Bug fixes + +- Fix `alpha_centrality()` crash when `weights` is a custom attribute name (#915, #2403). + +## Features + +- Add `make_full_multipartite()` and `make_turan()` graph constructors (#1562, #2406). + +- Add `count_loops()` to R interface (#1379, #2414). + +- Add `make_circulant()` to expose `igraph_circulant()` (#1563, #2407). + +- Add `mean_degree()` to R (#1380, #2415). + +- `vertices()` errors on duplicate attribute names (#1248, #2430). + +- Add `count_reachable()` function to R (#1349, #2412). + +## Chore + +- Auto-update from GitHub Actions (#2454). + + +# igraph 2.2.1.9002 + +## Bug fixes + +- Use `LC_ALL=C` instead of `LOCALE=C` in `deps.mk` (#2446, #2447). + +## Features + +- Add autogeneration for all C functions currently in use (#2424, #2442). + +## Chore + +- Format. + +- Ensure args are named. + +## Continuous integration + +- Fix final status as set by Copilot \[ci skip\]. + +## Documentation + +- More instructions \[ci skip\]. + +## Refactoring + +- Switch from `.Call()` to autogenerated `_impl` functions (#2434, #2443). + +## Testing + +- Add structured tests alongside snapshot tests for ALL \_impl functions in test-aaa-auto.R (#2448, #2449). + +## Uncategorized + +- Merge branch 'cran-2.2.1'. + + +# igraph 2.2.1.9001 + +## Bug fixes + +- Fix matrix lists for output. + +## Features + +- Add `invalidate_cache()` to R interface (#1387, #2416). + +- All arguments in calls to `_impl()` functions are named (#2423). + +## Chore + +- Use `Rx_` prefix for manually generated functions. + +- Clarify error testing preference \[ci skip\]. + +- Ignore \[ci skip\]. + +- Use `_impl` variants instead of inline `.Call()` for five functions with changed C signatures (#2428, #2429). + +- Format \[ci skip\]. + +- Expand remaining `_impl` aliases (#2422). + +- Remove unused `NTIMER` and `NPRINT` macro definitions (#1095, #2405). + +- Cleanup. + +- Request math notation. + +### deps + +- Bump jinja2 from 3.1.2 to 3.1.6 in /tools/py-stimulus (#2401). + +- Replace `_impl` aliases in `R/flow.R` (#2347, #2379). + +- Autogenerated file looks more like as if it was formatted with `air` (#2395). + +## Continuous integration + +- Run daily vendoring to avoid noise \[ci skip\]. + +- Snapshots \[ci skip\]. + +- Use proper actor name \[ci skip\]. + +- Reduce contention by running big matrices overnight. + +- Add workflow to auto-assign to Copilot. + +- Run running sanitizer only on cran branches to avoid pipeline contention. + +## Documentation + +- More instructions \[ci skip\]. + +- More instructions \[ci skip\]. + +- More instructions \[ci skip\]. + +- More instructions \[ci skip\]. + +- Experimental. + +- New code \[ci skip\]. + +- Add GitHub Copilot instructions and expand AGENTS.md (#2397, #2400). + +## Refactoring + +- Replace `_impl` aliases with explicit wrapper functions in `R/topology.R` (#2366, #2398). + +- Replace \_impl aliases in R/other.R (#2355, #2388). + + # igraph 2.2.1.9000 ## Chore diff --git a/R/aaa-auto.R b/R/aaa-auto.R index a019de8c302..70f78682028 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -38,6 +38,25 @@ add_edges_impl <- function( res } +add_vertices_impl <- function( + graph, + nv +) { + # Argument checks + ensure_igraph(graph) + nv <- as.numeric(nv) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_add_vertices, + graph, + nv + ) + + res +} + copy_impl <- function( from ) { @@ -54,6 +73,44 @@ copy_impl <- function( res } +delete_edges_impl <- function( + graph, + edges +) { + # Argument checks + ensure_igraph(graph) + edges <- as_igraph_es(graph, edges) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_delete_edges, + graph, + edges - 1 + ) + + res +} + +delete_vertices_impl <- function( + graph, + vertices +) { + # Argument checks + ensure_igraph(graph) + vertices <- as_igraph_vs(graph, vertices) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_delete_vertices, + graph, + vertices - 1 + ) + + res +} + delete_vertices_idx_impl <- function( graph, vertices @@ -89,6 +146,22 @@ vcount_impl <- function( res } +ecount_impl <- function( + graph +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_ecount, + graph + ) + + res +} + neighbors_impl <- function( graph, vid, @@ -119,6 +192,22 @@ neighbors_impl <- function( res } +is_directed_impl <- function( + graph +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_is_directed, + graph + ) + + res +} + degree_impl <- function( graph, vids = V(graph), @@ -144,6 +233,25 @@ degree_impl <- function( res } +edges_impl <- function( + graph, + eids +) { + # Argument checks + ensure_igraph(graph) + eids <- as_igraph_es(graph, eids) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_edges, + graph, + eids - 1 + ) + + res +} + get_all_eids_between_impl <- function( graph, from, @@ -183,6 +291,36 @@ get_all_eids_between_impl <- function( res } +incident_impl <- function( + graph, + vid, + mode = c("all", "out", "in", "total") +) { + # Argument checks + ensure_igraph(graph) + vid <- as_igraph_vs(graph, vid) + if (length(vid) == 0) { + cli::cli_abort( + "{.arg vid} must specify at least one vertex", + call = rlang::caller_env() + ) + } + mode <- switch_igraph_arg(mode, "out" = 1L, "in" = 2L, "all" = 3L, "total" = 3L) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_incident, + graph, + vid - 1, + mode + ) + if (igraph_opt("return.vs.es")) { + res <- create_es(graph, res) + } + res +} + wheel_impl <- function( n, mode = c("out", "in", "undirected", "mutual"), @@ -491,6 +629,22 @@ kautz_impl <- function( res } +famous_impl <- function( + name +) { + # Argument checks + + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_famous, + name + ) + + res +} + lcf_vector_impl <- function( n, shifts, @@ -601,6 +755,12 @@ full_multipartite_impl <- function( mode ) + if (igraph_opt("add.params")) { + res$name <- 'Full multipartite graph' + res$n <- n + res$mode <- mode + } + res } @@ -691,6 +851,11 @@ circulant_impl <- function( directed ) + if (igraph_opt("add.params")) { + res$name <- 'Circulant graph' + res$shifts <- shifts + } + res } @@ -729,6 +894,12 @@ turan_impl <- function( r ) + if (igraph_opt("add.params")) { + res$name <- 'Turan graph' + res$n <- n + res$r <- r + } + res } @@ -2380,6 +2551,28 @@ personalized_pagerank_vs_impl <- function( res } +rewire_impl <- function( + rewire, + n, + mode = c("simple", "simple_loops") +) { + # Argument checks + ensure_igraph(rewire) + n <- as.numeric(n) + mode <- switch_igraph_arg(mode, "simple" = 0L, "simple_loops" = 1L) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_rewire, + rewire, + n, + mode + ) + + res +} + induced_subgraph_impl <- function( graph, vids, @@ -2664,6 +2857,35 @@ reciprocity_impl <- function( res } +constraint_impl <- function( + graph, + vids = V(graph), + weights = NULL +) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && !all(is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_constraint, + graph, + vids - 1, + weights + ) + + res +} + maxdegree_impl <- function( graph, ..., @@ -2729,6 +2951,25 @@ mean_degree_impl <- function( res } +topological_sorting_impl <- function( + graph, + mode = c("out", "in", "all", "total") +) { + # Argument checks + ensure_igraph(graph) + mode <- switch_igraph_arg(mode, "out" = 1L, "in" = 2L, "all" = 3L, "total" = 3L) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_topological_sorting, + graph, + mode + ) + + res +} + feedback_arc_set_impl <- function( graph, weights = NULL, @@ -2944,6 +3185,24 @@ count_multiple_impl <- function( res } +girth_impl <- function( + graph +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_girth, + graph + ) + if (igraph_opt("return.vs.es")) { + res$circle <- create_vs(graph, res$circle) + } + res +} + is_perfect_impl <- function( graph ) { @@ -4616,6 +4875,28 @@ largest_cliques_impl <- function( res } +maximal_cliques_count_impl <- function( + graph, + min.size = 0, + max.size = 0 +) { + # Argument checks + ensure_igraph(graph) + min.size <- as.numeric(min.size) + max.size <- as.numeric(max.size) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_maximal_cliques_count, + graph, + min.size, + max.size + ) + + res +} + maximal_cliques_hist_impl <- function( graph, min.size = 0, @@ -4764,7 +5045,7 @@ is_independent_vertex_set_impl <- function( res } -layout_random_impl <- function( +largest_independent_vertex_sets_impl <- function( graph ) { # Argument checks @@ -4773,36 +5054,88 @@ layout_random_impl <- function( on.exit(.Call(R_igraph_finalizer)) # Function call res <- .Call( - R_igraph_layout_random, + R_igraph_largest_independent_vertex_sets, graph ) - + if (igraph_opt("return.vs.es")) { + res <- lapply(res, unsafe_create_vs, graph = graph, verts = V(graph)) + } res } -layout_circle_impl <- function( - graph, - order = V(graph) +maximal_independent_vertex_sets_impl <- function( + graph ) { # Argument checks ensure_igraph(graph) - order <- as_igraph_vs(graph, order) on.exit(.Call(R_igraph_finalizer)) # Function call res <- .Call( - R_igraph_layout_circle, - graph, - order - 1 + R_igraph_maximal_independent_vertex_sets, + graph ) - + if (igraph_opt("return.vs.es")) { + res <- lapply(res, unsafe_create_vs, graph = graph, verts = V(graph)) + } res } -layout_star_impl <- function( - graph, - center = V(graph)[1], - order = NULL +independence_number_impl <- function( + graph +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_independence_number, + graph + ) + + res +} + +layout_random_impl <- function( + graph +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_layout_random, + graph + ) + + res +} + +layout_circle_impl <- function( + graph, + order = V(graph) +) { + # Argument checks + ensure_igraph(graph) + order <- as_igraph_vs(graph, order) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_layout_circle, + graph, + order - 1 + ) + + res +} + +layout_star_impl <- function( + graph, + center = V(graph)[1], + order = NULL ) { # Argument checks ensure_igraph(graph) @@ -5200,6 +5533,44 @@ layout_align_impl <- function( res } +cocitation_impl <- function( + graph, + vids = V(graph) +) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_cocitation, + graph, + vids - 1 + ) + + res +} + +bibcoupling_impl <- function( + graph, + vids = V(graph) +) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_bibcoupling, + graph, + vids - 1 + ) + + res +} + similarity_dice_impl <- function( graph, vids = V(graph), @@ -5708,6 +6079,72 @@ graphlets_impl <- function( res } +graphlets_candidate_basis_impl <- function( + graph, + weights = NULL +) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && !all(is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_graphlets_candidate_basis, + graph, + weights + ) + if (igraph_opt("return.vs.es")) { + res$cliques <- lapply(res$cliques, unsafe_create_vs, graph = graph, verts = V(graph)) + } + res +} + +graphlets_project_impl <- function( + graph, + weights = NULL, + cliques, + Muc, + startMu = FALSE, + niter = 1000 +) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && !all(is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + Muc <- as.numeric(Muc) + startMu <- as.logical(startMu) + niter <- as.numeric(niter) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_graphlets_project, + graph, + weights, + lapply(cliques, function(.x) .x - 1), + Muc, + startMu, + niter + ) + + class(res) <- "igraphHRG" + res +} + hrg_fit_impl <- function( graph, hrg = NULL, @@ -5973,6 +6410,25 @@ get_adjacency_sparse_impl <- function( res } +get_edgelist_impl <- function( + graph, + bycol = FALSE +) { + # Argument checks + ensure_igraph(graph) + bycol <- as.logical(bycol) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_get_edgelist, + graph, + bycol + ) + + res +} + get_stochastic_impl <- function( graph, column.wise = FALSE, @@ -6072,6 +6528,223 @@ to_undirected_impl <- function( res } +read_graph_pajek_impl <- function( + instream +) { + # Argument checks + check_string(instream) + + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_read_graph_pajek, + instream + ) + + res +} + +read_graph_graphml_impl <- function( + instream, + index = 0 +) { + # Argument checks + check_string(instream) + + index <- as.numeric(index) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_read_graph_graphml, + instream, + index + ) + + res +} + +read_graph_graphdb_impl <- function( + instream, + directed = FALSE +) { + # Argument checks + check_string(instream) + + directed <- as.logical(directed) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_read_graph_graphdb, + instream, + directed + ) + + res +} + +read_graph_gml_impl <- function( + instream +) { + # Argument checks + check_string(instream) + + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_read_graph_gml, + instream + ) + + res +} + +read_graph_dl_impl <- function( + instream, + directed = TRUE +) { + # Argument checks + check_string(instream) + + directed <- as.logical(directed) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_read_graph_dl, + instream, + directed + ) + + res +} + +write_graph_edgelist_impl <- function( + graph, + outstream +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_write_graph_edgelist, + graph, + outstream + ) + + res +} + +write_graph_leda_impl <- function( + graph, + outstream, + names = "name", + weights = "weight" +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_write_graph_leda, + graph, + outstream, + names, + weights + ) + + res +} + +write_graph_graphml_impl <- function( + graph, + outstream, + prefixattr = TRUE +) { + # Argument checks + ensure_igraph(graph) + prefixattr <- as.logical(prefixattr) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_write_graph_graphml, + graph, + outstream, + prefixattr + ) + + res +} + +write_graph_pajek_impl <- function( + graph, + outstream +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_write_graph_pajek, + graph, + outstream + ) + + res +} + +write_graph_gml_impl <- function( + graph, + outstream, + options = c("default", "encode_only_quot"), + id, + creator = NULL +) { + # Argument checks + ensure_igraph(graph) + options <- switch_igraph_arg(options, "default" = 0L, "encode_only_quot" = 1L) + id <- as.numeric(id) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_write_graph_gml, + graph, + outstream, + options, + id, + creator + ) + + res +} + +write_graph_dot_impl <- function( + graph, + outstream +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_write_graph_dot, + graph, + outstream + ) + + res +} + motifs_randesu_impl <- function( graph, size = 3, @@ -6406,88 +7079,202 @@ local_scan_neighborhood_ecount_impl <- function( neighborhoods ) { # Argument checks - ensure_igraph(graph) - if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { - weights <- E(graph)$weight - } - if (!is.null(weights) && !all(is.na(weights))) { - weights <- as.numeric(weights) - } else { - weights <- NULL - } + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && !all(is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_local_scan_neighborhood_ecount, + graph, + weights, + lapply(neighborhoods, function(.x) .x - 1) + ) + + res +} + +local_scan_subset_ecount_impl <- function( + graph, + weights = NULL, + subsets +) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && !all(is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_local_scan_subset_ecount, + graph, + weights, + lapply(subsets, function(.x) .x - 1) + ) + + res +} + +list_triangles_impl <- function( + graph +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_list_triangles, + graph + ) + if (igraph_opt("return.vs.es")) { + res <- create_vs(graph, res) + } + res +} + +disjoint_union_impl <- function( + left, + right +) { + # Argument checks + ensure_igraph(left) + ensure_igraph(right) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_disjoint_union, + left, + right + ) + + res +} + +join_impl <- function( + left, + right +) { + # Argument checks + ensure_igraph(left) + ensure_igraph(right) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_join, + left, + right + ) + + res +} + +union_impl <- function( + left, + right +) { + # Argument checks + ensure_igraph(left) + ensure_igraph(right) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_union, + left, + right + ) + + res +} + +intersection_impl <- function( + left, + right +) { + # Argument checks + ensure_igraph(left) + ensure_igraph(right) on.exit(.Call(R_igraph_finalizer)) # Function call res <- .Call( - R_igraph_local_scan_neighborhood_ecount, - graph, - weights, - lapply(neighborhoods, function(.x) .x - 1) + R_igraph_intersection, + left, + right ) res } -local_scan_subset_ecount_impl <- function( - graph, - weights = NULL, - subsets +difference_impl <- function( + orig, + sub ) { # Argument checks - ensure_igraph(graph) - if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { - weights <- E(graph)$weight - } - if (!is.null(weights) && !all(is.na(weights))) { - weights <- as.numeric(weights) - } else { - weights <- NULL - } + ensure_igraph(orig) + ensure_igraph(sub) on.exit(.Call(R_igraph_finalizer)) # Function call res <- .Call( - R_igraph_local_scan_subset_ecount, - graph, - weights, - lapply(subsets, function(.x) .x - 1) + R_igraph_difference, + orig, + sub ) res } -list_triangles_impl <- function( - graph +complementer_impl <- function( + graph, + loops = FALSE ) { # Argument checks ensure_igraph(graph) + loops <- as.logical(loops) on.exit(.Call(R_igraph_finalizer)) # Function call res <- .Call( - R_igraph_list_triangles, - graph + R_igraph_complementer, + graph, + loops ) - if (igraph_opt("return.vs.es")) { - res <- create_vs(graph, res) - } + res } -join_impl <- function( - left, - right +compose_impl <- function( + g1, + g2 ) { # Argument checks - ensure_igraph(left) - ensure_igraph(right) + ensure_igraph(g1) + ensure_igraph(g2) on.exit(.Call(R_igraph_finalizer)) # Function call res <- .Call( - R_igraph_join, - left, - right + R_igraph_compose, + g1, + g2 ) res @@ -6662,6 +7449,66 @@ maxflow_impl <- function( res } +mincut_impl <- function( + graph, + capacity = NULL +) { + # Argument checks + ensure_igraph(graph) + if (is.null(capacity) && "capacity" %in% edge_attr_names(graph)) { + capacity <- E(graph)$capacity + } + if (!is.null(capacity) && !all(is.na(capacity))) { + capacity <- as.numeric(capacity) + } else { + capacity <- NULL + } + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_mincut, + graph, + capacity + ) + if (igraph_opt("return.vs.es")) { + res$partition1 <- create_vs(graph, res$partition1) + } + if (igraph_opt("return.vs.es")) { + res$partition2 <- create_vs(graph, res$partition2) + } + if (igraph_opt("return.vs.es")) { + res$cut <- create_es(graph, res$cut) + } + res +} + +mincut_value_impl <- function( + graph, + capacity = NULL +) { + # Argument checks + ensure_igraph(graph) + if (is.null(capacity) && "capacity" %in% edge_attr_names(graph)) { + capacity <- E(graph)$capacity + } + if (!is.null(capacity) && !all(is.na(capacity))) { + capacity <- as.numeric(capacity) + } else { + capacity <- NULL + } + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_mincut_value, + graph, + capacity + ) + + res +} + residual_graph_impl <- function( graph, capacity, @@ -6772,6 +7619,82 @@ st_mincut_impl <- function( res } +vertex_connectivity_impl <- function( + graph, + checks = TRUE +) { + # Argument checks + ensure_igraph(graph) + checks <- as.logical(checks) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_vertex_connectivity, + graph, + checks + ) + + res +} + +edge_connectivity_impl <- function( + graph, + checks = TRUE +) { + # Argument checks + ensure_igraph(graph) + checks <- as.logical(checks) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_edge_connectivity, + graph, + checks + ) + + res +} + +adhesion_impl <- function( + graph, + checks = TRUE +) { + # Argument checks + ensure_igraph(graph) + checks <- as.logical(checks) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_adhesion, + graph, + checks + ) + + res +} + +cohesion_impl <- function( + graph, + checks = TRUE +) { + # Argument checks + ensure_igraph(graph) + checks <- as.logical(checks) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_cohesion, + graph, + checks + ) + + res +} + dominator_tree_impl <- function( graph, root, @@ -6980,6 +7903,44 @@ minimum_size_separators_impl <- function( res } +cohesive_blocks_impl <- function( + graph +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_cohesive_blocks, + graph + ) + if (igraph_opt("return.vs.es")) { + res$blocks <- lapply(res$blocks, unsafe_create_vs, graph = graph, verts = V(graph)) + } + class(res) <- "cohesiveBlocks" + res +} + +coreness_impl <- function( + graph, + mode = c("all", "out", "in", "total") +) { + # Argument checks + ensure_igraph(graph) + mode <- switch_igraph_arg(mode, "out" = 1L, "in" = 2L, "all" = 3L, "total" = 3L) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_coreness, + graph, + mode + ) + + res +} + isoclass_impl <- function( graph ) { @@ -7980,6 +8941,25 @@ sir_impl <- function( res } +running_mean_impl <- function( + data, + binwidth +) { + # Argument checks + data <- as.numeric(data) + binwidth <- as.numeric(binwidth) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_running_mean, + data, + binwidth + ) + + res +} + convex_hull_2d_impl <- function( data ) { @@ -8342,6 +9322,48 @@ is_complete_impl <- function( res } +minimum_spanning_tree_unweighted_impl <- function( + graph +) { + # Argument checks + ensure_igraph(graph) + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_minimum_spanning_tree_unweighted, + graph + ) + + res +} + +minimum_spanning_tree_prim_impl <- function( + graph, + weights +) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && !all(is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit(.Call(R_igraph_finalizer)) + # Function call + res <- .Call( + R_igraph_minimum_spanning_tree_prim, + graph, + weights + ) + + res +} + random_spanning_tree_impl <- function( graph, vid = 0 diff --git a/R/adjacency.R b/R/adjacency.R index c96f3f1a54d..32eda290846 100644 --- a/R/adjacency.R +++ b/R/adjacency.R @@ -290,7 +290,7 @@ graph_from_adjacency_matrix <- function( add.rownames = NA ) { ensure_no_na(adjmatrix, "adjacency matrix") - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) if (!is.matrix(adjmatrix) && !inherits(adjmatrix, "Matrix")) { lifecycle::deprecate_soft( @@ -415,7 +415,7 @@ graph.adjacency.dense <- function( if (is.logical(diag)) { diag <- ifelse(diag, "once", "ignore") } - diag <- igraph.match.arg(diag) + diag <- igraph_match_arg(diag) diag <- switch(diag, "ignore" = 0L, "twice" = 1L, "once" = 2L) if (nrow(adjmatrix) != ncol(adjmatrix)) { diff --git a/R/assortativity.R b/R/assortativity.R index e6f9c98ca93..b33f9a7395d 100644 --- a/R/assortativity.R +++ b/R/assortativity.R @@ -212,7 +212,13 @@ assortativity <- function( values.in <- types2 } - assortativity_impl(graph, values, values.in, directed, normalized) + assortativity_impl( + graph = graph, + values = values, + values.in = values.in, + directed = directed, + normalized = normalized + ) } assortativity_legacy <- function( @@ -221,7 +227,12 @@ assortativity_legacy <- function( types2 = NULL, directed = TRUE ) { - assortativity_impl(graph, types1, types2, directed) + assortativity_impl( + graph = graph, + values = types1, + values.in = types2, + directed = directed + ) } #' @param types Vector giving the vertex types. They as assumed to be integer diff --git a/R/attributes.R b/R/attributes.R index 1e3348ac6e8..cf4291f95c8 100644 --- a/R/attributes.R +++ b/R/attributes.R @@ -328,7 +328,7 @@ graph_attr <- function(graph, name) { check_string(name) - .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ + .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph)[[ name ]] } @@ -402,7 +402,7 @@ set_graph_attr <- function(graph, name, value) { graph.attributes <- function(graph) { ensure_igraph(graph) .Call( - R_igraph_mybracket2_copy, + Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, igraph_attr_idx_graph @@ -418,7 +418,7 @@ graph.attributes <- function(graph) { } .Call( - R_igraph_mybracket2_set, + Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_graph, @@ -460,7 +460,7 @@ vertex_attr <- function(graph, name, index = V(graph)) { check_string(name) myattr <- .Call( - R_igraph_mybracket2, + Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex @@ -610,7 +610,7 @@ i_set_vertex_attr <- function( } vattrs <- .Call( - R_igraph_mybracket2, + Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex @@ -644,7 +644,7 @@ i_set_vertex_attr <- function( } .Call( - R_igraph_mybracket2_set, + Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_vertex, @@ -661,7 +661,7 @@ vertex.attributes <- function(graph, index = V(graph)) { } res <- .Call( - R_igraph_mybracket2_copy, + Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, igraph_attr_idx_vertex @@ -721,7 +721,7 @@ set_value_at <- function(value, idx, length_out) { } .Call( - R_igraph_mybracket2_set, + Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_vertex, @@ -762,7 +762,7 @@ edge_attr <- function(graph, name, index = E(graph)) { } else { check_string(name) myattr <- .Call( - R_igraph_mybracket2, + Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge @@ -866,7 +866,7 @@ i_set_edge_attr <- function( } eattrs <- .Call( - R_igraph_mybracket2, + Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge @@ -897,7 +897,7 @@ i_set_edge_attr <- function( } .Call( - R_igraph_mybracket2_set, + Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_edge, @@ -914,7 +914,7 @@ edge.attributes <- function(graph, index = E(graph)) { } res <- .Call( - R_igraph_mybracket2_copy, + Rx_igraph_mybracket2_copy, graph, igraph_t_idx_attr, igraph_attr_idx_edge @@ -964,7 +964,7 @@ edge.attributes <- function(graph, index = E(graph)) { } .Call( - R_igraph_mybracket2_set, + Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_edge, @@ -987,7 +987,7 @@ edge.attributes <- function(graph, index = E(graph)) { graph_attr_names <- function(graph) { ensure_igraph(graph) res <- .Call( - R_igraph_mybracket2_names, + Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, igraph_attr_idx_graph @@ -1016,7 +1016,7 @@ vertex_attr_names <- function(graph) { ensure_igraph(graph) res <- .Call( - R_igraph_mybracket2_names, + Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, igraph_attr_idx_vertex @@ -1044,7 +1044,7 @@ vertex_attr_names <- function(graph) { edge_attr_names <- function(graph) { ensure_igraph(graph) res <- .Call( - R_igraph_mybracket2_names, + Rx_igraph_mybracket2_names, graph, igraph_t_idx_attr, igraph_attr_idx_edge @@ -1078,7 +1078,7 @@ delete_graph_attr <- function(graph, name) { } gattr <- .Call( - R_igraph_mybracket2, + Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_graph @@ -1086,7 +1086,7 @@ delete_graph_attr <- function(graph, name) { gattr[[name]] <- NULL .Call( - R_igraph_mybracket2_set, + Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_graph, @@ -1118,7 +1118,7 @@ delete_vertex_attr <- function(graph, name) { } vattr <- .Call( - R_igraph_mybracket2, + Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex @@ -1126,7 +1126,7 @@ delete_vertex_attr <- function(graph, name) { vattr[[name]] <- NULL .Call( - R_igraph_mybracket2_set, + Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_vertex, @@ -1158,7 +1158,7 @@ delete_edge_attr <- function(graph, name) { } eattr <- .Call( - R_igraph_mybracket2, + Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge @@ -1166,7 +1166,7 @@ delete_edge_attr <- function(graph, name) { eattr[[name]] <- NULL .Call( - R_igraph_mybracket2_set, + Rx_igraph_mybracket2_set, graph, igraph_t_idx_attr, igraph_attr_idx_edge, diff --git a/R/bipartite.R b/R/bipartite.R index bf1dfb4673b..fdb184dd7b3 100644 --- a/R/bipartite.R +++ b/R/bipartite.R @@ -179,7 +179,7 @@ bipartite_projection <- function( probe1 <- -1 } which <- switch( - igraph.match.arg(which), + igraph_match_arg(which), "both" = 0L, "false" = 1L, "true" = 2L diff --git a/R/centrality.R b/R/centrality.R index 54f9c4bbb00..a8f328560bc 100644 --- a/R/centrality.R +++ b/R/centrality.R @@ -444,27 +444,12 @@ betweenness <- function( normalized = FALSE, cutoff = -1 ) { - ensure_igraph(graph) - - v <- as_igraph_vs(graph, v) - directed <- as.logical(directed) - if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { - weights <- E(graph)$weight - } - if (!is.null(weights) && any(!is.na(weights))) { - weights <- as.numeric(weights) - } else { - weights <- NULL - } - cutoff <- as.numeric(cutoff) - on.exit(.Call(R_igraph_finalizer)) - res <- .Call( - R_igraph_betweenness_cutoff, - graph, - v - 1, - directed, - weights, - cutoff + res <- betweenness_cutoff_impl( + graph = graph, + vids = v, + directed = directed, + weights = weights, + cutoff = cutoff ) if (normalized) { vc <- as.numeric(vcount(graph)) @@ -474,9 +459,6 @@ betweenness <- function( res <- 2 * res / (vc * vc - 3 * vc + 2) } } - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- V(graph)$name[v] - } res } @@ -490,29 +472,12 @@ edge_betweenness <- function( weights = NULL, cutoff = -1 ) { - # Argument checks - ensure_igraph(graph) - e <- as_igraph_es(graph, e) - directed <- as.logical(directed) - if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { - weights <- E(graph)$weight - } - if (!is.null(weights) && any(!is.na(weights))) { - weights <- as.numeric(weights) - } else { - weights <- NULL - } - cutoff <- as.numeric(cutoff) - - on.exit(.Call(R_igraph_finalizer)) - # Function call - res <- .Call( - R_igraph_edge_betweenness_cutoff, - graph, - directed, - weights, - cutoff + res <- edge_betweenness_cutoff_impl( + graph = graph, + directed = directed, + weights = weights, + cutoff = cutoff ) res[as.numeric(e)] } @@ -624,7 +589,7 @@ closeness <- function( vids <- as_igraph_vs(graph, vids) mode <- switch( - igraph.match.arg(mode), + igraph_match_arg(mode), "out" = 1, "in" = 2, "all" = 3, @@ -1056,7 +1021,7 @@ arpack <- function( } on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_arpack, func, extra, options, env, sym) + res <- .Call(Rx_igraph_arpack, func, extra, options, env, sym) if (complex) { rew <- arpack.unpack.complex( @@ -1094,7 +1059,7 @@ arpack.unpack.complex <- function(vectors, values, nev) { on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_arpack_unpack_complex, vectors, values, nev) + res <- .Call(Rx_igraph_arpack_unpack_complex, vectors, values, nev) res } @@ -1245,7 +1210,7 @@ spectrum <- function( } eigen_adjacency_impl( - graph, + graph = graph, algorithm = algorithm, which = which, options = options @@ -2053,7 +2018,7 @@ alpha.centrality.dense <- function( attr <- NULL } else if (is.character(weights) && length(weights) == 1) { ## name of an edge attribute, nothing to do - attr <- "weight" + attr <- weights } else if (any(!is.na(weights))) { ## weights != NULL and weights != rep(NA, x) graph <- set_edge_attr(graph, "weight", value = as.numeric(weights)) @@ -2100,7 +2065,7 @@ alpha.centrality.sparse <- function( attr <- NULL } else if (is.character(weights) && length(weights) == 1) { ## name of an edge attribute, nothing to do - attr <- "weight" + attr <- weights } else if (any(!is.na(weights))) { ## weights != NULL and weights != rep(NA, x) graph <- set_edge_attr(graph, "weight", value = as.numeric(weights)) diff --git a/R/centralization.R b/R/centralization.R index 6fa6678fdc5..8b787e187bc 100644 --- a/R/centralization.R +++ b/R/centralization.R @@ -424,7 +424,7 @@ centr_degree_tmax <- function( # Function call res <- centralization_degree_tmax_impl( - graph, + graph = graph, nodes = nodes, mode = mode, loops = loops @@ -478,9 +478,12 @@ centr_betw <- function(graph, directed = TRUE, normalized = TRUE) { directed <- as.logical(directed) normalized <- as.logical(normalized) - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_centralization_betweenness, graph, directed, normalized) + res <- centralization_betweenness_impl( + graph = graph, + directed = directed, + normalized = normalized + ) res } @@ -676,9 +679,9 @@ centr_eigen <- function( centralization_eigenvector_centrality_impl( graph = graph, directed = directed, + scale = TRUE, options = options, - normalized = normalized, - scale = TRUE + normalized = normalized ) } diff --git a/R/cliques.R b/R/cliques.R index ec3ee54fdd8..f84341c5f7e 100644 --- a/R/cliques.R +++ b/R/cliques.R @@ -354,7 +354,7 @@ count_max_cliques <- function(graph, min = NULL, max = NULL, subset = NULL) { on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_maximal_cliques_count, graph, subset, min, max) + res <- .Call(Rx_igraph_maximal_cliques_count, graph, subset, min, max) res } @@ -551,7 +551,7 @@ largest_ivs <- function(graph) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_largest_independent_vertex_sets, graph) + res <- .Call(Rx_igraph_largest_independent_vertex_sets, graph) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { @@ -567,7 +567,7 @@ max_ivs <- function(graph) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_maximal_independent_vertex_sets, graph) + res <- .Call(Rx_igraph_maximal_independent_vertex_sets, graph) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { @@ -598,7 +598,7 @@ ivs_size <- function(graph) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_independence_number, graph) + .Call(Rx_igraph_independence_number, graph) } #' @rdname ivs @@ -611,9 +611,17 @@ independence_number <- ivs_size #' @cdocs igraph_clique_size_hist clique_size_counts <- function(graph, min = 0, max = 0, maximal = FALSE) { if (maximal) { - maximal_cliques_hist_impl(graph, min, max) + maximal_cliques_hist_impl( + graph = graph, + min.size = min, + max.size = max + ) } else { - clique_size_hist_impl(graph, min, max) + clique_size_hist_impl( + graph = graph, + min.size = min, + max.size = max + ) } } diff --git a/R/cocitation.R b/R/cocitation.R index 885fdab879d..01d9fdbfdbe 100644 --- a/R/cocitation.R +++ b/R/cocitation.R @@ -58,7 +58,7 @@ cocitation <- function(graph, v = V(graph)) { v <- as_igraph_vs(graph, v) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_cocitation, graph, v - 1) + res <- .Call(Rx_igraph_cocitation, graph, v - 1) if (igraph_opt("add.vertex.names") && is_named(graph)) { rownames(res) <- vertex_attr(graph, "name", v) colnames(res) <- vertex_attr(graph, "name") @@ -73,7 +73,7 @@ bibcoupling <- function(graph, v = V(graph)) { v <- as_igraph_vs(graph, v) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_bibcoupling, graph, v - 1) + res <- .Call(Rx_igraph_bibcoupling, graph, v - 1) if (igraph_opt("add.vertex.names") && is_named(graph)) { rownames(res) <- vertex_attr(graph, "name", v) colnames(res) <- vertex_attr(graph, "name") diff --git a/R/cohesive.blocks.R b/R/cohesive.blocks.R index e59319008da..5fb85ecbde9 100644 --- a/R/cohesive.blocks.R +++ b/R/cohesive.blocks.R @@ -357,7 +357,7 @@ cohesive_blocks <- function(graph, labels = TRUE) { on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_cohesive_blocks, graph) + res <- .Call(Rx_igraph_cohesive_blocks, graph) class(res) <- "cohesiveBlocks" if (labels && "name" %in% vertex_attr_names(graph)) { res$labels <- V(graph)$name diff --git a/R/community.R b/R/community.R index af6497a92c6..7ea945821d6 100644 --- a/R/community.R +++ b/R/community.R @@ -984,9 +984,13 @@ modularity_matrix <- function( resolution <- as.numeric(resolution) directed <- as.logical(directed) - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_modularity_matrix, graph, weights, resolution, directed) + res <- modularity_matrix_impl( + graph = graph, + weights = weights, + resolution = resolution, + directed = directed + ) res } @@ -1326,7 +1330,7 @@ community.to.membership2 <- function(merges, vcount, steps) { mode(vcount) <- "numeric" mode(steps) <- "numeric" on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_community_to_membership2, merges - 1, vcount, steps) + res <- .Call(Rx_igraph_community_to_membership2, merges - 1, vcount, steps) res + 1 } @@ -1481,10 +1485,10 @@ cluster_spinglass <- function( weights <- NULL } - update.rule <- igraph.match.arg(update.rule) + update.rule <- igraph_match_arg(update.rule) update.rule <- switch(update.rule, "simple" = 0, "random" = 0, "config" = 1) implementation <- switch( - igraph.match.arg(implementation), + igraph_match_arg(implementation), "orig" = 0, "neg" = 1 ) @@ -1658,7 +1662,7 @@ cluster_leiden <- function( ensure_igraph(graph) # Parse objective function argument - objective_function <- igraph.match.arg(objective_function) + objective_function <- igraph_match_arg(objective_function) objective_function <- switch(objective_function, "cpm" = 0, "modularity" = 1) # Parse edge weights argument @@ -1698,9 +1702,8 @@ cluster_leiden <- function( membership <- initial_membership if (n_iterations > 0) { res <- community_leiden_impl( - graph, + graph = graph, weights = weights, - # FIXME: Also check below, might not be covered by tests vertex.weights = vertex_weights, resolution = resolution, beta = beta, @@ -1708,6 +1711,7 @@ cluster_leiden <- function( n.iterations = n_iterations, membership = membership ) + membership <- res$membership } else { prev_quality <- -Inf @@ -1715,9 +1719,8 @@ cluster_leiden <- function( while (prev_quality < quality) { prev_quality <- quality res <- community_leiden_impl( - graph, + graph = graph, weights = weights, - # FIXME: Also check above, might not be covered by tests vertex.weights = vertex_weights, resolution = resolution, beta = beta, @@ -1725,6 +1728,7 @@ cluster_leiden <- function( n.iterations = 1, membership = membership ) + membership <- res$membership quality <- res$quality } @@ -2119,7 +2123,7 @@ cluster_fast_greedy <- function( igraph.i.levc.arp <- function(externalP, externalE) { f <- function(v) { v <- as.numeric(v) - .Call(R_igraph_i_levc_arp, externalP, externalE, v) + .Call(Rx_igraph_i_levc_arp, externalP, externalE, v) } f } @@ -2409,16 +2413,17 @@ cluster_label_prop0 <- function( ensure_igraph(graph) # Necessary because evaluated later - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) # Function call membership <- community_label_propagation_impl( - graph, + graph = graph, mode = mode, weights = weights, initial = initial, fixed = fixed ) + res <- list() if (igraph_opt("add.vertex.names") && is_named(graph)) { res$names <- V(graph)$name @@ -2515,9 +2520,12 @@ cluster_louvain <- function(graph, weights = NULL, resolution = 1) { } resolution <- as.numeric(resolution) - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_community_multilevel, graph, weights, resolution) + res <- community_multilevel_impl( + graph = graph, + weights = weights, + resolution = resolution + ) if (igraph_opt("add.vertex.names") && is_named(graph)) { res$names <- V(graph)$name } @@ -2605,9 +2613,10 @@ cluster_optimal <- function(graph, weights = NULL) { # Function call res <- community_optimal_modularity_impl( - graph, + graph = graph, weights = weights ) + if (igraph_opt("add.vertex.names") && is_named(graph)) { res$names <- V(graph)$name } @@ -2675,35 +2684,11 @@ cluster_infomap <- function( nb.trials = 10, modularity = TRUE ) { - # Argument checks - ensure_igraph(graph) - - if (is.null(e.weights) && "weight" %in% edge_attr_names(graph)) { - e.weights <- E(graph)$weight - } - if (!is.null(e.weights) && any(!is.na(e.weights))) { - e.weights <- as.numeric(e.weights) - } else { - e.weights <- NULL - } - if (is.null(v.weights) && "weight" %in% vertex_attr_names(graph)) { - v.weights <- V(graph)$weight - } - if (!is.null(v.weights) && any(!is.na(v.weights))) { - v.weights <- as.numeric(v.weights) - } else { - v.weights <- NULL - } - nb.trials <- as.numeric(nb.trials) - - on.exit(.Call(R_igraph_finalizer)) - # Function call - res <- .Call( - R_igraph_community_infomap, - graph, - e.weights, - v.weights, - nb.trials + res <- community_infomap_impl( + graph = graph, + e.weights = e.weights, + v.weights = v.weights, + nb.trials = nb.trials ) if (igraph_opt("add.vertex.names") && is_named(graph)) { @@ -2835,7 +2820,7 @@ plot_dendrogram.communities <- function( use.modularity = FALSE, palette = categorical_pal(8) ) { - mode <- igraph.match.arg(mode, c("auto", "phylo", "hclust", "dendrogram")) + mode <- igraph_match_arg(mode, c("auto", "phylo", "hclust", "dendrogram")) old_palette <- palette(palette) on.exit(palette(old_palette), add = TRUE) @@ -3069,16 +3054,12 @@ i_compare <- function( } else { as.numeric(as.factor(comm2)) } - method <- switch( - igraph.match.arg(method), - vi = 0L, - nmi = 1L, - split.join = 2L, - rand = 3L, - adjusted.rand = 4L + method <- igraph_match_arg(method) + res <- compare_communities_impl( + comm1 = comm1, + comm2 = comm2, + method = method ) - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_compare_communities, comm1, comm2, method) res } @@ -3126,8 +3107,10 @@ split_join_distance <- function(comm1, comm2) { } else { as.numeric(comm2) } - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_split_join_distance, comm1, comm2) + res <- split_join_distance_impl( + comm1 = comm1, + comm2 = comm2 + ) unlist(res) } @@ -3304,7 +3287,6 @@ voronoi_cells <- function( voronoi_impl( graph = graph, generators = generators, - ..., weights = weights, mode = mode, tiebreaker = tiebreaker diff --git a/R/components.R b/R/components.R index 8e3ccb8fed9..c1b6257f467 100644 --- a/R/components.R +++ b/R/components.R @@ -203,7 +203,7 @@ decompose <- function( min.vertices = 0 ) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "weak" = 1L, "strong" = 2L) if (is.na(max.comps)) { @@ -258,14 +258,18 @@ decompose <- function( #' @export #' @cdocs igraph_articulation_points articulation_points <- function(graph) { - articulation_points_impl(graph = graph) + articulation_points_impl( + graph = graph + ) } #' @rdname articulation_points #' @export #' @cdocs igraph_bridges bridges <- function(graph) { - bridges_impl(graph = graph) + bridges_impl( + graph = graph + ) } @@ -319,7 +323,9 @@ bridges <- function(graph) { #' @cdocs igraph_biconnected_components biconnected_components <- function(graph) { # Function call - res <- biconnected_components_impl(graph) + res <- biconnected_components_impl( + graph = graph + ) # TODO: Clean up after fixing "." / "_" problem. # See https://github.com/igraph/rigraph/issues/1203 @@ -388,7 +394,9 @@ biconnected_components <- function(graph) { #' @export #' @cdocs igraph_is_biconnected is_biconnected <- function(graph) { - is_biconnected_impl(graph = graph) + is_biconnected_impl( + graph = graph + ) } diff --git a/R/conversion.R b/R/conversion.R index 534d772770b..c2ebf5bd807 100644 --- a/R/conversion.R +++ b/R/conversion.R @@ -229,7 +229,7 @@ get.adjacency.dense <- function( ) { ensure_igraph(graph) - type <- igraph.match.arg(type) + type <- igraph_match_arg(type) if (is.logical(loops)) { loops <- ifelse(loops, "once", "ignore") @@ -242,7 +242,7 @@ get.adjacency.dense <- function( ) ) } - loops <- igraph.match.arg(loops) + loops <- igraph_match_arg(loops) loops <- switch(loops, "ignore" = 0L, "twice" = 1L, "once" = 2L) if (!is.null(weights)) { @@ -285,7 +285,7 @@ get.adjacency.sparse <- function( ) { ensure_igraph(graph) - type <- igraph.match.arg(type) + type <- igraph_match_arg(type) vc <- vcount(graph) @@ -489,7 +489,7 @@ as_adj <- function( as_edgelist <- function(graph, names = TRUE) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - res <- matrix(.Call(R_igraph_get_edgelist, graph, TRUE), ncol = 2) + res <- matrix(.Call(Rx_igraph_get_edgelist, graph, TRUE), ncol = 2) res <- res + 1 if (names && "name" %in% vertex_attr_names(graph)) { res <- matrix(V(graph)$name[res], ncol = 2) @@ -624,17 +624,14 @@ as_undirected <- function( ) { # Argument checks ensure_igraph(graph) - mode <- switch( - igraph.match.arg(mode), - "collapse" = 1L, - "each" = 0L, - "mutual" = 2L - ) - edge.attr.comb <- igraph.i.attribute.combination(edge.attr.comb) + mode <- igraph_match_arg(mode) - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_to_undirected, graph, mode, edge.attr.comb) + res <- to_undirected_impl( + graph = graph, + mode = mode, + edge.attr.comb = edge.attr.comb + ) res } @@ -688,9 +685,9 @@ as_adj_list <- function( ) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- as.numeric(switch(mode, "out" = 1, "in" = 2, "all" = 3, "total" = 3)) - loops <- igraph.match.arg(loops) + loops <- igraph_match_arg(loops) loops <- as.numeric(switch(loops, "ignore" = 0, "twice" = 1, "once" = 2)) if (is_directed(graph) && loops == 1) { @@ -699,7 +696,7 @@ as_adj_list <- function( multiple <- if (multiple) 1 else 0 on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_get_adjlist, graph, mode, loops, multiple) + res <- .Call(Rx_igraph_get_adjlist, graph, mode, loops, multiple) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { res <- lapply(res, unsafe_create_vs, graph = graph, verts = V(graph)) @@ -719,9 +716,9 @@ as_adj_edge_list <- function( ) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- as.numeric(switch(mode, "out" = 1, "in" = 2, "all" = 3, "total" = 3)) - loops <- igraph.match.arg(loops) + loops <- igraph_match_arg(loops) loops <- as.numeric(switch(loops, "ignore" = 0, "twice" = 1, "once" = 2)) if (is_directed(graph) && loops == 1) { @@ -729,7 +726,7 @@ as_adj_edge_list <- function( } on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_get_adjedgelist, graph, mode, loops) + res <- .Call(Rx_igraph_get_adjedgelist, graph, mode, loops) res <- lapply(res, function(.x) E(graph)[.x + 1]) if (is_named(graph)) { names(res) <- V(graph)$name @@ -965,7 +962,10 @@ get.incidence.dense <- function( ) { if (is.null(attr)) { ## Function call - res <- get_biadjacency_impl(graph, types) + res <- get_biadjacency_impl( + graph = graph, + types = types + ) if (names && "name" %in% vertex_attr_names(graph)) { rownames(res$res) <- V(graph)$name[res$row_ids] @@ -1186,11 +1186,11 @@ as_incidence_matrix <- function(...) { #' @export as_data_frame <- function(x, what = c("edges", "vertices", "both")) { ensure_igraph(x) - what <- igraph.match.arg(what) + what <- igraph_match_arg(what) if (what %in% c("vertices", "both")) { ver <- .Call( - R_igraph_mybracket2, + Rx_igraph_mybracket2, x, igraph_t_idx_attr, igraph_attr_idx_vertex @@ -1208,7 +1208,7 @@ as_data_frame <- function(x, what = c("edges", "vertices", "both")) { el <- as_edgelist(x) edg <- c( list(from = el[, 1], to = el[, 2]), - .Call(R_igraph_mybracket2, x, igraph_t_idx_attr, igraph_attr_idx_edge) + .Call(Rx_igraph_mybracket2, x, igraph_t_idx_attr, igraph_attr_idx_edge) ) class(edg) <- "data.frame" rownames(edg) <- seq_len(ecount(x)) @@ -1315,7 +1315,7 @@ as_long_data_frame <- function(graph) { ensure_igraph(graph) ver <- .Call( - R_igraph_mybracket2, + Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_vertex @@ -1332,7 +1332,7 @@ as_long_data_frame <- function(graph) { edg <- c( list(from = el[, 1]), list(to = el[, 2]), - .Call(R_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge) + .Call(Rx_igraph_mybracket2, graph, igraph_t_idx_attr, igraph_attr_idx_edge) ) class(edg) <- "data.frame" rownames(edg) <- seq_len(ecount(graph)) diff --git a/R/cycles.R b/R/cycles.R index e74e3fd9465..af003d8310f 100644 --- a/R/cycles.R +++ b/R/cycles.R @@ -97,5 +97,12 @@ simple_cycles <- function( # Argument checks ensure_igraph(graph) - simple_cycles_impl(graph, mode, min %||% -1, max %||% -1) + simple_cycles_impl( + graph = graph, + mode = mode, + min.cycle.length = min %||% + -1, + max.cycle.length = max %||% + -1 + ) } diff --git a/R/embedding.R b/R/embedding.R index da8c4ad1557..406f7338aa9 100644 --- a/R/embedding.R +++ b/R/embedding.R @@ -183,7 +183,9 @@ embed_adjacency_matrix <- function( #' @export #' @cdocs igraph_dim_select dim_select <- function(sv) { - dim_select_impl(sv = sv) + dim_select_impl( + sv = sv + ) } @@ -398,5 +400,8 @@ sample_sphere_volume <- function(dim, n = 1, radius = 1, positive = TRUE) { #' colSums(lpvs.dir) sample_dirichlet <- function(n, alpha) { # Use the _impl function - sample_dirichlet_impl(n = n, alpha = alpha) + sample_dirichlet_impl( + n = n, + alpha = alpha + ) } diff --git a/R/epi.R b/R/epi.R index 507965304c3..9571504efca 100644 --- a/R/epi.R +++ b/R/epi.R @@ -68,7 +68,7 @@ median.sir <- function(x, na.rm = FALSE, ...) { #' @export quantile.sir <- function(x, comp = c("NI", "NS", "NR"), prob, ...) { sir <- x - comp <- toupper(igraph.match.arg(comp)) + comp <- toupper(igraph_match_arg(comp)) times <- unlist(sapply(sir, "[[", "times")) big.N <- unlist(sapply(sir, function(x) { x[[comp]] @@ -159,7 +159,7 @@ plot.sir <- function( ) { sir <- x - comp <- toupper(igraph.match.arg(comp)) + comp <- toupper(igraph_match_arg(comp)) if (!all(quantiles >= 0 & quantiles <= 1)) { cli::cli_abort("All {.arg quantiles} should be in [0,1].") } diff --git a/R/eulerian.R b/R/eulerian.R index baf9ea992fa..592209653b6 100644 --- a/R/eulerian.R +++ b/R/eulerian.R @@ -68,14 +68,20 @@ #' @export #' @cdocs igraph_is_eulerian has_eulerian_path <- function(graph) { - is_eulerian_impl(graph)$has_path + res <- is_eulerian_impl( + graph = graph + ) + res$has_path } #' @rdname has_eulerian_path #' @export #' @cdocs igraph_is_eulerian has_eulerian_cycle <- function(graph) { - is_eulerian_impl(graph)$has_cycle + res <- is_eulerian_impl( + graph = graph + ) + res$has_cycle } #' @rdname has_eulerian_path diff --git a/R/fit.R b/R/fit.R index 32c6d33e475..b1f0292c94b 100644 --- a/R/fit.R +++ b/R/fit.R @@ -190,7 +190,7 @@ fit_power_law <- function( p.precision = NULL, ... ) { - implementation <- igraph.match.arg(implementation) + implementation <- igraph_match_arg(implementation) if (implementation == "r.mle") { if (isTRUE(p.value)) { diff --git a/R/flow.R b/R/flow.R index a4a221d283b..0dc17ed20d2 100644 --- a/R/flow.R +++ b/R/flow.R @@ -411,9 +411,9 @@ min_cut <- function( if (is.null(target) && is.null(source)) { if (value.only) { - res <- .Call(R_igraph_mincut_value, graph, capacity) + res <- .Call(Rx_igraph_mincut_value, graph, capacity) } else { - res <- .Call(R_igraph_mincut, graph, capacity) + res <- .Call(Rx_igraph_mincut, graph, capacity) res$cut <- res$cut + 1 res$partition1 <- res$partition1 + 1 res$partition2 <- res$partition2 + 1 @@ -542,7 +542,7 @@ vertex_connectivity <- function( if (is.null(source) && is.null(target)) { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_vertex_connectivity, graph, as.logical(checks)) + .Call(Rx_igraph_vertex_connectivity, graph, as.logical(checks)) } else if (!is.null(source) && !is.null(target)) { on.exit(.Call(R_igraph_finalizer)) .Call( @@ -648,7 +648,7 @@ edge_connectivity <- function( if (is.null(source) && is.null(target)) { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_edge_connectivity, graph, as.logical(checks)) + .Call(Rx_igraph_edge_connectivity, graph, as.logical(checks)) } else if (!is.null(source) && !is.null(target)) { on.exit(.Call(R_igraph_finalizer)) .Call( @@ -704,7 +704,7 @@ adhesion <- function(graph, checks = TRUE) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_adhesion, graph, as.logical(checks)) + .Call(Rx_igraph_adhesion, graph, as.logical(checks)) } #' @rdname vertex_connectivity @@ -714,7 +714,7 @@ cohesion.igraph <- function(x, checks = TRUE, ...) { ensure_igraph(x) on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_cohesion, x, as.logical(checks)) + .Call(Rx_igraph_cohesion, x, as.logical(checks)) } #' List all (s,t)-cuts of a graph @@ -906,17 +906,14 @@ dominator_tree <- function(graph, root, mode = c("out", "in", "all", "total")) { } root <- as_igraph_vs(graph, root) - mode <- switch( - igraph.match.arg(mode), - "out" = 1, - "in" = 2, - "all" = 3, - "total" = 3 - ) + mode <- igraph_match_arg(mode) - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_dominator_tree, graph, root - 1, mode) + res <- dominator_tree_impl( + graph = graph, + root = root, + mode = mode + ) if (igraph_opt("return.vs.es")) { res$leftout <- create_vs(graph, res$leftout) } @@ -978,7 +975,9 @@ dominator_tree <- function(graph, root, mode = c("out", "in", "all", "total")) { #' @family flow #' @cdocs igraph_all_minimal_st_separators min_st_separators <- function(graph) { - all_minimal_st_separators_impl(graph = graph) + all_minimal_st_separators_impl( + graph = graph + ) } @@ -1214,5 +1213,7 @@ is_min_separator <- function(graph, candidate) { #' min_separators(camp) #' @cdocs igraph_minimum_size_separators min_separators <- function(graph) { - minimum_size_separators_impl(graph = graph) + minimum_size_separators_impl( + graph = graph + ) } diff --git a/R/foreign.R b/R/foreign.R index d7ccc5c354a..ab5917cc0e7 100644 --- a/R/foreign.R +++ b/R/foreign.R @@ -331,7 +331,7 @@ read_graph <- function( write.graph.fromraw(buffer, file) } - format <- igraph.match.arg(format) + format <- igraph_match_arg(format) res <- switch( format, "pajek" = read.graph.pajek(file, ...), @@ -497,7 +497,7 @@ write_graph <- function( tmpfile <- FALSE } - format <- igraph.match.arg(format) + format <- igraph_match_arg(format) res <- switch( format, "pajek" = write.graph.pajek(graph, file, ...), @@ -535,7 +535,7 @@ read.graph.edgelist <- function(file, n = 0, directed = TRUE) { write.graph.edgelist <- function(graph, file) { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_write_graph_edgelist, graph, file) + .Call(Rx_igraph_write_graph_edgelist, graph, file) } ################################################################ @@ -550,7 +550,7 @@ read.graph.ncol <- function( directed = FALSE ) { weights <- switch( - igraph.match.arg(weights), + igraph_match_arg(weights), "no" = 0L, "yes" = 1L, "auto" = 2L @@ -598,7 +598,7 @@ read.graph.lgl <- function( directed = FALSE ) { weights <- switch( - igraph.match.arg(weights), + igraph_match_arg(weights), "no" = 0L, "yes" = 1L, "auto" = 2L @@ -642,7 +642,7 @@ write.graph.lgl <- function( read.graph.pajek <- function(file) { on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_read_graph_pajek, file) + res <- .Call(Rx_igraph_read_graph_pajek, file) if ("type" %in% vertex_attr_names(res)) { type <- as.logical(V(res)$type) res <- delete_vertex_attr(res, "type") @@ -653,11 +653,11 @@ read.graph.pajek <- function(file) { write.graph.pajek <- function(graph, file) { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_write_graph_pajek, graph, file) + .Call(Rx_igraph_write_graph_pajek, graph, file) } read.graph.dimacs <- function(file, directed = TRUE) { - res <- .Call(R_igraph_read_graph_dimacs, file, as.logical(directed)) + res <- .Call(Rx_igraph_read_graph_dimacs, file, as.logical(directed)) if (res[[1]][1] == "max") { graph <- res[[2]] graph <- set_graph_attr(graph, "problem", res[[1]]) @@ -707,12 +707,12 @@ write.graph.dimacs <- function( read.graph.graphml <- function(file, index = 0) { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_read_graph_graphml, file, as.numeric(index)) + .Call(Rx_igraph_read_graph_graphml, file, as.numeric(index)) } write.graph.graphml <- function(graph, file, prefixAttr = TRUE) { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_write_graph_graphml, graph, file, as.logical(prefixAttr)) + .Call(Rx_igraph_write_graph_graphml, graph, file, as.logical(prefixAttr)) } ################################################################ @@ -721,7 +721,7 @@ write.graph.graphml <- function(graph, file, prefixAttr = TRUE) { read.graph.gml <- function(file) { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_read_graph_gml, file) + .Call(Rx_igraph_read_graph_gml, file) } write.graph.gml <- function(graph, file, id = NULL, creator = NULL) { @@ -732,7 +732,7 @@ write.graph.gml <- function(graph, file, id = NULL, creator = NULL) { creator <- as.character(creator) } on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_write_graph_gml, graph, file, id, creator) + .Call(Rx_igraph_write_graph_gml, graph, file, id, creator) } ################################################################ @@ -741,7 +741,7 @@ write.graph.gml <- function(graph, file, id = NULL, creator = NULL) { read.graph.dl <- function(file, directed = TRUE) { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_read_graph_dl, file, as.logical(directed)) + .Call(Rx_igraph_read_graph_dl, file, as.logical(directed)) } ################################################################ @@ -750,7 +750,7 @@ read.graph.dl <- function(file, directed = TRUE) { write.graph.dot <- function(graph, file) { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_write_graph_dot, graph, file) + .Call(Rx_igraph_write_graph_dot, graph, file) } ################################################################ @@ -914,12 +914,12 @@ graph_from_graphdb <- function( f <- tempfile() write.graph.fromraw(buffer, f) - .Call(R_igraph_read_graph_graphdb, f, as.logical(directed)) + .Call(Rx_igraph_read_graph_graphdb, f, as.logical(directed)) } read.graph.graphdb <- function(file, directed = TRUE) { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_read_graph_graphdb, file, as.logical(directed)) + .Call(Rx_igraph_read_graph_graphdb, file, as.logical(directed)) } write.graph.leda <- function( @@ -935,5 +935,5 @@ write.graph.leda <- function( edge.attr <- as.character(edge.attr) } on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_write_graph_leda, graph, file, vertex.attr, edge.attr) + .Call(Rx_igraph_write_graph_leda, graph, file, vertex.attr, edge.attr) } diff --git a/R/games.R b/R/games.R index 0d848daabca..ad4b5c39b35 100644 --- a/R/games.R +++ b/R/games.R @@ -942,7 +942,7 @@ sample_pa <- function( out.seq <- numeric() } - algorithm <- igraph.match.arg(algorithm) + algorithm <- igraph_match_arg(algorithm) algorithm1 <- switch( algorithm, "psumtree" = 1, @@ -1022,13 +1022,11 @@ sample_gnp <- function(n, p, directed = FALSE, loops = FALSE) { type <- "gnp" type1 <- switch(type, "gnp" = 0, "gnm" = 1) - on.exit(.Call(R_igraph_finalizer)) - res <- .Call( - R_igraph_erdos_renyi_game_gnp, - as.numeric(n), - as.numeric(p), - as.logical(directed), - as.logical(loops) + res <- erdos_renyi_game_gnp_impl( + n = n, + p = p, + directed = directed, + loops = loops ) if (igraph_opt("add.params")) { @@ -1142,7 +1140,7 @@ erdos.renyi.game <- function( directed = FALSE, loops = FALSE ) { - type <- igraph.match.arg(type) + type <- igraph_match_arg(type) if (type == "gnp") { lifecycle::deprecate_soft("0.8.0", "erdos.renyi.game()", "sample_gnp()") @@ -1162,7 +1160,7 @@ random.graph.game <- function( directed = FALSE, loops = FALSE ) { - type <- igraph.match.arg(type) + type <- igraph_match_arg(type) if (type == "gnp") { lifecycle::deprecate_soft("0.8.0", "random.graph.game()", "sample_gnp()") @@ -1360,7 +1358,7 @@ sample_degseq <- function( if (missing(method)) { method <- method[1] } - method <- igraph.match.arg( + method <- igraph_match_arg( method, values = c( "configuration", @@ -1469,7 +1467,6 @@ sample_growing <- function(n, m = 1, ..., directed = TRUE, citation = FALSE) { growing_random_game_impl( n = n, m = m, - ..., directed = directed, citation = citation ) @@ -2041,7 +2038,7 @@ asym_pref <- function(...) constructor_spec(sample_asym_pref, ...) #' @family functions for manipulating graph structure connect <- function(graph, order, mode = c("all", "out", "in", "total")) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3, "total" = 3) on.exit(.Call(R_igraph_finalizer)) @@ -2313,8 +2310,8 @@ sample_bipartite <- function( directed = FALSE, mode = c("out", "in", "all") ) { - type <- igraph.match.arg(type) - mode <- igraph.match.arg(mode) + type <- igraph_match_arg(type) + mode <- igraph_match_arg(mode) if (type == "gnp") { lifecycle::deprecate_soft( @@ -2420,7 +2417,7 @@ sample_bipartite_gnm <- function( mode = c("out", "in", "all") ) { check_dots_empty() - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) m <- as.numeric(m) res <- bipartite_game_gnm_impl( @@ -2449,7 +2446,7 @@ sample_bipartite_gnp <- function( mode = c("out", "in", "all") ) { check_dots_empty() - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) p <- as.numeric(p) res <- bipartite_game_gnp_impl( @@ -2576,7 +2573,13 @@ sample_hierarchical_sbm <- function(n, m, rho, C, p) { commonlen <- unique(c(mlen, rholen, Clen)) if (length(commonlen) == 1 && commonlen == 1) { - hsbm_game_impl(n, m, rho, C, p) + hsbm_game_impl( + n = n, + m = m, + rho = rho, + C = C, + p = p + ) } else { commonlen <- setdiff(commonlen, 1) if (length(commonlen) != 1) { @@ -2593,7 +2596,13 @@ sample_hierarchical_sbm <- function(n, m, rho, C, p) { } else { rep(list(C), length.out = commonlen) } - hsbm_list_game_impl(n, m, rho, C, p) + hsbm_list_game_impl( + n = n, + mlist = m, + rholist = rho, + Clist = C, + p = p + ) } } @@ -2900,7 +2909,6 @@ sample_chung_lu <- function( chung_lu_game_impl( out.weights = out.weights, in.weights = in.weights, - ..., loops = loops, variant = variant ) diff --git a/R/glet.R b/R/glet.R index 77b6087a04f..f010c9b4ece 100644 --- a/R/glet.R +++ b/R/glet.R @@ -149,7 +149,7 @@ graphlet_basis <- function(graph, weights = NULL) { on.exit(.Call(R_igraph_finalizer)) ## Function call - res <- .Call(R_igraph_graphlets_candidate_basis, graph, weights) + res <- .Call(Rx_igraph_graphlets_candidate_basis, graph, weights) res } @@ -178,7 +178,7 @@ graphlet_proj <- function( on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_graphlets_project, graph, weights, cliques, Mu, niter) + res <- .Call(Rx_igraph_graphlets_project, graph, weights, cliques, Mu, niter) res } diff --git a/R/hrg.R b/R/hrg.R index 7532b814e1b..b9bbe940e23 100644 --- a/R/hrg.R +++ b/R/hrg.R @@ -251,9 +251,13 @@ fit_hrg <- function(graph, hrg = NULL, start = FALSE, steps = 0) { start <- as.logical(start) steps <- as.numeric(steps) - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_hrg_fit, graph, hrg, start, steps) + res <- hrg_fit_impl( + graph = graph, + hrg = hrg, + start = start, + steps = steps + ) if (igraph_opt("add.vertex.names") && is_named(graph)) { res$names <- V(graph)$name @@ -357,7 +361,9 @@ hrg_tree <- function(hrg) { ) } - out <- from_hrg_dendrogram_impl(hrg) + out <- from_hrg_dendrogram_impl( + hrg = hrg + ) g <- out$graph set_vertex_attr(g, "probability", value = out$prob) @@ -382,7 +388,9 @@ sample_hrg <- function(hrg) { ) } - hrg_game_impl(hrg) + hrg_game_impl( + hrg = hrg + ) } #' Predict edges based on a hierarchical random graph model #' @@ -903,7 +911,7 @@ print.igraphHRG <- function( level = 3, ... ) { - type <- igraph.match.arg(type) + type <- igraph_match_arg(type) if (type == "auto") { is_graph_small <- (length(x$left) <= 100) type <- if (is_graph_small) "tree" else "plain" diff --git a/R/incidence.R b/R/incidence.R index 3ac1f48ec3d..3937ad025af 100644 --- a/R/incidence.R +++ b/R/incidence.R @@ -80,11 +80,12 @@ graph_incidence_build <- function( # Handle dense unweighted matrices first if (!inherits(incidence, "Matrix") && is.null(weighted)) { - mode(incidence) <- "double" - on.exit(.Call(R_igraph_finalizer)) - - mode_num <- switch(mode, "out" = 1, "in" = 2, "all" = 3, "total" = 3) - res <- .Call(R_igraph_biadjacency, incidence, directed, mode_num, multiple) + res <- biadjacency_impl( + incidence = incidence, + directed = directed, + mode = mode, + multiple = multiple + ) return(set_vertex_attr(res$graph, "type", value = res$types)) } @@ -194,7 +195,7 @@ graph_from_biadjacency_matrix <- function( # Argument checks ensure_no_na(incidence, "biadjacency matrix") directed <- as.logical(directed) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) multiple <- as.logical(multiple) diff --git a/R/interface.R b/R/interface.R index 44e0efc67c0..3831da207a4 100644 --- a/R/interface.R +++ b/R/interface.R @@ -218,7 +218,7 @@ add_vertices <- function(graph, nv, ..., attr = list()) { vertices.orig <- vcount(graph) on.exit(.Call(R_igraph_finalizer)) - graph <- .Call(R_igraph_add_vertices, graph, as.numeric(nv)) + graph <- .Call(Rx_igraph_add_vertices, graph, as.numeric(nv)) vertices.new <- vcount(graph) if (vertices.new - vertices.orig != 0) { @@ -265,7 +265,7 @@ delete_edges <- function(graph, edges) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_delete_edges, graph, as_igraph_es(graph, edges) - 1) + .Call(Rx_igraph_delete_edges, graph, as_igraph_es(graph, edges) - 1) } #' Delete vertices from a graph @@ -291,7 +291,7 @@ delete_vertices <- function(graph, v) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_delete_vertices, graph, as_igraph_vs(graph, v) - 1) + .Call(Rx_igraph_delete_vertices, graph, as_igraph_vs(graph, v) - 1) } ################################################################### @@ -321,7 +321,7 @@ gsize <- function(graph) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_ecount, graph) + .Call(Rx_igraph_ecount, graph) } #' @rdname gsize #' @export @@ -349,14 +349,18 @@ ecount <- gsize #' intersection(n1, n34) neighbors <- function(graph, v, mode = c("out", "in", "all", "total")) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) v <- as_igraph_vs(graph, v) if (length(v) == 0) { stop("No vertex was specified") } - neighbors_impl(graph, vid = v, mode = mode) + neighbors_impl( + graph = graph, + vid = v, + mode = mode + ) } #' Incident edges of a vertex in a graph @@ -379,7 +383,7 @@ neighbors <- function(graph, v, mode = c("out", "in", "all", "total")) { incident <- function(graph, v, mode = c("all", "out", "in", "total")) { ensure_igraph(graph) if (is_directed(graph)) { - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3, "total" = 3) } else { mode <- 1 @@ -389,7 +393,7 @@ incident <- function(graph, v, mode = c("all", "out", "in", "total")) { stop("No vertex was specified") } on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_incident, graph, v - 1, as.numeric(mode)) + 1L + res <- .Call(Rx_igraph_incident, graph, v - 1, as.numeric(mode)) + 1L if (igraph_opt("return.vs.es")) { res <- create_es(graph, res) @@ -416,7 +420,7 @@ is_directed <- function(graph) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_is_directed, graph) + .Call(Rx_igraph_is_directed, graph) } #' Incident vertices of some graph edges @@ -444,9 +448,9 @@ ends <- function(graph, es, names = TRUE) { on.exit(.Call(R_igraph_finalizer)) if (length(es) == 1) { - res[, !is.na(es)] <- .Call(R_igraph_get_edge, graph, es2) + 1 + res[, !is.na(es)] <- .Call(Rx_igraph_get_edge, graph, es2) + 1 } else { - res[, !is.na(es)] <- .Call(R_igraph_edges, graph, es2) + 1 + res[, !is.na(es)] <- .Call(Rx_igraph_edges, graph, es2) + 1 } if (names && is_named(graph)) { @@ -613,7 +617,9 @@ get.edge.ids <- function( #' vcount(g) #' @cdocs igraph_vcount vcount <- function(graph) { - as.numeric(vcount_impl(graph)) + as.numeric(vcount_impl( + graph = graph + )) } #' @export @@ -645,7 +651,7 @@ adjacent_vertices <- function(graph, v, mode = c("out", "in", "all", "total")) { on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_adjacent_vertices, graph, vv, mode) + res <- .Call(Rx_igraph_adjacent_vertices, graph, vv, mode) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { @@ -684,7 +690,7 @@ incident_edges <- function(graph, v, mode = c("out", "in", "all", "total")) { on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_incident_edges, graph, vv, mode) + res <- .Call(Rx_igraph_incident_edges, graph, vv, mode) res <- lapply(res, `+`, 1) if (igraph_opt("return.vs.es")) { @@ -697,3 +703,37 @@ incident_edges <- function(graph, v, mode = c("out", "in", "all", "total")) { res } + +#' Invalidate the cache of a graph +#' +#' igraph graphs cache some basic properties (such as whether the graph is a +#' DAG or whether it is simple) in an internal data structure for faster +#' repeated queries. This function invalidates the cache, forcing a +#' recalculation of the cached properties the next time they are needed. +#' +#' You should not need to call this function during normal usage; however, it +#' may be useful for debugging cache-related issues. A tell-tale sign of an +#' invalid cache entry is when the result of a cached function (such as +#' \code{\link{is_dag}()} or \code{\link{is_simple}()}) changes after calling +#' this function. +#' +#' @param graph The graph whose cache is to be invalidated. +#' @return The graph with its cache invalidated. Since the graph is modified +#' in place in R as well, you can also ignore the return value. +#' +#' @family low-level operations +#' +#' @export +#' @examples +#' g <- make_ring(10) +#' # Cache is populated when calling is_simple() +#' is_simple(g) +#' # Invalidate cache (for debugging purposes) +#' invalidate_cache(g) +#' # Result should be the same +#' is_simple(g) +invalidate_cache <- function(graph) { + invalidate_cache_impl( + graph = graph + ) +} diff --git a/R/iterators.R b/R/iterators.R index 31e87dbe307..c1199014b6e 100644 --- a/R/iterators.R +++ b/R/iterators.R @@ -30,7 +30,7 @@ update_es_ref <- update_vs_ref <- function(graph) { get_es_ref <- get_vs_ref <- function(graph) { if (is_igraph(graph) && !warn_version(graph)) { - .Call(R_igraph_copy_env, graph) + .Call(Rx_igraph_copy_env, graph) } else { NULL } @@ -84,7 +84,7 @@ get_es_graph_id <- get_vs_graph_id <- function(seq) { #' @export identical_graphs <- function(g1, g2, attrs = TRUE) { stopifnot(is_igraph(g1), is_igraph(g2)) - .Call(R_igraph_identical_graphs, g1, g2, as.logical(attrs)) + .Call(Rx_igraph_identical_graphs, g1, g2, as.logical(attrs)) } add_vses_graph_ref <- function(vses, graph) { @@ -583,7 +583,7 @@ simple_vs_index <- function(x, i, na_ok = FALSE) { .nei <- function(v, mode = c("all", "in", "out", "total")) { ## TRUE iff the vertex is a neighbor (any type) ## of at least one vertex in v - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3, "total" = 3) if (is.logical(v)) { @@ -1061,8 +1061,8 @@ simple_es_index <- function(x, i, na_ok = FALSE) { parent = top, c( attrs, - .igraph.from = list(.Call(R_igraph_copy_from, graph)[as.numeric(x)]), - .igraph.to = list(.Call(R_igraph_copy_to, graph)[as.numeric(x)]), + .igraph.from = list(.Call(Rx_igraph_copy_from, graph)[as.numeric(x)]), + .igraph.to = list(.Call(Rx_igraph_copy_to, graph)[as.numeric(x)]), .igraph.graph = list(graph), .env = env, .data = list(attrs) diff --git a/R/layout.R b/R/layout.R index 53aa268cee4..af06249748c 100644 --- a/R/layout.R +++ b/R/layout.R @@ -608,7 +608,13 @@ layout_as_bipartite <- function( ## Argument checks ensure_igraph(graph) # Use the _impl function - layout_bipartite_impl(graph, types, hgap, vgap, maxiter) + layout_bipartite_impl( + graph = graph, + types = types, + hgap = hgap, + vgap = vgap, + maxiter = maxiter + ) } @@ -658,7 +664,11 @@ layout_as_star <- function(graph, center = V(graph)[1], order = NULL) { return(layout_in_circle(graph)) } # Use the _impl function - layout_star_impl(graph, center, order) + layout_star_impl( + graph = graph, + center = center, + order = order + ) } @@ -739,7 +749,7 @@ layout_as_tree <- function( circular <- as.logical(circular) rootlevel <- as.double(rootlevel) mode <- switch( - igraph.match.arg(mode), + igraph_match_arg(mode), "out" = 1, "in" = 2, "all" = 3, @@ -823,7 +833,10 @@ layout.reingold.tilford <- function(..., params = list()) { #' plot(karate, layout = coords) layout_in_circle <- function(graph, order = V(graph)) { # Use the _impl function - layout_circle_impl(graph, order) + layout_circle_impl( + graph = graph, + order = order + ) } #' @rdname layout_in_circle @@ -1013,9 +1026,16 @@ layout_on_grid <- function(graph, width = 0, height = 0, dim = 2) { # Function call if (dim == 2) { - layout_grid_impl(graph, width) + layout_grid_impl( + graph = graph, + width = width + ) } else { - layout_grid_3d_impl(graph, width, height) + layout_grid_3d_impl( + graph = graph, + width = width, + height = height + ) } } @@ -1061,7 +1081,9 @@ layout.grid.3d <- function(graph, width = 0, height = 0) { #' @family graph layouts layout_on_sphere <- function(graph) { # Use the _impl function - layout_sphere_impl(graph) + layout_sphere_impl( + graph = graph + ) } @@ -1107,12 +1129,16 @@ layout.sphere <- function(..., params = list()) { layout_randomly <- function(graph, dim = c(2, 3)) { ensure_igraph(graph) - dim <- igraph.match.arg(dim) + dim <- igraph_match_arg(dim) if (dim == 2) { - layout_random_impl(graph) + layout_random_impl( + graph = graph + ) } else if (dim == 3) { - layout_random_3d_impl(graph) + layout_random_3d_impl( + graph = graph + ) } } @@ -1408,7 +1434,7 @@ layout_with_fr <- function( # Argument checks ensure_igraph(graph) coords[] <- as.numeric(coords) - dim <- igraph.match.arg(dim) + dim <- igraph_match_arg(dim) if (!missing(niter) && !missing(maxiter)) { cli::cli_abort(c( "{.arg niter} and {.arg maxiter} must not be specified at the same time.", @@ -1421,7 +1447,7 @@ layout_with_fr <- function( niter <- as.numeric(niter) start.temp <- as.numeric(start.temp) - grid <- igraph.match.arg(grid) + grid <- igraph_match_arg(grid) grid <- switch(grid, "grid" = 0L, "nogrid" = 1L, "auto" = 2L) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { @@ -1785,7 +1811,7 @@ layout_with_kk <- function( ensure_igraph(graph) coords[] <- as.numeric(coords) - dim <- igraph.match.arg(dim) + dim <- igraph_match_arg(dim) maxiter <- as.numeric(maxiter) epsilon <- as.numeric(epsilon) @@ -2043,7 +2069,11 @@ layout_with_mds <- function( dim <- as.numeric(dim) # Function call - layout_mds_impl(graph, dist, dim) + layout_mds_impl( + graph = graph, + dist = dist, + dim = dim + ) } @@ -2290,7 +2320,7 @@ layout_with_sugiyama <- function( } else { weights <- NULL } - attributes <- igraph.match.arg(attributes) + attributes <- igraph_match_arg(attributes) on.exit(.Call(R_igraph_finalizer)) # Function call @@ -2793,7 +2823,7 @@ layout_with_drl <- function( ) { ensure_igraph(graph) - dim <- igraph.match.arg(dim) + dim <- igraph_match_arg(dim) use.seed <- as.logical(use.seed) seed <- as.matrix(seed) diff --git a/R/make.R b/R/make.R index 7547b44e593..a5def584cbd 100644 --- a/R/make.R +++ b/R/make.R @@ -267,8 +267,9 @@ line.graph <- function(graph) { lifecycle::deprecate_soft("2.1.0", "line.graph()", "make_line_graph()") ensure_igraph(graph) - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_linegraph, graph) + res <- linegraph_impl( + graph = graph + ) if (igraph_opt("add.params")) { res$name <- "Line graph" } @@ -317,7 +318,7 @@ graph.ring <- function(n, directed = FALSE, mutual = FALSE, circular = TRUE) { graph.tree <- function(n, children = 2, mode = c("out", "in", "undirected")) { # nocov start lifecycle::deprecate_soft("2.1.0", "graph.tree()", "make_tree()") - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode1 <- switch(mode, "out" = 0, "in" = 1, "undirected" = 2) on.exit(.Call(R_igraph_finalizer)) @@ -352,7 +353,7 @@ graph.star <- function( ) { # nocov start lifecycle::deprecate_soft("2.1.0", "graph.star()", "make_star()") - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode1 <- switch(mode, "out" = 0, "in" = 1, "undirected" = 2, "mutual" = 3) on.exit(.Call(R_igraph_finalizer)) @@ -384,7 +385,11 @@ graph.lcf <- function(n, shifts, repeats = 1) { # nocov start lifecycle::deprecate_soft("2.1.0", "graph.lcf()", "graph_from_lcf()") # Use the _impl function - lcf_vector_impl(n = n, shifts = shifts, repeats = repeats) + lcf_vector_impl( + n = n, + shifts = shifts, + repeats = repeats + ) } # nocov end #' Create a lattice graph @@ -438,7 +443,14 @@ graph.lattice <- function( } on.exit(.Call(R_igraph_finalizer)) - res <- square_lattice_impl(dimvector, nei, directed, mutual, periodic) + res <- square_lattice_impl( + dimvector = dimvector, + nei = nei, + directed = directed, + mutual = mutual, + periodic = periodic + ) + if (igraph_opt("add.params")) { res$name <- "Lattice graph" res$dimvector <- dimvector @@ -462,8 +474,10 @@ graph.lattice <- function( graph.kautz <- function(m, n) { # nocov start lifecycle::deprecate_soft("2.1.0", "graph.kautz()", "make_kautz_graph()") - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_kautz, as.numeric(m), as.numeric(n)) + res <- kautz_impl( + m = m, + n = n + ) if (igraph_opt("add.params")) { res$name <- sprintf("Kautz graph %i-%i", m, n) res$m <- m @@ -489,13 +503,11 @@ graph.full.citation <- function(n, directed = TRUE) { "graph.full.citation()", "make_full_citation_graph()" ) - # Argument checks - n <- as.numeric(n) - directed <- as.logical(directed) - - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_full_citation, n, directed) + res <- full_citation_impl( + n = n, + directed = directed + ) res <- set_graph_attr(res, "name", "Full citation graph") res @@ -527,15 +539,19 @@ graph.full.bipartite <- function( n2 <- as.numeric(n2) directed <- as.logical(directed) mode1 <- switch( - igraph.match.arg(mode), + igraph_match_arg(mode), "out" = 1, "in" = 2, "all" = 3, "total" = 3 ) - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_full_bipartite, n1, n2, as.logical(directed), mode1) + res <- full_bipartite_impl( + n1 = n1, + n2 = n2, + directed = directed, + mode = mode + ) if (igraph_opt("add.params")) { res$graph$name <- "Full bipartite graph" res$n1 <- n1 @@ -633,13 +649,11 @@ graph.extended.chordal.ring <- function(n, w, directed = FALSE) { graph.empty <- function(n = 0, directed = TRUE) { # nocov start lifecycle::deprecate_soft("2.1.0", "graph.empty()", "make_empty_graph()") - # Argument checks - n <- as.numeric(n) - directed <- as.logical(directed) - - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_empty, n, directed) + res <- empty_impl( + n = n, + directed = directed + ) res } # nocov end @@ -661,8 +675,10 @@ graph.de.bruijn <- function(m, n) { "graph.de.bruijn()", "make_de_bruijn_graph()" ) - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_de_bruijn, as.numeric(m), as.numeric(n)) + res <- de_bruijn_impl( + m = m, + n = n + ) if (igraph_opt("add.params")) { res$name <- sprintf("De-Bruijn graph %i-%i", m, n) res$m <- m @@ -732,8 +748,9 @@ graph.bipartite <- function(types, edges, directed = FALSE) { graph.atlas <- function(n) { # nocov start lifecycle::deprecate_soft("2.1.0", "graph.atlas()", "graph_from_atlas()") - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_atlas, as.numeric(n)) + res <- atlas_impl( + number = n + ) if (igraph_opt("add.params")) { res$name <- sprintf("Graph from the Atlas #%i", n) res$n <- n @@ -1536,7 +1553,7 @@ make_famous_graph <- function(name) { name <- gsub("\\s", "_", name) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_famous, name) + res <- .Call(Rx_igraph_famous, name) if (igraph_opt("add.params")) { res$name <- capitalize(name) } @@ -1595,7 +1612,10 @@ make_empty_graph <- function(n = 0, directed = TRUE) { "{.arg directed} must be a logical, not {.obj_type_friendly {directed}}." ) } - empty_impl(n, directed) + empty_impl( + n = n, + directed = directed + ) } #' @rdname make_empty_graph @@ -1859,7 +1879,7 @@ make_star <- function( mode = c("in", "out", "mutual", "undirected"), center = 1 ) { - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode1 <- switch(mode, "out" = 0, "in" = 1, "undirected" = 2, "mutual" = 3) on.exit(.Call(R_igraph_finalizer)) @@ -1983,7 +2003,14 @@ make_lattice <- function( } on.exit(.Call(R_igraph_finalizer)) - res <- square_lattice_impl(dimvector, nei, directed, mutual, periodic) + res <- square_lattice_impl( + dimvector = dimvector, + nei = nei, + directed = directed, + mutual = mutual, + periodic = periodic + ) + if (igraph_opt("add.params")) { res$name <- "Lattice graph" res$dimvector <- dimvector @@ -2001,6 +2028,74 @@ lattice <- function(...) constructor_spec(make_lattice, ...) ## ----------------------------------------------------------------- +#' Create a triangular lattice graph +#' +#' `r lifecycle::badge("experimental")` +#' +#' `make_tri_lattice()` creates a triangular lattice with a specified shape. +#' The shape can be triangular (1 dimension), quasi-rectangular (2 dimensions), +#' or hexagonal (3 dimensions). +#' +#' @concept Lattice +#' @param dims Integer vector defining the shape of the lattice. +#' - If `dims` is of length 1, the resulting lattice has a triangular shape +#' where each side of the triangle contains `dims[1]` vertices. +#' - If `dims` is of length 2, the resulting lattice has a "quasi rectangular" +#' shape with the sides containing `dims[1]` and `dims[2]` vertices, respectively. +#' - If `dims` is of length 3, the resulting lattice has a hexagonal shape +#' where the sides of the hexagon contain `dims[1]`, `dims[2]`, and `dims[3]` +#' vertices. +#' All dimensions must be non-negative. +#' @param ... These dots are for future extensions and must be empty. +#' @param directed Logical scalar, whether to create a directed graph. +#' If the `mutual` argument is not set to `TRUE`, edges will be directed +#' from lower-index vertices towards higher-index ones. +#' @param mutual Logical scalar, if the graph is directed, this gives whether +#' to create all connections as mutual. +#' @return An igraph graph. +#' +#' @family deterministic constructors +#' @export +#' @examples +#' # Triangular lattice (1D case - creates a triangle) +#' g1 <- make_tri_lattice(5) +#' plot(g1) +#' +#' # Quasi-rectangular lattice (2D case) +#' g2 <- make_tri_lattice(c(3, 4)) +#' plot(g2) +#' +#' # Hexagonal lattice (3D case) +#' g3 <- make_tri_lattice(c(3, 3, 3)) +#' plot(g3) +#' +#' # Directed triangular lattice with mutual edges +#' g4 <- make_tri_lattice(c(3, 3), directed = TRUE, mutual = TRUE) +#' @cdocs igraph_triangular_lattice +make_tri_lattice <- function(dims, ..., directed = FALSE, mutual = FALSE) { + check_dots_empty() + + on.exit(.Call(R_igraph_finalizer)) + res <- triangular_lattice_impl( + dimvector = dims, + directed = directed, + mutual = mutual + ) + if (igraph_opt("add.params")) { + res$name <- "Triangular lattice" + res$dims <- dims + res$directed <- directed + res$mutual <- mutual + } + res +} + +#' @rdname make_tri_lattice +#' @export +tri_lattice <- function(...) constructor_spec(make_tri_lattice, ...) + +## ----------------------------------------------------------------- + #' Create a ring graph #' #' A ring is a one-dimensional lattice and this function is a special case @@ -2066,7 +2161,7 @@ ring <- function(...) constructor_spec(make_ring, ...) #' make_tree(10, 2) #' make_tree(10, 3, mode = "undirected") make_tree <- function(n, children = 2, mode = c("out", "in", "undirected")) { - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode1 <- switch(mode, "out" = 0, "in" = 1, "undirected" = 2) on.exit(.Call(R_igraph_finalizer)) @@ -2193,8 +2288,9 @@ from_prufer <- function(...) constructor_spec(make_from_prufer, ...) #' graph_from_atlas(sample(0:1252, 1)) #' graph_from_atlas(sample(0:1252, 1)) graph_from_atlas <- function(n) { - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_atlas, as.numeric(n)) + res <- atlas_impl( + number = n + ) if (igraph_opt("add.params")) { res$name <- sprintf("Graph from the Atlas #%i", n) res$n <- n @@ -2258,6 +2354,41 @@ chordal_ring <- function(...) constructor_spec(make_chordal_ring, ...) ## ----------------------------------------------------------------- +#' Create a circulant graph +#' +#' A circulant graph \eqn{C_n^{\textrm{shifts}}} consists of \eqn{n} vertices +#' \eqn{v_0, \ldots, v_{n-1}} such that for each \eqn{s_i} in the list of offsets +#' `shifts`, \eqn{v_j} is connected to \eqn{v_{(j + s_i) \mod n}} for all \eqn{j}. +#' +#' The function can generate either directed or undirected graphs. +#' It does not generate multi-edges or self-loops. +#' +#' @param n Integer, the number of vertices in the circulant graph. +#' @param shifts Integer vector, a list of the offsets within the circulant graph. +#' @param directed Boolean, whether to create a directed graph. +#' @return An igraph graph. +#' +#' @family deterministic constructors +#' @export +#' @examples +#' # Create a circulant graph with 10 vertices and shifts 1 and 3 +#' g <- make_circulant(10, c(1, 3)) +#' plot(g, layout = layout_in_circle) +#' +#' # A directed circulant graph +#' g2 <- make_circulant(10, c(1, 3), directed = TRUE) +#' plot(g2, layout = layout_in_circle) +make_circulant <- function(n, shifts, directed = FALSE) { + circulant_impl(n = n, shifts = shifts, directed = directed) +} + +#' @rdname make_circulant +#' @param ... Passed to `make_circulant()`. +#' @export +circulant <- function(...) constructor_spec(make_circulant, ...) + +## ----------------------------------------------------------------- + #' Line graph of a graph #' #' This function calculates the line graph of another graph. @@ -2290,8 +2421,9 @@ chordal_ring <- function(...) constructor_spec(make_chordal_ring, ...) make_line_graph <- function(graph) { ensure_igraph(graph) - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_linegraph, graph) + res <- linegraph_impl( + graph = graph + ) if (igraph_opt("add.params")) { res$name <- "Line graph" } @@ -2337,8 +2469,10 @@ line_graph <- function(...) constructor_spec(make_line_graph, ...) #' make_de_bruijn_graph(2, 2) #' make_line_graph(g) make_de_bruijn_graph <- function(m, n) { - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_de_bruijn, as.numeric(m), as.numeric(n)) + res <- de_bruijn_impl( + m = m, + n = n + ) if (igraph_opt("add.params")) { res$name <- sprintf("De-Bruijn graph %i-%i", m, n) res$m <- m @@ -2382,8 +2516,10 @@ de_bruijn_graph <- function(...) constructor_spec(make_de_bruijn_graph, ...) #' make_kautz_graph(2, 2) #' make_kautz_graph <- function(m, n) { - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_kautz, as.numeric(m), as.numeric(n)) + res <- kautz_impl( + m = m, + n = n + ) if (igraph_opt("add.params")) { res$name <- sprintf("Kautz graph %i-%i", m, n) res$m <- m @@ -2438,15 +2574,19 @@ make_full_bipartite_graph <- function( n2 <- as.numeric(n2) directed <- as.logical(directed) mode1 <- switch( - igraph.match.arg(mode), + igraph_match_arg(mode), "out" = 1, "in" = 2, "all" = 3, "total" = 3 ) - on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_full_bipartite, n1, n2, as.logical(directed), mode1) + res <- full_bipartite_impl( + n1 = n1, + n2 = n2, + directed = directed, + mode = mode + ) if (igraph_opt("add.params")) { res$graph$name <- "Full bipartite graph" res$n1 <- n1 @@ -2545,6 +2685,117 @@ bipartite_graph <- function(...) constructor_spec(make_bipartite_graph, ...) ## ----------------------------------------------------------------- +#' Create a full multipartite graph +#' +#' A multipartite graph contains multiple types of vertices and connections +#' are only possible between vertices of different types. This function +#' creates a complete multipartite graph where all possible edges between +#' different partitions are present. +#' +#' @param n A numeric vector giving the number of vertices in each partition. +#' @param directed Logical scalar, whether to create a directed graph. +#' @param mode Character scalar, the type of connections for directed graphs. +#' If `"out"`, then edges point from vertices of partitions with lower +#' indices to partitions with higher indices; if `"in"`, then the opposite +#' direction is realized; `"all"` creates mutual edges. This parameter is +#' ignored for undirected graphs. +#' @return An igraph graph with a vertex attribute `type` storing the +#' partition index of each vertex. Partition indices start from 1. +#' +#' @family deterministic constructors +#' @export +#' @examples +#' # Create a multipartite graph with partitions of size 2, 3, and 4 +#' g <- make_full_multipartite(c(2, 3, 4)) +#' plot(g) +#' +#' # Create a directed multipartite graph +#' g2 <- make_full_multipartite(c(2, 2, 2), directed = TRUE, mode = "out") +#' plot(g2) +#' @cdocs igraph_full_multipartite +make_full_multipartite <- function( + n, + directed = FALSE, + mode = c("all", "out", "in") +) { + n <- as.numeric(n) + directed <- as.logical(directed) + mode <- igraph_match_arg(mode) + + res <- full_multipartite_impl(n = n, directed = directed, mode = mode) + graph <- set_vertex_attr(res$graph, "type", value = res$types) + + # Transfer graph attributes from res to graph if add.params is enabled + if (igraph_opt("add.params")) { + for (attr_name in setdiff(names(res), c("graph", "types"))) { + graph <- set_graph_attr(graph, attr_name, res[[attr_name]]) + } + } + graph +} + +#' @rdname make_full_multipartite +#' @param ... Passed to `make_full_multipartite()`. +#' @export +full_multipartite <- function(...) { + constructor_spec(make_full_multipartite, ...) +} + +## ----------------------------------------------------------------- + +#' Create a Turán graph +#' +#' Turán graphs are complete multipartite graphs with the property that the +#' sizes of the partitions are as close to equal as possible. +#' +#' @details +#' The Turán graph with `n` vertices and `r` partitions is the densest +#' graph on `n` vertices that does not contain a clique of size `r+1`. +#' +#' This function generates undirected graphs. The null graph is +#' returned when the number of vertices is zero. A complete graph is +#' returned if the number of partitions is greater than the number of vertices. +#' +#' @param n Integer, the number of vertices in the graph. +#' @param r Integer, the number of partitions in the graph, must be positive. +#' @return An igraph graph with a vertex attribute `type` storing the +#' partition index of each vertex. Partition indices start from 1. +#' +#' @family deterministic constructors +#' @export +#' @examples +#' # Create a Turán graph with 10 vertices and 3 partitions +#' g <- make_turan(10, 3) +#' plot(g) +#' +#' # The sizes of the partitions are as balanced as possible +#' table(V(g)$type) +#' @cdocs igraph_turan +make_turan <- function(n, r) { + n <- as.numeric(n) + r <- as.numeric(r) + + res <- turan_impl(n = n, r = r) + graph <- set_vertex_attr(res$graph, "type", value = res$types) + + # Transfer graph attributes from res to graph if add.params is enabled + if (igraph_opt("add.params")) { + for (attr_name in setdiff(names(res), c("graph", "types"))) { + graph <- set_graph_attr(graph, attr_name, res[[attr_name]]) + } + } + graph +} + +#' @rdname make_turan +#' @param ... Passed to `make_turan()`. +#' @export +turan <- function(...) { + constructor_spec(make_turan, ...) +} + +## ----------------------------------------------------------------- + #' Create a complete (full) citation graph #' #' `make_full_citation_graph()` creates a full citation graph. This is a @@ -2560,13 +2811,11 @@ bipartite_graph <- function(...) constructor_spec(make_bipartite_graph, ...) #' @examples #' print_all(make_full_citation_graph(10)) make_full_citation_graph <- function(n, directed = TRUE) { - # Argument checks - n <- as.numeric(n) - directed <- as.logical(directed) - - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_full_citation, n, directed) + res <- full_citation_impl( + n = n, + directed = directed + ) res <- set_graph_attr(res, "name", "Full citation graph") res @@ -2637,7 +2886,11 @@ graph_from_lcf <- function( ) } - lcf_vector_impl(n = n, shifts = shifts, repeats = repeats) + lcf_vector_impl( + n = n, + shifts = shifts, + repeats = repeats + ) } ## ----------------------------------------------------------------- @@ -2795,14 +3048,15 @@ realize_bipartite_degseq <- function( method = c("smallest", "largest", "index") ) { check_dots_empty() - allowed.edge.types <- igraph.match.arg(allowed.edge.types) - method <- igraph.match.arg(method) + allowed.edge.types <- igraph_match_arg(allowed.edge.types) + method <- igraph_match_arg(method) g <- realize_bipartite_degree_sequence_impl( degrees1 = degrees1, degrees2 = degrees2, allowed.edge.types = allowed.edge.types, method = method ) + V(g)$type <- c(rep(TRUE, length(degrees1)), rep(FALSE, length(degrees2))) g } diff --git a/R/minimum.spanning.tree.R b/R/minimum.spanning.tree.R index 4a47836555d..0ab3b564836 100644 --- a/R/minimum.spanning.tree.R +++ b/R/minimum.spanning.tree.R @@ -92,7 +92,7 @@ mst <- function(graph, weights = NULL, algorithm = NULL, ...) { if (algorithm == "unweighted") { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_minimum_spanning_tree_unweighted, graph) + .Call(Rx_igraph_minimum_spanning_tree_unweighted, graph) } else if (algorithm == "prim") { if (is.null(weights) && !"weight" %in% edge_attr_names(graph)) { cli::cli_abort("edges weights must be supplied for Prim's algorithm.") @@ -100,7 +100,7 @@ mst <- function(graph, weights = NULL, algorithm = NULL, ...) { weights <- E(graph)$weight } on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_minimum_spanning_tree_prim, graph, as.numeric(weights)) + .Call(Rx_igraph_minimum_spanning_tree_prim, graph, as.numeric(weights)) } else { cli::cli_abort("Invalid {.arg algorithm}.") } diff --git a/R/motifs.R b/R/motifs.R index cca68c34749..49b697dcd04 100644 --- a/R/motifs.R +++ b/R/motifs.R @@ -156,10 +156,11 @@ motifs <- function(graph, size = 3, cut.prob = NULL) { } res <- motifs_randesu_impl( - graph, + graph = graph, size = size, cut.prob = cut.prob ) + res[is.nan(res)] <- NA res } @@ -197,7 +198,7 @@ count_motifs <- function(graph, size = 3, cut.prob = NULL) { } motifs_randesu_no_impl( - graph, + graph = graph, size = size, cut.prob = cut.prob ) @@ -258,11 +259,11 @@ sample_motifs <- function( } motifs_randesu_estimate_impl( - graph, + graph = graph, size = size, cut.prob = cut.prob, sample.size = sample.size, - sample + sample = sample ) } @@ -309,7 +310,9 @@ dyad_census <- function(graph) { warn("`dyad_census()` requires a directed graph.") } - dyad_census_impl(graph) + dyad_census_impl( + graph = graph + ) } @@ -395,5 +398,7 @@ dyad_census <- function(graph) { #' @export #' @cdocs igraph_triad_census triad_census <- function(graph) { - triad_census_impl(graph = graph) + triad_census_impl( + graph = graph + ) } diff --git a/R/operators.R b/R/operators.R index 20cea8fc969..2a58a86ca00 100644 --- a/R/operators.R +++ b/R/operators.R @@ -126,7 +126,7 @@ rename.attr.if.needed <- function( maps2 = NULL, ignore = character() ) { - type <- igraph.match.arg(type) + type <- igraph_match_arg(type) listfun <- switch( type, @@ -229,7 +229,7 @@ disjoint_union <- function(...) { lapply(graphs, ensure_igraph) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_disjoint_union, graphs) + res <- .Call(Rx_igraph_disjoint_union, graphs) ## Graph attributes graph.attributes(res) <- rename.attr.if.needed("g", graphs) @@ -350,9 +350,9 @@ disjoint_union <- function(...) { on.exit(.Call(R_igraph_finalizer)) if (call == "union") { - res <- .Call(R_igraph_union, newgraphs, edgemaps) + res <- .Call(Rx_igraph_union, newgraphs, edgemaps) } else { - res <- .Call(R_igraph_intersection, newgraphs, edgemaps) + res <- .Call(Rx_igraph_intersection, newgraphs, edgemaps) } maps <- res$edgemaps res <- res$graph @@ -390,9 +390,9 @@ disjoint_union <- function(...) { on.exit(.Call(R_igraph_finalizer)) if (call == "union") { - res <- .Call(R_igraph_union, graphs, edgemaps) + res <- .Call(Rx_igraph_union, graphs, edgemaps) } else { - res <- .Call(R_igraph_intersection, graphs, edgemaps) + res <- .Call(Rx_igraph_intersection, graphs, edgemaps) } maps <- res$edgemaps res <- res$graph @@ -696,11 +696,11 @@ difference.igraph <- function(big, small, byname = "auto", ...) { big <- permute(big, perm) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_difference, big, small) + res <- .Call(Rx_igraph_difference, big, small) permute(res, match(V(res)$name, bnames)) } else { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_difference, big, small) + .Call(Rx_igraph_difference, big, small) } } @@ -747,7 +747,7 @@ complementer <- function(graph, loops = FALSE) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_complementer, graph, as.logical(loops)) + .Call(Rx_igraph_complementer, graph, as.logical(loops)) } @@ -851,7 +851,7 @@ compose <- function(g1, g2, byname = "auto") { length(edge_attr_names(g2)) != 0) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_compose, g1, g2, edgemaps) + res <- .Call(Rx_igraph_compose, g1, g2, edgemaps) maps <- list(res$edge_map1, res$edge_map2) res <- res$graph @@ -967,7 +967,21 @@ edges <- edge #' g #' plot(g) vertex <- function(...) { - structure(list(...), class = "igraph.vertex") + args <- list(...) + arg_names <- names(args) + + # Check for duplicate named arguments + if (!is.null(arg_names)) { + named_args <- arg_names[arg_names != ""] + if (anyDuplicated(named_args)) { + duplicates <- unique(named_args[duplicated(named_args)]) + cli::cli_abort( + "Duplicate attribute {cli::qty(duplicates)}name{?s} in {.fn vertices}: {.val {duplicates}}." + ) + } + } + + structure(args, class = "igraph.vertex") } #' @export diff --git a/R/other.R b/R/other.R index a28d2cf8c8c..4eff3d52685 100644 --- a/R/other.R +++ b/R/other.R @@ -96,7 +96,7 @@ running_mean <- function(v, binwidth) { } on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_running_mean, v, binwidth) + .Call(Rx_igraph_running_mean, v, binwidth) } @@ -224,5 +224,7 @@ igraph.i.spMatrix <- function(M) { #' @export #' @cdocs igraph_convex_hull convex_hull <- function(data) { - convex_hull_2d_impl(data = data) + convex_hull_2d_impl( + data = data + ) } diff --git a/R/par.R b/R/par.R index 9507dc039b3..ac5d3d1c3f8 100644 --- a/R/par.R +++ b/R/par.R @@ -76,7 +76,7 @@ getIgraphOpt <- function(x, default = NULL) { igraph.pars.set.verbose <- function(verbose) { if (is.logical(verbose)) { - .Call(R_igraph_set_verbose, verbose) + .Call(Rx_igraph_set_verbose, verbose) } else if (is.character(verbose)) { if (!verbose %in% c("tk", "tkconsole")) { cli::cli_abort("Unknown {.arg verbose} value.") @@ -89,7 +89,7 @@ igraph.pars.set.verbose <- function(verbose) { cli::cli_abort("tcltk package not available.") } } - .Call(R_igraph_set_verbose, TRUE) + .Call(Rx_igraph_set_verbose, TRUE) } else { cli::cli_abort("{.arg verbose} should be a logical or character scalar.") } diff --git a/R/paths.R b/R/paths.R index 857bbf8bf04..972bcc136b7 100644 --- a/R/paths.R +++ b/R/paths.R @@ -120,7 +120,7 @@ all_simple_paths <- function( res <- with_igraph_opt( list(return.vs.es = FALSE), get_all_simple_paths_impl( - graph, + graph = graph, from = from, to = to, cutoff = cutoff, @@ -161,7 +161,9 @@ all_simple_paths <- function( #' @export #' @cdocs igraph_is_dag is_dag <- function(graph) { - is_dag_impl(graph = graph) + is_dag_impl( + graph = graph + ) } #' Acyclic graphs @@ -186,7 +188,9 @@ is_dag <- function(graph) { #' @export #' @cdocs igraph_is_acyclic is_acyclic <- function(graph) { - is_acyclic_impl(graph = graph) + is_acyclic_impl( + graph = graph + ) } #' Maximum cardinality search @@ -245,7 +249,9 @@ is_acyclic <- function(graph) { #' @family chordal #' @cdocs igraph_maximum_cardinality_search max_cardinality <- function(graph) { - maximum_cardinality_search_impl(graph = graph) + maximum_cardinality_search_impl( + graph = graph + ) } @@ -300,7 +306,12 @@ eccentricity <- function( } } - eccentricity_dijkstra_impl(graph, vids = vids, weights = weights, mode = mode) + eccentricity_dijkstra_impl( + graph = graph, + vids = vids, + weights = weights, + mode = mode + ) } @@ -354,7 +365,11 @@ radius <- function( } } - radius_dijkstra_impl(graph, weights = weights, mode = mode) + radius_dijkstra_impl( + graph = graph, + weights = weights, + mode = mode + ) } #' Central vertices of a graph @@ -392,7 +407,6 @@ graph_center <- function( ) { graph_center_dijkstra_impl( graph = graph, - ..., weights = weights, mode = mode ) @@ -404,5 +418,8 @@ graph_center <- function( #' @export #' @cdocs igraph_path_length_hist distance_table <- function(graph, directed = TRUE) { - path_length_hist_impl(graph = graph, directed = directed) + path_length_hist_impl( + graph = graph, + directed = directed + ) } diff --git a/R/plot.common.R b/R/plot.common.R index 00b7f456164..4f78cce3d2a 100644 --- a/R/plot.common.R +++ b/R/plot.common.R @@ -548,7 +548,7 @@ i.parse.plot.params <- function(graph, params) { range = NULL, dontcall = FALSE ) { - type <- igraph.match.arg(type) + type <- igraph_match_arg(type) ret <- function() { v <- p[[type]][[name]] if (is.function(v) && !dontcall) { diff --git a/R/plot.shapes.R b/R/plot.shapes.R index 298e2e3391f..b8380cb10fe 100644 --- a/R/plot.shapes.R +++ b/R/plot.shapes.R @@ -351,7 +351,7 @@ shapes <- function(shape = NULL) { #' @rdname shapes #' @export shape_noclip <- function(coords, el, params, end = c("both", "from", "to")) { - end <- igraph.match.arg(end) + end <- igraph_match_arg(end) if (end == "both") { coords diff --git a/R/pp.R b/R/pp.R index d452b97fa12..a412f1d434a 100644 --- a/R/pp.R +++ b/R/pp.R @@ -20,5 +20,5 @@ ################################################################### get.all.simple.paths.pp <- function(vect) { - .Call(R_igraph_get_all_simple_paths_pp, vect) + .Call(Rx_igraph_get_all_simple_paths_pp, vect) } diff --git a/R/print.R b/R/print.R index 25058f30828..243a7d2055d 100644 --- a/R/print.R +++ b/R/print.R @@ -33,7 +33,7 @@ sep = "", gal, " (g/", - .Call(R_igraph_get_attr_mode, object, 2L), + .Call(Rx_igraph_get_attr_mode, object, 2L), ")" ) } @@ -43,7 +43,7 @@ sep = "", val, " (v/", - .Call(R_igraph_get_attr_mode, object, 3L), + .Call(Rx_igraph_get_attr_mode, object, 3L), ")" ) } @@ -53,7 +53,7 @@ sep = "", edge_attr_names(object), " (e/", - .Call(R_igraph_get_attr_mode, object, 4L), + .Call(Rx_igraph_get_attr_mode, object, 4L), ")" ) } diff --git a/R/random_walk.R b/R/random_walk.R index 3df2c6edd8a..bb78e0e5175 100644 --- a/R/random_walk.R +++ b/R/random_walk.R @@ -58,7 +58,15 @@ random_walk <- function( ) { mode <- match.arg(mode) stuck <- match.arg(stuck) - out <- random_walk_impl(graph, start, steps, weights, mode, stuck) + out <- random_walk_impl( + graph = graph, + start = start, + steps = steps, + weights = weights, + mode = mode, + stuck = stuck + ) + # FIXME: Support returning the full structure out$vertices } @@ -76,7 +84,15 @@ random_edge_walk <- function( ) { mode <- match.arg(mode) stuck <- match.arg(stuck) - out <- random_walk_impl(graph, start, steps, weights, mode, stuck) + out <- random_walk_impl( + graph = graph, + start = start, + steps = steps, + weights = weights, + mode = mode, + stuck = stuck + ) + # FIXME: Support returning the full structure out$edges } diff --git a/R/rewire.R b/R/rewire.R index 44354e904b2..755fe8733ff 100644 --- a/R/rewire.R +++ b/R/rewire.R @@ -41,7 +41,7 @@ rewire <- function(graph, with) { if (!is(with, "igraph_rewiring_method")) { cli::cli_abort( - "{.arg with} must be an igraph rewiring method, + "{.arg with} must be an igraph rewiring method, not {.obj_type_friendly {with}}." ) } @@ -89,7 +89,7 @@ rewire_keeping_degseq <- function(graph, loops, niter) { mode <- if (loops) 1 else 0 on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_rewire, graph, as.numeric(niter), as.numeric(mode)) + .Call(Rx_igraph_rewire, graph, as.numeric(niter), as.numeric(mode)) } #' Rewires the endpoints of the edges of a graph to a random vertex @@ -134,7 +134,7 @@ each_edge <- function( mode = c("all", "out", "in", "total") ) { mode <- switch( - igraph.match.arg(mode), + igraph_match_arg(mode), "out" = 1, "in" = 2, "all" = 3, @@ -162,15 +162,11 @@ each_edge <- function( } rewire_each_edge <- function(graph, prob, loops, multiple) { - ensure_igraph(graph) - - on.exit(.Call(R_igraph_finalizer)) - .Call( - R_igraph_rewire_edges, - graph, - as.numeric(prob), - as.logical(loops), - as.logical(multiple) + rewire_edges_impl( + graph = graph, + prob = prob, + loops = loops, + multiple = multiple ) } diff --git a/R/scan.R b/R/scan.R index 0efea006863..a866b25faf9 100644 --- a/R/scan.R +++ b/R/scan.R @@ -163,7 +163,7 @@ local_scan <- function( } ## Check mode argument - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) cmode <- switch(mode, out = 1, `in` = 2, all = 3, total = 3) sumweights <- function(g) sum(E(g)$weight) @@ -404,7 +404,7 @@ scan_stat <- function( ## ell must the a non-negative integer stopifnot(length(ell) == 1, ell >= 0, trunc(ell) == ell) - locality <- igraph.match.arg(locality) + locality <- igraph_match_arg(locality) ## number of time steps and number of vertices maxTime <- length(graphs) diff --git a/R/sgm.R b/R/sgm.R index ad7baa465ab..b18961b055b 100644 --- a/R/sgm.R +++ b/R/sgm.R @@ -24,8 +24,11 @@ solve_LSAP <- function(x, maximum = FALSE) { if (maximum) { x <- max(x) - x } - storage.mode(x) <- "double" - out <- .Call(R_igraph_solve_lsap, x, as.numeric(nc)) + 1L + out <- solve_lsap_impl( + c = x, + n = as.numeric(nc) + ) + + 1L out[seq_len(nr)] } diff --git a/R/similarity.R b/R/similarity.R index b86fd2f9c3e..870d57cbcaf 100644 --- a/R/similarity.R +++ b/R/similarity.R @@ -66,13 +66,27 @@ similarity <- function( "invlogweighted" ) ) { - method <- igraph.match.arg(method) + method <- igraph_match_arg(method) if (method == "jaccard") { - similarity_jaccard_impl(graph, vids, mode, loops) + similarity_jaccard_impl( + graph = graph, + vids = vids, + mode = mode, + loops = loops + ) } else if (method == "dice") { - similarity_dice_impl(graph, vids, mode, loops) + similarity_dice_impl( + graph = graph, + vids = vids, + mode = mode, + loops = loops + ) } else if (method == "invlogweighted") { - similarity_inverse_log_weighted_impl(graph, vids, mode) + similarity_inverse_log_weighted_impl( + graph = graph, + vids = vids, + mode = mode + ) } } diff --git a/R/simple.R b/R/simple.R index 78132bd4dc5..b81116f6283 100644 --- a/R/simple.R +++ b/R/simple.R @@ -118,9 +118,10 @@ simplify_and_colorize <- function(graph) { # Argument checks ensure_igraph(graph) - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_simplify_and_colorize, graph) + res <- simplify_and_colorize_impl( + graph = graph + ) V(res$res)$color <- res$vertex_color E(res$res)$color <- res$edge_color diff --git a/R/stochastic_matrix.R b/R/stochastic_matrix.R index eb5afe3a6c0..35480f1ce92 100644 --- a/R/stochastic_matrix.R +++ b/R/stochastic_matrix.R @@ -95,12 +95,19 @@ stochastic_matrix <- function( ) } - on.exit(.Call(R_igraph_finalizer)) if (sparse) { - res <- .Call(R_igraph_get_stochastic_sparse, graph, column.wise, NULL) + res <- get_stochastic_sparse_impl( + graph = graph, + column.wise = column.wise, + weights = NULL + ) res <- igraph.i.spMatrix(res) } else { - res <- .Call(R_igraph_get_stochastic, graph, column.wise, NULL) + res <- get_stochastic_impl( + graph = graph, + column.wise = column.wise, + weights = NULL + ) } if (igraph_opt("add.vertex.names") && is_named(graph)) { diff --git a/R/structural-properties.R b/R/structural-properties.R index b99ba9e37f5..82808d2424f 100644 --- a/R/structural-properties.R +++ b/R/structural-properties.R @@ -150,8 +150,8 @@ shortest.paths <- function( ) { # nocov start lifecycle::deprecate_soft("2.0.0", "shortest.paths()", "distances()") - algorithm <- igraph.match.arg(algorithm) - mode <- igraph.match.arg(mode) + algorithm <- igraph_match_arg(algorithm) + mode <- igraph_match_arg(mode) distances( graph = graph, v = v, @@ -852,8 +852,21 @@ farthest_vertices <- function( #' @export #' @rdname distances #' @cdocs igraph_average_path_length_dijkstra -mean_distance <- average_path_length_dijkstra_impl - +mean_distance <- function( + graph, + weights = NULL, + directed = TRUE, + unconnected = TRUE, + details = FALSE +) { + average_path_length_dijkstra_impl( + graph = graph, + weights = weights, + directed = directed, + unconnected = unconnected, + details = details + ) +} #' Degree and degree distribution of the vertices #' @@ -881,6 +894,10 @@ mean_distance <- average_path_length_dijkstra_impl #' For `max_degree()`, the largest degree in the graph. When no vertices are #' selected, or when the input is the null graph, zero is returned as this #' is the smallest possible degree. +#' +#' For `mean_degree()`, the average degree in the graph as a single number. +#' For graphs with no vertices, `NaN` is returned. +#' `r lifecycle::badge("experimental")` #' @author Gabor Csardi \email{csardi.gabor@@gmail.com} #' @keywords graphs #' @family structural.properties @@ -891,6 +908,7 @@ mean_distance <- average_path_length_dijkstra_impl #' degree(g) #' g2 <- sample_gnp(1000, 10 / 1000) #' max_degree(g2) +#' mean_degree(g2) #' degree_distribution(g2) #' degree <- function( @@ -902,14 +920,15 @@ degree <- function( ) { ensure_igraph(graph) v <- as_igraph_vs(graph, v) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) res <- degree_impl( - graph, + graph = graph, vids = v, mode = mode, loops = loops ) + if (normalized) { res <- res / (vcount(graph) - 1) } @@ -922,7 +941,30 @@ degree <- function( #' @rdname degree #' @export #' @cdocs igraph_maxdegree -max_degree <- maxdegree_impl +max_degree <- function( + graph, + ..., + v = V(graph), + mode = c("all", "out", "in", "total"), + loops = TRUE +) { + maxdegree_impl( + graph = graph, + v = v, + mode = mode, + loops = loops + ) +} + +#' @rdname degree +#' @export +#' @cdocs igraph_mean_degree +mean_degree <- function(graph, loops = TRUE) { + mean_degree_impl( + graph = graph, + loops = loops + ) +} #' @rdname degree #' @param cumulative Logical; whether the cumulative degree distribution is to @@ -1172,9 +1214,9 @@ distances <- function( v <- as_igraph_vs(graph, v) to <- as_igraph_vs(graph, to) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) - algorithm <- igraph.match.arg(algorithm) + algorithm <- igraph_match_arg(algorithm) algorithm <- switch( algorithm, "automatic" = 0, @@ -1255,11 +1297,11 @@ shortest_paths <- function( algorithm = c("automatic", "unweighted", "dijkstra", "bellman-ford") ) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) - output <- igraph.match.arg(output) + output <- igraph_match_arg(output) output <- switch(output, "vpath" = 0, "epath" = 1, "both" = 2) - algorithm <- igraph.match.arg(algorithm) + algorithm <- igraph_match_arg(algorithm) algorithm <- switch( algorithm, "automatic" = 0, @@ -1361,7 +1403,7 @@ all_shortest_paths <- function( ) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) if (is.null(weights)) { if ("weight" %in% edge_attr_names(graph)) { @@ -1371,14 +1413,14 @@ all_shortest_paths <- function( if (is.null(weights)) { res <- get_all_shortest_paths_impl( - graph, + graph = graph, from = from, to = to, mode = mode ) } else { res <- get_all_shortest_paths_dijkstra_impl( - graph, + graph = graph, from = from, to = to, weights = weights, @@ -1447,7 +1489,6 @@ k_shortest_paths <- function( from = from, to = to, k = k, - ..., weights = weights, mode = mode ) @@ -1482,7 +1523,7 @@ k_shortest_paths <- function( #' subcomponent(g, 1, "all") subcomponent <- function(graph, v, mode = c("all", "out", "in")) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) on.exit(.Call(R_igraph_finalizer)) @@ -1556,16 +1597,14 @@ induced_subgraph <- function( # Argument checks ensure_igraph(graph) vids <- as_igraph_vs(graph, vids) - impl <- switch( - igraph.match.arg(impl), - "auto" = 0L, - "copy_and_delete" = 1L, - "create_from_scratch" = 2L - ) + impl <- igraph_match_arg(impl) - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_induced_subgraph, graph, vids - 1, impl) + res <- induced_subgraph_impl( + graph = graph, + vids = vids, + impl = impl + ) res } @@ -1576,14 +1615,18 @@ induced_subgraph <- function( #' not have any adjacent edges in `eids`. #' @export subgraph_from_edges <- function(graph, eids, delete.vertices = TRUE) { + # Argument checks # Argument checks ensure_igraph(graph) eids <- as_igraph_es(graph, eids) delete.vertices <- as.logical(delete.vertices) - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_subgraph_from_edges, graph, eids - 1, delete.vertices) + res <- subgraph_from_edges_impl( + graph = graph, + eids = eids, + delete.vertices = delete.vertices + ) res } @@ -1745,7 +1788,7 @@ transitivity <- function( isolates = c("NaN", "zero") ) { ensure_igraph(graph) - type <- igraph.match.arg(type) + type <- igraph_match_arg(type) type <- switch( type, "undirected" = 0L, @@ -1769,57 +1812,79 @@ transitivity <- function( weights <- NULL } - isolates <- igraph.match.arg(isolates) - isolates <- as.double(switch(isolates, "nan" = 0, "zero" = 1)) + isolates <- igraph_match_arg(isolates) - on.exit(.Call(R_igraph_finalizer)) if (type == 0) { - .Call(R_igraph_transitivity_undirected, graph, isolates) + transitivity_undirected_impl( + graph = graph, + mode = isolates + ) } else if (type == 1) { + isolates_num <- as.double(switch(isolates, "nan" = 0, "zero" = 1)) if (is.null(vids)) { - res <- .Call(R_igraph_transitivity_local_undirected_all, graph, isolates) + res <- .Call( + Rx_igraph_transitivity_local_undirected_all, + graph, + isolates_num + ) if (igraph_opt("add.vertex.names") && is_named(graph)) { names(res) <- V(graph)$name } res } else { - vids <- as_igraph_vs(graph, vids) - res <- .Call( - R_igraph_transitivity_local_undirected, - graph, - vids - 1, - isolates + res <- transitivity_local_undirected_impl( + graph = graph, + vids = vids, + mode = isolates ) if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- V(graph)$name[vids] + vids_indices <- as_igraph_vs(graph, vids) + names(res) <- V(graph)$name[vids_indices] } res } } else if (type == 2) { - .Call(R_igraph_transitivity_avglocal_undirected, graph, isolates) + transitivity_avglocal_undirected_impl( + graph = graph, + mode = isolates + ) } else if (type == 3) { - if (is.null(vids)) { - vids <- V(graph) - } - vids <- as_igraph_vs(graph, vids) + # Save original vids for naming if needed + vids_for_names <- if (is.null(vids)) V(graph) else vids + res <- if (is.null(weights)) { - .Call( - R_igraph_transitivity_local_undirected, - graph, - vids - 1, - isolates - ) + if (is.null(vids)) { + transitivity_local_undirected_impl( + graph = graph, + mode = isolates + ) + } else { + transitivity_local_undirected_impl( + graph = graph, + vids = vids, + mode = isolates + ) + } } else { - .Call( - R_igraph_transitivity_barrat, - graph, - vids - 1, - weights, - isolates - ) + if (is.null(vids)) { + transitivity_barrat_impl( + graph = graph, + weights = weights, + mode = isolates + ) + } else { + transitivity_barrat_impl( + graph = graph, + vids = vids, + weights = weights, + mode = isolates + ) + } } + if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- V(graph)$name[vids] + vids_indices <- as_igraph_vs(graph, vids_for_names) + names(res) <- V(graph)$name[vids_indices] } res } @@ -1879,7 +1944,7 @@ constraint <- function(graph, nodes = V(graph), weights = NULL) { } on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_constraint, graph, nodes - 1, as.numeric(weights)) + res <- .Call(Rx_igraph_constraint, graph, nodes - 1, as.numeric(weights)) if (igraph_opt("add.vertex.names") && is_named(graph)) { names(res) <- V(graph)$name[nodes] } @@ -1989,7 +2054,7 @@ ego_size <- function( mindist = 0 ) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) mindist <- as.numeric(mindist) @@ -2103,7 +2168,7 @@ ego <- function( mindist = 0 ) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) mindist <- as.numeric(mindist) @@ -2138,7 +2203,7 @@ make_ego_graph <- function( mindist = 0 ) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1L, "in" = 2L, "all" = 3L) mindist <- as.numeric(mindist) @@ -2195,11 +2260,11 @@ make_neighborhood_graph <- make_ego_graph #' coreness <- function(graph, mode = c("all", "out", "in")) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_coreness, graph, as.numeric(mode)) + res <- .Call(Rx_igraph_coreness, graph, as.numeric(mode)) if (igraph_opt("add.vertex.names") && is_named(graph)) { names(res) <- vertex_attr(graph, "name") } @@ -2238,11 +2303,11 @@ coreness <- function(graph, mode = c("all", "out", "in")) { #' topo_sort <- function(graph, mode = c("out", "all", "in")) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "out" = 1, "in" = 2, "all" = 3) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_topological_sorting, graph, as.numeric(mode)) + 1L + res <- .Call(Rx_igraph_topological_sorting, graph, as.numeric(mode)) + 1L if (igraph_opt("return.vs.es")) { res <- create_vs(graph, res) @@ -2390,7 +2455,7 @@ girth <- function(graph, circle = TRUE) { ensure_igraph(graph) on.exit(.Call(R_igraph_finalizer)) - res <- .Call(R_igraph_girth, graph, as.logical(circle)) + res <- .Call(Rx_igraph_girth, graph, as.logical(circle)) if (res$girth == 0) { res$girth <- Inf } @@ -2410,6 +2475,8 @@ girth <- function(graph, circle = TRUE) { #' #' `which_loop()` decides whether the edges of the graph are loop edges. #' +#' `count_loops()` counts the total number of loop edges in the graph. +#' #' `any_multiple()` decides whether the graph has any multiple edges. #' #' `which_multiple()` decides whether the edges of the graph are multiple @@ -2431,6 +2498,7 @@ girth <- function(graph, circle = TRUE) { #' all edges in the graph. #' @return `any_loop()` and `any_multiple()` return a logical scalar. #' `which_loop()` and `which_multiple()` return a logical vector. +#' `count_loops()` returns a numeric scalar with the total number of loop edges. #' `count_multiple()` returns a numeric vector. #' @author Gabor Csardi \email{csardi.gabor@@gmail.com} #' @seealso [simplify()] to eliminate loop and multiple edges. @@ -2443,6 +2511,7 @@ girth <- function(graph, circle = TRUE) { #' g <- make_graph(c(1, 1, 2, 2, 3, 3, 4, 5)) #' any_loop(g) #' which_loop(g) +#' count_loops(g) #' #' # Multiple edges #' g <- sample_pa(10, m = 3, algorithm = "bag") @@ -2504,6 +2573,14 @@ any_loop <- function(graph) { graph = graph ) } +#' @rdname which_multiple +#' @export +#' @cdocs igraph_count_loops +count_loops <- function(graph) { + count_loops_impl( + graph = graph + ) +} #' Breadth-first search @@ -2678,7 +2755,7 @@ bfs <- function( root <- 0 # ignored anyway } mode <- switch( - igraph.match.arg(mode), + igraph_match_arg(mode), "out" = 1, "in" = 2, "all" = 3, @@ -2934,7 +3011,7 @@ dfs <- function( root <- as_igraph_vs(graph, root) - 1 mode <- switch( - igraph.match.arg(mode), + igraph_match_arg(mode), "out" = 1, "in" = 2, "all" = 3, @@ -3074,11 +3151,14 @@ dfs <- function( components <- function(graph, mode = c("weak", "strong")) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "weak" = 1, "strong" = 2) + mode <- igraph_match_arg(mode) - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_connected_components, graph, mode) + res <- connected_components_impl( + graph = graph, + mode = mode, + details = TRUE + ) res$membership <- res$membership + 1 if (igraph_opt("add.vertex.names") && is_named(graph)) { names(res$membership) <- V(graph)$name @@ -3101,11 +3181,62 @@ is_connected <- function(graph, mode = c("weak", "strong")) { #' @export count_components <- function(graph, mode = c("weak", "strong")) { ensure_igraph(graph) - mode <- igraph.match.arg(mode) + mode <- igraph_match_arg(mode) mode <- switch(mode, "weak" = 1L, "strong" = 2L) on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_no_components, graph, mode) + .Call(Rx_igraph_no_components, graph, mode) +} + +#' Count reachable vertices +#' +#' `r lifecycle::badge("experimental")` +#' +#' Counts the number of vertices reachable from each vertex in the graph. +#' +#' For each vertex in the graph, this function counts how many vertices +#' are reachable from it, including the vertex itself. +#' A vertex is reachable from another if there is a directed path between them. +#' For undirected graphs, two vertices are reachable from each other if they +#' are in the same connected component. +#' +#' @param graph The input graph. +#' @param mode Character constant, defines how edge directions are considered +#' in directed graphs. +#' `"out"` counts vertices reachable via outgoing edges, +#' `"in"` counts vertices from which the current vertex is reachable via +#' incoming edges, +#' `"all"` or `"total"` ignores edge directions. +#' This parameter is ignored for undirected graphs. +#' @return An integer vector of length `vcount(graph)`. +#' The i-th element is the number of vertices reachable from vertex i +#' (including vertex i itself). +#' @author Gabor Csardi \email{csardi.gabor@@gmail.com} +#' @seealso [components()], [subcomponent()], [is_connected()] +#' @family components +#' @export +#' @keywords graphs +#' @examples +#' +#' # In a directed path graph, the reachability depends on direction +#' g <- make_graph(~ 1 -+ 2 -+ 3 -+ 4 -+ 5) +#' count_reachable(g, mode = "out") +#' count_reachable(g, mode = "in") +#' +#' # In an undirected graph, reachability is the same in all directions +#' g2 <- make_graph(~ 1 - 2 - 3 - 4 - 5) +#' count_reachable(g2, mode = "out") +#' +#' # A graph with multiple components +#' g3 <- make_graph(~ 1 - 2 - 3, 4 - 5, 6) +#' count_reachable(g3, mode = "all") +#' +#' @cdocs igraph_count_reachable +count_reachable <- function(graph, mode = c("out", "in", "all", "total")) { + count_reachable_impl( + graph = graph, + mode = mode + ) } #' Convert a general graph into a forest @@ -3150,18 +3281,15 @@ count_components <- function(graph, mode = c("weak", "strong")) { unfold_tree <- function(graph, mode = c("all", "out", "in", "total"), roots) { # Argument checks ensure_igraph(graph) - mode <- switch( - igraph.match.arg(mode), - "out" = 1, - "in" = 2, - "all" = 3, - "total" = 3 - ) + mode <- igraph_match_arg(mode) roots <- as_igraph_vs(graph, roots) - 1 - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_unfold_tree, graph, mode, roots) + res <- unfold_tree_impl( + graph = graph, + mode = mode, + roots = roots + ) res } @@ -3260,9 +3388,19 @@ laplacian_matrix <- function( on.exit(.Call(R_igraph_finalizer)) # Function call if (sparse) { - res <- get_laplacian_sparse_impl(graph, "out", normalization, weights) + res <- get_laplacian_sparse_impl( + graph = graph, + mode = "out", + normalization = normalization, + weights = weights + ) } else { - res <- get_laplacian_impl(graph, "out", normalization, weights) + res <- get_laplacian_impl( + graph = graph, + mode = "out", + normalization = normalization, + weights = weights + ) } if (sparse) { res <- igraph.i.spMatrix(res) @@ -3372,12 +3510,15 @@ is_matching <- function(graph, matching, types = NULL) { # Argument checks ensure_igraph(graph) types <- handle_vertex_type_arg(types, graph, required = F) - matching <- as_igraph_vs(graph, matching, na.ok = TRUE) - 1 - matching[is.na(matching)] <- -1 + matching <- as_igraph_vs(graph, matching, na.ok = TRUE) + matching[is.na(matching)] <- 0 # Use 0 since is_matching_impl will subtract 1, making it -1 - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_is_matching, graph, types, matching) + res <- is_matching_impl( + graph = graph, + types = types, + matching = matching + ) res } @@ -3388,12 +3529,15 @@ is_max_matching <- function(graph, matching, types = NULL) { # Argument checks ensure_igraph(graph) types <- handle_vertex_type_arg(types, graph, required = F) - matching <- as_igraph_vs(graph, matching, na.ok = TRUE) - 1 - matching[is.na(matching)] <- -1 + matching <- as_igraph_vs(graph, matching, na.ok = TRUE) + matching[is.na(matching)] <- 0 # Use 0 since is_maximal_matching_impl will subtract 1, making it -1 - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_is_maximal_matching, graph, types, matching) + res <- is_maximal_matching_impl( + graph = graph, + types = types, + matching = matching + ) res } diff --git a/R/topology.R b/R/topology.R index 14bc4bd81f3..df2cbc0bb11 100644 --- a/R/topology.R +++ b/R/topology.R @@ -269,9 +269,11 @@ graph.isoclass.subgraph <- function(graph, vids) { ensure_igraph(graph) vids <- as_igraph_vs(graph, vids) - 1 - on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_isoclass_subgraph, graph, vids) + res <- isoclass_subgraph_impl( + graph = graph, + vids = vids + ) res } @@ -455,14 +457,18 @@ isomorphic <- function( ) { ensure_igraph(graph1) ensure_igraph(graph2) - method <- igraph.match.arg(method) + method <- igraph_match_arg(method) if (method == "auto") { - on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_isomorphic, graph1, graph2) + isomorphic_impl( + graph1 = graph1, + graph2 = graph2 + ) } else if (method == "direct") { - on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_isomorphic, graph1, graph2) + isomorphic_impl( + graph1 = graph1, + graph2 = graph2 + ) } else if (method == "vf2") { graph.isomorphic.vf2(graph1, graph2, ...)$iso } else if (method == "bliss") { @@ -646,7 +652,7 @@ subgraph_isomorphic <- function( method = c("auto", "lad", "vf2"), ... ) { - method <- igraph.match.arg(method) + method <- igraph_match_arg(method) if (method == "auto") { method <- "lad" @@ -705,7 +711,7 @@ is_subgraph_isomorphic_to <- subgraph_isomorphic #' vertex.color2 = NULL #' ) count_isomorphisms <- function(graph1, graph2, method = "vf2", ...) { - method <- igraph.match.arg(method) + method <- igraph_match_arg(method) if (method == "vf2") { graph.count.isomorphisms.vf2(graph1, graph2, ...) @@ -810,7 +816,7 @@ count_subgraph_isomorphisms <- function( method = c("lad", "vf2"), ... ) { - method <- igraph.match.arg(method) + method <- igraph_match_arg(method) if (method == "lad") { length(graph.subisomorphic.lad(pattern, target, all.maps = TRUE, ...)$maps) @@ -862,7 +868,7 @@ graph.count.subisomorphisms.vf2 <- function( #' @export #' @family graph isomorphism isomorphisms <- function(graph1, graph2, method = "vf2", ...) { - method <- igraph.match.arg(method) + method <- igraph_match_arg(method) if (method == "vf2") { graph.get.isomorphisms.vf2(graph1, graph2, ...) @@ -933,7 +939,7 @@ subgraph_isomorphisms <- function( method = c("lad", "vf2"), ... ) { - method <- igraph.match.arg(method) + method <- igraph_match_arg(method) if (method == "lad") { graph.subisomorphic.lad(pattern, target, all.maps = TRUE, ...)$maps @@ -1367,3 +1373,47 @@ automorphism_group <- function( details = details ) } + +#' Transitive closure of a graph +#' +#' @description +#' `r lifecycle::badge("experimental")` +#' +#' Computes the transitive closure of a graph. +#' The resulting graph will have an edge from vertex \eqn{i} to vertex \eqn{j} +#' if \eqn{j} is reachable from \eqn{i} in the original graph. +#' +#' The transitive closure of a graph is a new graph where there is an edge +#' between any two vertices if there is a path between them in the original +#' graph. +#' For directed graphs, an edge from \eqn{i} to \eqn{j} is added if there is +#' a directed path from \eqn{i} to \eqn{j}. +#' For undirected graphs, this is equivalent to connecting all vertices that +#' are in the same connected component. +#' +#' @param graph The input graph. +#' It can be directed or undirected. +#' @return A new graph object representing the transitive closure. +#' The returned graph will have the same directedness as the input. +#' @author Fabio Zanini \email{fabio.zanini@@unsw.edu.au} +#' @seealso [distances()], [are_adjacent()] +#' @keywords graphs +#' @examples +#' +#' # Directed graph +#' g <- make_graph(c(1, 2, 2, 3, 3, 4)) +#' tc <- transitive_closure(g) +#' # The closure has edges 1->2, 1->3, 1->4, 2->3, 2->4, 3->4 +#' print_all(tc) +#' +#' # Undirected graph - connects all vertices in same component +#' g2 <- make_graph(c(1, 2, 3, 4), directed = FALSE) +#' tc2 <- transitive_closure(g2) +#' # Full graph on vertices 1, 2 and full graph on vertices 3, 4 +#' print_all(tc2) +#' @family functions for manipulating graph structure +#' @export +#' @cdocs igraph_transitive_closure +transitive_closure <- function(graph) { + transitive_closure_impl(graph = graph) +} diff --git a/R/trees.R b/R/trees.R index 49e0e3d45f7..03adbc86ee3 100644 --- a/R/trees.R +++ b/R/trees.R @@ -46,7 +46,12 @@ is_tree <- function( mode = c("out", "in", "all", "total"), details = FALSE ) { - out <- is_tree_impl(graph, mode, details) + out <- is_tree_impl( + graph = graph, + mode = mode, + details = details + ) + if (isTRUE(details) && !out$res && vcount(graph) > 0) { out$root <- V(graph)[1] } @@ -134,7 +139,9 @@ is_forest <- function( #' @export #' @cdocs igraph_to_prufer to_prufer <- function(graph) { - to_prufer_impl(graph = graph) + to_prufer_impl( + graph = graph + ) } #' Samples from the spanning trees of a graph randomly and uniformly @@ -164,4 +171,9 @@ to_prufer <- function(graph) { #' @family trees #' @export #' @cdocs igraph_random_spanning_tree -sample_spanning_tree <- random_spanning_tree_impl +sample_spanning_tree <- function(graph, vid = 0) { + random_spanning_tree_impl( + graph = graph, + vid = vid + ) +} diff --git a/R/utils-assert-args.R b/R/utils-assert-args.R index d6bbf43419f..3f9a2708a7f 100644 --- a/R/utils-assert-args.R +++ b/R/utils-assert-args.R @@ -29,7 +29,7 @@ switch_igraph_arg <- function( if (length(arg) > 1) { values <- intersect(values, tolower(arg)) } - match <- igraph.match.arg( + match <- igraph_match_arg( arg, values, error_arg = .error_arg, @@ -38,7 +38,7 @@ switch_igraph_arg <- function( switch(match, ...) } -igraph.match.arg <- function( +igraph_match_arg <- function( arg, values, error_arg = rlang::caller_arg(arg), diff --git a/R/utils.R b/R/utils.R index fad1d5c10e6..b9c51b8bbbc 100644 --- a/R/utils.R +++ b/R/utils.R @@ -72,7 +72,7 @@ capitalize <- function(x) { } address <- function(x) { - .Call(R_igraph_address, x) + .Call(Rx_igraph_address, x) } `%+%` <- function(x, y) { diff --git a/R/uuid.R b/R/uuid.R index 0abee1c312b..b617afeff4f 100644 --- a/R/uuid.R +++ b/R/uuid.R @@ -5,7 +5,7 @@ generate_uuid <- function(use_time = NA) { get_graph_id <- function(graph) { if (!warn_version(graph)) { - .Call(R_igraph_get_graph_id, graph) + .Call(Rx_igraph_get_graph_id, graph) } else { NA_character_ } diff --git a/R/versions.R b/R/versions.R index 928dde1fe93..b4a3b4696fe 100644 --- a/R/versions.R +++ b/R/versions.R @@ -57,7 +57,7 @@ graph_version <- function(graph) { # Don't call is_igraph() here to avoid recursion stopifnot(inherits(graph, "igraph")) - .Call(R_igraph_graph_version, graph) + .Call(Rx_igraph_graph_version, graph) } #' igraph data structure versions @@ -99,13 +99,13 @@ upgrade_graph <- function(graph) { # g_ver < p_ver if (g_ver == ver_0_4) { - .Call(R_igraph_add_env, graph) + .Call(Rx_igraph_add_env, graph) } else if (g_ver == ver_0_7_999) { # Not observed in the wild - .Call(R_igraph_add_myid_to_env, graph) - .Call(R_igraph_add_version_to_env, graph) + .Call(Rx_igraph_add_myid_to_env, graph) + .Call(Rx_igraph_add_version_to_env, graph) } else if (g_ver == ver_0_8) { - .Call(R_igraph_add_version_to_env, graph) + .Call(Rx_igraph_add_version_to_env, graph) graph <- unclass(graph) graph[igraph_t_idx_oi:igraph_t_idx_is] <- list(NULL) class(graph) <- "igraph" @@ -130,7 +130,7 @@ warn_version <- function(graph) { .Call(R_igraph_vcount, graph) # graph_version() calls is_igraph(), but that function must call warn_version() for safety - their_version <- .Call(R_igraph_graph_version, graph) + their_version <- .Call(Rx_igraph_graph_version, graph) if (pkg_graph_version == their_version) { return(FALSE) @@ -151,7 +151,7 @@ warn_version <- function(graph) { # Users will have to call upgrade_graph(), but this is what the message # is about. if (pkg_graph_version <= ver_1_5_0) { - .Call(R_igraph_add_version_to_env, graph) + .Call(Rx_igraph_add_version_to_env, graph) } return(TRUE) } diff --git a/R/weakref.R b/R/weakref.R index 608ce4cb584..45970feeaf1 100644 --- a/R/weakref.R +++ b/R/weakref.R @@ -22,17 +22,17 @@ ## ----------------------------------------------------------------------- make_weak_ref <- function(key, value, finalizer = NULL) { - .Call(R_igraph_make_weak_ref, key, value, finalizer) + .Call(Rx_igraph_make_weak_ref, key, value, finalizer) } weak_ref_key <- function(ref) { - .Call(R_igraph_weak_ref_key, ref) + .Call(Rx_igraph_weak_ref_key, ref) } weak_ref_value <- function(ref) { - .Call(R_igraph_weak_ref_value, ref) + .Call(Rx_igraph_weak_ref_value, ref) } weak_ref_run_finalizer <- function(ref) { - .Call(R_igraph_weak_ref_run_finalizer, ref) + .Call(Rx_igraph_weak_ref_run_finalizer, ref) } diff --git a/_pkgdown.yml b/_pkgdown.yml index 633d73b986b..051cd2647a5 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -113,6 +113,9 @@ reference: - running_mean - sample_seq - fit_power_law +- subtitle: Low-level operations +- contents: + - has_concept("low-level operations") # [[[ network analysis start - title: Structural properties - contents: diff --git a/man/add_edges.Rd b/man/add_edges.Rd index 3289635293e..1dd4efc7f3a 100644 --- a/man/add_edges.Rd +++ b/man/add_edges.Rd @@ -68,6 +68,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/add_vertices.Rd b/man/add_vertices.Rd index 54fb0fcf714..06b61187877 100644 --- a/man/add_vertices.Rd +++ b/man/add_vertices.Rd @@ -63,6 +63,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/articulation_points.Rd b/man/articulation_points.Rd index 91016495ccb..aea69793056 100644 --- a/man/articulation_points.Rd +++ b/man/articulation_points.Rd @@ -49,6 +49,7 @@ bridges(g) Connected components \code{\link{biconnected_components}()}, \code{\link{component_distribution}()}, +\code{\link{count_reachable}()}, \code{\link{decompose}()}, \code{\link{is_biconnected}()} } diff --git a/man/biconnected_components.Rd b/man/biconnected_components.Rd index 73e140047c9..370bf5ad072 100644 --- a/man/biconnected_components.Rd +++ b/man/biconnected_components.Rd @@ -59,6 +59,7 @@ bc <- biconnected_components(g) Connected components \code{\link{articulation_points}()}, \code{\link{component_distribution}()}, +\code{\link{count_reachable}()}, \code{\link{decompose}()}, \code{\link{is_biconnected}()} } diff --git a/man/complementer.Rd b/man/complementer.Rd index dc9d08799af..5b3ef9b06fd 100644 --- a/man/complementer.Rd +++ b/man/complementer.Rd @@ -62,6 +62,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/components.Rd b/man/components.Rd index ac7bffb001b..43f5430d97b 100644 --- a/man/components.Rd +++ b/man/components.Rd @@ -97,6 +97,7 @@ largest_component(g) Connected components \code{\link{articulation_points}()}, \code{\link{biconnected_components}()}, +\code{\link{count_reachable}()}, \code{\link{decompose}()}, \code{\link{is_biconnected}()} diff --git a/man/compose.Rd b/man/compose.Rd index 4d0a4ab5157..bcefd04e217 100644 --- a/man/compose.Rd +++ b/man/compose.Rd @@ -92,6 +92,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/contract.Rd b/man/contract.Rd index e76972702aa..5f2c561b467 100644 --- a/man/contract.Rd +++ b/man/contract.Rd @@ -66,6 +66,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/count_reachable.Rd b/man/count_reachable.Rd new file mode 100644 index 00000000000..249715c0c3a --- /dev/null +++ b/man/count_reachable.Rd @@ -0,0 +1,69 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/structural-properties.R +\name{count_reachable} +\alias{count_reachable} +\title{Count reachable vertices} +\usage{ +count_reachable(graph, mode = c("out", "in", "all", "total")) +} +\arguments{ +\item{graph}{The input graph.} + +\item{mode}{Character constant, defines how edge directions are considered +in directed graphs. +\code{"out"} counts vertices reachable via outgoing edges, +\code{"in"} counts vertices from which the current vertex is reachable via +incoming edges, +\code{"all"} or \code{"total"} ignores edge directions. +This parameter is ignored for undirected graphs.} +} +\value{ +An integer vector of length \code{vcount(graph)}. +The i-th element is the number of vertices reachable from vertex i +(including vertex i itself). +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +} +\details{ +Counts the number of vertices reachable from each vertex in the graph. + +For each vertex in the graph, this function counts how many vertices +are reachable from it, including the vertex itself. +A vertex is reachable from another if there is a directed path between them. +For undirected graphs, two vertices are reachable from each other if they +are in the same connected component. +} +\examples{ + +# In a directed path graph, the reachability depends on direction +g <- make_graph(~ 1 -+ 2 -+ 3 -+ 4 -+ 5) +count_reachable(g, mode = "out") +count_reachable(g, mode = "in") + +# In an undirected graph, reachability is the same in all directions +g2 <- make_graph(~ 1 - 2 - 3 - 4 - 5) +count_reachable(g2, mode = "out") + +# A graph with multiple components +g3 <- make_graph(~ 1 - 2 - 3, 4 - 5, 6) +count_reachable(g3, mode = "all") + +} +\seealso{ +\code{\link[=components]{components()}}, \code{\link[=subcomponent]{subcomponent()}}, \code{\link[=is_connected]{is_connected()}} + +Connected components +\code{\link{articulation_points}()}, +\code{\link{biconnected_components}()}, +\code{\link{component_distribution}()}, +\code{\link{decompose}()}, +\code{\link{is_biconnected}()} +} +\author{ +Gabor Csardi \email{csardi.gabor@gmail.com} +} +\concept{components} +\keyword{graphs} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_count_reachable}{\code{count_reachable()}}.} + diff --git a/man/decompose.Rd b/man/decompose.Rd index 9976de28b6e..7b98ae098f7 100644 --- a/man/decompose.Rd +++ b/man/decompose.Rd @@ -45,6 +45,7 @@ Connected components \code{\link{articulation_points}()}, \code{\link{biconnected_components}()}, \code{\link{component_distribution}()}, +\code{\link{count_reachable}()}, \code{\link{is_biconnected}()} } \author{ diff --git a/man/degree.Rd b/man/degree.Rd index 098cf73fea2..2bd19522f86 100644 --- a/man/degree.Rd +++ b/man/degree.Rd @@ -3,6 +3,7 @@ \name{degree} \alias{degree} \alias{max_degree} +\alias{mean_degree} \alias{degree_distribution} \title{Degree and degree distribution of the vertices} \usage{ @@ -22,6 +23,8 @@ max_degree( loops = TRUE ) +mean_degree(graph, loops = TRUE) + degree_distribution(graph, cumulative = FALSE, ...) } \arguments{ @@ -55,6 +58,10 @@ degree vertices, the second vertices with degree one, etc. For \code{max_degree()}, the largest degree in the graph. When no vertices are selected, or when the input is the null graph, zero is returned as this is the smallest possible degree. + +For \code{mean_degree()}, the average degree in the graph as a single number. +For graphs with no vertices, \code{NaN} is returned. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \description{ The degree of a vertex is its most basic structural property, the number of @@ -66,6 +73,7 @@ g <- make_ring(10) degree(g) g2 <- sample_gnp(1000, 10 / 1000) max_degree(g2) +mean_degree(g2) degree_distribution(g2) } @@ -101,5 +109,5 @@ Gabor Csardi \email{csardi.gabor@gmail.com} } \concept{structural.properties} \keyword{graphs} -\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_maxdegree}{\code{maxdegree()}}.} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_maxdegree}{\code{maxdegree()}}, \href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_mean_degree}{\code{mean_degree()}}.} diff --git a/man/delete_edges.Rd b/man/delete_edges.Rd index 62c7f23b37c..862be149fef 100644 --- a/man/delete_edges.Rd +++ b/man/delete_edges.Rd @@ -55,6 +55,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/delete_vertices.Rd b/man/delete_vertices.Rd index f8e261f0620..b21361a1975 100644 --- a/man/delete_vertices.Rd +++ b/man/delete_vertices.Rd @@ -50,6 +50,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/difference.Rd b/man/difference.Rd index 42d56d3007d..71ca15b607e 100644 --- a/man/difference.Rd +++ b/man/difference.Rd @@ -43,6 +43,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/difference.igraph.Rd b/man/difference.igraph.Rd index 393eb215b08..129b86b4d50 100644 --- a/man/difference.igraph.Rd +++ b/man/difference.igraph.Rd @@ -81,6 +81,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/disjoint_union.Rd b/man/disjoint_union.Rd index 626248720ee..ef4b90aa2ee 100644 --- a/man/disjoint_union.Rd +++ b/man/disjoint_union.Rd @@ -73,6 +73,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/edge.Rd b/man/edge.Rd index ed963639f10..ed57091dccb 100644 --- a/man/edge.Rd +++ b/man/edge.Rd @@ -72,6 +72,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/ego.Rd b/man/ego.Rd index 69c018240fe..66039cec73d 100644 --- a/man/ego.Rd +++ b/man/ego.Rd @@ -171,6 +171,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/graph_from_atlas.Rd b/man/graph_from_atlas.Rd index f54d1fc6466..76f44c09ab1 100644 --- a/man/graph_from_atlas.Rd +++ b/man/graph_from_atlas.Rd @@ -44,14 +44,18 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{Graph Atlas.} \concept{deterministic constructors} diff --git a/man/graph_from_edgelist.Rd b/man/graph_from_edgelist.Rd index 453451315d3..e13b59cae57 100644 --- a/man/graph_from_edgelist.Rd +++ b/man/graph_from_edgelist.Rd @@ -40,14 +40,18 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{Edge list} \concept{deterministic constructors} diff --git a/man/graph_from_literal.Rd b/man/graph_from_literal.Rd index 191735aed37..61fed4add35 100644 --- a/man/graph_from_literal.Rd +++ b/man/graph_from_literal.Rd @@ -131,13 +131,17 @@ Other deterministic constructors: \code{\link{graph_from_edgelist}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{deterministic constructors} diff --git a/man/igraph-minus.Rd b/man/igraph-minus.Rd index 4648ba984b5..663c4f255a4 100644 --- a/man/igraph-minus.Rd +++ b/man/igraph-minus.Rd @@ -78,6 +78,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/intersection.Rd b/man/intersection.Rd index 078f966349f..795c3ca88b2 100644 --- a/man/intersection.Rd +++ b/man/intersection.Rd @@ -43,6 +43,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/intersection.igraph.Rd b/man/intersection.igraph.Rd index fc193b0ac89..5f87df0a316 100644 --- a/man/intersection.igraph.Rd +++ b/man/intersection.igraph.Rd @@ -79,6 +79,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/invalidate_cache.Rd b/man/invalidate_cache.Rd new file mode 100644 index 00000000000..d6aa0352871 --- /dev/null +++ b/man/invalidate_cache.Rd @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/interface.R +\name{invalidate_cache} +\alias{invalidate_cache} +\title{Invalidate the cache of a graph} +\usage{ +invalidate_cache(graph) +} +\arguments{ +\item{graph}{The graph whose cache is to be invalidated.} +} +\value{ +The graph with its cache invalidated. Since the graph is modified +in place in R as well, you can also ignore the return value. +} +\description{ +igraph graphs cache some basic properties (such as whether the graph is a +DAG or whether it is simple) in an internal data structure for faster +repeated queries. This function invalidates the cache, forcing a +recalculation of the cached properties the next time they are needed. +} +\details{ +You should not need to call this function during normal usage; however, it +may be useful for debugging cache-related issues. A tell-tale sign of an +invalid cache entry is when the result of a cached function (such as +\code{\link{is_dag}()} or \code{\link{is_simple}()}) changes after calling +this function. +} +\examples{ +g <- make_ring(10) +# Cache is populated when calling is_simple() +is_simple(g) +# Invalidate cache (for debugging purposes) +invalidate_cache(g) +# Result should be the same +is_simple(g) +} +\concept{low-level operations} diff --git a/man/is_biconnected.Rd b/man/is_biconnected.Rd index 16f847b1bae..68af404b60d 100644 --- a/man/is_biconnected.Rd +++ b/man/is_biconnected.Rd @@ -40,6 +40,7 @@ Connected components \code{\link{articulation_points}()}, \code{\link{biconnected_components}()}, \code{\link{component_distribution}()}, +\code{\link{count_reachable}()}, \code{\link{decompose}()} } \concept{components} diff --git a/man/make_.Rd b/man/make_.Rd index 1d988b9d4ac..b33bc13ef62 100644 --- a/man/make_.Rd +++ b/man/make_.Rd @@ -47,14 +47,18 @@ Other deterministic constructors: \code{\link{graph_from_edgelist}()}, \code{\link{graph_from_literal}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} Constructor modifiers (and related functions) \code{\link{sample_}()}, diff --git a/man/make_chordal_ring.Rd b/man/make_chordal_ring.Rd index 2b4127f4d01..9f72177067a 100644 --- a/man/make_chordal_ring.Rd +++ b/man/make_chordal_ring.Rd @@ -47,13 +47,17 @@ Other deterministic constructors: \code{\link{graph_from_edgelist}()}, \code{\link{graph_from_literal}()}, \code{\link{make_}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{deterministic constructors} diff --git a/man/make_circulant.Rd b/man/make_circulant.Rd new file mode 100644 index 00000000000..f007dab0bb2 --- /dev/null +++ b/man/make_circulant.Rd @@ -0,0 +1,61 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_circulant} +\alias{make_circulant} +\alias{circulant} +\title{Create a circulant graph} +\usage{ +make_circulant(n, shifts, directed = FALSE) + +circulant(...) +} +\arguments{ +\item{n}{Integer, the number of vertices in the circulant graph.} + +\item{shifts}{Integer vector, a list of the offsets within the circulant graph.} + +\item{directed}{Boolean, whether to create a directed graph.} + +\item{...}{Passed to \code{make_circulant()}.} +} +\value{ +An igraph graph. +} +\description{ +A circulant graph \eqn{C_n^{\textrm{shifts}}} consists of \eqn{n} vertices +\eqn{v_0, \ldots, v_{n-1}} such that for each \eqn{s_i} in the list of offsets +\code{shifts}, \eqn{v_j} is connected to \eqn{v_{(j + s_i) \mod n}} for all \eqn{j}. +} +\details{ +The function can generate either directed or undirected graphs. +It does not generate multi-edges or self-loops. +} +\examples{ +# Create a circulant graph with 10 vertices and shifts 1 and 3 +g <- make_circulant(10, c(1, 3)) +plot(g, layout = layout_in_circle) + +# A directed circulant graph +g2 <- make_circulant(10, c(1, 3), directed = TRUE) +plot(g2, layout = layout_in_circle) +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} +} +\concept{deterministic constructors} diff --git a/man/make_empty_graph.Rd b/man/make_empty_graph.Rd index 030f1ed1b97..747692c06e8 100644 --- a/man/make_empty_graph.Rd +++ b/man/make_empty_graph.Rd @@ -33,13 +33,17 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{Empty graph.} \concept{deterministic constructors} diff --git a/man/make_full_citation_graph.Rd b/man/make_full_citation_graph.Rd index 1b71a67b0ee..e52439ad4be 100644 --- a/man/make_full_citation_graph.Rd +++ b/man/make_full_citation_graph.Rd @@ -34,12 +34,16 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{deterministic constructors} diff --git a/man/make_full_graph.Rd b/man/make_full_graph.Rd index be28e7efc5b..49d588ea7fd 100644 --- a/man/make_full_graph.Rd +++ b/man/make_full_graph.Rd @@ -35,13 +35,17 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{Full graph} \concept{deterministic constructors} diff --git a/man/make_full_multipartite.Rd b/man/make_full_multipartite.Rd new file mode 100644 index 00000000000..5541fec70a2 --- /dev/null +++ b/man/make_full_multipartite.Rd @@ -0,0 +1,65 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_full_multipartite} +\alias{make_full_multipartite} +\alias{full_multipartite} +\title{Create a full multipartite graph} +\usage{ +make_full_multipartite(n, directed = FALSE, mode = c("all", "out", "in")) + +full_multipartite(...) +} +\arguments{ +\item{n}{A numeric vector giving the number of vertices in each partition.} + +\item{directed}{Logical scalar, whether to create a directed graph.} + +\item{mode}{Character scalar, the type of connections for directed graphs. +If \code{"out"}, then edges point from vertices of partitions with lower +indices to partitions with higher indices; if \code{"in"}, then the opposite +direction is realized; \code{"all"} creates mutual edges. This parameter is +ignored for undirected graphs.} + +\item{...}{Passed to \code{make_full_multipartite()}.} +} +\value{ +An igraph graph with a vertex attribute \code{type} storing the +partition index of each vertex. Partition indices start from 1. +} +\description{ +A multipartite graph contains multiple types of vertices and connections +are only possible between vertices of different types. This function +creates a complete multipartite graph where all possible edges between +different partitions are present. +} +\examples{ +# Create a multipartite graph with partitions of size 2, 3, and 4 +g <- make_full_multipartite(c(2, 3, 4)) +plot(g) + +# Create a directed multipartite graph +g2 <- make_full_multipartite(c(2, 2, 2), directed = TRUE, mode = "out") +plot(g2) +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} +} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_full_multipartite}{\code{full_multipartite()}}.} + diff --git a/man/make_graph.Rd b/man/make_graph.Rd index 96d8bf78c0d..aa866eac56c 100644 --- a/man/make_graph.Rd +++ b/man/make_graph.Rd @@ -244,12 +244,16 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{deterministic constructors} diff --git a/man/make_lattice.Rd b/man/make_lattice.Rd index 52e2dfe39cb..cab870dbfd9 100644 --- a/man/make_lattice.Rd +++ b/man/make_lattice.Rd @@ -64,13 +64,17 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_ring}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{Lattice} \concept{deterministic constructors} diff --git a/man/make_ring.Rd b/man/make_ring.Rd index 25cadf9e45a..2e998774e12 100644 --- a/man/make_ring.Rd +++ b/man/make_ring.Rd @@ -41,12 +41,16 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_star}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{deterministic constructors} diff --git a/man/make_star.Rd b/man/make_star.Rd index 59dd345bedb..b3cd5d8a680 100644 --- a/man/make_star.Rd +++ b/man/make_star.Rd @@ -40,13 +40,17 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, -\code{\link{make_tree}()} +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{Star graph} \concept{deterministic constructors} diff --git a/man/make_tree.Rd b/man/make_tree.Rd index 42446786e14..ae2ca3e6947 100644 --- a/man/make_tree.Rd +++ b/man/make_tree.Rd @@ -41,13 +41,17 @@ Other deterministic constructors: \code{\link{graph_from_literal}()}, \code{\link{make_}()}, \code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, \code{\link{make_empty_graph}()}, \code{\link{make_full_citation_graph}()}, \code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, \code{\link{make_graph}()}, \code{\link{make_lattice}()}, \code{\link{make_ring}()}, -\code{\link{make_star}()} +\code{\link{make_star}()}, +\code{\link{make_tri_lattice}()}, +\code{\link{make_turan}()} } \concept{Trees.} \concept{deterministic constructors} diff --git a/man/make_tri_lattice.Rd b/man/make_tri_lattice.Rd new file mode 100644 index 00000000000..4f551ee58e4 --- /dev/null +++ b/man/make_tri_lattice.Rd @@ -0,0 +1,83 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_tri_lattice} +\alias{make_tri_lattice} +\alias{tri_lattice} +\title{Create a triangular lattice graph} +\usage{ +make_tri_lattice(dims, ..., directed = FALSE, mutual = FALSE) + +tri_lattice(...) +} +\arguments{ +\item{dims}{Integer vector defining the shape of the lattice. +\itemize{ +\item If \code{dims} is of length 1, the resulting lattice has a triangular shape +where each side of the triangle contains \code{dims[1]} vertices. +\item If \code{dims} is of length 2, the resulting lattice has a "quasi rectangular" +shape with the sides containing \code{dims[1]} and \code{dims[2]} vertices, respectively. +\item If \code{dims} is of length 3, the resulting lattice has a hexagonal shape +where the sides of the hexagon contain \code{dims[1]}, \code{dims[2]}, and \code{dims[3]} +vertices. +All dimensions must be non-negative. +}} + +\item{...}{These dots are for future extensions and must be empty.} + +\item{directed}{Logical scalar, whether to create a directed graph. +If the \code{mutual} argument is not set to \code{TRUE}, edges will be directed +from lower-index vertices towards higher-index ones.} + +\item{mutual}{Logical scalar, if the graph is directed, this gives whether +to create all connections as mutual.} +} +\value{ +An igraph graph. +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +} +\details{ +\code{make_tri_lattice()} creates a triangular lattice with a specified shape. +The shape can be triangular (1 dimension), quasi-rectangular (2 dimensions), +or hexagonal (3 dimensions). +} +\examples{ +# Triangular lattice (1D case - creates a triangle) +g1 <- make_tri_lattice(5) +plot(g1) + +# Quasi-rectangular lattice (2D case) +g2 <- make_tri_lattice(c(3, 4)) +plot(g2) + +# Hexagonal lattice (3D case) +g3 <- make_tri_lattice(c(3, 3, 3)) +plot(g3) + +# Directed triangular lattice with mutual edges +g4 <- make_tri_lattice(c(3, 3), directed = TRUE, mutual = TRUE) +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_tree}()}, +\code{\link{make_turan}()} +} +\concept{Lattice} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_triangular_lattice}{\code{triangular_lattice()}}.} + diff --git a/man/make_turan.Rd b/man/make_turan.Rd new file mode 100644 index 00000000000..f23e06bae49 --- /dev/null +++ b/man/make_turan.Rd @@ -0,0 +1,64 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/make.R +\name{make_turan} +\alias{make_turan} +\alias{turan} +\title{Create a Turán graph} +\usage{ +make_turan(n, r) + +turan(...) +} +\arguments{ +\item{n}{Integer, the number of vertices in the graph.} + +\item{r}{Integer, the number of partitions in the graph, must be positive.} + +\item{...}{Passed to \code{make_turan()}.} +} +\value{ +An igraph graph with a vertex attribute \code{type} storing the +partition index of each vertex. Partition indices start from 1. +} +\description{ +Turán graphs are complete multipartite graphs with the property that the +sizes of the partitions are as close to equal as possible. +} +\details{ +The Turán graph with \code{n} vertices and \code{r} partitions is the densest +graph on \code{n} vertices that does not contain a clique of size \code{r+1}. + +This function generates undirected graphs. The null graph is +returned when the number of vertices is zero. A complete graph is +returned if the number of partitions is greater than the number of vertices. +} +\examples{ +# Create a Turán graph with 10 vertices and 3 partitions +g <- make_turan(10, 3) +plot(g) + +# The sizes of the partitions are as balanced as possible +table(V(g)$type) +} +\seealso{ +Other deterministic constructors: +\code{\link{graph_from_atlas}()}, +\code{\link{graph_from_edgelist}()}, +\code{\link{graph_from_literal}()}, +\code{\link{make_}()}, +\code{\link{make_chordal_ring}()}, +\code{\link{make_circulant}()}, +\code{\link{make_empty_graph}()}, +\code{\link{make_full_citation_graph}()}, +\code{\link{make_full_graph}()}, +\code{\link{make_full_multipartite}()}, +\code{\link{make_graph}()}, +\code{\link{make_lattice}()}, +\code{\link{make_ring}()}, +\code{\link{make_star}()}, +\code{\link{make_tree}()}, +\code{\link{make_tri_lattice}()} +} +\concept{deterministic constructors} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Generators.html#igraph_turan}{\code{turan()}}.} + diff --git a/man/path.Rd b/man/path.Rd index 0e20b51dfe8..0c13a5f94be 100644 --- a/man/path.Rd +++ b/man/path.Rd @@ -66,6 +66,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/permute.Rd b/man/permute.Rd index 2dab221f426..cfb42733418 100644 --- a/man/permute.Rd +++ b/man/permute.Rd @@ -69,6 +69,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/plus-.igraph.Rd b/man/plus-.igraph.Rd index cf500e99ce9..eb1f65b141d 100644 --- a/man/plus-.igraph.Rd +++ b/man/plus-.igraph.Rd @@ -123,6 +123,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/rep.igraph.Rd b/man/rep.igraph.Rd index 6fb7562540b..958ccaebdbe 100644 --- a/man/rep.igraph.Rd +++ b/man/rep.igraph.Rd @@ -50,6 +50,7 @@ Other functions for manipulating graph structure: \code{\link{permute}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/reverse_edges.Rd b/man/reverse_edges.Rd index c4afc1e66c6..bc71af9cded 100644 --- a/man/reverse_edges.Rd +++ b/man/reverse_edges.Rd @@ -53,6 +53,7 @@ Other functions for manipulating graph structure: \code{\link{permute}()}, \code{\link{rep.igraph}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/simplify.Rd b/man/simplify.Rd index 9ebaa39c3ca..93a2ced2ceb 100644 --- a/man/simplify.Rd +++ b/man/simplify.Rd @@ -92,6 +92,7 @@ Other functions for manipulating graph structure: \code{\link{permute}()}, \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} diff --git a/man/transitive_closure.Rd b/man/transitive_closure.Rd new file mode 100644 index 00000000000..01461959e4d --- /dev/null +++ b/man/transitive_closure.Rd @@ -0,0 +1,81 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/topology.R +\name{transitive_closure} +\alias{transitive_closure} +\title{Transitive closure of a graph} +\usage{ +transitive_closure(graph) +} +\arguments{ +\item{graph}{The input graph. +It can be directed or undirected.} +} +\value{ +A new graph object representing the transitive closure. +The returned graph will have the same directedness as the input. +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +Computes the transitive closure of a graph. +The resulting graph will have an edge from vertex \eqn{i} to vertex \eqn{j} +if \eqn{j} is reachable from \eqn{i} in the original graph. + +The transitive closure of a graph is a new graph where there is an edge +between any two vertices if there is a path between them in the original +graph. +For directed graphs, an edge from \eqn{i} to \eqn{j} is added if there is +a directed path from \eqn{i} to \eqn{j}. +For undirected graphs, this is equivalent to connecting all vertices that +are in the same connected component. +} +\examples{ + +# Directed graph +g <- make_graph(c(1, 2, 2, 3, 3, 4)) +tc <- transitive_closure(g) +# The closure has edges 1->2, 1->3, 1->4, 2->3, 2->4, 3->4 +print_all(tc) + +# Undirected graph - connects all vertices in same component +g2 <- make_graph(c(1, 2, 3, 4), directed = FALSE) +tc2 <- transitive_closure(g2) +# Full graph on vertices 1, 2 and full graph on vertices 3, 4 +print_all(tc2) +} +\seealso{ +\code{\link[=distances]{distances()}}, \code{\link[=are_adjacent]{are_adjacent()}} + +Other functions for manipulating graph structure: +\code{\link{+.igraph}()}, +\code{\link{add_edges}()}, +\code{\link{add_vertices}()}, +\code{\link{complementer}()}, +\code{\link{compose}()}, +\code{\link{connect}()}, +\code{\link{contract}()}, +\code{\link{delete_edges}()}, +\code{\link{delete_vertices}()}, +\code{\link{difference}()}, +\code{\link{difference.igraph}()}, +\code{\link{disjoint_union}()}, +\code{\link{edge}()}, +\code{\link{igraph-minus}}, +\code{\link{intersection}()}, +\code{\link{intersection.igraph}()}, +\code{\link{path}()}, +\code{\link{permute}()}, +\code{\link{rep.igraph}()}, +\code{\link{reverse_edges}()}, +\code{\link{simplify}()}, +\code{\link{union}()}, +\code{\link{union.igraph}()}, +\code{\link{vertex}()} +} +\author{ +Fabio Zanini \email{fabio.zanini@unsw.edu.au} +} +\concept{functions for manipulating graph structure} +\keyword{graphs} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_transitive_closure}{\code{transitive_closure()}}.} + diff --git a/man/union.Rd b/man/union.Rd index 91bfdcc7545..eeda392e3b4 100644 --- a/man/union.Rd +++ b/man/union.Rd @@ -44,6 +44,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union.igraph}()}, \code{\link{vertex}()} } diff --git a/man/union.igraph.Rd b/man/union.igraph.Rd index 67973087403..750a4a904cd 100644 --- a/man/union.igraph.Rd +++ b/man/union.igraph.Rd @@ -77,6 +77,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{vertex}()} } diff --git a/man/vertex.Rd b/man/vertex.Rd index 86c68845bda..56add28973a 100644 --- a/man/vertex.Rd +++ b/man/vertex.Rd @@ -60,6 +60,7 @@ Other functions for manipulating graph structure: \code{\link{rep.igraph}()}, \code{\link{reverse_edges}()}, \code{\link{simplify}()}, +\code{\link{transitive_closure}()}, \code{\link{union}()}, \code{\link{union.igraph}()} } diff --git a/man/which_multiple.Rd b/man/which_multiple.Rd index c7ae8a79065..05f7f22c25e 100644 --- a/man/which_multiple.Rd +++ b/man/which_multiple.Rd @@ -6,6 +6,7 @@ \alias{count_multiple} \alias{which_loop} \alias{any_loop} +\alias{count_loops} \title{Find the multiple or loop edges in a graph} \usage{ which_multiple(graph, eids = E(graph)) @@ -17,6 +18,8 @@ count_multiple(graph, eids = E(graph)) which_loop(graph, eids = E(graph)) any_loop(graph) + +count_loops(graph) } \arguments{ \item{graph}{The input graph.} @@ -27,6 +30,7 @@ all edges in the graph.} \value{ \code{any_loop()} and \code{any_multiple()} return a logical scalar. \code{which_loop()} and \code{which_multiple()} return a logical vector. +\code{count_loops()} returns a numeric scalar with the total number of loop edges. \code{count_multiple()} returns a numeric vector. } \description{ @@ -39,6 +43,8 @@ without multiple and loop edges is called a simple graph. \code{which_loop()} decides whether the edges of the graph are loop edges. +\code{count_loops()} counts the total number of loop edges in the graph. + \code{any_multiple()} decides whether the graph has any multiple edges. \code{which_multiple()} decides whether the edges of the graph are multiple @@ -61,6 +67,7 @@ original multiplicity as an edge attribute. g <- make_graph(c(1, 1, 2, 2, 3, 3, 4, 5)) any_loop(g) which_loop(g) +count_loops(g) # Multiple edges g <- sample_pa(10, m = 3, algorithm = "bag") @@ -116,5 +123,5 @@ Gabor Csardi \email{csardi.gabor@gmail.com} } \concept{structural.properties} \keyword{graphs} -\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_is_multiple}{\code{is_multiple()}}, \href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_has_multiple}{\code{has_multiple()}}, \href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_count_multiple}{\code{count_multiple()}}, \href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_is_loop}{\code{is_loop()}}, \href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_has_loop}{\code{has_loop()}}.} +\section{Related documentation in the C library}{\href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_is_multiple}{\code{is_multiple()}}, \href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_has_multiple}{\code{has_multiple()}}, \href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_count_multiple}{\code{count_multiple()}}, \href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_is_loop}{\code{is_loop()}}, \href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_has_loop}{\code{has_loop()}}, \href{https://igraph.org/c/html/latest/igraph-Structural.html#igraph_count_loops}{\code{count_loops()}}.} diff --git a/src/Makevars.in b/src/Makevars.in index a49ad9a17ff..35405db624b 100644 --- a/src/Makevars.in +++ b/src/Makevars.in @@ -23,7 +23,7 @@ PKG_CXXFLAGS=$(CXX_VISIBILITY) PKG_FFLAGS=$(F_VISIBILITY) PKG_CPPFLAGS=-DUSING_R -I. -Ivendor -Ivendor/cigraph/src -Ivendor/cigraph/include -Ivendor/cigraph/vendor -Ivendor/io/parsers @cflags@ \ - -DNDEBUG -DNTIMER -DNPRINT -DIGRAPH_THREAD_LOCAL= \ + -DNDEBUG -DIGRAPH_THREAD_LOCAL= \ -DPRPACK_IGRAPH_SUPPORT \ -DHAVE_GFORTRAN=1 \ -D_GNU_SOURCE=1 diff --git a/src/Makevars.ucrt b/src/Makevars.ucrt index 96071ea7722..b91c03877db 100644 --- a/src/Makevars.ucrt +++ b/src/Makevars.ucrt @@ -28,7 +28,7 @@ else endif PKG_CPPFLAGS += -DUSING_R -I. -Ivendor -Ivendor/cigraph/src -Ivendor/cigraph/include -Ivendor/cigraph/vendor -Ivendor/io/parsers -Ivendor/mini-gmp \ - -DNDEBUG -DNTIMER -DNPRINT -DIGRAPH_THREAD_LOCAL= \ + -DNDEBUG -DIGRAPH_THREAD_LOCAL= \ -DPRPACK_IGRAPH_SUPPORT \ -DHAVE_GFORTRAN=1 \ -D_GNU_SOURCE=1 \ diff --git a/src/Makevars.win b/src/Makevars.win index 16b9bbd9b85..f0ed80c2fdf 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -20,7 +20,7 @@ GLPK_HOME ?= $(MINGW_PREFIX) LIB_GMP ?= $(MINGW_PREFIX) PKG_CPPFLAGS=-DUSING_R -I. -Ivendor -Ivendor/cigraph/src -Ivendor/cigraph/include -Ivendor/cigraph/vendor -Ivendor/io/parsers -Ivendor/mini-gmp \ - -DNDEBUG -DNTIMER -DNPRINT -DIGRAPH_THREAD_LOCAL= \ + -DNDEBUG -DIGRAPH_THREAD_LOCAL= \ -DPRPACK_IGRAPH_SUPPORT \ -DHAVE_GFORTRAN=1 \ -D_GNU_SOURCE=1 \ diff --git a/src/README.md b/src/README.md index 171928561e5..73e930afa78 100644 --- a/src/README.md +++ b/src/README.md @@ -24,3 +24,40 @@ ``` 4. Commit and push + +## Dependency Tracking System + +The build system uses an automated dependency tracking mechanism to enable efficient incremental compilation. + +### How It Works + +1. **Dependency Generation**: When compiling C/C++ files, the compiler generates `.d` files containing all dependencies (headers) for each source file. + +2. **Filtering**: The `deps.mk` makefile processes these `.d` files to create `.dd` files that: + - Include only local project headers (not system headers) + - Format dependencies in a Makefile-compatible format with proper line continuations + - Add a header comment indicating they are auto-generated + +3. **Integration**: The generated `.dd` files are included by the main Makefile, allowing Make to automatically recompile sources when their dependencies change. + +### File Types + +- **`.d` files**: Raw dependency files generated by the compiler (ignored by git via `.gitignore`) +- **`.dd` files**: Processed dependency files with only local headers (committed but need to be kept clean of system headers) + +### Important Notes + +- **Never commit `.d` files**: They contain machine-specific paths and are regenerated on each build +- **Never add system headers to `.dd` files**: They are for review only +- **Never edit `.dd` files**: They are automatically generated; manual edits will be overwritten +- The system is implemented in `deps.mk` and works transparently during normal builds +- For clean builds or troubleshooting, remove all `.d` files: `rm -f src/*.d` + +### Implementation Details + +See `src/deps.mk` for the implementation. The key steps are: + +1. The compiler's `-MMD -MP` flags generate `.d` files during compilation +2. A sed-based pipeline filters and formats the dependencies +3. System headers and vendored dependencies are excluded to reduce file size +4. Dependencies are sorted for consistency diff --git a/src/cpp11.cpp b/src/cpp11.cpp index 61d8955f03d..b8774dc926b 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -24,22 +24,15 @@ extern "C" { /* .Call calls */ extern SEXP R_igraph_add_edges(SEXP, SEXP); extern SEXP R_igraph_add_edges_manual(SEXP, SEXP); -extern SEXP R_igraph_add_env(SEXP); -extern SEXP R_igraph_add_myid_to_env(SEXP); -extern SEXP R_igraph_add_version_to_env(SEXP); extern SEXP R_igraph_add_vertices(SEXP, SEXP); -extern SEXP R_igraph_address(SEXP); extern SEXP R_igraph_adhesion(SEXP, SEXP); extern SEXP R_igraph_adjacency(SEXP, SEXP, SEXP); extern SEXP R_igraph_adjacency_spectral_embedding(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_adjacent_vertices(SEXP, SEXP, SEXP); extern SEXP R_igraph_adjlist(SEXP, SEXP, SEXP); extern SEXP R_igraph_all_minimal_st_separators(SEXP); extern SEXP R_igraph_all_st_cuts(SEXP, SEXP, SEXP); extern SEXP R_igraph_all_st_mincuts(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_are_adjacent(SEXP, SEXP, SEXP); -extern SEXP R_igraph_arpack(SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_arpack_unpack_complex(SEXP, SEXP, SEXP); extern SEXP R_igraph_articulation_points(SEXP); extern SEXP R_igraph_assortativity(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_assortativity_degree(SEXP, SEXP); @@ -97,19 +90,15 @@ extern SEXP R_igraph_community_leading_eigenvector(SEXP, SEXP, SEXP, SEXP, SEXP, extern SEXP R_igraph_community_leiden(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_community_multilevel(SEXP, SEXP, SEXP); extern SEXP R_igraph_community_optimal_modularity(SEXP, SEXP); -extern SEXP R_igraph_community_to_membership2(SEXP, SEXP, SEXP); extern SEXP R_igraph_compare_communities(SEXP, SEXP, SEXP); extern SEXP R_igraph_complementer(SEXP, SEXP); -extern SEXP R_igraph_compose(SEXP, SEXP, SEXP); +extern SEXP R_igraph_compose(SEXP, SEXP); extern SEXP R_igraph_connect_neighborhood(SEXP, SEXP, SEXP); extern SEXP R_igraph_connected_components(SEXP, SEXP); extern SEXP R_igraph_constraint(SEXP, SEXP, SEXP); extern SEXP R_igraph_contract_vertices(SEXP, SEXP, SEXP); extern SEXP R_igraph_convex_hull_2d(SEXP); extern SEXP R_igraph_copy(SEXP); -extern SEXP R_igraph_copy_env(SEXP); -extern SEXP R_igraph_copy_from(SEXP); -extern SEXP R_igraph_copy_to(SEXP); extern SEXP R_igraph_coreness(SEXP, SEXP); extern SEXP R_igraph_correlated_game(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_correlated_pair_game(SEXP, SEXP, SEXP, SEXP, SEXP); @@ -138,7 +127,7 @@ extern SEXP R_igraph_dfs(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, S extern SEXP R_igraph_diameter(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_difference(SEXP, SEXP); extern SEXP R_igraph_dim_select(SEXP); -extern SEXP R_igraph_disjoint_union(SEXP); +extern SEXP R_igraph_disjoint_union(SEXP, SEXP); extern SEXP R_igraph_diversity(SEXP, SEXP, SEXP); extern SEXP R_igraph_dominator_tree(SEXP, SEXP, SEXP); extern SEXP R_igraph_dot_product_game(SEXP, SEXP); @@ -183,20 +172,14 @@ extern SEXP R_igraph_fundamental_cycles(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_generalized_petersen(SEXP, SEXP); extern SEXP R_igraph_get_adjacency(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_adjacency_sparse(SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_get_adjedgelist(SEXP, SEXP, SEXP); -extern SEXP R_igraph_get_adjlist(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_all_eids_between(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_all_shortest_paths(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_all_shortest_paths_dijkstra(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_all_simple_paths(SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_get_all_simple_paths_pp(SEXP); -extern SEXP R_igraph_get_attr_mode(SEXP, SEXP); extern SEXP R_igraph_get_biadjacency(SEXP, SEXP); extern SEXP R_igraph_get_diameter(SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_get_edge(SEXP, SEXP); extern SEXP R_igraph_get_edgelist(SEXP, SEXP); extern SEXP R_igraph_get_eids(SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_get_graph_id(SEXP); extern SEXP R_igraph_get_isomorphisms_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_isomorphisms_vf2_callback(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_k_shortest_paths(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); @@ -211,16 +194,15 @@ extern SEXP R_igraph_get_stochastic_sparse(SEXP, SEXP, SEXP); extern SEXP R_igraph_get_subisomorphisms_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_widest_path(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_widest_paths(SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_girth(SEXP, SEXP); +extern SEXP R_igraph_girth(SEXP); extern SEXP R_igraph_global_efficiency(SEXP, SEXP, SEXP); extern SEXP R_igraph_gomory_hu_tree(SEXP, SEXP); extern SEXP R_igraph_graph_center_dijkstra(SEXP, SEXP, SEXP); extern SEXP R_igraph_graph_count(SEXP, SEXP); extern SEXP R_igraph_graph_power(SEXP, SEXP, SEXP); -extern SEXP R_igraph_graph_version(SEXP); extern SEXP R_igraph_graphlets(SEXP, SEXP, SEXP); extern SEXP R_igraph_graphlets_candidate_basis(SEXP, SEXP); -extern SEXP R_igraph_graphlets_project(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_graphlets_project(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_grg_game(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_growing_random_game(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_harmonic_centrality_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); @@ -240,10 +222,7 @@ extern SEXP R_igraph_hsbm_game(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_hsbm_list_game(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_hub_and_authority_scores(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_hypercube(SEXP, SEXP); -extern SEXP R_igraph_i_levc_arp(SEXP, SEXP, SEXP); -extern SEXP R_igraph_identical_graphs(SEXP, SEXP, SEXP); extern SEXP R_igraph_incident(SEXP, SEXP, SEXP); -extern SEXP R_igraph_incident_edges(SEXP, SEXP, SEXP); extern SEXP R_igraph_independence_number(SEXP); extern SEXP R_igraph_independent_vertex_sets(SEXP, SEXP, SEXP); extern SEXP R_igraph_induced_subgraph(SEXP, SEXP, SEXP); @@ -332,11 +311,10 @@ extern SEXP R_igraph_local_scan_k_ecount(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_local_scan_k_ecount_them(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_local_scan_neighborhood_ecount(SEXP, SEXP, SEXP); extern SEXP R_igraph_local_scan_subset_ecount(SEXP, SEXP, SEXP); -extern SEXP R_igraph_make_weak_ref(SEXP, SEXP, SEXP); extern SEXP R_igraph_maxdegree(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_maxflow(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_maximal_cliques(SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_maximal_cliques_count(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_maximal_cliques_count(SEXP, SEXP, SEXP); extern SEXP R_igraph_maximal_cliques_file(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_maximal_cliques_hist(SEXP, SEXP, SEXP); extern SEXP R_igraph_maximal_independent_vertex_sets(SEXP); @@ -355,10 +333,6 @@ extern SEXP R_igraph_moran_process(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_motifs_randesu(SEXP, SEXP, SEXP); extern SEXP R_igraph_motifs_randesu_estimate(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_motifs_randesu_no(SEXP, SEXP, SEXP); -extern SEXP R_igraph_mybracket2(SEXP, SEXP, SEXP); -extern SEXP R_igraph_mybracket2_copy(SEXP, SEXP, SEXP); -extern SEXP R_igraph_mybracket2_names(SEXP, SEXP, SEXP); -extern SEXP R_igraph_mybracket2_set(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_mybracket3_set(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_mycielski_graph(SEXP); extern SEXP R_igraph_mycielskian(SEXP, SEXP); @@ -366,7 +340,6 @@ extern SEXP R_igraph_neighborhood(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_neighborhood_graphs(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_neighborhood_size(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_neighbors(SEXP, SEXP, SEXP); -extern SEXP R_igraph_no_components(SEXP, SEXP); extern SEXP R_igraph_path_graph(SEXP, SEXP, SEXP); extern SEXP R_igraph_path_length_hist(SEXP, SEXP); extern SEXP R_igraph_permute_vertices(SEXP, SEXP); @@ -382,7 +355,6 @@ extern SEXP R_igraph_radius_dijkstra(SEXP, SEXP, SEXP); extern SEXP R_igraph_random_sample(SEXP, SEXP, SEXP); extern SEXP R_igraph_random_spanning_tree(SEXP, SEXP); extern SEXP R_igraph_random_walk(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_read_graph_dimacs(SEXP, SEXP); extern SEXP R_igraph_read_graph_dl(SEXP, SEXP); extern SEXP R_igraph_read_graph_edgelist(SEXP, SEXP, SEXP); extern SEXP R_igraph_read_graph_gml(SEXP); @@ -412,7 +384,6 @@ extern SEXP R_igraph_sample_dirichlet(SEXP, SEXP); extern SEXP R_igraph_sample_sphere_surface(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_sample_sphere_volume(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_sbm_game(SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_set_verbose(SEXP); extern SEXP R_igraph_shortest_paths(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_similarity_dice(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_similarity_dice_es(SEXP, SEXP, SEXP, SEXP); @@ -457,7 +428,6 @@ extern SEXP R_igraph_transitive_closure_dag(SEXP); extern SEXP R_igraph_transitivity_avglocal_undirected(SEXP, SEXP); extern SEXP R_igraph_transitivity_barrat(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_transitivity_local_undirected(SEXP, SEXP, SEXP); -extern SEXP R_igraph_transitivity_local_undirected_all(SEXP, SEXP); extern SEXP R_igraph_transitivity_undirected(SEXP, SEXP); extern SEXP R_igraph_tree_from_parent_vector(SEXP, SEXP); extern SEXP R_igraph_tree_game(SEXP, SEXP, SEXP); @@ -478,9 +448,6 @@ extern SEXP R_igraph_vs_adj(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_vs_nei(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_walktrap_community(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_watts_strogatz_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_weak_ref_key(SEXP); -extern SEXP R_igraph_weak_ref_run_finalizer(SEXP); -extern SEXP R_igraph_weak_ref_value(SEXP); extern SEXP R_igraph_weighted_adjacency(SEXP, SEXP, SEXP); extern SEXP R_igraph_weighted_clique_number(SEXP, SEXP); extern SEXP R_igraph_weighted_cliques(SEXP, SEXP, SEXP, SEXP, SEXP); @@ -490,33 +457,108 @@ extern SEXP R_igraph_widest_path_widths_floyd_warshall(SEXP, SEXP, SEXP, SEXP, S extern SEXP R_igraph_write_graph_dimacs(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_dot(SEXP, SEXP); extern SEXP R_igraph_write_graph_edgelist(SEXP, SEXP); -extern SEXP R_igraph_write_graph_gml(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_write_graph_gml(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_graphml(SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_leda(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_lgl(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_ncol(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_pajek(SEXP, SEXP); +extern SEXP Rx_igraph_add_env(SEXP); +extern SEXP Rx_igraph_add_myid_to_env(SEXP); +extern SEXP Rx_igraph_add_version_to_env(SEXP); +extern SEXP Rx_igraph_add_vertices(SEXP, SEXP); +extern SEXP Rx_igraph_address(SEXP); +extern SEXP Rx_igraph_adhesion(SEXP, SEXP); +extern SEXP Rx_igraph_adjacent_vertices(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_arpack(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_arpack_unpack_complex(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_bibcoupling(SEXP, SEXP); +extern SEXP Rx_igraph_cocitation(SEXP, SEXP); +extern SEXP Rx_igraph_cohesion(SEXP, SEXP); +extern SEXP Rx_igraph_cohesive_blocks(SEXP); +extern SEXP Rx_igraph_community_to_membership2(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_complementer(SEXP, SEXP); +extern SEXP Rx_igraph_compose(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_constraint(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_copy_env(SEXP); +extern SEXP Rx_igraph_copy_from(SEXP); +extern SEXP Rx_igraph_copy_to(SEXP); +extern SEXP Rx_igraph_coreness(SEXP, SEXP); +extern SEXP Rx_igraph_delete_edges(SEXP, SEXP); +extern SEXP Rx_igraph_delete_vertices(SEXP, SEXP); +extern SEXP Rx_igraph_difference(SEXP, SEXP); +extern SEXP Rx_igraph_disjoint_union(SEXP); +extern SEXP Rx_igraph_ecount(SEXP); +extern SEXP Rx_igraph_edge_connectivity(SEXP, SEXP); +extern SEXP Rx_igraph_edges(SEXP, SEXP); +extern SEXP Rx_igraph_famous(SEXP); +extern SEXP Rx_igraph_get_adjedgelist(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_get_adjlist(SEXP, SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_get_all_simple_paths_pp(SEXP); +extern SEXP Rx_igraph_get_attr_mode(SEXP, SEXP); +extern SEXP Rx_igraph_get_edge(SEXP, SEXP); +extern SEXP Rx_igraph_get_edgelist(SEXP, SEXP); +extern SEXP Rx_igraph_get_graph_id(SEXP); +extern SEXP Rx_igraph_girth(SEXP, SEXP); +extern SEXP Rx_igraph_graph_version(SEXP); +extern SEXP Rx_igraph_graphlets_candidate_basis(SEXP, SEXP); +extern SEXP Rx_igraph_graphlets_project(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_i_levc_arp(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_identical_graphs(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_incident(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_incident_edges(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_independence_number(SEXP); +extern SEXP Rx_igraph_intersection(SEXP, SEXP); +extern SEXP Rx_igraph_is_directed(SEXP); +extern SEXP Rx_igraph_largest_independent_vertex_sets(SEXP); +extern SEXP Rx_igraph_make_weak_ref(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_maximal_cliques_count(SEXP, SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_maximal_independent_vertex_sets(SEXP); +extern SEXP Rx_igraph_mincut(SEXP, SEXP); +extern SEXP Rx_igraph_mincut_value(SEXP, SEXP); +extern SEXP Rx_igraph_minimum_spanning_tree_prim(SEXP, SEXP); +extern SEXP Rx_igraph_minimum_spanning_tree_unweighted(SEXP); +extern SEXP Rx_igraph_mybracket2(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_mybracket2_copy(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_mybracket2_names(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_mybracket2_set(SEXP, SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_no_components(SEXP, SEXP); +extern SEXP Rx_igraph_read_graph_dimacs(SEXP, SEXP); +extern SEXP Rx_igraph_read_graph_dl(SEXP, SEXP); +extern SEXP Rx_igraph_read_graph_gml(SEXP); +extern SEXP Rx_igraph_read_graph_graphdb(SEXP, SEXP); +extern SEXP Rx_igraph_read_graph_graphml(SEXP, SEXP); +extern SEXP Rx_igraph_read_graph_pajek(SEXP); +extern SEXP Rx_igraph_rewire(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_running_mean(SEXP, SEXP); +extern SEXP Rx_igraph_set_verbose(SEXP); +extern SEXP Rx_igraph_topological_sorting(SEXP, SEXP); +extern SEXP Rx_igraph_transitivity_local_undirected_all(SEXP, SEXP); +extern SEXP Rx_igraph_union(SEXP, SEXP); +extern SEXP Rx_igraph_vertex_connectivity(SEXP, SEXP); +extern SEXP Rx_igraph_weak_ref_key(SEXP); +extern SEXP Rx_igraph_weak_ref_run_finalizer(SEXP); +extern SEXP Rx_igraph_weak_ref_value(SEXP); +extern SEXP Rx_igraph_write_graph_dot(SEXP, SEXP); +extern SEXP Rx_igraph_write_graph_edgelist(SEXP, SEXP); +extern SEXP Rx_igraph_write_graph_gml(SEXP, SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_write_graph_graphml(SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_write_graph_leda(SEXP, SEXP, SEXP, SEXP); +extern SEXP Rx_igraph_write_graph_pajek(SEXP, SEXP); extern SEXP UUID_gen(SEXP); static const R_CallMethodDef CallEntries[] = { {"R_igraph_add_edges", (DL_FUNC) &R_igraph_add_edges, 2}, {"R_igraph_add_edges_manual", (DL_FUNC) &R_igraph_add_edges_manual, 2}, - {"R_igraph_add_env", (DL_FUNC) &R_igraph_add_env, 1}, - {"R_igraph_add_myid_to_env", (DL_FUNC) &R_igraph_add_myid_to_env, 1}, - {"R_igraph_add_version_to_env", (DL_FUNC) &R_igraph_add_version_to_env, 1}, {"R_igraph_add_vertices", (DL_FUNC) &R_igraph_add_vertices, 2}, - {"R_igraph_address", (DL_FUNC) &R_igraph_address, 1}, {"R_igraph_adhesion", (DL_FUNC) &R_igraph_adhesion, 2}, {"R_igraph_adjacency", (DL_FUNC) &R_igraph_adjacency, 3}, {"R_igraph_adjacency_spectral_embedding", (DL_FUNC) &R_igraph_adjacency_spectral_embedding, 7}, - {"R_igraph_adjacent_vertices", (DL_FUNC) &R_igraph_adjacent_vertices, 3}, {"R_igraph_adjlist", (DL_FUNC) &R_igraph_adjlist, 3}, {"R_igraph_all_minimal_st_separators", (DL_FUNC) &R_igraph_all_minimal_st_separators, 1}, {"R_igraph_all_st_cuts", (DL_FUNC) &R_igraph_all_st_cuts, 3}, {"R_igraph_all_st_mincuts", (DL_FUNC) &R_igraph_all_st_mincuts, 4}, {"R_igraph_are_adjacent", (DL_FUNC) &R_igraph_are_adjacent, 3}, - {"R_igraph_arpack", (DL_FUNC) &R_igraph_arpack, 5}, - {"R_igraph_arpack_unpack_complex", (DL_FUNC) &R_igraph_arpack_unpack_complex, 3}, {"R_igraph_articulation_points", (DL_FUNC) &R_igraph_articulation_points, 1}, {"R_igraph_assortativity", (DL_FUNC) &R_igraph_assortativity, 5}, {"R_igraph_assortativity_degree", (DL_FUNC) &R_igraph_assortativity_degree, 2}, @@ -574,19 +616,15 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_community_leiden", (DL_FUNC) &R_igraph_community_leiden, 8}, {"R_igraph_community_multilevel", (DL_FUNC) &R_igraph_community_multilevel, 3}, {"R_igraph_community_optimal_modularity", (DL_FUNC) &R_igraph_community_optimal_modularity, 2}, - {"R_igraph_community_to_membership2", (DL_FUNC) &R_igraph_community_to_membership2, 3}, {"R_igraph_compare_communities", (DL_FUNC) &R_igraph_compare_communities, 3}, {"R_igraph_complementer", (DL_FUNC) &R_igraph_complementer, 2}, - {"R_igraph_compose", (DL_FUNC) &R_igraph_compose, 3}, + {"R_igraph_compose", (DL_FUNC) &R_igraph_compose, 2}, {"R_igraph_connect_neighborhood", (DL_FUNC) &R_igraph_connect_neighborhood, 3}, {"R_igraph_connected_components", (DL_FUNC) &R_igraph_connected_components, 2}, {"R_igraph_constraint", (DL_FUNC) &R_igraph_constraint, 3}, {"R_igraph_contract_vertices", (DL_FUNC) &R_igraph_contract_vertices, 3}, {"R_igraph_convex_hull_2d", (DL_FUNC) &R_igraph_convex_hull_2d, 1}, {"R_igraph_copy", (DL_FUNC) &R_igraph_copy, 1}, - {"R_igraph_copy_env", (DL_FUNC) &R_igraph_copy_env, 1}, - {"R_igraph_copy_from", (DL_FUNC) &R_igraph_copy_from, 1}, - {"R_igraph_copy_to", (DL_FUNC) &R_igraph_copy_to, 1}, {"R_igraph_coreness", (DL_FUNC) &R_igraph_coreness, 2}, {"R_igraph_correlated_game", (DL_FUNC) &R_igraph_correlated_game, 4}, {"R_igraph_correlated_pair_game", (DL_FUNC) &R_igraph_correlated_pair_game, 5}, @@ -615,7 +653,7 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_diameter", (DL_FUNC) &R_igraph_diameter, 4}, {"R_igraph_difference", (DL_FUNC) &R_igraph_difference, 2}, {"R_igraph_dim_select", (DL_FUNC) &R_igraph_dim_select, 1}, - {"R_igraph_disjoint_union", (DL_FUNC) &R_igraph_disjoint_union, 1}, + {"R_igraph_disjoint_union", (DL_FUNC) &R_igraph_disjoint_union, 2}, {"R_igraph_diversity", (DL_FUNC) &R_igraph_diversity, 3}, {"R_igraph_dominator_tree", (DL_FUNC) &R_igraph_dominator_tree, 3}, {"R_igraph_dot_product_game", (DL_FUNC) &R_igraph_dot_product_game, 2}, @@ -660,20 +698,14 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_generalized_petersen", (DL_FUNC) &R_igraph_generalized_petersen, 2}, {"R_igraph_get_adjacency", (DL_FUNC) &R_igraph_get_adjacency, 4}, {"R_igraph_get_adjacency_sparse", (DL_FUNC) &R_igraph_get_adjacency_sparse, 4}, - {"R_igraph_get_adjedgelist", (DL_FUNC) &R_igraph_get_adjedgelist, 3}, - {"R_igraph_get_adjlist", (DL_FUNC) &R_igraph_get_adjlist, 4}, {"R_igraph_get_all_eids_between", (DL_FUNC) &R_igraph_get_all_eids_between, 4}, {"R_igraph_get_all_shortest_paths", (DL_FUNC) &R_igraph_get_all_shortest_paths, 4}, {"R_igraph_get_all_shortest_paths_dijkstra", (DL_FUNC) &R_igraph_get_all_shortest_paths_dijkstra, 5}, {"R_igraph_get_all_simple_paths", (DL_FUNC) &R_igraph_get_all_simple_paths, 5}, - {"R_igraph_get_all_simple_paths_pp", (DL_FUNC) &R_igraph_get_all_simple_paths_pp, 1}, - {"R_igraph_get_attr_mode", (DL_FUNC) &R_igraph_get_attr_mode, 2}, {"R_igraph_get_biadjacency", (DL_FUNC) &R_igraph_get_biadjacency, 2}, {"R_igraph_get_diameter", (DL_FUNC) &R_igraph_get_diameter, 4}, - {"R_igraph_get_edge", (DL_FUNC) &R_igraph_get_edge, 2}, {"R_igraph_get_edgelist", (DL_FUNC) &R_igraph_get_edgelist, 2}, {"R_igraph_get_eids", (DL_FUNC) &R_igraph_get_eids, 4}, - {"R_igraph_get_graph_id", (DL_FUNC) &R_igraph_get_graph_id, 1}, {"R_igraph_get_isomorphisms_vf2", (DL_FUNC) &R_igraph_get_isomorphisms_vf2, 6}, {"R_igraph_get_isomorphisms_vf2_callback", (DL_FUNC) &R_igraph_get_isomorphisms_vf2_callback, 6}, {"R_igraph_get_k_shortest_paths", (DL_FUNC) &R_igraph_get_k_shortest_paths, 6}, @@ -688,16 +720,15 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_get_subisomorphisms_vf2", (DL_FUNC) &R_igraph_get_subisomorphisms_vf2, 6}, {"R_igraph_get_widest_path", (DL_FUNC) &R_igraph_get_widest_path, 5}, {"R_igraph_get_widest_paths", (DL_FUNC) &R_igraph_get_widest_paths, 5}, - {"R_igraph_girth", (DL_FUNC) &R_igraph_girth, 2}, + {"R_igraph_girth", (DL_FUNC) &R_igraph_girth, 1}, {"R_igraph_global_efficiency", (DL_FUNC) &R_igraph_global_efficiency, 3}, {"R_igraph_gomory_hu_tree", (DL_FUNC) &R_igraph_gomory_hu_tree, 2}, {"R_igraph_graph_center_dijkstra", (DL_FUNC) &R_igraph_graph_center_dijkstra, 3}, {"R_igraph_graph_count", (DL_FUNC) &R_igraph_graph_count, 2}, {"R_igraph_graph_power", (DL_FUNC) &R_igraph_graph_power, 3}, - {"R_igraph_graph_version", (DL_FUNC) &R_igraph_graph_version, 1}, {"R_igraph_graphlets", (DL_FUNC) &R_igraph_graphlets, 3}, {"R_igraph_graphlets_candidate_basis", (DL_FUNC) &R_igraph_graphlets_candidate_basis, 2}, - {"R_igraph_graphlets_project", (DL_FUNC) &R_igraph_graphlets_project, 5}, + {"R_igraph_graphlets_project", (DL_FUNC) &R_igraph_graphlets_project, 6}, {"R_igraph_grg_game", (DL_FUNC) &R_igraph_grg_game, 4}, {"R_igraph_growing_random_game", (DL_FUNC) &R_igraph_growing_random_game, 4}, {"R_igraph_harmonic_centrality_cutoff", (DL_FUNC) &R_igraph_harmonic_centrality_cutoff, 6}, @@ -717,10 +748,7 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_hsbm_list_game", (DL_FUNC) &R_igraph_hsbm_list_game, 5}, {"R_igraph_hub_and_authority_scores", (DL_FUNC) &R_igraph_hub_and_authority_scores, 4}, {"R_igraph_hypercube", (DL_FUNC) &R_igraph_hypercube, 2}, - {"R_igraph_i_levc_arp", (DL_FUNC) &R_igraph_i_levc_arp, 3}, - {"R_igraph_identical_graphs", (DL_FUNC) &R_igraph_identical_graphs, 3}, {"R_igraph_incident", (DL_FUNC) &R_igraph_incident, 3}, - {"R_igraph_incident_edges", (DL_FUNC) &R_igraph_incident_edges, 3}, {"R_igraph_independence_number", (DL_FUNC) &R_igraph_independence_number, 1}, {"R_igraph_independent_vertex_sets", (DL_FUNC) &R_igraph_independent_vertex_sets, 3}, {"R_igraph_induced_subgraph", (DL_FUNC) &R_igraph_induced_subgraph, 3}, @@ -809,11 +837,10 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_local_scan_k_ecount_them", (DL_FUNC) &R_igraph_local_scan_k_ecount_them, 5}, {"R_igraph_local_scan_neighborhood_ecount", (DL_FUNC) &R_igraph_local_scan_neighborhood_ecount, 3}, {"R_igraph_local_scan_subset_ecount", (DL_FUNC) &R_igraph_local_scan_subset_ecount, 3}, - {"R_igraph_make_weak_ref", (DL_FUNC) &R_igraph_make_weak_ref, 3}, {"R_igraph_maxdegree", (DL_FUNC) &R_igraph_maxdegree, 4}, {"R_igraph_maxflow", (DL_FUNC) &R_igraph_maxflow, 4}, {"R_igraph_maximal_cliques", (DL_FUNC) &R_igraph_maximal_cliques, 4}, - {"R_igraph_maximal_cliques_count", (DL_FUNC) &R_igraph_maximal_cliques_count, 4}, + {"R_igraph_maximal_cliques_count", (DL_FUNC) &R_igraph_maximal_cliques_count, 3}, {"R_igraph_maximal_cliques_file", (DL_FUNC) &R_igraph_maximal_cliques_file, 5}, {"R_igraph_maximal_cliques_hist", (DL_FUNC) &R_igraph_maximal_cliques_hist, 3}, {"R_igraph_maximal_independent_vertex_sets", (DL_FUNC) &R_igraph_maximal_independent_vertex_sets, 1}, @@ -832,10 +859,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_motifs_randesu", (DL_FUNC) &R_igraph_motifs_randesu, 3}, {"R_igraph_motifs_randesu_estimate", (DL_FUNC) &R_igraph_motifs_randesu_estimate, 5}, {"R_igraph_motifs_randesu_no", (DL_FUNC) &R_igraph_motifs_randesu_no, 3}, - {"R_igraph_mybracket2", (DL_FUNC) &R_igraph_mybracket2, 3}, - {"R_igraph_mybracket2_copy", (DL_FUNC) &R_igraph_mybracket2_copy, 3}, - {"R_igraph_mybracket2_names", (DL_FUNC) &R_igraph_mybracket2_names, 3}, - {"R_igraph_mybracket2_set", (DL_FUNC) &R_igraph_mybracket2_set, 4}, {"R_igraph_mybracket3_set", (DL_FUNC) &R_igraph_mybracket3_set, 5}, {"R_igraph_mycielski_graph", (DL_FUNC) &R_igraph_mycielski_graph, 1}, {"R_igraph_mycielskian", (DL_FUNC) &R_igraph_mycielskian, 2}, @@ -843,7 +866,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_neighborhood_graphs", (DL_FUNC) &R_igraph_neighborhood_graphs, 5}, {"R_igraph_neighborhood_size", (DL_FUNC) &R_igraph_neighborhood_size, 5}, {"R_igraph_neighbors", (DL_FUNC) &R_igraph_neighbors, 3}, - {"R_igraph_no_components", (DL_FUNC) &R_igraph_no_components, 2}, {"R_igraph_path_graph", (DL_FUNC) &R_igraph_path_graph, 3}, {"R_igraph_path_length_hist", (DL_FUNC) &R_igraph_path_length_hist, 2}, {"R_igraph_permute_vertices", (DL_FUNC) &R_igraph_permute_vertices, 2}, @@ -859,7 +881,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_random_sample", (DL_FUNC) &R_igraph_random_sample, 3}, {"R_igraph_random_spanning_tree", (DL_FUNC) &R_igraph_random_spanning_tree, 2}, {"R_igraph_random_walk", (DL_FUNC) &R_igraph_random_walk, 6}, - {"R_igraph_read_graph_dimacs", (DL_FUNC) &R_igraph_read_graph_dimacs, 2}, {"R_igraph_read_graph_dl", (DL_FUNC) &R_igraph_read_graph_dl, 2}, {"R_igraph_read_graph_edgelist", (DL_FUNC) &R_igraph_read_graph_edgelist, 3}, {"R_igraph_read_graph_gml", (DL_FUNC) &R_igraph_read_graph_gml, 1}, @@ -889,7 +910,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_sample_sphere_surface", (DL_FUNC) &R_igraph_sample_sphere_surface, 4}, {"R_igraph_sample_sphere_volume", (DL_FUNC) &R_igraph_sample_sphere_volume, 4}, {"R_igraph_sbm_game", (DL_FUNC) &R_igraph_sbm_game, 5}, - {"R_igraph_set_verbose", (DL_FUNC) &R_igraph_set_verbose, 1}, {"R_igraph_shortest_paths", (DL_FUNC) &R_igraph_shortest_paths, 6}, {"R_igraph_similarity_dice", (DL_FUNC) &R_igraph_similarity_dice, 4}, {"R_igraph_similarity_dice_es", (DL_FUNC) &R_igraph_similarity_dice_es, 4}, @@ -934,7 +954,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_transitivity_avglocal_undirected", (DL_FUNC) &R_igraph_transitivity_avglocal_undirected, 2}, {"R_igraph_transitivity_barrat", (DL_FUNC) &R_igraph_transitivity_barrat, 4}, {"R_igraph_transitivity_local_undirected", (DL_FUNC) &R_igraph_transitivity_local_undirected, 3}, - {"R_igraph_transitivity_local_undirected_all", (DL_FUNC) &R_igraph_transitivity_local_undirected_all, 2}, {"R_igraph_transitivity_undirected", (DL_FUNC) &R_igraph_transitivity_undirected, 2}, {"R_igraph_tree_from_parent_vector", (DL_FUNC) &R_igraph_tree_from_parent_vector, 2}, {"R_igraph_tree_game", (DL_FUNC) &R_igraph_tree_game, 3}, @@ -955,9 +974,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_vs_nei", (DL_FUNC) &R_igraph_vs_nei, 4}, {"R_igraph_walktrap_community", (DL_FUNC) &R_igraph_walktrap_community, 6}, {"R_igraph_watts_strogatz_game", (DL_FUNC) &R_igraph_watts_strogatz_game, 6}, - {"R_igraph_weak_ref_key", (DL_FUNC) &R_igraph_weak_ref_key, 1}, - {"R_igraph_weak_ref_run_finalizer", (DL_FUNC) &R_igraph_weak_ref_run_finalizer, 1}, - {"R_igraph_weak_ref_value", (DL_FUNC) &R_igraph_weak_ref_value, 1}, {"R_igraph_weighted_adjacency", (DL_FUNC) &R_igraph_weighted_adjacency, 3}, {"R_igraph_weighted_clique_number", (DL_FUNC) &R_igraph_weighted_clique_number, 2}, {"R_igraph_weighted_cliques", (DL_FUNC) &R_igraph_weighted_cliques, 5}, @@ -967,12 +983,94 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_write_graph_dimacs", (DL_FUNC) &R_igraph_write_graph_dimacs, 5}, {"R_igraph_write_graph_dot", (DL_FUNC) &R_igraph_write_graph_dot, 2}, {"R_igraph_write_graph_edgelist", (DL_FUNC) &R_igraph_write_graph_edgelist, 2}, - {"R_igraph_write_graph_gml", (DL_FUNC) &R_igraph_write_graph_gml, 4}, + {"R_igraph_write_graph_gml", (DL_FUNC) &R_igraph_write_graph_gml, 5}, {"R_igraph_write_graph_graphml", (DL_FUNC) &R_igraph_write_graph_graphml, 3}, {"R_igraph_write_graph_leda", (DL_FUNC) &R_igraph_write_graph_leda, 4}, {"R_igraph_write_graph_lgl", (DL_FUNC) &R_igraph_write_graph_lgl, 5}, {"R_igraph_write_graph_ncol", (DL_FUNC) &R_igraph_write_graph_ncol, 4}, {"R_igraph_write_graph_pajek", (DL_FUNC) &R_igraph_write_graph_pajek, 2}, + {"Rx_igraph_add_env", (DL_FUNC) &Rx_igraph_add_env, 1}, + {"Rx_igraph_add_myid_to_env", (DL_FUNC) &Rx_igraph_add_myid_to_env, 1}, + {"Rx_igraph_add_version_to_env", (DL_FUNC) &Rx_igraph_add_version_to_env, 1}, + {"Rx_igraph_add_vertices", (DL_FUNC) &Rx_igraph_add_vertices, 2}, + {"Rx_igraph_address", (DL_FUNC) &Rx_igraph_address, 1}, + {"Rx_igraph_adhesion", (DL_FUNC) &Rx_igraph_adhesion, 2}, + {"Rx_igraph_adjacent_vertices", (DL_FUNC) &Rx_igraph_adjacent_vertices, 3}, + {"Rx_igraph_arpack", (DL_FUNC) &Rx_igraph_arpack, 5}, + {"Rx_igraph_arpack_unpack_complex", (DL_FUNC) &Rx_igraph_arpack_unpack_complex, 3}, + {"Rx_igraph_bibcoupling", (DL_FUNC) &Rx_igraph_bibcoupling, 2}, + {"Rx_igraph_cocitation", (DL_FUNC) &Rx_igraph_cocitation, 2}, + {"Rx_igraph_cohesion", (DL_FUNC) &Rx_igraph_cohesion, 2}, + {"Rx_igraph_cohesive_blocks", (DL_FUNC) &Rx_igraph_cohesive_blocks, 1}, + {"Rx_igraph_community_to_membership2", (DL_FUNC) &Rx_igraph_community_to_membership2, 3}, + {"Rx_igraph_complementer", (DL_FUNC) &Rx_igraph_complementer, 2}, + {"Rx_igraph_compose", (DL_FUNC) &Rx_igraph_compose, 3}, + {"Rx_igraph_constraint", (DL_FUNC) &Rx_igraph_constraint, 3}, + {"Rx_igraph_copy_env", (DL_FUNC) &Rx_igraph_copy_env, 1}, + {"Rx_igraph_copy_from", (DL_FUNC) &Rx_igraph_copy_from, 1}, + {"Rx_igraph_copy_to", (DL_FUNC) &Rx_igraph_copy_to, 1}, + {"Rx_igraph_coreness", (DL_FUNC) &Rx_igraph_coreness, 2}, + {"Rx_igraph_delete_edges", (DL_FUNC) &Rx_igraph_delete_edges, 2}, + {"Rx_igraph_delete_vertices", (DL_FUNC) &Rx_igraph_delete_vertices, 2}, + {"Rx_igraph_difference", (DL_FUNC) &Rx_igraph_difference, 2}, + {"Rx_igraph_disjoint_union", (DL_FUNC) &Rx_igraph_disjoint_union, 1}, + {"Rx_igraph_ecount", (DL_FUNC) &Rx_igraph_ecount, 1}, + {"Rx_igraph_edge_connectivity", (DL_FUNC) &Rx_igraph_edge_connectivity, 2}, + {"Rx_igraph_edges", (DL_FUNC) &Rx_igraph_edges, 2}, + {"Rx_igraph_famous", (DL_FUNC) &Rx_igraph_famous, 1}, + {"Rx_igraph_get_adjedgelist", (DL_FUNC) &Rx_igraph_get_adjedgelist, 3}, + {"Rx_igraph_get_adjlist", (DL_FUNC) &Rx_igraph_get_adjlist, 4}, + {"Rx_igraph_get_all_simple_paths_pp", (DL_FUNC) &Rx_igraph_get_all_simple_paths_pp, 1}, + {"Rx_igraph_get_attr_mode", (DL_FUNC) &Rx_igraph_get_attr_mode, 2}, + {"Rx_igraph_get_edge", (DL_FUNC) &Rx_igraph_get_edge, 2}, + {"Rx_igraph_get_edgelist", (DL_FUNC) &Rx_igraph_get_edgelist, 2}, + {"Rx_igraph_get_graph_id", (DL_FUNC) &Rx_igraph_get_graph_id, 1}, + {"Rx_igraph_girth", (DL_FUNC) &Rx_igraph_girth, 2}, + {"Rx_igraph_graph_version", (DL_FUNC) &Rx_igraph_graph_version, 1}, + {"Rx_igraph_graphlets_candidate_basis", (DL_FUNC) &Rx_igraph_graphlets_candidate_basis, 2}, + {"Rx_igraph_graphlets_project", (DL_FUNC) &Rx_igraph_graphlets_project, 5}, + {"Rx_igraph_i_levc_arp", (DL_FUNC) &Rx_igraph_i_levc_arp, 3}, + {"Rx_igraph_identical_graphs", (DL_FUNC) &Rx_igraph_identical_graphs, 3}, + {"Rx_igraph_incident", (DL_FUNC) &Rx_igraph_incident, 3}, + {"Rx_igraph_incident_edges", (DL_FUNC) &Rx_igraph_incident_edges, 3}, + {"Rx_igraph_independence_number", (DL_FUNC) &Rx_igraph_independence_number, 1}, + {"Rx_igraph_intersection", (DL_FUNC) &Rx_igraph_intersection, 2}, + {"Rx_igraph_is_directed", (DL_FUNC) &Rx_igraph_is_directed, 1}, + {"Rx_igraph_largest_independent_vertex_sets", (DL_FUNC) &Rx_igraph_largest_independent_vertex_sets, 1}, + {"Rx_igraph_make_weak_ref", (DL_FUNC) &Rx_igraph_make_weak_ref, 3}, + {"Rx_igraph_maximal_cliques_count", (DL_FUNC) &Rx_igraph_maximal_cliques_count, 4}, + {"Rx_igraph_maximal_independent_vertex_sets", (DL_FUNC) &Rx_igraph_maximal_independent_vertex_sets, 1}, + {"Rx_igraph_mincut", (DL_FUNC) &Rx_igraph_mincut, 2}, + {"Rx_igraph_mincut_value", (DL_FUNC) &Rx_igraph_mincut_value, 2}, + {"Rx_igraph_minimum_spanning_tree_prim", (DL_FUNC) &Rx_igraph_minimum_spanning_tree_prim, 2}, + {"Rx_igraph_minimum_spanning_tree_unweighted", (DL_FUNC) &Rx_igraph_minimum_spanning_tree_unweighted, 1}, + {"Rx_igraph_mybracket2", (DL_FUNC) &Rx_igraph_mybracket2, 3}, + {"Rx_igraph_mybracket2_copy", (DL_FUNC) &Rx_igraph_mybracket2_copy, 3}, + {"Rx_igraph_mybracket2_names", (DL_FUNC) &Rx_igraph_mybracket2_names, 3}, + {"Rx_igraph_mybracket2_set", (DL_FUNC) &Rx_igraph_mybracket2_set, 4}, + {"Rx_igraph_no_components", (DL_FUNC) &Rx_igraph_no_components, 2}, + {"Rx_igraph_read_graph_dimacs", (DL_FUNC) &Rx_igraph_read_graph_dimacs, 2}, + {"Rx_igraph_read_graph_dl", (DL_FUNC) &Rx_igraph_read_graph_dl, 2}, + {"Rx_igraph_read_graph_gml", (DL_FUNC) &Rx_igraph_read_graph_gml, 1}, + {"Rx_igraph_read_graph_graphdb", (DL_FUNC) &Rx_igraph_read_graph_graphdb, 2}, + {"Rx_igraph_read_graph_graphml", (DL_FUNC) &Rx_igraph_read_graph_graphml, 2}, + {"Rx_igraph_read_graph_pajek", (DL_FUNC) &Rx_igraph_read_graph_pajek, 1}, + {"Rx_igraph_rewire", (DL_FUNC) &Rx_igraph_rewire, 3}, + {"Rx_igraph_running_mean", (DL_FUNC) &Rx_igraph_running_mean, 2}, + {"Rx_igraph_set_verbose", (DL_FUNC) &Rx_igraph_set_verbose, 1}, + {"Rx_igraph_topological_sorting", (DL_FUNC) &Rx_igraph_topological_sorting, 2}, + {"Rx_igraph_transitivity_local_undirected_all", (DL_FUNC) &Rx_igraph_transitivity_local_undirected_all, 2}, + {"Rx_igraph_union", (DL_FUNC) &Rx_igraph_union, 2}, + {"Rx_igraph_vertex_connectivity", (DL_FUNC) &Rx_igraph_vertex_connectivity, 2}, + {"Rx_igraph_weak_ref_key", (DL_FUNC) &Rx_igraph_weak_ref_key, 1}, + {"Rx_igraph_weak_ref_run_finalizer", (DL_FUNC) &Rx_igraph_weak_ref_run_finalizer, 1}, + {"Rx_igraph_weak_ref_value", (DL_FUNC) &Rx_igraph_weak_ref_value, 1}, + {"Rx_igraph_write_graph_dot", (DL_FUNC) &Rx_igraph_write_graph_dot, 2}, + {"Rx_igraph_write_graph_edgelist", (DL_FUNC) &Rx_igraph_write_graph_edgelist, 2}, + {"Rx_igraph_write_graph_gml", (DL_FUNC) &Rx_igraph_write_graph_gml, 4}, + {"Rx_igraph_write_graph_graphml", (DL_FUNC) &Rx_igraph_write_graph_graphml, 3}, + {"Rx_igraph_write_graph_leda", (DL_FUNC) &Rx_igraph_write_graph_leda, 4}, + {"Rx_igraph_write_graph_pajek", (DL_FUNC) &Rx_igraph_write_graph_pajek, 2}, {"UUID_gen", (DL_FUNC) &UUID_gen, 1}, {"_igraph_getsphere", (DL_FUNC) &_igraph_getsphere, 7}, {"_igraph_igraph_hcass2", (DL_FUNC) &_igraph_igraph_hcass2, 3}, diff --git a/src/deps.mk b/src/deps.mk index ce053cfa71f..0a86fbcc7ab 100644 --- a/src/deps.mk +++ b/src/deps.mk @@ -5,4 +5,4 @@ include $(GLUE_CPP_SOURCES:.o=.dd) # Include only local dependencies for smaller footprint # Add trailing backslash and sort %.dd: %.d - sed -r 's/([^ ]) ([^ \\])/\1 \\\n \2/g' $< | sed -r '/^ ([/]|vendor|[.][.])/D;$$s/([^\\])$$/\1 \\/' | { echo "# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers"; read -r header; printf '%s\n' "$$header"; LOCALE=C sort; } > $@ + sed -r 's/([^ ]) ([^ \\])/\1 \\\n \2/g' $< | sed -r '/^ +([/]|vendor|[.][.])/D;$$s/([^\\])$$/\1 \\/' | { echo "# Generated by deps.mk, do not edit by hand and do not add dependencies to system headers"; read -r header; printf '%s\n' "$$header"; LC_ALL=C sort; } > $@ diff --git a/src/rinterface.c b/src/rinterface.c index d1bd108609a..a2218afcc69 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -88,6 +88,34 @@ SEXP R_igraph_add_edges(SEXP graph, SEXP edges) { return(r_result); } +/*-------------------------------------------/ +/ igraph_add_vertices / +/-------------------------------------------*/ +SEXP R_igraph_add_vertices(SEXP graph, SEXP nv) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_nv; + + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + IGRAPH_R_CHECK_INT(nv); + c_nv = (igraph_integer_t) REAL(nv)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_add_vertices(&c_graph, c_nv, 0)); + + /* Convert output */ + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_copy / /-------------------------------------------*/ @@ -114,6 +142,64 @@ SEXP R_igraph_copy(SEXP from) { return(r_result); } +/*-------------------------------------------/ +/ igraph_delete_edges / +/-------------------------------------------*/ +SEXP R_igraph_delete_edges(SEXP graph, SEXP edges) { + /* Declarations */ + igraph_t c_graph; + igraph_es_t c_edges; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + igraph_vector_int_t c_edges_data; + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(edges, &c_graph, &c_edges, &c_edges_data)); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_delete_edges(&c_graph, c_edges)); + + /* Convert output */ + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_edges_data); + igraph_es_destroy(&c_edges); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_delete_vertices / +/-------------------------------------------*/ +SEXP R_igraph_delete_vertices(SEXP graph, SEXP vertices) { + /* Declarations */ + igraph_t c_graph; + igraph_vs_t c_vertices; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + igraph_vector_int_t c_vertices_data; + R_SEXP_to_igraph_vs(vertices, &c_graph, &c_vertices, &c_vertices_data); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_delete_vertices(&c_graph, c_vertices)); + + /* Convert output */ + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vertices_data); + igraph_vs_destroy(&c_vertices); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_delete_vertices_idx / /-------------------------------------------*/ @@ -188,6 +274,28 @@ SEXP R_igraph_vcount(SEXP graph) { return(r_result); } +/*-------------------------------------------/ +/ igraph_ecount / +/-------------------------------------------*/ +SEXP R_igraph_ecount(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_result; + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + /* Call igraph */ + c_result=igraph_ecount(&c_graph); + + /* Convert output */ + + PROTECT(r_result=NEW_NUMERIC(1)); + REAL(r_result)[0]=(double) c_result; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_neighbors / /-------------------------------------------*/ @@ -219,6 +327,28 @@ SEXP R_igraph_neighbors(SEXP graph, SEXP vid, SEXP mode) { return(r_result); } +/*-------------------------------------------/ +/ igraph_is_directed / +/-------------------------------------------*/ +SEXP R_igraph_is_directed(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_bool_t c_result; + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + /* Call igraph */ + c_result=igraph_is_directed(&c_graph); + + /* Convert output */ + + PROTECT(r_result=NEW_LOGICAL(1)); + LOGICAL(r_result)[0]=c_result; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_degree / /-------------------------------------------*/ @@ -256,6 +386,38 @@ SEXP R_igraph_degree(SEXP graph, SEXP vids, SEXP mode, SEXP loops) { return(r_result); } +/*-------------------------------------------/ +/ igraph_edges / +/-------------------------------------------*/ +SEXP R_igraph_edges(SEXP graph, SEXP eids) { + /* Declarations */ + igraph_t c_graph; + igraph_es_t c_eids; + igraph_vector_int_t c_edges; + SEXP edges; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + igraph_vector_int_t c_eids_data; + IGRAPH_R_CHECK(R_SEXP_to_igraph_es(eids, &c_graph, &c_eids, &c_eids_data)); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edges, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_edges(&c_graph, c_eids, &c_edges)); + + /* Convert output */ + igraph_vector_int_destroy(&c_eids_data); + igraph_es_destroy(&c_eids); + PROTECT(edges=R_igraph_vector_int_to_SEXP(&c_edges)); + igraph_vector_int_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + r_result = edges; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_get_all_eids_between / /-------------------------------------------*/ @@ -290,6 +452,37 @@ SEXP R_igraph_get_all_eids_between(SEXP graph, SEXP from, SEXP to, SEXP directed return(r_result); } +/*-------------------------------------------/ +/ igraph_incident / +/-------------------------------------------*/ +SEXP R_igraph_incident(SEXP graph, SEXP vid, SEXP mode) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_eids; + igraph_integer_t c_vid; + igraph_neimode_t c_mode; + SEXP eids; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_eids, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_eids); + c_vid = (igraph_integer_t) REAL(vid)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_incident(&c_graph, &c_eids, c_vid, c_mode)); + + /* Convert output */ + PROTECT(eids=R_igraph_vector_int_to_SEXPp1(&c_eids)); + igraph_vector_int_destroy(&c_eids); + IGRAPH_FINALLY_CLEAN(1); + r_result = eids; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_adjacency / /-------------------------------------------*/ @@ -843,6 +1036,32 @@ SEXP R_igraph_kautz(SEXP m, SEXP n) { return(r_result); } +/*-------------------------------------------/ +/ igraph_famous / +/-------------------------------------------*/ +SEXP R_igraph_famous(SEXP name) { + /* Declarations */ + igraph_t c_graph; + const char* c_name; + SEXP graph; + + SEXP r_result; + /* Convert input */ + c_name = Rf_translateCharUTF8(STRING_ELT(name, 0)); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_famous(&c_graph, c_name)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_lcf_vector / /-------------------------------------------*/ @@ -3217,7 +3436,7 @@ SEXP R_igraph_personalized_pagerank(SEXP graph, SEXP algo, SEXP vids, SEXP direc igraph_vector_int_destroy(&c_vids_data); igraph_vs_destroy(&c_vids); if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { - PROTECT(options = R_igraph_arpack_options_to_SEXP(&c_options1)); + PROTECT(options = Rx_igraph_arpack_options_to_SEXP(&c_options1)); } else { PROTECT(options); } @@ -3294,7 +3513,7 @@ SEXP R_igraph_personalized_pagerank_vs(SEXP graph, SEXP algo, SEXP vids, SEXP di igraph_vector_int_destroy(&c_reset_vids_data); igraph_vs_destroy(&c_reset_vids); if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { - PROTECT(options = R_igraph_arpack_options_to_SEXP(&c_options1)); + PROTECT(options = Rx_igraph_arpack_options_to_SEXP(&c_options1)); } else { PROTECT(options); } @@ -3311,6 +3530,35 @@ SEXP R_igraph_personalized_pagerank_vs(SEXP graph, SEXP algo, SEXP vids, SEXP di return(r_result); } +/*-------------------------------------------/ +/ igraph_rewire / +/-------------------------------------------*/ +SEXP R_igraph_rewire(SEXP rewire, SEXP n, SEXP mode) { + /* Declarations */ + igraph_t c_rewire; + igraph_integer_t c_n; + igraph_rewiring_t c_mode; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph_copy(rewire, &c_rewire); + IGRAPH_FINALLY(igraph_destroy, &c_rewire); + IGRAPH_R_CHECK_INT(n); + c_n = (igraph_integer_t) REAL(n)[0]; + c_mode = (igraph_rewiring_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_rewire(&c_rewire, c_n, c_mode)); + + /* Convert output */ + PROTECT(rewire=R_igraph_to_SEXP(&c_rewire)); + IGRAPH_I_DESTROY(&c_rewire); + IGRAPH_FINALLY_CLEAN(1); + r_result = rewire; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_induced_subgraph / /-------------------------------------------*/ @@ -3722,6 +3970,42 @@ SEXP R_igraph_reciprocity(SEXP graph, SEXP ignore_loops, SEXP mode) { return(r_result); } +/*-------------------------------------------/ +/ igraph_constraint / +/-------------------------------------------*/ +SEXP R_igraph_constraint(SEXP graph, SEXP vids, SEXP weights) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + igraph_vs_t c_vids; + igraph_vector_t c_weights; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_constraint(&c_graph, &c_res, c_vids, (Rf_isNull(weights) ? 0 : &c_weights))); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_maxdegree / /-------------------------------------------*/ @@ -3812,33 +4096,62 @@ SEXP R_igraph_mean_degree(SEXP graph, SEXP loops) { } /*-------------------------------------------/ -/ igraph_feedback_arc_set / +/ igraph_topological_sorting / /-------------------------------------------*/ -SEXP R_igraph_feedback_arc_set(SEXP graph, SEXP weights, SEXP algo) { +SEXP R_igraph_topological_sorting(SEXP graph, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_int_t c_result; - igraph_vector_t c_weights; - igraph_fas_algorithm_t c_algo; - SEXP result; + igraph_vector_int_t c_res; + igraph_neimode_t c_mode; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - IGRAPH_R_CHECK(igraph_vector_int_init(&c_result, 0)); - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_result); - if (!Rf_isNull(weights)) { - R_SEXP_to_vector(weights, &c_weights); - } - c_algo = (igraph_fas_algorithm_t) Rf_asInteger(algo); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_res, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_feedback_arc_set(&c_graph, &c_result, (Rf_isNull(weights) ? 0 : &c_weights), c_algo)); + IGRAPH_R_CHECK(igraph_topological_sorting(&c_graph, &c_res, c_mode)); /* Convert output */ - PROTECT(result=R_igraph_vector_int_to_SEXPp1(&c_result)); - igraph_vector_int_destroy(&c_result); + PROTECT(res=R_igraph_vector_int_to_SEXP(&c_res)); + igraph_vector_int_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = result; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_feedback_arc_set / +/-------------------------------------------*/ +SEXP R_igraph_feedback_arc_set(SEXP graph, SEXP weights, SEXP algo) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_result; + igraph_vector_t c_weights; + igraph_fas_algorithm_t c_algo; + SEXP result; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_result, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_result); + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } + c_algo = (igraph_fas_algorithm_t) Rf_asInteger(algo); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_feedback_arc_set(&c_graph, &c_result, (Rf_isNull(weights) ? 0 : &c_weights), c_algo)); + + /* Convert output */ + PROTECT(result=R_igraph_vector_int_to_SEXPp1(&c_result)); + igraph_vector_int_destroy(&c_result); + IGRAPH_FINALLY_CLEAN(1); + r_result = result; UNPROTECT(1); return(r_result); @@ -4118,6 +4431,44 @@ SEXP R_igraph_count_multiple(SEXP graph, SEXP es) { return(r_result); } +/*-------------------------------------------/ +/ igraph_girth / +/-------------------------------------------*/ +SEXP R_igraph_girth(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_real_t c_girth; + igraph_vector_int_t c_circle; + SEXP girth; + SEXP circle; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_circle, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_circle); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_girth(&c_graph, &c_girth, &c_circle)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(girth=NEW_NUMERIC(1)); + REAL(girth)[0]=c_girth; + PROTECT(circle=R_igraph_vector_int_to_SEXPp1(&c_circle)); + igraph_vector_int_destroy(&c_circle); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, girth); + SET_VECTOR_ELT(r_result, 1, circle); + SET_STRING_ELT(r_names, 0, Rf_mkChar("girth")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("circle")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_is_perfect / /-------------------------------------------*/ @@ -4181,7 +4532,7 @@ SEXP R_igraph_eigenvector_centrality(SEXP graph, SEXP directed, SEXP scale, SEXP IGRAPH_FINALLY_CLEAN(1); PROTECT(value=NEW_NUMERIC(1)); REAL(value)[0]=c_value; - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(options=Rx_igraph_arpack_options_to_SEXP(&c_options)); SET_VECTOR_ELT(r_result, 0, vector); SET_VECTOR_ELT(r_result, 1, value); SET_VECTOR_ELT(r_result, 2, options); @@ -4238,7 +4589,7 @@ SEXP R_igraph_hub_and_authority_scores(SEXP graph, SEXP scale, SEXP weights, SEX IGRAPH_FINALLY_CLEAN(1); PROTECT(value=NEW_NUMERIC(1)); REAL(value)[0]=c_value; - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(options=Rx_igraph_arpack_options_to_SEXP(&c_options)); SET_VECTOR_ELT(r_result, 0, hub); SET_VECTOR_ELT(r_result, 1, authority); SET_VECTOR_ELT(r_result, 2, value); @@ -4900,7 +5251,7 @@ SEXP R_igraph_centralization_eigenvector_centrality(SEXP graph, SEXP directed, S IGRAPH_FINALLY_CLEAN(1); PROTECT(value=NEW_NUMERIC(1)); REAL(value)[0]=c_value; - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(options=Rx_igraph_arpack_options_to_SEXP(&c_options)); PROTECT(centralization=NEW_NUMERIC(1)); REAL(centralization)[0]=c_centralization; PROTECT(theoretical_max=NEW_NUMERIC(1)); @@ -6718,6 +7069,37 @@ SEXP R_igraph_largest_cliques(SEXP graph) { return(r_result); } +/*-------------------------------------------/ +/ igraph_maximal_cliques_count / +/-------------------------------------------*/ +SEXP R_igraph_maximal_cliques_count(SEXP graph, SEXP min_size, SEXP max_size) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_no; + igraph_integer_t c_min_size; + igraph_integer_t c_max_size; + SEXP no; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_no=0; + IGRAPH_R_CHECK_INT(min_size); + c_min_size = (igraph_integer_t) REAL(min_size)[0]; + IGRAPH_R_CHECK_INT(max_size); + c_max_size = (igraph_integer_t) REAL(max_size)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_maximal_cliques_count(&c_graph, &c_no, c_min_size, c_max_size)); + + /* Convert output */ + PROTECT(no=NEW_NUMERIC(1)); + REAL(no)[0]=(double) c_no; + r_result = no; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_maximal_cliques_hist / /-------------------------------------------*/ @@ -6904,6 +7286,85 @@ SEXP R_igraph_is_independent_vertex_set(SEXP graph, SEXP candidate) { return(r_result); } +/*-------------------------------------------/ +/ igraph_largest_independent_vertex_sets / +/-------------------------------------------*/ +SEXP R_igraph_largest_independent_vertex_sets(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_list_t c_res; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_res, 0)); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_largest_independent_vertex_sets(&c_graph, &c_res)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_int_list_to_SEXPp1(&c_res)); + igraph_vector_int_list_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_maximal_independent_vertex_sets / +/-------------------------------------------*/ +SEXP R_igraph_maximal_independent_vertex_sets(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_list_t c_res; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_res, 0)); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_maximal_independent_vertex_sets(&c_graph, &c_res)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_int_list_to_SEXPp1(&c_res)); + igraph_vector_int_list_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_independence_number / +/-------------------------------------------*/ +SEXP R_igraph_independence_number(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_no; + SEXP no; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_no=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_independence_number(&c_graph, &c_no)); + + /* Convert output */ + PROTECT(no=NEW_NUMERIC(1)); + REAL(no)[0]=(double) c_no; + r_result = no; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_layout_random / /-------------------------------------------*/ @@ -7596,6 +8057,70 @@ SEXP R_igraph_layout_align(SEXP graph, SEXP layout) { return(r_result); } +/*-------------------------------------------/ +/ igraph_cocitation / +/-------------------------------------------*/ +SEXP R_igraph_cocitation(SEXP graph, SEXP vids) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_vs_t c_vids; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_cocitation(&c_graph, &c_res, c_vids)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_bibcoupling / +/-------------------------------------------*/ +SEXP R_igraph_bibcoupling(SEXP graph, SEXP vids) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_vs_t c_vids; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_matrix_init(&c_res, 0, 0)); + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + igraph_vector_int_t c_vids_data; + R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids, &c_vids_data); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_bibcoupling(&c_graph, &c_res, c_vids)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + igraph_vector_int_destroy(&c_vids_data); + igraph_vs_destroy(&c_vids); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_similarity_dice / /-------------------------------------------*/ @@ -8302,68 +8827,154 @@ SEXP R_igraph_community_infomap(SEXP graph, SEXP e_weights, SEXP v_weights, SEXP } /*-------------------------------------------/ -/ igraph_hrg_fit / +/ igraph_graphlets_candidate_basis / /-------------------------------------------*/ -SEXP R_igraph_hrg_fit(SEXP graph, SEXP hrg, SEXP start, SEXP steps) { +SEXP R_igraph_graphlets_candidate_basis(SEXP graph, SEXP weights) { /* Declarations */ igraph_t c_graph; - igraph_hrg_t c_hrg; - igraph_bool_t c_start; - igraph_integer_t c_steps; + igraph_vector_t c_weights; + igraph_vector_int_list_t c_cliques; + igraph_vector_t c_thresholds; + SEXP cliques; + SEXP thresholds; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); - IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); - IGRAPH_R_CHECK_BOOL(start); - c_start = LOGICAL(start)[0]; - IGRAPH_R_CHECK_INT(steps); - c_steps = (igraph_integer_t) REAL(steps)[0]; + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_cliques, 0)); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_cliques); + IGRAPH_R_CHECK(igraph_vector_init(&c_thresholds, 0)); + IGRAPH_FINALLY(igraph_vector_destroy, &c_thresholds); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_fit(&c_graph, &c_hrg, c_start, c_steps)); + IGRAPH_R_CHECK(igraph_graphlets_candidate_basis(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_cliques, &c_thresholds)); /* Convert output */ - PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); - igraph_hrg_destroy(&c_hrg); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(cliques=R_igraph_vector_int_list_to_SEXPp1(&c_cliques)); + igraph_vector_int_list_destroy(&c_cliques); IGRAPH_FINALLY_CLEAN(1); - r_result = hrg; + PROTECT(thresholds=R_igraph_vector_to_SEXP(&c_thresholds)); + igraph_vector_destroy(&c_thresholds); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, cliques); + SET_VECTOR_ELT(r_result, 1, thresholds); + SET_STRING_ELT(r_names, 0, Rf_mkChar("cliques")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("thresholds")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_sample / +/ igraph_graphlets_project / /-------------------------------------------*/ -SEXP R_igraph_hrg_sample(SEXP hrg) { +SEXP R_igraph_graphlets_project(SEXP graph, SEXP weights, SEXP cliques, SEXP Muc, SEXP startMu, SEXP niter) { /* Declarations */ - igraph_hrg_t c_hrg; - igraph_t c_sample; - SEXP sample; + igraph_t c_graph; + igraph_vector_t c_weights; + igraph_vector_int_list_t c_cliques; + igraph_vector_t c_Muc; + igraph_bool_t c_startMu; + igraph_integer_t c_niter; SEXP r_result; /* Convert input */ - IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); - IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(weights)) { + R_SEXP_to_vector(weights, &c_weights); + } + IGRAPH_R_CHECK(R_igraph_SEXP_to_vector_int_list(cliques, &c_cliques)); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_cliques); + IGRAPH_R_CHECK(R_SEXP_to_vector_copy(Muc, &c_Muc)); + IGRAPH_FINALLY(igraph_vector_destroy, &c_Muc); + IGRAPH_R_CHECK_BOOL(startMu); + c_startMu = LOGICAL(startMu)[0]; + IGRAPH_R_CHECK_INT(niter); + c_niter = (igraph_integer_t) REAL(niter)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_sample(&c_hrg, &c_sample)); + IGRAPH_R_CHECK(igraph_graphlets_project(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_cliques, &c_Muc, c_startMu, c_niter)); /* Convert output */ - igraph_hrg_destroy(&c_hrg); + igraph_vector_int_list_destroy(&c_cliques); IGRAPH_FINALLY_CLEAN(1); - IGRAPH_FINALLY(igraph_destroy, &c_sample); - PROTECT(sample=R_igraph_to_SEXP(&c_sample)); - IGRAPH_I_DESTROY(&c_sample); + PROTECT(Muc=R_igraph_vector_to_SEXP(&c_Muc)); + igraph_vector_destroy(&c_Muc); IGRAPH_FINALLY_CLEAN(1); - r_result = sample; + r_result = Muc; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_sample_many / +/ igraph_hrg_fit / +/-------------------------------------------*/ +SEXP R_igraph_hrg_fit(SEXP graph, SEXP hrg, SEXP start, SEXP steps) { + /* Declarations */ + igraph_t c_graph; + igraph_hrg_t c_hrg; + igraph_bool_t c_start; + igraph_integer_t c_steps; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); + IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); + IGRAPH_R_CHECK_BOOL(start); + c_start = LOGICAL(start)[0]; + IGRAPH_R_CHECK_INT(steps); + c_steps = (igraph_integer_t) REAL(steps)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_fit(&c_graph, &c_hrg, c_start, c_steps)); + + /* Convert output */ + PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); + igraph_hrg_destroy(&c_hrg); + IGRAPH_FINALLY_CLEAN(1); + r_result = hrg; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_sample / +/-------------------------------------------*/ +SEXP R_igraph_hrg_sample(SEXP hrg) { + /* Declarations */ + igraph_hrg_t c_hrg; + igraph_t c_sample; + SEXP sample; + + SEXP r_result; + /* Convert input */ + IGRAPH_R_CHECK(R_SEXP_to_hrg_copy(hrg, &c_hrg)); + IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_sample(&c_hrg, &c_sample)); + + /* Convert output */ + igraph_hrg_destroy(&c_hrg); + IGRAPH_FINALLY_CLEAN(1); + IGRAPH_FINALLY(igraph_destroy, &c_sample); + PROTECT(sample=R_igraph_to_SEXP(&c_sample)); + IGRAPH_I_DESTROY(&c_sample); + IGRAPH_FINALLY_CLEAN(1); + r_result = sample; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_sample_many / /-------------------------------------------*/ SEXP R_igraph_hrg_sample_many(SEXP hrg, SEXP num_samples) { /* Declarations */ @@ -8695,6 +9306,36 @@ SEXP R_igraph_get_adjacency_sparse(SEXP graph, SEXP type, SEXP weights, SEXP loo return(r_result); } +/*-------------------------------------------/ +/ igraph_get_edgelist / +/-------------------------------------------*/ +SEXP R_igraph_get_edgelist(SEXP graph, SEXP bycol) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_res; + igraph_bool_t c_bycol; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_res, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + IGRAPH_R_CHECK_BOOL(bycol); + c_bycol = LOGICAL(bycol)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_get_edgelist(&c_graph, &c_res, c_bycol)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_int_to_SEXP(&c_res)); + igraph_vector_int_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_get_stochastic / /-------------------------------------------*/ @@ -8806,18 +9447,297 @@ SEXP R_igraph_to_undirected(SEXP graph, SEXP mode, SEXP edge_attr_comb) { R_SEXP_to_attr_comb(edge_attr_comb, &c_edge_attr_comb); IGRAPH_FINALLY(igraph_attribute_combination_destroy, &c_edge_attr_comb); /* Call igraph */ - IGRAPH_R_CHECK(igraph_to_undirected(&c_graph, c_mode, &c_edge_attr_comb)); + IGRAPH_R_CHECK(igraph_to_undirected(&c_graph, c_mode, &c_edge_attr_comb)); + + /* Convert output */ + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + igraph_attribute_combination_destroy(&c_edge_attr_comb); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_read_graph_pajek / +/-------------------------------------------*/ +SEXP R_igraph_read_graph_pajek(SEXP instream) { + /* Declarations */ + igraph_t c_graph; + FILE* c_instream; + SEXP graph; + + SEXP r_result; + /* Convert input */ + c_instream = R_igraph_fopen_read(instream); + IGRAPH_FINALLY(fclose, c_instream); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_read_graph_pajek(&c_graph, c_instream)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_read_graph_graphml / +/-------------------------------------------*/ +SEXP R_igraph_read_graph_graphml(SEXP instream, SEXP index) { + /* Declarations */ + igraph_t c_graph; + FILE* c_instream; + igraph_integer_t c_index; + SEXP graph; + + SEXP r_result; + /* Convert input */ + c_instream = R_igraph_fopen_read(instream); + IGRAPH_FINALLY(fclose, c_instream); + IGRAPH_R_CHECK_INT(index); + c_index = (igraph_integer_t) REAL(index)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_read_graph_graphml(&c_graph, c_instream, c_index)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_read_graph_graphdb / +/-------------------------------------------*/ +SEXP R_igraph_read_graph_graphdb(SEXP instream, SEXP directed) { + /* Declarations */ + igraph_t c_graph; + FILE* c_instream; + igraph_bool_t c_directed; + SEXP graph; + + SEXP r_result; + /* Convert input */ + c_instream = R_igraph_fopen_read(instream); + IGRAPH_FINALLY(fclose, c_instream); + IGRAPH_R_CHECK_BOOL(directed); + c_directed = LOGICAL(directed)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_read_graph_graphdb(&c_graph, c_instream, c_directed)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_read_graph_gml / +/-------------------------------------------*/ +SEXP R_igraph_read_graph_gml(SEXP instream) { + /* Declarations */ + igraph_t c_graph; + FILE* c_instream; + SEXP graph; + + SEXP r_result; + /* Convert input */ + c_instream = R_igraph_fopen_read(instream); + IGRAPH_FINALLY(fclose, c_instream); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_read_graph_gml(&c_graph, c_instream)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_read_graph_dl / +/-------------------------------------------*/ +SEXP R_igraph_read_graph_dl(SEXP instream, SEXP directed) { + /* Declarations */ + igraph_t c_graph; + FILE* c_instream; + igraph_bool_t c_directed; + SEXP graph; + + SEXP r_result; + /* Convert input */ + c_instream = R_igraph_fopen_read(instream); + IGRAPH_FINALLY(fclose, c_instream); + IGRAPH_R_CHECK_BOOL(directed); + c_directed = LOGICAL(directed)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_read_graph_dl(&c_graph, c_instream, c_directed)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + IGRAPH_I_DESTROY(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_write_graph_edgelist / +/-------------------------------------------*/ +SEXP R_igraph_write_graph_edgelist(SEXP graph, SEXP outstream) { + /* Declarations */ + igraph_t c_graph; + FILE* c_outstream; + + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_write_graph_edgelist(&c_graph, c_outstream)); + + /* Convert output */ + + + + return(R_NilValue); +} + +/*-------------------------------------------/ +/ igraph_write_graph_leda / +/-------------------------------------------*/ +SEXP R_igraph_write_graph_leda(SEXP graph, SEXP outstream, SEXP names, SEXP weights) { + /* Declarations */ + igraph_t c_graph; + FILE* c_outstream; + const char* c_names; + const char* c_weights; + + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_names = Rf_translateCharUTF8(STRING_ELT(names, 0)); + c_weights = Rf_translateCharUTF8(STRING_ELT(weights, 0)); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_write_graph_leda(&c_graph, c_outstream, c_names, c_weights)); + + /* Convert output */ + + + + return(R_NilValue); +} + +/*-------------------------------------------/ +/ igraph_write_graph_graphml / +/-------------------------------------------*/ +SEXP R_igraph_write_graph_graphml(SEXP graph, SEXP outstream, SEXP prefixattr) { + /* Declarations */ + igraph_t c_graph; + FILE* c_outstream; + igraph_bool_t c_prefixattr; + + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK_BOOL(prefixattr); + c_prefixattr = LOGICAL(prefixattr)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_write_graph_graphml(&c_graph, c_outstream, c_prefixattr)); + + /* Convert output */ + + + + return(R_NilValue); +} + +/*-------------------------------------------/ +/ igraph_write_graph_pajek / +/-------------------------------------------*/ +SEXP R_igraph_write_graph_pajek(SEXP graph, SEXP outstream) { + /* Declarations */ + igraph_t c_graph; + FILE* c_outstream; + + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_write_graph_pajek(&c_graph, c_outstream)); + + /* Convert output */ + + + + return(R_NilValue); +} + +/*-------------------------------------------/ +/ igraph_write_graph_gml / +/-------------------------------------------*/ +SEXP R_igraph_write_graph_gml(SEXP graph, SEXP outstream, SEXP options, SEXP id, SEXP creator) { + /* Declarations */ + igraph_t c_graph; + FILE* c_outstream; + igraph_write_gml_sw_t c_options; + igraph_vector_t c_id; + const char* c_creator; + + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_options = (igraph_write_gml_sw_t) Rf_asInteger(options); + R_SEXP_to_vector(id, &c_id); + if (!Rf_isNull(creator)) { + c_creator = Rf_translateCharUTF8(STRING_ELT(creator, 0)); + } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_write_graph_gml(&c_graph, c_outstream, c_options, &c_id, (Rf_isNull(creator) ? 0 : c_creator))); + + /* Convert output */ + + + + return(R_NilValue); +} + +/*-------------------------------------------/ +/ igraph_write_graph_dot / +/-------------------------------------------*/ +SEXP R_igraph_write_graph_dot(SEXP graph, SEXP outstream) { + /* Declarations */ + igraph_t c_graph; + FILE* c_outstream; + + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_write_graph_dot(&c_graph, c_outstream)); /* Convert output */ - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - IGRAPH_I_DESTROY(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - igraph_attribute_combination_destroy(&c_edge_attr_comb); - IGRAPH_FINALLY_CLEAN(1); - r_result = graph; - UNPROTECT(1); - return(r_result); + + + return(R_NilValue); } /*-------------------------------------------/ @@ -9364,6 +10284,34 @@ SEXP R_igraph_list_triangles(SEXP graph) { return(r_result); } +/*-------------------------------------------/ +/ igraph_disjoint_union / +/-------------------------------------------*/ +SEXP R_igraph_disjoint_union(SEXP left, SEXP right) { + /* Declarations */ + igraph_t c_res; + igraph_t c_left; + igraph_t c_right; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(left, &c_left); + R_SEXP_to_igraph(right, &c_right); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_disjoint_union(&c_res, &c_left, &c_right)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + IGRAPH_I_DESTROY(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_join / /-------------------------------------------*/ @@ -9392,6 +10340,216 @@ SEXP R_igraph_join(SEXP left, SEXP right) { return(r_result); } +/*-------------------------------------------/ +/ igraph_union / +/-------------------------------------------*/ +SEXP R_igraph_union(SEXP left, SEXP right) { + /* Declarations */ + igraph_t c_res; + igraph_t c_left; + igraph_t c_right; + igraph_vector_int_t c_edge_map_left; + igraph_vector_int_t c_edge_map_right; + SEXP res; + SEXP edge_map_left; + SEXP edge_map_right; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(left, &c_left); + R_SEXP_to_igraph(right, &c_right); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_map_left, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_map_left); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_map_right, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_map_right); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_union(&c_res, &c_left, &c_right, &c_edge_map_left, &c_edge_map_right)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + IGRAPH_I_DESTROY(&c_res); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edge_map_left=R_igraph_vector_int_to_SEXPp1(&c_edge_map_left)); + igraph_vector_int_destroy(&c_edge_map_left); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edge_map_right=R_igraph_vector_int_to_SEXPp1(&c_edge_map_right)); + igraph_vector_int_destroy(&c_edge_map_right); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, edge_map_left); + SET_VECTOR_ELT(r_result, 2, edge_map_right); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edge_map_left")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("edge_map_right")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_intersection / +/-------------------------------------------*/ +SEXP R_igraph_intersection(SEXP left, SEXP right) { + /* Declarations */ + igraph_t c_res; + igraph_t c_left; + igraph_t c_right; + igraph_vector_int_t c_edge_map_left; + igraph_vector_int_t c_edge_map_right; + SEXP res; + SEXP edge_map_left; + SEXP edge_map_right; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(left, &c_left); + R_SEXP_to_igraph(right, &c_right); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_map_left, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_map_left); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_map_right, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_map_right); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_intersection(&c_res, &c_left, &c_right, &c_edge_map_left, &c_edge_map_right)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + IGRAPH_I_DESTROY(&c_res); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edge_map_left=R_igraph_vector_int_to_SEXPp1(&c_edge_map_left)); + igraph_vector_int_destroy(&c_edge_map_left); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edge_map_right=R_igraph_vector_int_to_SEXPp1(&c_edge_map_right)); + igraph_vector_int_destroy(&c_edge_map_right); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, edge_map_left); + SET_VECTOR_ELT(r_result, 2, edge_map_right); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edge_map_left")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("edge_map_right")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_difference / +/-------------------------------------------*/ +SEXP R_igraph_difference(SEXP orig, SEXP sub) { + /* Declarations */ + igraph_t c_res; + igraph_t c_orig; + igraph_t c_sub; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(orig, &c_orig); + R_SEXP_to_igraph(sub, &c_sub); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_difference(&c_res, &c_orig, &c_sub)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + IGRAPH_I_DESTROY(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_complementer / +/-------------------------------------------*/ +SEXP R_igraph_complementer(SEXP graph, SEXP loops) { + /* Declarations */ + igraph_t c_res; + igraph_t c_graph; + igraph_bool_t c_loops; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK_BOOL(loops); + c_loops = LOGICAL(loops)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_complementer(&c_res, &c_graph, c_loops)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + IGRAPH_I_DESTROY(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_compose / +/-------------------------------------------*/ +SEXP R_igraph_compose(SEXP g1, SEXP g2) { + /* Declarations */ + igraph_t c_res; + igraph_t c_g1; + igraph_t c_g2; + igraph_vector_int_t c_edge_map1; + igraph_vector_int_t c_edge_map2; + SEXP res; + SEXP edge_map1; + SEXP edge_map2; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(g1, &c_g1); + R_SEXP_to_igraph(g2, &c_g2); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_map1, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_map1); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_edge_map2, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_map2); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_compose(&c_res, &c_g1, &c_g2, &c_edge_map1, &c_edge_map2)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + IGRAPH_I_DESTROY(&c_res); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edge_map1=R_igraph_vector_int_to_SEXPp1(&c_edge_map1)); + igraph_vector_int_destroy(&c_edge_map1); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edge_map2=R_igraph_vector_int_to_SEXPp1(&c_edge_map2)); + igraph_vector_int_destroy(&c_edge_map2); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, edge_map1); + SET_VECTOR_ELT(r_result, 2, edge_map2); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edge_map1")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("edge_map2")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_induced_subgraph_map / /-------------------------------------------*/ @@ -9592,68 +10750,156 @@ SEXP R_igraph_maxflow(SEXP graph, SEXP source, SEXP target, SEXP capacity) { igraph_vector_int_t c_cut; igraph_vector_int_t c_partition1; igraph_vector_int_t c_partition2; - igraph_integer_t c_source; - igraph_integer_t c_target; + igraph_integer_t c_source; + igraph_integer_t c_target; + igraph_vector_t c_capacity; + igraph_maxflow_stats_t c_stats; + SEXP value; + SEXP flow; + SEXP cut; + SEXP partition1; + SEXP partition2; + SEXP stats; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_vector_init(&c_flow, 0)); + IGRAPH_FINALLY(igraph_vector_destroy, &c_flow); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_cut, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_cut); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_partition1, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition1); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_partition2, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition2); + c_source = (igraph_integer_t) REAL(source)[0]; + c_target = (igraph_integer_t) REAL(target)[0]; + if (!Rf_isNull(capacity)) { + R_SEXP_to_vector(capacity, &c_capacity); + } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_maxflow(&c_graph, &c_value, &c_flow, &c_cut, &c_partition1, &c_partition2, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity), &c_stats)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(6)); + PROTECT(r_names=NEW_CHARACTER(6)); + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + PROTECT(flow=R_igraph_vector_to_SEXP(&c_flow)); + igraph_vector_destroy(&c_flow); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(cut=R_igraph_vector_int_to_SEXPp1(&c_cut)); + igraph_vector_int_destroy(&c_cut); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition1=R_igraph_vector_int_to_SEXPp1(&c_partition1)); + igraph_vector_int_destroy(&c_partition1); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition2=R_igraph_vector_int_to_SEXPp1(&c_partition2)); + igraph_vector_int_destroy(&c_partition2); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(stats=R_igraph_maxflow_stats_to_SEXP(&c_stats)); + SET_VECTOR_ELT(r_result, 0, value); + SET_VECTOR_ELT(r_result, 1, flow); + SET_VECTOR_ELT(r_result, 2, cut); + SET_VECTOR_ELT(r_result, 3, partition1); + SET_VECTOR_ELT(r_result, 4, partition2); + SET_VECTOR_ELT(r_result, 5, stats); + SET_STRING_ELT(r_names, 0, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("flow")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("cut")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("partition1")); + SET_STRING_ELT(r_names, 4, Rf_mkChar("partition2")); + SET_STRING_ELT(r_names, 5, Rf_mkChar("stats")); + SET_NAMES(r_result, r_names); + UNPROTECT(7); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_mincut / +/-------------------------------------------*/ +SEXP R_igraph_mincut(SEXP graph, SEXP capacity) { + /* Declarations */ + igraph_t c_graph; + igraph_real_t c_value; + igraph_vector_int_t c_partition1; + igraph_vector_int_t c_partition2; + igraph_vector_int_t c_cut; igraph_vector_t c_capacity; - igraph_maxflow_stats_t c_stats; SEXP value; - SEXP flow; - SEXP cut; SEXP partition1; SEXP partition2; - SEXP stats; + SEXP cut; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - IGRAPH_R_CHECK(igraph_vector_init(&c_flow, 0)); - IGRAPH_FINALLY(igraph_vector_destroy, &c_flow); - IGRAPH_R_CHECK(igraph_vector_int_init(&c_cut, 0)); - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_cut); IGRAPH_R_CHECK(igraph_vector_int_init(&c_partition1, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition1); IGRAPH_R_CHECK(igraph_vector_int_init(&c_partition2, 0)); IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition2); - c_source = (igraph_integer_t) REAL(source)[0]; - c_target = (igraph_integer_t) REAL(target)[0]; + IGRAPH_R_CHECK(igraph_vector_int_init(&c_cut, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_cut); if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_maxflow(&c_graph, &c_value, &c_flow, &c_cut, &c_partition1, &c_partition2, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity), &c_stats)); + IGRAPH_R_CHECK(igraph_mincut(&c_graph, &c_value, &c_partition1, &c_partition2, &c_cut, (Rf_isNull(capacity) ? 0 : &c_capacity))); /* Convert output */ - PROTECT(r_result=NEW_LIST(6)); - PROTECT(r_names=NEW_CHARACTER(6)); + PROTECT(r_result=NEW_LIST(4)); + PROTECT(r_names=NEW_CHARACTER(4)); PROTECT(value=NEW_NUMERIC(1)); REAL(value)[0]=c_value; - PROTECT(flow=R_igraph_vector_to_SEXP(&c_flow)); - igraph_vector_destroy(&c_flow); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(cut=R_igraph_vector_int_to_SEXPp1(&c_cut)); - igraph_vector_int_destroy(&c_cut); - IGRAPH_FINALLY_CLEAN(1); PROTECT(partition1=R_igraph_vector_int_to_SEXPp1(&c_partition1)); igraph_vector_int_destroy(&c_partition1); IGRAPH_FINALLY_CLEAN(1); PROTECT(partition2=R_igraph_vector_int_to_SEXPp1(&c_partition2)); igraph_vector_int_destroy(&c_partition2); IGRAPH_FINALLY_CLEAN(1); - PROTECT(stats=R_igraph_maxflow_stats_to_SEXP(&c_stats)); + PROTECT(cut=R_igraph_vector_int_to_SEXPp1(&c_cut)); + igraph_vector_int_destroy(&c_cut); + IGRAPH_FINALLY_CLEAN(1); SET_VECTOR_ELT(r_result, 0, value); - SET_VECTOR_ELT(r_result, 1, flow); - SET_VECTOR_ELT(r_result, 2, cut); - SET_VECTOR_ELT(r_result, 3, partition1); - SET_VECTOR_ELT(r_result, 4, partition2); - SET_VECTOR_ELT(r_result, 5, stats); + SET_VECTOR_ELT(r_result, 1, partition1); + SET_VECTOR_ELT(r_result, 2, partition2); + SET_VECTOR_ELT(r_result, 3, cut); SET_STRING_ELT(r_names, 0, Rf_mkChar("value")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("flow")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("cut")); - SET_STRING_ELT(r_names, 3, Rf_mkChar("partition1")); - SET_STRING_ELT(r_names, 4, Rf_mkChar("partition2")); - SET_STRING_ELT(r_names, 5, Rf_mkChar("stats")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("partition1")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("partition2")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("cut")); SET_NAMES(r_result, r_names); - UNPROTECT(7); + UNPROTECT(5); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_mincut_value / +/-------------------------------------------*/ +SEXP R_igraph_mincut_value(SEXP graph, SEXP capacity) { + /* Declarations */ + igraph_t c_graph; + igraph_real_t c_res; + igraph_vector_t c_capacity; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(capacity)) { + R_SEXP_to_vector(capacity, &c_capacity); + } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_mincut_value(&c_graph, &c_res, (Rf_isNull(capacity) ? 0 : &c_capacity))); + + /* Convert output */ + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); @@ -9798,6 +11044,118 @@ SEXP R_igraph_st_mincut(SEXP graph, SEXP source, SEXP target, SEXP capacity) { return(r_result); } +/*-------------------------------------------/ +/ igraph_vertex_connectivity / +/-------------------------------------------*/ +SEXP R_igraph_vertex_connectivity(SEXP graph, SEXP checks) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_res; + igraph_bool_t c_checks; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_res=0; + IGRAPH_R_CHECK_BOOL(checks); + c_checks = LOGICAL(checks)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_vertex_connectivity(&c_graph, &c_res, c_checks)); + + /* Convert output */ + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=(double) c_res; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_edge_connectivity / +/-------------------------------------------*/ +SEXP R_igraph_edge_connectivity(SEXP graph, SEXP checks) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_res; + igraph_bool_t c_checks; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_res=0; + IGRAPH_R_CHECK_BOOL(checks); + c_checks = LOGICAL(checks)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_edge_connectivity(&c_graph, &c_res, c_checks)); + + /* Convert output */ + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=(double) c_res; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_adhesion / +/-------------------------------------------*/ +SEXP R_igraph_adhesion(SEXP graph, SEXP checks) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_res; + igraph_bool_t c_checks; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_res=0; + IGRAPH_R_CHECK_BOOL(checks); + c_checks = LOGICAL(checks)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_adhesion(&c_graph, &c_res, c_checks)); + + /* Convert output */ + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=(double) c_res; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_cohesion / +/-------------------------------------------*/ +SEXP R_igraph_cohesion(SEXP graph, SEXP checks) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_res; + igraph_bool_t c_checks; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_res=0; + IGRAPH_R_CHECK_BOOL(checks); + c_checks = LOGICAL(checks)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_cohesion(&c_graph, &c_res, c_checks)); + + /* Convert output */ + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=(double) c_res; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_dominator_tree / /-------------------------------------------*/ @@ -10104,6 +11462,93 @@ SEXP R_igraph_minimum_size_separators(SEXP graph) { return(r_result); } +/*-------------------------------------------/ +/ igraph_cohesive_blocks / +/-------------------------------------------*/ +SEXP R_igraph_cohesive_blocks(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_list_t c_blocks; + igraph_vector_int_t c_cohesion; + igraph_vector_int_t c_parent; + igraph_t c_blockTree; + SEXP blocks; + SEXP cohesion; + SEXP parent; + SEXP blockTree; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_vector_int_list_init(&c_blocks, 0)); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_blocks); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_cohesion, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_cohesion); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_parent, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_parent); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_cohesive_blocks(&c_graph, &c_blocks, &c_cohesion, &c_parent, &c_blockTree)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(4)); + PROTECT(r_names=NEW_CHARACTER(4)); + PROTECT(blocks=R_igraph_vector_int_list_to_SEXPp1(&c_blocks)); + igraph_vector_int_list_destroy(&c_blocks); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(cohesion=R_igraph_vector_int_to_SEXP(&c_cohesion)); + igraph_vector_int_destroy(&c_cohesion); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(parent=R_igraph_vector_int_to_SEXPp1(&c_parent)); + igraph_vector_int_destroy(&c_parent); + IGRAPH_FINALLY_CLEAN(1); + IGRAPH_FINALLY(igraph_destroy, &c_blockTree); + PROTECT(blockTree=R_igraph_to_SEXP(&c_blockTree)); + IGRAPH_I_DESTROY(&c_blockTree); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, blocks); + SET_VECTOR_ELT(r_result, 1, cohesion); + SET_VECTOR_ELT(r_result, 2, parent); + SET_VECTOR_ELT(r_result, 3, blockTree); + SET_STRING_ELT(r_names, 0, Rf_mkChar("blocks")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("cohesion")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("parent")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("blockTree")); + SET_NAMES(r_result, r_names); + UNPROTECT(5); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_coreness / +/-------------------------------------------*/ +SEXP R_igraph_coreness(SEXP graph, SEXP mode) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_cores; + igraph_neimode_t c_mode; + SEXP cores; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + IGRAPH_R_CHECK(igraph_vector_int_init(&c_cores, 0)); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_cores); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_coreness(&c_graph, &c_cores, c_mode)); + + /* Convert output */ + PROTECT(cores=R_igraph_vector_int_to_SEXP(&c_cores)); + igraph_vector_int_destroy(&c_cores); + IGRAPH_FINALLY_CLEAN(1); + r_result = cores; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_isoclass / /-------------------------------------------*/ @@ -11255,7 +12700,7 @@ SEXP R_igraph_eigen_adjacency(SEXP graph, SEXP algorithm, SEXP which, SEXP optio /* Convert output */ PROTECT(r_result=NEW_LIST(5)); PROTECT(r_names=NEW_CHARACTER(5)); - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(options=Rx_igraph_arpack_options_to_SEXP(&c_options)); PROTECT(values=R_igraph_vector_to_SEXP(&c_values)); igraph_vector_destroy(&c_values); IGRAPH_FINALLY_CLEAN(1); @@ -11350,6 +12795,36 @@ SEXP R_igraph_sir(SEXP graph, SEXP beta, SEXP gamma, SEXP no_sim) { return(r_result); } +/*-------------------------------------------/ +/ igraph_running_mean / +/-------------------------------------------*/ +SEXP R_igraph_running_mean(SEXP data, SEXP binwidth) { + /* Declarations */ + igraph_vector_t c_data; + igraph_vector_t c_res; + igraph_integer_t c_binwidth; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_vector(data, &c_data); + IGRAPH_R_CHECK(igraph_vector_init(&c_res, 0)); + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + IGRAPH_R_CHECK_INT(binwidth); + c_binwidth = (igraph_integer_t) REAL(binwidth)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_running_mean(&c_data, &c_res, c_binwidth)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_convex_hull_2d / /-------------------------------------------*/ @@ -11922,6 +13397,60 @@ SEXP R_igraph_is_complete(SEXP graph) { return(r_result); } +/*-------------------------------------------/ +/ igraph_minimum_spanning_tree_unweighted / +/-------------------------------------------*/ +SEXP R_igraph_minimum_spanning_tree_unweighted(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_t c_mst; + SEXP mst; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_minimum_spanning_tree_unweighted(&c_graph, &c_mst)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_mst); + PROTECT(mst=R_igraph_to_SEXP(&c_mst)); + IGRAPH_I_DESTROY(&c_mst); + IGRAPH_FINALLY_CLEAN(1); + r_result = mst; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_minimum_spanning_tree_prim / +/-------------------------------------------*/ +SEXP R_igraph_minimum_spanning_tree_prim(SEXP graph, SEXP weights) { + /* Declarations */ + igraph_t c_graph; + igraph_t c_mst; + igraph_vector_t c_weights; + SEXP mst; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + R_SEXP_to_vector(weights, &c_weights); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_minimum_spanning_tree_prim(&c_graph, &c_mst, &c_weights)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_mst); + PROTECT(mst=R_igraph_to_SEXP(&c_mst)); + IGRAPH_I_DESTROY(&c_mst); + IGRAPH_FINALLY_CLEAN(1); + r_result = mst; + + UNPROTECT(1); + return(r_result); +} + /*-------------------------------------------/ / igraph_random_spanning_tree / /-------------------------------------------*/ diff --git a/src/rinterface.h b/src/rinterface.h index e80a49ff997..4486ea3d91a 100644 --- a/src/rinterface.h +++ b/src/rinterface.h @@ -39,7 +39,7 @@ #define IGRAPH_I_DESTROY IGRAPH_I_ATTRIBUTE_DESTROY -SEXP R_igraph_add_env(SEXP graph); +SEXP Rx_igraph_add_env(SEXP graph); void R_igraph_attribute_clean_preserve_list(void); void R_igraph_set_in_r_check(bool set); @@ -68,7 +68,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph); SEXP R_igraph_vector_int_list_to_SEXP(const igraph_vector_int_list_t *list); SEXP R_igraph_vector_int_list_to_SEXPp1(const igraph_vector_int_list_t *list); SEXP R_igraph_0orvector_int_list_to_SEXP(const igraph_vector_int_list_t *list); -SEXP R_igraph_matrixlist_to_SEXP(const igraph_vector_ptr_t *ptr); +SEXP R_igraph_matrixlist_to_SEXP(const igraph_matrix_list_t *ptr); SEXP R_igraph_graphlist_to_SEXP(const igraph_graph_list_t *list); SEXP R_igraph_hrg_to_SEXP(const igraph_hrg_t *hrg); SEXP R_igraph_plfit_result_to_SEXP(const igraph_plfit_result_t *plfit); @@ -77,7 +77,7 @@ SEXP R_igraph_0orsparsemat_to_SEXP(const igraph_sparsemat_t *sp); SEXP R_igraph_maxflow_stats_to_SEXP(const igraph_maxflow_stats_t *st); SEXP R_igraph_sirlist_to_SEXP(const igraph_vector_ptr_t *sl); void R_igraph_sirlist_destroy(igraph_vector_ptr_t *sl); -SEXP R_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt); +SEXP Rx_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt); SEXP R_igraph_bliss_info_to_SEXP(const igraph_bliss_info_t *info); igraph_error_t R_igraph_SEXP_to_strvector(SEXP rval, igraph_strvector_t *sv); @@ -145,6 +145,7 @@ void igraph_vector_int_list_destroy_pv(void *pv_ptr); void R_check_int_scalar(SEXP value); void R_check_real_scalar(SEXP value); void R_check_bool_scalar(SEXP value); +FILE* R_igraph_fopen_read(SEXP instream); igraph_error_t R_get_int_scalar(SEXP sexp, R_xlen_t index, igraph_integer_t *res); igraph_error_t R_get_real_scalar(SEXP sexp, R_xlen_t index, igraph_real_t *res); diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 5e08a4021b1..053aa2f9a0a 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -162,6 +162,15 @@ igraph_error_t R_get_bool_scalar(SEXP sexp, R_xlen_t index, igraph_bool_t *res) return IGRAPH_SUCCESS; } +FILE* R_igraph_fopen_read(SEXP instream) { + FILE *file; + + file=fopen(CHAR(STRING_ELT(instream, 0)), "r"); + if (file==0) { igraph_error("Cannot open file for reading", __FILE__, __LINE__, + IGRAPH_EFILE); } + return file; +} + SEXP R_igraph_i_lang7(SEXP s, SEXP t, SEXP u, SEXP v, SEXP w, SEXP x, SEXP y) { PROTECT(s); @@ -290,7 +299,7 @@ SEXP R_igraph_handle_safe_eval_result(SEXP result) { * Attributes * *****************************************************/ -SEXP R_igraph_get_attr_mode(SEXP graph, SEXP pwhich) { +SEXP Rx_igraph_get_attr_mode(SEXP graph, SEXP pwhich) { int which=INTEGER(pwhich)[0]-1; SEXP obj=VECTOR_ELT(VECTOR_ELT(graph, igraph_t_idx_attr), which); igraph_integer_t len=Rf_xlength(obj); @@ -2467,7 +2476,7 @@ void R_igraph_init_handlers(DllInfo *dll) { igraph_set_attribute_table(&R_igraph_attribute_table); } -SEXP R_igraph_set_verbose(SEXP verbose) { +SEXP Rx_igraph_set_verbose(SEXP verbose) { if (LOGICAL(verbose)[0]) { igraph_set_status_handler(R_igraph_status_handler); igraph_set_progress_handler(R_igraph_progress_handler); @@ -2909,7 +2918,7 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { /* Environment for vertex/edge seqs */ SET_VECTOR_ELT(result, igraph_t_idx_env, R_NilValue); - R_igraph_add_env(result); + Rx_igraph_add_env(result); R_igraph_set_pointer(result, graph); /* Set from and to requires environment */ R_igraph_set_from(result, graph); @@ -2994,13 +3003,13 @@ SEXP R_igraph_vector_int_list_to_SEXPp1(const igraph_vector_int_list_t *list) { return result; } -SEXP R_igraph_matrixlist_to_SEXP(const igraph_vector_ptr_t *ptr) { +SEXP R_igraph_matrixlist_to_SEXP(const igraph_matrix_list_t *ptr) { SEXP result; - igraph_integer_t n=igraph_vector_ptr_size(ptr); + igraph_integer_t n=igraph_matrix_list_size(ptr); PROTECT(result=NEW_LIST(n)); for (igraph_integer_t i=0; iiparam[6]=opt->mode; } -SEXP R_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt) { +SEXP Rx_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt) { SEXP result, names; char bmat[2], which[3]; @@ -3722,21 +3731,21 @@ SEXP R_igraph_bliss_info_to_SEXP(const igraph_bliss_info_t *info) { /*******************************************************************/ -SEXP R_igraph_copy_from(SEXP graph) +SEXP Rx_igraph_copy_from(SEXP graph) { igraph_vector_int_t from; R_igraph_get_from(graph, &from); return R_igraph_vector_int_to_SEXP(&from); } -SEXP R_igraph_copy_to(SEXP graph) +SEXP Rx_igraph_copy_to(SEXP graph) { igraph_vector_int_t to; R_igraph_get_to(graph, &to); return R_igraph_vector_int_to_SEXP(&to); } -SEXP R_igraph_copy_env(SEXP graph) +SEXP Rx_igraph_copy_env(SEXP graph) { return Rf_duplicate(R_igraph_graph_env(graph)); } @@ -3746,13 +3755,13 @@ SEXP R_igraph_mybracket(SEXP graph, SEXP pidx) { return Rf_duplicate(VECTOR_ELT(graph, idx)); } -SEXP R_igraph_mybracket2(SEXP graph, SEXP pidx1, SEXP pidx2) { +SEXP Rx_igraph_mybracket2(SEXP graph, SEXP pidx1, SEXP pidx2) { int idx1=INTEGER(pidx1)[0]-1; int idx2=INTEGER(pidx2)[0]-1; return Rf_duplicate(VECTOR_ELT(VECTOR_ELT(graph, idx1), idx2)); } -SEXP R_igraph_mybracket2_names(SEXP graph, SEXP pidx1, SEXP pidx2) { +SEXP Rx_igraph_mybracket2_names(SEXP graph, SEXP pidx1, SEXP pidx2) { SEXP result; int idx1=INTEGER(pidx1)[0]-1; int idx2=INTEGER(pidx2)[0]-1; @@ -3766,13 +3775,13 @@ SEXP R_igraph_mybracket2_names(SEXP graph, SEXP pidx1, SEXP pidx2) { return result; } -SEXP R_igraph_mybracket2_copy(SEXP graph, SEXP pidx1, SEXP pidx2) { +SEXP Rx_igraph_mybracket2_copy(SEXP graph, SEXP pidx1, SEXP pidx2) { int idx1=INTEGER(pidx1)[0]-1; int idx2=INTEGER(pidx2)[0]-1; return Rf_duplicate(VECTOR_ELT(VECTOR_ELT(graph, idx1), idx2)); } -SEXP R_igraph_mybracket2_set(SEXP graph, SEXP pidx1, SEXP pidx2, +SEXP Rx_igraph_mybracket2_set(SEXP graph, SEXP pidx1, SEXP pidx2, SEXP value) { SEXP newgraph; int idx1=INTEGER(pidx1)[0]-1; @@ -3845,7 +3854,7 @@ SEXP R_igraph_add_edges_manual(SEXP graph, SEXP edges) { return result; } -SEXP R_igraph_add_vertices(SEXP graph, SEXP pnv) { +SEXP Rx_igraph_add_vertices(SEXP graph, SEXP pnv) { igraph_integer_t nv; igraph_t g; @@ -3862,7 +3871,7 @@ SEXP R_igraph_add_vertices(SEXP graph, SEXP pnv) { return result; } -SEXP R_igraph_ecount(SEXP graph) { +SEXP Rx_igraph_ecount(SEXP graph) { igraph_t g; SEXP result; @@ -3875,7 +3884,7 @@ SEXP R_igraph_ecount(SEXP graph) { return result; } -SEXP R_igraph_incident(SEXP graph, SEXP pvid, SEXP pmode) { +SEXP Rx_igraph_incident(SEXP graph, SEXP pvid, SEXP pmode) { igraph_t g; igraph_vector_int_t neis; @@ -3896,7 +3905,7 @@ SEXP R_igraph_incident(SEXP graph, SEXP pvid, SEXP pmode) { return result; } -SEXP R_igraph_delete_edges(SEXP graph, SEXP edges) { +SEXP Rx_igraph_delete_edges(SEXP graph, SEXP edges) { igraph_es_t es; igraph_vector_int_t es_data; @@ -3915,7 +3924,7 @@ SEXP R_igraph_delete_edges(SEXP graph, SEXP edges) { return result; } -SEXP R_igraph_delete_vertices(SEXP graph, SEXP vertices) { +SEXP Rx_igraph_delete_vertices(SEXP graph, SEXP vertices) { igraph_vs_t vs; igraph_vector_int_t vs_data; @@ -3934,7 +3943,7 @@ SEXP R_igraph_delete_vertices(SEXP graph, SEXP vertices) { return result; } -SEXP R_igraph_is_directed(SEXP graph) { +SEXP Rx_igraph_is_directed(SEXP graph) { igraph_t g; SEXP result; @@ -4068,7 +4077,7 @@ SEXP R_igraph_subcomponent(SEXP graph, SEXP pvertex, SEXP pmode) { return result; } -SEXP R_igraph_running_mean(SEXP pdata, SEXP pbinwidth) { +SEXP Rx_igraph_running_mean(SEXP pdata, SEXP pbinwidth) { igraph_vector_t data; igraph_integer_t binwidth=(igraph_integer_t) REAL(pbinwidth)[0]; @@ -4088,7 +4097,7 @@ SEXP R_igraph_running_mean(SEXP pdata, SEXP pbinwidth) { return result; } -SEXP R_igraph_cocitation(SEXP graph, SEXP pvids) { +SEXP Rx_igraph_cocitation(SEXP graph, SEXP pvids) { igraph_t g; igraph_vs_t vs; @@ -4110,7 +4119,7 @@ SEXP R_igraph_cocitation(SEXP graph, SEXP pvids) { return result; } -SEXP R_igraph_bibcoupling(SEXP graph, SEXP pvids) { +SEXP Rx_igraph_bibcoupling(SEXP graph, SEXP pvids) { igraph_t g; igraph_vs_t vs; @@ -4524,7 +4533,7 @@ SEXP R_igraph_layout_lgl(SEXP graph, SEXP pmaxiter, SEXP pmaxdelta, return result; } -SEXP R_igraph_minimum_spanning_tree_unweighted(SEXP graph) { +SEXP Rx_igraph_minimum_spanning_tree_unweighted(SEXP graph) { igraph_t g; igraph_t mst; @@ -4539,7 +4548,7 @@ SEXP R_igraph_minimum_spanning_tree_unweighted(SEXP graph) { return result; } -SEXP R_igraph_minimum_spanning_tree_prim(SEXP graph, SEXP pweights) { +SEXP Rx_igraph_minimum_spanning_tree_prim(SEXP graph, SEXP pweights) { igraph_t g; igraph_t mst; @@ -4757,7 +4766,7 @@ SEXP R_igraph_random_sample(SEXP plow, SEXP phigh, SEXP plength) { return result; } -SEXP R_igraph_get_edgelist(SEXP graph, SEXP pbycol) { +SEXP Rx_igraph_get_edgelist(SEXP graph, SEXP pbycol) { igraph_t g; igraph_vector_int_t res; @@ -4821,7 +4830,7 @@ SEXP R_igraph_degree_sequence_game(SEXP pout_seq, SEXP pin_seq, return result; } -SEXP R_igraph_transitivity_local_undirected_all(SEXP graph, SEXP mode) { +SEXP Rx_igraph_transitivity_local_undirected_all(SEXP graph, SEXP mode) { igraph_t g; igraph_vector_t res; @@ -4866,7 +4875,7 @@ SEXP R_igraph_read_graph_edgelist(SEXP pvfile, SEXP pn, SEXP pdirected) { return result; } -SEXP R_igraph_read_graph_gml(SEXP pvfile) { +SEXP Rx_igraph_read_graph_gml(SEXP pvfile) { igraph_t g; FILE *file; @@ -4888,7 +4897,7 @@ SEXP R_igraph_read_graph_gml(SEXP pvfile) { return result; } -SEXP R_igraph_read_graph_dl(SEXP pvfile, SEXP pdirected) { +SEXP Rx_igraph_read_graph_dl(SEXP pvfile, SEXP pdirected) { igraph_t g; FILE *file; @@ -4911,7 +4920,7 @@ SEXP R_igraph_read_graph_dl(SEXP pvfile, SEXP pdirected) { return result; } -SEXP R_igraph_read_graph_graphdb(SEXP pvfile, SEXP pdirected) { +SEXP Rx_igraph_read_graph_graphdb(SEXP pvfile, SEXP pdirected) { igraph_t g; igraph_bool_t directed=LOGICAL(pdirected)[0]; FILE *file; @@ -4933,7 +4942,7 @@ SEXP R_igraph_read_graph_graphdb(SEXP pvfile, SEXP pdirected) { return result; } -SEXP R_igraph_write_graph_edgelist(SEXP graph, SEXP file) { +SEXP Rx_igraph_write_graph_edgelist(SEXP graph, SEXP file) { igraph_t g; FILE *stream; #if HAVE_OPEN_MEMSTREAM == 1 @@ -4964,7 +4973,7 @@ SEXP R_igraph_write_graph_edgelist(SEXP graph, SEXP file) { return result; } -SEXP R_igraph_write_graph_gml(SEXP graph, SEXP file, SEXP pid, SEXP pcreator) { +SEXP Rx_igraph_write_graph_gml(SEXP graph, SEXP file, SEXP pid, SEXP pcreator) { igraph_t g; FILE *stream; #if HAVE_OPEN_MEMSTREAM == 1 @@ -4999,7 +5008,7 @@ SEXP R_igraph_write_graph_gml(SEXP graph, SEXP file, SEXP pid, SEXP pcreator) { return result; } -SEXP R_igraph_write_graph_dot(SEXP graph, SEXP file) { +SEXP Rx_igraph_write_graph_dot(SEXP graph, SEXP file) { igraph_t g; FILE *stream; #if HAVE_OPEN_MEMSTREAM == 1 @@ -5030,7 +5039,7 @@ SEXP R_igraph_write_graph_dot(SEXP graph, SEXP file) { return result; } -SEXP R_igraph_write_graph_leda(SEXP graph, SEXP file, SEXP va, SEXP ea) { +SEXP Rx_igraph_write_graph_leda(SEXP graph, SEXP file, SEXP va, SEXP ea) { igraph_t g; FILE *stream; #if HAVE_OPEN_MEMSTREAM == 1 @@ -5061,7 +5070,7 @@ SEXP R_igraph_write_graph_leda(SEXP graph, SEXP file, SEXP va, SEXP ea) { return result; } -SEXP R_igraph_write_graph_pajek(SEXP graph, SEXP file) { +SEXP Rx_igraph_write_graph_pajek(SEXP graph, SEXP file) { igraph_t g; FILE *stream; @@ -5235,7 +5244,7 @@ SEXP R_igraph_write_graph_lgl(SEXP graph, SEXP file, SEXP pnames, return result; } -SEXP R_igraph_read_graph_pajek(SEXP pvfile) { +SEXP Rx_igraph_read_graph_pajek(SEXP pvfile) { igraph_t g; FILE *file; SEXP result; @@ -5356,7 +5365,7 @@ SEXP R_igraph_layout_merge_dla(SEXP graphs, SEXP layouts) { return result; } -SEXP R_igraph_disjoint_union(SEXP pgraphs) { +SEXP Rx_igraph_disjoint_union(SEXP pgraphs) { igraph_vector_ptr_t ptrvec; igraph_t *graphs; @@ -5379,7 +5388,7 @@ SEXP R_igraph_disjoint_union(SEXP pgraphs) { return result; } -SEXP R_igraph_union(SEXP pgraphs, SEXP pedgemaps) { +SEXP Rx_igraph_union(SEXP pgraphs, SEXP pedgemaps) { igraph_vector_ptr_t ptrvec; igraph_t *graphs; @@ -5416,7 +5425,7 @@ SEXP R_igraph_union(SEXP pgraphs, SEXP pedgemaps) { return result; } -SEXP R_igraph_intersection(SEXP pgraphs, SEXP pedgemaps) { +SEXP Rx_igraph_intersection(SEXP pgraphs, SEXP pedgemaps) { igraph_vector_ptr_t ptrvec; igraph_t *graphs; @@ -5453,7 +5462,7 @@ SEXP R_igraph_intersection(SEXP pgraphs, SEXP pedgemaps) { return result; } -SEXP R_igraph_difference(SEXP pleft, SEXP pright) { +SEXP Rx_igraph_difference(SEXP pleft, SEXP pright) { igraph_t left, right; igraph_t res; @@ -5469,7 +5478,7 @@ SEXP R_igraph_difference(SEXP pleft, SEXP pright) { return result; } -SEXP R_igraph_complementer(SEXP pgraph, SEXP ploops) { +SEXP Rx_igraph_complementer(SEXP pgraph, SEXP ploops) { igraph_t g; igraph_t res; @@ -5485,7 +5494,7 @@ SEXP R_igraph_complementer(SEXP pgraph, SEXP ploops) { return result; } -SEXP R_igraph_compose(SEXP pleft, SEXP pright, SEXP pedgemaps) { +SEXP Rx_igraph_compose(SEXP pleft, SEXP pright, SEXP pedgemaps) { igraph_t left, right; igraph_t res; @@ -5588,7 +5597,7 @@ SEXP R_igraph_recent_degree_aging_game(SEXP pn, SEXP ppa_exp, SEXP paging_exp, return result; } -SEXP R_igraph_get_edge(SEXP graph, SEXP peid) { +SEXP Rx_igraph_get_edge(SEXP graph, SEXP peid) { igraph_t g; igraph_integer_t eid=(igraph_integer_t) REAL(peid)[0]; @@ -5605,7 +5614,7 @@ SEXP R_igraph_get_edge(SEXP graph, SEXP peid) { return result; } -SEXP R_igraph_edges(SEXP graph, SEXP eids) { +SEXP Rx_igraph_edges(SEXP graph, SEXP eids) { igraph_t g; igraph_es_t es; igraph_vector_int_t es_data; @@ -5626,7 +5635,7 @@ SEXP R_igraph_edges(SEXP graph, SEXP eids) { return result; } -SEXP R_igraph_constraint(SEXP graph, SEXP vids, SEXP pweights) { +SEXP Rx_igraph_constraint(SEXP graph, SEXP vids, SEXP pweights) { igraph_t g; igraph_vs_t vs; @@ -5729,7 +5738,7 @@ SEXP R_igraph_layout_reingold_tilford(SEXP graph, SEXP proot, return result; } -SEXP R_igraph_rewire(SEXP graph, SEXP pn, SEXP pmode) { +SEXP Rx_igraph_rewire(SEXP graph, SEXP pn, SEXP pmode) { igraph_t g; igraph_integer_t n=(igraph_integer_t) REAL(pn)[0]; @@ -5745,7 +5754,7 @@ SEXP R_igraph_rewire(SEXP graph, SEXP pn, SEXP pmode) { return result; } -SEXP R_igraph_read_graph_graphml(SEXP pvfile, SEXP pindex) { +SEXP Rx_igraph_read_graph_graphml(SEXP pvfile, SEXP pindex) { igraph_t g; int index=(int) REAL(pindex)[0]; FILE *file; @@ -5767,7 +5776,7 @@ SEXP R_igraph_read_graph_graphml(SEXP pvfile, SEXP pindex) { return result; } -SEXP R_igraph_write_graph_graphml(SEXP graph, SEXP file, SEXP pprefixattr) { +SEXP Rx_igraph_write_graph_graphml(SEXP graph, SEXP file, SEXP pprefixattr) { igraph_t g; FILE *stream; @@ -5954,7 +5963,7 @@ SEXP R_igraph_grg_game(SEXP pn, SEXP pradius, SEXP ptorus, return result; } -SEXP R_igraph_read_graph_dimacs(SEXP pvfile, SEXP pdirected) { +SEXP Rx_igraph_read_graph_dimacs(SEXP pvfile, SEXP pdirected) { igraph_t g; igraph_bool_t directed=LOGICAL(pdirected)[0]; @@ -6049,7 +6058,7 @@ SEXP R_igraph_write_graph_dimacs(SEXP graph, SEXP file, return result; } -SEXP R_igraph_mincut(SEXP graph, SEXP pcapacity) { +SEXP Rx_igraph_mincut(SEXP graph, SEXP pcapacity) { igraph_t g; igraph_vector_t capacity, *ppcapacity=0; @@ -6091,7 +6100,7 @@ SEXP R_igraph_mincut(SEXP graph, SEXP pcapacity) { return result; } -SEXP R_igraph_mincut_value(SEXP graph, SEXP pcapacity) { +SEXP Rx_igraph_mincut_value(SEXP graph, SEXP pcapacity) { igraph_t g; igraph_vector_t capacity, *ppcapacity=0; @@ -6131,7 +6140,7 @@ SEXP R_igraph_st_vertex_connectivity(SEXP graph, SEXP psource, return result; } -SEXP R_igraph_vertex_connectivity(SEXP graph, SEXP pchecks) { +SEXP Rx_igraph_vertex_connectivity(SEXP graph, SEXP pchecks) { igraph_t g; igraph_integer_t res; @@ -6166,7 +6175,7 @@ SEXP R_igraph_st_edge_connectivity(SEXP graph, SEXP psource, SEXP ptarget) { return result; } -SEXP R_igraph_edge_connectivity(SEXP graph, SEXP pchecks) { +SEXP Rx_igraph_edge_connectivity(SEXP graph, SEXP pchecks) { igraph_t g; igraph_integer_t res; @@ -6239,7 +6248,7 @@ SEXP R_igraph_vertex_disjoint_paths(SEXP graph, SEXP psource, SEXP ptarget) { return result; } -SEXP R_igraph_adhesion(SEXP graph, SEXP pchecks) { +SEXP Rx_igraph_adhesion(SEXP graph, SEXP pchecks) { igraph_t g; igraph_integer_t res; @@ -6255,7 +6264,7 @@ SEXP R_igraph_adhesion(SEXP graph, SEXP pchecks) { return result; } -SEXP R_igraph_cohesion(SEXP graph, SEXP pchecks) { +SEXP Rx_igraph_cohesion(SEXP graph, SEXP pchecks) { igraph_t g; igraph_integer_t res; @@ -6371,7 +6380,7 @@ SEXP R_igraph_spinglass_my_community(SEXP graph, SEXP weights, return result; } -SEXP R_igraph_no_components(SEXP graph, SEXP pmode) { +SEXP Rx_igraph_no_components(SEXP graph, SEXP pmode) { igraph_t g; igraph_integer_t mode=(igraph_integer_t) INTEGER(pmode)[0]; @@ -6496,7 +6505,7 @@ SEXP R_igraph_watts_strogatz_game(SEXP pdim, SEXP psize, SEXP pnei, SEXP pp, return result; } -SEXP R_igraph_coreness(SEXP graph, SEXP pmode) { +SEXP Rx_igraph_coreness(SEXP graph, SEXP pmode) { igraph_t g; igraph_neimode_t mode=(igraph_neimode_t) Rf_asInteger(pmode); @@ -6590,7 +6599,7 @@ SEXP R_igraph_maximal_cliques_file(SEXP graph, SEXP psubset, SEXP file, return result; } -SEXP R_igraph_maximal_cliques_count(SEXP graph, SEXP psubset, +SEXP Rx_igraph_maximal_cliques_count(SEXP graph, SEXP psubset, SEXP min_size, SEXP max_size) { /* Declarations */ igraph_t c_graph; @@ -6645,7 +6654,7 @@ SEXP R_igraph_independent_vertex_sets(SEXP graph, return result; } -SEXP R_igraph_largest_independent_vertex_sets(SEXP graph) { +SEXP Rx_igraph_largest_independent_vertex_sets(SEXP graph) { igraph_t g; igraph_vector_int_list_t list; SEXP result; @@ -6660,7 +6669,7 @@ SEXP R_igraph_largest_independent_vertex_sets(SEXP graph) { return result; } -SEXP R_igraph_maximal_independent_vertex_sets(SEXP graph) { +SEXP Rx_igraph_maximal_independent_vertex_sets(SEXP graph) { igraph_t g; igraph_vector_int_list_t list; SEXP result; @@ -6675,7 +6684,7 @@ SEXP R_igraph_maximal_independent_vertex_sets(SEXP graph) { return result; } -SEXP R_igraph_independence_number(SEXP graph) { +SEXP Rx_igraph_independence_number(SEXP graph) { igraph_t g; igraph_integer_t res; SEXP result; @@ -6803,7 +6812,7 @@ SEXP R_igraph_walktrap_community(SEXP graph, SEXP pweights, return result; } -SEXP R_igraph_topological_sorting(SEXP graph, SEXP pmode) { +SEXP Rx_igraph_topological_sorting(SEXP graph, SEXP pmode) { igraph_t g; igraph_vector_int_t res; igraph_neimode_t mode=(igraph_neimode_t) Rf_asInteger(pmode); @@ -6971,7 +6980,7 @@ SEXP R_igraph_community_to_membership(SEXP graph, SEXP pmerges, return result; } -SEXP R_igraph_community_to_membership2(SEXP pmerges, SEXP pvcount, +SEXP Rx_igraph_community_to_membership2(SEXP pmerges, SEXP pvcount, SEXP psteps) { igraph_matrix_int_t merges; @@ -6997,7 +7006,7 @@ SEXP R_igraph_community_to_membership2(SEXP pmerges, SEXP pvcount, return result; } -SEXP R_igraph_girth(SEXP graph, SEXP pcircle) { +SEXP Rx_igraph_girth(SEXP graph, SEXP pcircle) { igraph_t g; igraph_vector_int_t circle, *ppcircle=0; @@ -7023,7 +7032,7 @@ SEXP R_igraph_girth(SEXP graph, SEXP pcircle) { return result; } -SEXP R_igraph_famous(SEXP name) { +SEXP Rx_igraph_famous(SEXP name) { igraph_t g; SEXP result; @@ -7036,7 +7045,7 @@ SEXP R_igraph_famous(SEXP name) { return result; } -SEXP R_igraph_get_adjlist(SEXP graph, SEXP pmode, SEXP ploops, SEXP pmultiple) { +SEXP Rx_igraph_get_adjlist(SEXP graph, SEXP pmode, SEXP ploops, SEXP pmultiple) { igraph_t g; igraph_neimode_t mode=(igraph_neimode_t) Rf_asInteger(pmode); @@ -7060,7 +7069,7 @@ SEXP R_igraph_get_adjlist(SEXP graph, SEXP pmode, SEXP ploops, SEXP pmultiple) { return result; } -SEXP R_igraph_get_adjedgelist(SEXP graph, SEXP pmode, SEXP ploops) { +SEXP Rx_igraph_get_adjedgelist(SEXP graph, SEXP pmode, SEXP ploops) { igraph_t g; igraph_neimode_t mode=(igraph_neimode_t) Rf_asInteger(pmode); @@ -7106,7 +7115,7 @@ igraph_error_t R_igraph_i_arpack_callback(igraph_real_t *to, const igraph_real_t return 0; } -SEXP R_igraph_arpack(SEXP function, SEXP extra, SEXP options, SEXP rho, +SEXP Rx_igraph_arpack(SEXP function, SEXP extra, SEXP options, SEXP rho, SEXP sym) { igraph_vector_t values; @@ -7158,7 +7167,7 @@ SEXP R_igraph_arpack(SEXP function, SEXP extra, SEXP options, SEXP rho, } SET_VECTOR_ELT(result, 1, R_igraph_matrix_to_SEXP(&vectors)); igraph_matrix_destroy(&vectors); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(result, 2, R_igraph_arpack_options_to_SEXP(&c_options)); + SET_VECTOR_ELT(result, 2, Rx_igraph_arpack_options_to_SEXP(&c_options)); PROTECT(names=NEW_CHARACTER(3)); SET_STRING_ELT(names, 0, Rf_mkChar("values")); SET_STRING_ELT(names, 1, Rf_mkChar("vectors")); @@ -7514,7 +7523,7 @@ SEXP R_igraph_dfs(SEXP graph, SEXP proot, SEXP pmode, SEXP punreachable, return result; } -SEXP R_igraph_cohesive_blocks(SEXP graph) { +SEXP Rx_igraph_cohesive_blocks(SEXP graph) { igraph_vector_int_list_t c_blocks; igraph_vector_int_t c_cohesion; igraph_vector_int_t c_parent; @@ -7576,7 +7585,7 @@ typedef struct { igraph_arpack_function_t *fun; } R_igraph_i_function_container_t; -SEXP R_igraph_i_levc_arp(SEXP extP, SEXP extE, SEXP pv) { +SEXP Rx_igraph_i_levc_arp(SEXP extP, SEXP extE, SEXP pv) { R_igraph_i_function_container_t *cont = R_ExternalPtrAddr(extP); igraph_arpack_function_t *fun= cont->fun; void *extra=R_ExternalPtrAddr(extE); @@ -7702,7 +7711,7 @@ SEXP R_igraph_community_leading_eigenvector(SEXP graph, SEXP steps, PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); igraph_vector_int_destroy(&c_membership); IGRAPH_FINALLY_CLEAN(1); - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(options=Rx_igraph_arpack_options_to_SEXP(&c_options)); PROTECT(modularity=NEW_NUMERIC(1)); REAL(modularity)[0]=c_modularity; PROTECT(eigenvalues=R_igraph_vector_to_SEXP(&c_eigenvalues)); @@ -7899,7 +7908,7 @@ SEXP R_igraph_graphlets(SEXP graph, SEXP weights, SEXP niter) { /*-------------------------------------------/ / igraph_graphlets_candidate_basis / /-------------------------------------------*/ -SEXP R_igraph_graphlets_candidate_basis(SEXP graph, SEXP weights) { +SEXP Rx_igraph_graphlets_candidate_basis(SEXP graph, SEXP weights) { /* Declarations */ igraph_t c_graph; igraph_vector_t c_weights; @@ -7953,7 +7962,7 @@ igraph_error_t igraph_i_graphlets_project( / igraph_graphlets_project / /-------------------------------------------*/ -SEXP R_igraph_graphlets_project(SEXP graph, SEXP weights, SEXP cliques, +SEXP Rx_igraph_graphlets_project(SEXP graph, SEXP weights, SEXP cliques, SEXP Mu, SEXP niter) { /* Declarations */ igraph_t c_graph; @@ -8067,7 +8076,7 @@ SEXP R_igraph_adjacency_spectral_embedding(SEXP graph, SEXP no, PROTECT(D=R_igraph_vector_to_SEXP(&c_D)); igraph_vector_destroy(&c_D); IGRAPH_FINALLY_CLEAN(1); - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(options=Rx_igraph_arpack_options_to_SEXP(&c_options)); SET_VECTOR_ELT(result, 0, X); SET_VECTOR_ELT(result, 1, Y); SET_VECTOR_ELT(result, 2, D); @@ -8146,7 +8155,7 @@ SEXP R_igraph_laplacian_spectral_embedding(SEXP graph, SEXP no, PROTECT(D=R_igraph_0orvector_to_SEXP(&c_D)); igraph_vector_destroy(&c_D); IGRAPH_FINALLY_CLEAN(1); - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(options=Rx_igraph_arpack_options_to_SEXP(&c_options)); SET_VECTOR_ELT(result, 0, X); SET_VECTOR_ELT(result, 1, Y); SET_VECTOR_ELT(result, 2, D); @@ -8238,7 +8247,7 @@ SEXP R_igraph_bipartite_projection(SEXP graph, SEXP types, SEXP probe1, return(result); } -SEXP R_igraph_adjacent_vertices(SEXP pgraph, SEXP pv, SEXP pmode) { +SEXP Rx_igraph_adjacent_vertices(SEXP pgraph, SEXP pv, SEXP pmode) { igraph_t graph; igraph_vs_t vs; @@ -8284,7 +8293,7 @@ SEXP R_igraph_adjacent_vertices(SEXP pgraph, SEXP pv, SEXP pmode) { return result; } -SEXP R_igraph_incident_edges(SEXP pgraph, SEXP pe, SEXP pmode) { +SEXP Rx_igraph_incident_edges(SEXP pgraph, SEXP pe, SEXP pmode) { igraph_t graph; igraph_vs_t vs; @@ -8515,7 +8524,7 @@ int igraphhcass2(int n, const int *ia, const int *ib, return 0; } /* hcass2_ */ -SEXP R_igraph_get_all_simple_paths_pp(SEXP vector) { +SEXP Rx_igraph_get_all_simple_paths_pp(SEXP vector) { SEXP result; igraph_integer_t no=0, n=Rf_xlength(vector); double *vec=REAL(vector), *p=vec, *pp=vec; @@ -8536,30 +8545,30 @@ SEXP R_igraph_get_all_simple_paths_pp(SEXP vector) { return result; } -SEXP R_igraph_address(SEXP object) { +SEXP Rx_igraph_address(SEXP object) { char s[64]; snprintf(s, 64, "%p", (void*) object); return Rf_ScalarString(Rf_mkChar(s)); } -SEXP R_igraph_make_weak_ref(SEXP key, SEXP value, SEXP finalizer) { +SEXP Rx_igraph_make_weak_ref(SEXP key, SEXP value, SEXP finalizer) { return R_MakeWeakRef(key, value, finalizer, Rf_isNull(finalizer) ? 0 : 1); } -SEXP R_igraph_weak_ref_key(SEXP ref) { +SEXP Rx_igraph_weak_ref_key(SEXP ref) { return R_WeakRefKey(ref); } -SEXP R_igraph_weak_ref_value(SEXP ref) { +SEXP Rx_igraph_weak_ref_value(SEXP ref) { return R_WeakRefValue(ref); } -SEXP R_igraph_weak_ref_run_finalizer(SEXP ref) { +SEXP Rx_igraph_weak_ref_run_finalizer(SEXP ref) { R_RunWeakRefFinalizer(ref); return R_NilValue; } -SEXP R_igraph_identical_graphs(SEXP g1, SEXP g2, SEXP attrs) { +SEXP Rx_igraph_identical_graphs(SEXP g1, SEXP g2, SEXP attrs) { igraph_integer_t n = LOGICAL(attrs)[0] ? igraph_t_idx_attr + 1 : igraph_t_idx_attr; for (igraph_integer_t i = 0; i < n; i++) { if (!R_compute_identical(VECTOR_ELT(g1, i), VECTOR_ELT(g2, i), 0)) { @@ -8569,7 +8578,7 @@ SEXP R_igraph_identical_graphs(SEXP g1, SEXP g2, SEXP attrs) { return Rf_ScalarLogical(1); } -SEXP R_igraph_graph_version(SEXP graph) { +SEXP Rx_igraph_graph_version(SEXP graph) { if (Rf_xlength(graph) == 11) { return Rf_ScalarInteger(ver_0_1_1); } @@ -8590,7 +8599,7 @@ SEXP R_igraph_graph_version(SEXP graph) { return ver; } -SEXP R_igraph_add_myid_to_env(SEXP graph) { +SEXP Rx_igraph_add_myid_to_env(SEXP graph) { uuid_t my_id; char my_id_chr[40]; @@ -8604,7 +8613,7 @@ SEXP R_igraph_add_myid_to_env(SEXP graph) { return graph; } -SEXP R_igraph_add_version_to_env(SEXP graph) { +SEXP Rx_igraph_add_version_to_env(SEXP graph) { SEXP l1 = PROTECT(Rf_install(R_IGRAPH_VERSION_VAR)); SEXP l2 = PROTECT(Rf_ScalarInteger(ver_current)); Rf_defineVar(l1, l2, R_igraph_graph_env(graph)); @@ -8613,7 +8622,7 @@ SEXP R_igraph_add_version_to_env(SEXP graph) { return graph; } -SEXP R_igraph_add_env(SEXP graph) { +SEXP Rx_igraph_add_env(SEXP graph) { SEXP result = graph; R_xlen_t i; uuid_t my_id; @@ -8659,6 +8668,6 @@ SEXP R_igraph_add_env(SEXP graph) { return result; } -SEXP R_igraph_get_graph_id(SEXP graph) { +SEXP Rx_igraph_get_graph_id(SEXP graph) { return Rf_findVar(Rf_install("myid"), R_igraph_graph_env(graph)); } diff --git a/tests/testthat/_snaps/aaa-auto.md b/tests/testthat/_snaps/aaa-auto.md index b820114a9e0..6249283e3dd 100644 --- a/tests/testthat/_snaps/aaa-auto.md +++ b/tests/testthat/_snaps/aaa-auto.md @@ -9,7 +9,7 @@ --- Code - empty_impl(5, directed = FALSE) + empty_impl(n = 5, directed = FALSE) Output IGRAPH U--- 5 0 -- + edges: @@ -25,7 +25,7 @@ # add_edges_impl basic Code - add_edges_impl(g, c(0, 1, 1, 2)) + add_edges_impl(graph = g, edges = c(0, 1, 1, 2)) Output IGRAPH D--- 3 2 -- + edges: @@ -42,7 +42,7 @@ # copy_impl basic Code - copy_impl(g) + copy_impl(from = g) Output IGRAPH D--- 2 0 -- + edges: @@ -58,7 +58,7 @@ # delete_vertices_idx_impl basic Code - delete_vertices_idx_impl(g, 1) + delete_vertices_idx_impl(graph = g, vertices = 1) Output $graph IGRAPH D--- 2 0 -- @@ -82,7 +82,7 @@ # vcount_impl basic Code - vcount_impl(g) + vcount_impl(graph = g) Output [1] 4 @@ -97,14 +97,14 @@ # degree_impl basic Code - degree_impl(g) + degree_impl(graph = g) Output [1] 0 0 0 --- Code - degree_impl(g, mode = "in") + degree_impl(graph = g, mode = "in") Output [1] 0 0 0 @@ -119,7 +119,7 @@ # get_all_eids_between_impl basic Code - get_all_eids_between_impl(g, 1, 2) + get_all_eids_between_impl(graph = g, from = 1, to = 2) Output + 0/0 edges: @@ -134,7 +134,7 @@ # wheel_impl basic Code - wheel_impl(5) + wheel_impl(n = 5) Output IGRAPH D--- 5 8 -- + edges: @@ -143,7 +143,7 @@ --- Code - wheel_impl(5, mode = "in", center = 2) + wheel_impl(n = 5, mode = "in", center = 2) Output IGRAPH D--- 5 8 -- + edges: @@ -160,7 +160,7 @@ # hypercube_impl basic Code - hypercube_impl(3) + hypercube_impl(n = 3) Output IGRAPH U--- 8 12 -- + edges: @@ -169,7 +169,7 @@ --- Code - hypercube_impl(3, directed = TRUE) + hypercube_impl(n = 3, directed = TRUE) Output IGRAPH D--- 8 12 -- + edges: @@ -186,7 +186,7 @@ # square_lattice_impl basic Code - square_lattice_impl(c(2, 2)) + square_lattice_impl(dimvector = c(2, 2)) Output IGRAPH U--- 4 4 -- + edges: @@ -195,8 +195,8 @@ --- Code - square_lattice_impl(c(2, 2), nei = 2, directed = TRUE, mutual = TRUE, periodic = c( - TRUE, TRUE)) + square_lattice_impl(dimvector = c(2, 2), nei = 2, directed = TRUE, mutual = TRUE, + periodic = c(TRUE, TRUE)) Output IGRAPH D--- 4 10 -- + edges: @@ -213,7 +213,7 @@ # triangular_lattice_impl basic Code - triangular_lattice_impl(c(2, 2)) + triangular_lattice_impl(dimvector = c(2, 2)) Output IGRAPH U--- 4 5 -- + edges: @@ -222,7 +222,7 @@ --- Code - triangular_lattice_impl(c(2, 2), directed = TRUE, mutual = TRUE) + triangular_lattice_impl(dimvector = c(2, 2), directed = TRUE, mutual = TRUE) Output IGRAPH D--- 4 10 -- + edges: @@ -239,7 +239,7 @@ # path_graph_impl basic Code - path_graph_impl(5) + path_graph_impl(n = 5) Output IGRAPH U--- 5 4 -- + edges: @@ -248,7 +248,7 @@ --- Code - path_graph_impl(5, directed = TRUE, mutual = TRUE) + path_graph_impl(n = 5, directed = TRUE, mutual = TRUE) Output IGRAPH D--- 5 8 -- + edges: @@ -265,7 +265,7 @@ # cycle_graph_impl basic Code - cycle_graph_impl(5) + cycle_graph_impl(n = 5) Output IGRAPH U--- 5 5 -- + edges: @@ -274,7 +274,7 @@ --- Code - cycle_graph_impl(5, directed = TRUE, mutual = TRUE) + cycle_graph_impl(n = 5, directed = TRUE, mutual = TRUE) Output IGRAPH D--- 5 10 -- + edges: @@ -291,7 +291,7 @@ # symmetric_tree_impl basic Code - symmetric_tree_impl(3) + symmetric_tree_impl(branches = 3) Output IGRAPH D--- 4 3 -- + edges: @@ -300,7 +300,7 @@ --- Code - symmetric_tree_impl(3, type = "in") + symmetric_tree_impl(branches = 3, type = "in") Output IGRAPH D--- 4 3 -- + edges: @@ -317,7 +317,7 @@ # regular_tree_impl basic Code - regular_tree_impl(2) + regular_tree_impl(h = 2) Output IGRAPH U--- 10 9 -- + edges: @@ -326,7 +326,7 @@ --- Code - regular_tree_impl(2, k = 4, type = "in") + regular_tree_impl(h = 2, k = 4, type = "in") Output IGRAPH D--- 17 16 -- + edges: @@ -344,7 +344,7 @@ # full_citation_impl basic Code - full_citation_impl(5) + full_citation_impl(n = 5) Output IGRAPH D--- 5 10 -- + edges: @@ -353,7 +353,7 @@ --- Code - full_citation_impl(5, directed = FALSE) + full_citation_impl(n = 5, directed = FALSE) Output IGRAPH U--- 5 10 -- + edges: @@ -370,7 +370,7 @@ # atlas_impl basic Code - atlas_impl(0) + atlas_impl(number = 0) Output IGRAPH U--- 0 0 -- + edges: @@ -378,7 +378,7 @@ --- Code - atlas_impl(5) + atlas_impl(number = 5) Output IGRAPH U--- 3 1 -- + edge: @@ -395,7 +395,7 @@ # extended_chordal_ring_impl basic Code - extended_chordal_ring_impl(5, matrix(c(1, 2))) + extended_chordal_ring_impl(nodes = 5, W = matrix(c(1, 2))) Output IGRAPH U--- 5 15 -- + edges: @@ -404,7 +404,7 @@ --- Code - extended_chordal_ring_impl(5, matrix(c(1, 2)), directed = TRUE) + extended_chordal_ring_impl(nodes = 5, W = matrix(c(1, 2)), directed = TRUE) Output IGRAPH D--- 5 15 -- + edges: @@ -421,7 +421,7 @@ # graph_power_impl basic Code - graph_power_impl(g, 2) + graph_power_impl(graph = g, order = 2) Output IGRAPH U--- 5 7 -- + edges: @@ -430,7 +430,7 @@ --- Code - graph_power_impl(g, 2, directed = TRUE) + graph_power_impl(graph = g, order = 2, directed = TRUE) Output IGRAPH U--- 5 7 -- + edges: @@ -447,7 +447,7 @@ # linegraph_impl basic Code - linegraph_impl(g) + linegraph_impl(graph = g) Output IGRAPH U--- 4 3 -- + edges: @@ -464,7 +464,7 @@ # de_bruijn_impl basic Code - de_bruijn_impl(2, 3) + de_bruijn_impl(m = 2, n = 3) Output IGRAPH D--- 8 16 -- + edges: @@ -482,7 +482,7 @@ # kautz_impl basic Code - kautz_impl(2, 3) + kautz_impl(m = 2, n = 3) Output IGRAPH D--- 24 48 -- + edges: @@ -503,7 +503,7 @@ # lcf_vector_impl basic Code - lcf_vector_impl(10, c(3, -3, 4), 2) + lcf_vector_impl(n = 10, shifts = c(3, -3, 4), repeats = 2) Output IGRAPH U--- 10 16 -- LCF graph + attr: name (g/c) @@ -522,7 +522,7 @@ # mycielski_graph_impl basic Code - mycielski_graph_impl(3) + mycielski_graph_impl(k = 3) Output IGRAPH U--- 5 5 -- + edges: @@ -539,7 +539,7 @@ # adjlist_impl basic Code - adjlist_impl(list(c(2, 3), c(1), c(1)), mode = "out") + adjlist_impl(adjlist = list(c(2, 3), c(1), c(1)), mode = "out") Output IGRAPH D--- 3 4 -- + edges: @@ -556,7 +556,7 @@ # full_bipartite_impl basic Code - full_bipartite_impl(2, 3) + full_bipartite_impl(n1 = 2, n2 = 3) Output $graph IGRAPH U--- 5 6 -- @@ -570,7 +570,7 @@ --- Code - full_bipartite_impl(2, 3, directed = TRUE, mode = "in") + full_bipartite_impl(n1 = 2, n2 = 3, directed = TRUE, mode = "in") Output $graph IGRAPH D--- 5 6 -- @@ -592,7 +592,7 @@ # full_multipartite_impl basic Code - full_multipartite_impl(c(2, 3, 4)) + full_multipartite_impl(n = c(2, 3, 4)) Output $graph IGRAPH U--- 9 26 -- @@ -603,11 +603,20 @@ $types [1] 1 1 2 2 2 3 3 3 3 + $name + [1] "Full multipartite graph" + + $n + [1] 2 3 4 + + $mode + [1] 3 + --- Code - full_multipartite_impl(c(2, 3, 4), directed = TRUE, mode = "in") + full_multipartite_impl(n = c(2, 3, 4), directed = TRUE, mode = "in") Output $graph IGRAPH D--- 9 26 -- @@ -618,6 +627,15 @@ $types [1] 1 1 2 2 2 3 3 3 3 + $name + [1] "Full multipartite graph" + + $n + [1] 2 3 4 + + $mode + [1] 2 + # full_multipartite_impl errors @@ -630,7 +648,7 @@ # realize_degree_sequence_impl basic Code - realize_degree_sequence_impl(c(2, 2, 2)) + realize_degree_sequence_impl(out.deg = c(2, 2, 2)) Output IGRAPH U--- 3 3 -- Graph from degree sequence + attr: name (g/c), out.deg (g/n), in.deg (g/x), allowed.edge.types @@ -641,8 +659,8 @@ --- Code - realize_degree_sequence_impl(c(2, 2, 2), c(2, 2, 2), allowed.edge.types = "simple", - method = "largest") + realize_degree_sequence_impl(out.deg = c(2, 2, 2), in.deg = c(2, 2, 2), + allowed.edge.types = "simple", method = "largest") Output IGRAPH D--- 3 6 -- Graph from degree sequence + attr: name (g/c), out.deg (g/n), in.deg (g/n), allowed.edge.types @@ -661,7 +679,7 @@ # realize_bipartite_degree_sequence_impl basic Code - realize_bipartite_degree_sequence_impl(c(2, 2), c(2, 2)) + realize_bipartite_degree_sequence_impl(degrees1 = c(2, 2), degrees2 = c(2, 2)) Output IGRAPH U--- 4 4 -- Bipartite graph from degree sequence + attr: name (g/c), degrees1 (g/n), degrees2 (g/n), allowed.edge.types @@ -672,8 +690,8 @@ --- Code - realize_bipartite_degree_sequence_impl(c(2, 2), c(2, 2), allowed.edge.types = "loops", - method = "largest") + realize_bipartite_degree_sequence_impl(degrees1 = c(2, 2), degrees2 = c(2, 2), + allowed.edge.types = "loops", method = "largest") Output IGRAPH U--- 4 4 -- Bipartite graph from degree sequence + attr: name (g/c), degrees1 (g/n), degrees2 (g/n), allowed.edge.types @@ -692,18 +710,20 @@ # circulant_impl basic Code - circulant_impl(5, c(1, 2)) + circulant_impl(n = 5, shifts = c(1, 2)) Output - IGRAPH U--- 5 10 -- + IGRAPH U--- 5 10 -- Circulant graph + + attr: name (g/c), shifts (g/n) + edges: [1] 1--2 2--3 3--4 4--5 1--5 1--3 2--4 3--5 1--4 2--5 --- Code - circulant_impl(5, c(1, 2), directed = TRUE) + circulant_impl(n = 5, shifts = c(1, 2), directed = TRUE) Output - IGRAPH D--- 5 10 -- + IGRAPH D--- 5 10 -- Circulant graph + + attr: name (g/c), shifts (g/n) + edges: [1] 1->2 2->3 3->4 4->5 5->1 1->3 2->4 3->5 4->1 5->2 @@ -718,7 +738,7 @@ # generalized_petersen_impl basic Code - generalized_petersen_impl(5, 2) + generalized_petersen_impl(n = 5, k = 2) Output IGRAPH U--- 10 15 -- + edges: @@ -736,7 +756,7 @@ # turan_impl basic Code - turan_impl(5, 2) + turan_impl(n = 5, r = 2) Output $graph IGRAPH U--- 5 6 -- @@ -746,6 +766,15 @@ $types [1] 1 1 1 2 2 + $name + [1] "Turan graph" + + $n + [1] 5 + + $r + [1] 2 + # turan_impl errors @@ -758,7 +787,7 @@ # erdos_renyi_game_gnp_impl basic Code - erdos_renyi_game_gnp_impl(5, 0.5) + erdos_renyi_game_gnp_impl(n = 5, p = 0.5) Output IGRAPH U--- 5 7 -- + edges: @@ -767,7 +796,7 @@ --- Code - erdos_renyi_game_gnp_impl(5, 0.5, directed = TRUE, loops = TRUE) + erdos_renyi_game_gnp_impl(n = 5, p = 0.5, directed = TRUE, loops = TRUE) Output IGRAPH D--- 5 12 -- + edges: @@ -784,7 +813,7 @@ # erdos_renyi_game_gnm_impl basic Code - erdos_renyi_game_gnm_impl(5, 3) + erdos_renyi_game_gnm_impl(n = 5, m = 3) Output IGRAPH U--- 5 3 -- + edges: @@ -793,7 +822,7 @@ --- Code - erdos_renyi_game_gnm_impl(5, 3, directed = TRUE, loops = TRUE) + erdos_renyi_game_gnm_impl(n = 5, m = 3, directed = TRUE, loops = TRUE) Output IGRAPH D--- 5 3 -- + edges: @@ -810,7 +839,7 @@ # growing_random_game_impl basic Code - growing_random_game_impl(5, 2) + growing_random_game_impl(n = 5, m = 2) Output IGRAPH D--- 5 8 -- Growing random graph + attr: name (g/c), m (g/n), citation (g/l) @@ -820,7 +849,7 @@ --- Code - growing_random_game_impl(5, 2, directed = FALSE, citation = TRUE) + growing_random_game_impl(n = 5, m = 2, directed = FALSE, citation = TRUE) Output IGRAPH U--- 5 8 -- Growing random graph + attr: name (g/c), m (g/n), citation (g/l) @@ -838,8 +867,8 @@ # preference_game_impl basic Code - preference_game_impl(5, 2, c(0.5, 0.5), FALSE, matrix(c(0.5, 0.5, 0.5, 0.5), 2, - 2)) + preference_game_impl(nodes = 5, types = 2, type.dist = c(0.5, 0.5), + fixed.sizes = FALSE, pref.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2)) Output $graph IGRAPH U--- 5 4 -- @@ -861,8 +890,9 @@ # asymmetric_preference_game_impl basic Code - asymmetric_preference_game_impl(5, 2, 2, matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2), - matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2)) + asymmetric_preference_game_impl(nodes = 5, out.types = 2, in.types = 2, + type.dist.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2), pref.matrix = matrix( + c(0.5, 0.5, 0.5, 0.5), 2, 2)) Output $graph IGRAPH D--- 5 9 -- @@ -887,7 +917,7 @@ # rewire_edges_impl basic Code - rewire_edges_impl(g, 0.5) + rewire_edges_impl(graph = g, prob = 0.5) Output IGRAPH U--- 5 4 -- + edges: @@ -904,7 +934,7 @@ # rewire_directed_edges_impl basic Code - rewire_directed_edges_impl(g, 0.5) + rewire_directed_edges_impl(graph = g, prob = 0.5) Output IGRAPH D--- 5 4 -- + edges: @@ -921,7 +951,7 @@ # forest_fire_game_impl basic Code - forest_fire_game_impl(5, 0.5) + forest_fire_game_impl(nodes = 5, fw.prob = 0.5) Output IGRAPH D--- 5 9 -- Forest fire model + attr: name (g/c), fw.prob (g/n), bw.factor (g/n), ambs (g/n) @@ -931,7 +961,8 @@ --- Code - forest_fire_game_impl(5, 0.5, bw.factor = 0.2, ambs = 2, directed = FALSE) + forest_fire_game_impl(nodes = 5, fw.prob = 0.5, bw.factor = 0.2, ambs = 2, + directed = FALSE) Output IGRAPH U--- 5 4 -- Forest fire model + attr: name (g/c), fw.prob (g/n), bw.factor (g/n), ambs (g/n) @@ -949,7 +980,8 @@ # simple_interconnected_islands_game_impl basic Code - simple_interconnected_islands_game_impl(2, 3, 0.5, 1) + simple_interconnected_islands_game_impl(islands.n = 2, islands.size = 3, + islands.pin = 0.5, n.inter = 1) Output IGRAPH U--- 6 5 -- Interconnected islands model + attr: name (g/c), islands.n (g/n), islands.size (g/n), islands.pin @@ -968,7 +1000,7 @@ # chung_lu_game_impl basic Code - chung_lu_game_impl(c(2, 2, 2)) + chung_lu_game_impl(out.weights = c(2, 2, 2)) Output IGRAPH U--- 3 5 -- Chung-Lu model + attr: name (g/c), variant (g/n) @@ -978,7 +1010,8 @@ --- Code - chung_lu_game_impl(c(1, 2, 3), c(1, 2, 3), loops = FALSE, variant = "maxent") + chung_lu_game_impl(out.weights = c(1, 2, 3), in.weights = c(1, 2, 3), loops = FALSE, + variant = "maxent") Output IGRAPH D--- 3 1 -- Chung-Lu model + attr: name (g/c), variant (g/n) @@ -996,7 +1029,7 @@ # static_fitness_game_impl basic Code - static_fitness_game_impl(3, c(1, 2, 3)) + static_fitness_game_impl(no.of.edges = 3, fitness.out = c(1, 2, 3)) Output IGRAPH U--- 3 3 -- Static fitness model + attr: name (g/c), loops (g/l), multiple (g/l) @@ -1006,7 +1039,8 @@ --- Code - static_fitness_game_impl(3, c(1, 2, 3), c(1, 2, 3), loops = TRUE, multiple = TRUE) + static_fitness_game_impl(no.of.edges = 3, fitness.out = c(1, 2, 3), fitness.in = c( + 1, 2, 3), loops = TRUE, multiple = TRUE) Output IGRAPH D--- 3 3 -- Static fitness model + attr: name (g/c), loops (g/l), multiple (g/l) @@ -1024,7 +1058,7 @@ # static_power_law_game_impl basic Code - static_power_law_game_impl(5, 4, 2.5) + static_power_law_game_impl(no.of.nodes = 5, no.of.edges = 4, exponent.out = 2.5) Output IGRAPH U--- 5 4 -- Static power law model + attr: name (g/c), exponent.out (g/n), exponent.in (g/n), loops (g/l), @@ -1035,8 +1069,8 @@ --- Code - static_power_law_game_impl(5, 4, 2.5, exponent.in = 2, loops = TRUE, multiple = TRUE, - finite.size.correction = FALSE) + static_power_law_game_impl(no.of.nodes = 5, no.of.edges = 4, exponent.out = 2.5, + exponent.in = 2, loops = TRUE, multiple = TRUE, finite.size.correction = FALSE) Output IGRAPH D--- 5 4 -- Static power law model + attr: name (g/c), exponent.out (g/n), exponent.in (g/n), loops (g/l), @@ -1055,7 +1089,7 @@ # k_regular_game_impl basic Code - k_regular_game_impl(5, 2) + k_regular_game_impl(no.of.nodes = 5, k = 2) Output IGRAPH U--- 5 5 -- k-regular graph + attr: name (g/c), k (g/n) @@ -1065,7 +1099,7 @@ --- Code - k_regular_game_impl(5, 2, directed = TRUE, multiple = TRUE) + k_regular_game_impl(no.of.nodes = 5, k = 2, directed = TRUE, multiple = TRUE) Output IGRAPH D--- 5 10 -- k-regular graph + attr: name (g/c), k (g/n) @@ -1083,7 +1117,7 @@ # sbm_game_impl basic Code - sbm_game_impl(5, matrix(0.5, 2, 2), c(2, 3)) + sbm_game_impl(n = 5, pref.matrix = matrix(0.5, 2, 2), block.sizes = c(2, 3)) Output IGRAPH U--- 5 6 -- Stochastic block model + attr: name (g/c), loops (g/l) @@ -1093,7 +1127,8 @@ --- Code - sbm_game_impl(5, matrix(0.5, 2, 2), c(2, 3), directed = TRUE, loops = TRUE) + sbm_game_impl(n = 5, pref.matrix = matrix(0.5, 2, 2), block.sizes = c(2, 3), + directed = TRUE, loops = TRUE) Output IGRAPH D--- 5 14 -- Stochastic block model + attr: name (g/c), loops (g/l) @@ -1111,7 +1146,7 @@ # hsbm_game_impl basic Code - hsbm_game_impl(6, 2, c(0.5, 0.5), matrix(1, 2, 2), 0.5) + hsbm_game_impl(n = 6, m = 2, rho = c(0.5, 0.5), C = matrix(1, 2, 2), p = 0.5) Output IGRAPH U--- 6 9 -- Hierarchical stochastic block model + attr: name (g/c), m (g/n), rho (g/n), C (g/n), p (g/n) @@ -1129,8 +1164,8 @@ # hsbm_list_game_impl basic Code - hsbm_list_game_impl(100, list(50, 50), rho = list(c(3, 3, 4) / 10), C = list(C), - p = 1 / 20) + hsbm_list_game_impl(n = 100, mlist = list(50, 50), rholist = list(c(3, 3, 4) / + 10), Clist = list(C), p = 1 / 20) Output IGRAPH U--- 100 783 -- Hierarchical stochastic block model + attr: name (g/c), p (g/n) @@ -1156,7 +1191,7 @@ # correlated_game_impl basic Code - correlated_game_impl(g, 0.5) + correlated_game_impl(old.graph = g, corr = 0.5) Output IGRAPH U--- 5 3 -- Correlated random graph + attr: name (g/c), corr (g/n), p (g/n) @@ -1174,7 +1209,7 @@ # correlated_pair_game_impl basic Code - correlated_pair_game_impl(5, 0.5, 0.5) + correlated_pair_game_impl(n = 5, corr = 0.5, p = 0.5) Output $graph1 IGRAPH U--- 5 7 -- @@ -1190,7 +1225,7 @@ --- Code - correlated_pair_game_impl(5, 0.5, 0.5, directed = TRUE) + correlated_pair_game_impl(n = 5, corr = 0.5, p = 0.5, directed = TRUE) Output $graph1 IGRAPH D--- 5 10 -- @@ -1214,7 +1249,7 @@ # dot_product_game_impl basic Code - dot_product_game_impl(matrix(0.5, 5, 2)) + dot_product_game_impl(vecs = matrix(0.5, 5, 2)) Condition Warning in `dot_product_game_impl()`: At vendor/cigraph/src/games/dotproduct.c:90 : Greater than 1 connection probability in dot-product graph. @@ -1226,7 +1261,7 @@ --- Code - dot_product_game_impl(matrix(0.5, 5, 2), directed = TRUE) + dot_product_game_impl(vecs = matrix(0.5, 5, 2), directed = TRUE) Condition Warning in `dot_product_game_impl()`: At vendor/cigraph/src/games/dotproduct.c:90 : Greater than 1 connection probability in dot-product graph. @@ -1246,7 +1281,7 @@ # sample_sphere_surface_impl basic Code - sample_sphere_surface_impl(3, 5) + sample_sphere_surface_impl(dim = 3, n = 5) Output [,1] [,2] [,3] [,4] [,5] [1,] 0.87877523 0.8206548 0.1430028 0.6349227 0.99933629 @@ -1256,7 +1291,7 @@ --- Code - sample_sphere_surface_impl(3, 5, radius = 2, positive = FALSE) + sample_sphere_surface_impl(dim = 3, n = 5, radius = 2, positive = FALSE) Output [,1] [,2] [,3] [,4] [,5] [1,] -0.4904253 -1.4825368 -0.5141332 1.95644246 0.369407 @@ -1274,7 +1309,7 @@ # sample_sphere_volume_impl basic Code - sample_sphere_volume_impl(3, 5) + sample_sphere_volume_impl(dim = 3, n = 5) Output [,1] [,2] [,3] [,4] [,5] [1,] 0.67165090 0.6105364 0.09806950 0.4132698 0.73325518 @@ -1284,7 +1319,7 @@ --- Code - sample_sphere_volume_impl(3, 5, radius = 2, positive = FALSE) + sample_sphere_volume_impl(dim = 3, n = 5, radius = 2, positive = FALSE) Output [,1] [,2] [,3] [,4] [,5] [1,] 1.903629152 -1.3795904 -1.2061886 0.9035986 -1.1692436 @@ -1302,7 +1337,7 @@ # sample_dirichlet_impl basic Code - sample_dirichlet_impl(5, c(1, 1, 1)) + sample_dirichlet_impl(n = 5, alpha = c(1, 1, 1)) Output [,1] [,2] [,3] [,4] [,5] [1,] 0.6298008 0.4168413 0.29594281 0.2432340 0.1516815 @@ -1320,7 +1355,7 @@ # are_adjacent_impl basic Code - are_adjacent_impl(g, 1, 2) + are_adjacent_impl(graph = g, v1 = 1, v2 = 2) Output [1] TRUE @@ -1335,7 +1370,7 @@ # closeness_impl basic Code - closeness_impl(g) + closeness_impl(graph = g) Output $res [1] 0.3333333 0.5000000 0.3333333 @@ -1350,7 +1385,7 @@ --- Code - closeness_impl(g, mode = "in", normalized = TRUE) + closeness_impl(graph = g, mode = "in", normalized = TRUE) Output $res [1] 0.6666667 1.0000000 0.6666667 @@ -1373,7 +1408,7 @@ # closeness_cutoff_impl basic Code - closeness_cutoff_impl(g, cutoff = 2) + closeness_cutoff_impl(graph = g, cutoff = 2) Output $res [1] 0.3333333 0.5000000 0.3333333 @@ -1388,7 +1423,7 @@ --- Code - closeness_cutoff_impl(g, mode = "in", normalized = TRUE, cutoff = 1) + closeness_cutoff_impl(graph = g, mode = "in", normalized = TRUE, cutoff = 1) Output $res [1] 1 1 1 @@ -1411,7 +1446,7 @@ # get_shortest_path_impl basic Code - get_shortest_path_impl(g, 1, 3) + get_shortest_path_impl(graph = g, from = 1, to = 3) Output $vertices + 3/3 vertices: @@ -1433,7 +1468,7 @@ # get_shortest_path_bellman_ford_impl basic Code - get_shortest_path_bellman_ford_impl(g, 1, 3) + get_shortest_path_bellman_ford_impl(graph = g, from = 1, to = 3) Output $vertices + 3/3 vertices: @@ -1455,7 +1490,7 @@ # get_shortest_path_dijkstra_impl basic Code - get_shortest_path_dijkstra_impl(g, 1, 3) + get_shortest_path_dijkstra_impl(graph = g, from = 1, to = 3) Output $vertices + 3/3 vertices: @@ -1477,7 +1512,7 @@ # get_all_shortest_paths_impl basic Code - get_all_shortest_paths_impl(g, 1, 3) + get_all_shortest_paths_impl(graph = g, from = 1, to = 3) Output $vpaths $vpaths[[1]] @@ -1506,7 +1541,7 @@ # get_all_shortest_paths_dijkstra_impl basic Code - get_all_shortest_paths_dijkstra_impl(g, 1, 3) + get_all_shortest_paths_dijkstra_impl(graph = g, from = 1, to = 3) Output $vpaths $vpaths[[1]] @@ -1535,7 +1570,7 @@ # voronoi_impl basic Code - voronoi_impl(g, 1) + voronoi_impl(graph = g, generators = 1) Output $membership [1] 0 0 0 @@ -1547,7 +1582,7 @@ --- Code - voronoi_impl(g, 1, mode = "in", tiebreaker = "first") + voronoi_impl(graph = g, generators = 1, mode = "in", tiebreaker = "first") Output $membership [1] 0 0 0 @@ -1567,7 +1602,7 @@ # get_all_simple_paths_impl basic Code - get_all_simple_paths_impl(g, 1, 3) + get_all_simple_paths_impl(graph = g, from = 1, to = 3) Output + 3/3 vertices: [1] 1 2 3 @@ -1583,7 +1618,7 @@ # get_k_shortest_paths_impl basic Code - get_k_shortest_paths_impl(g, 1, 3, k = 2) + get_k_shortest_paths_impl(graph = g, from = 1, to = 3, k = 2) Output $vpaths $vpaths[[1]] @@ -1609,7 +1644,7 @@ # get_widest_path_impl basic Code - get_widest_path_impl(g, 1, 3, weights = c(1, 2)) + get_widest_path_impl(graph = g, from = 1, to = 3, weights = c(1, 2)) Output $vertices + 3/3 vertices: @@ -1631,7 +1666,7 @@ # get_widest_paths_impl basic Code - get_widest_paths_impl(g, 1, 3, weights = c(1, 2)) + get_widest_paths_impl(graph = g, from = 1, to = 3, weights = c(1, 2)) Output $vertices $vertices[[1]] @@ -1663,7 +1698,7 @@ # spanner_impl basic Code - spanner_impl(g, 2) + spanner_impl(graph = g, stretch = 2) Output + 2/2 edges: [1] 1--2 2--3 @@ -1679,7 +1714,7 @@ # betweenness_cutoff_impl basic Code - betweenness_cutoff_impl(g, cutoff = 2) + betweenness_cutoff_impl(graph = g, cutoff = 2) Output [1] 0 1 0 @@ -1694,7 +1729,7 @@ # betweenness_subset_impl basic Code - betweenness_subset_impl(g) + betweenness_subset_impl(graph = g) Output [1] 0 1 0 @@ -1709,7 +1744,7 @@ # edge_betweenness_impl basic Code - edge_betweenness_impl(g) + edge_betweenness_impl(graph = g) Output [1] 2 2 @@ -1724,7 +1759,7 @@ # edge_betweenness_cutoff_impl basic Code - edge_betweenness_cutoff_impl(g, cutoff = 2) + edge_betweenness_cutoff_impl(graph = g, cutoff = 2) Output [1] 2 2 @@ -1739,7 +1774,7 @@ # edge_betweenness_subset_impl basic Code - edge_betweenness_subset_impl(g) + edge_betweenness_subset_impl(graph = g) Output [1] 2 2 @@ -1754,7 +1789,7 @@ # harmonic_centrality_cutoff_impl basic Code - harmonic_centrality_cutoff_impl(g, cutoff = 2) + harmonic_centrality_cutoff_impl(graph = g, cutoff = 2) Output [1] 1.5 2.0 1.5 @@ -1769,7 +1804,7 @@ # personalized_pagerank_impl basic Code - personalized_pagerank_impl(g) + personalized_pagerank_impl(graph = g) Output $vector [1] 0.2567568 0.4864865 0.2567568 @@ -1784,7 +1819,7 @@ --- Code - personalized_pagerank_impl(g, algo = "arpack", damping = 0.9) + personalized_pagerank_impl(graph = g, algo = "arpack", damping = 0.9) Output $vector [1] 0.2543860 0.4912281 0.2543860 @@ -1866,14 +1901,15 @@ # personalized_pagerank_vs_impl basic Code - personalized_pagerank_vs_impl(g, reset.vids = 1) + personalized_pagerank_vs_impl(graph = g, reset.vids = 1) Output [1] 0.3452703 0.4594595 0.1952703 --- Code - personalized_pagerank_vs_impl(g, algo = "arpack", reset.vids = 1, details = TRUE) + personalized_pagerank_vs_impl(graph = g, algo = "arpack", reset.vids = 1, + details = TRUE) Output $vector [1] 0.3452703 0.4594595 0.1952703 @@ -1955,7 +1991,7 @@ # induced_subgraph_impl basic Code - induced_subgraph_impl(g, 1:2) + induced_subgraph_impl(graph = g, vids = 1:2) Output IGRAPH U--- 2 1 -- + edge: @@ -1972,7 +2008,7 @@ # subgraph_from_edges_impl basic Code - subgraph_from_edges_impl(g, 1) + subgraph_from_edges_impl(graph = g, eids = 1) Output IGRAPH U--- 2 1 -- + edge: @@ -1989,7 +2025,7 @@ # reverse_edges_impl basic Code - reverse_edges_impl(g) + reverse_edges_impl(graph = g) Output IGRAPH U--- 3 2 -- + edges: @@ -2006,7 +2042,7 @@ # path_length_hist_impl basic Code - path_length_hist_impl(g) + path_length_hist_impl(graph = g) Output $res [1] 2 1 @@ -2018,7 +2054,7 @@ --- Code - path_length_hist_impl(g, directed = FALSE) + path_length_hist_impl(graph = g, directed = FALSE) Output $res [1] 2 1 @@ -2038,7 +2074,7 @@ # simplify_impl basic Code - simplify_impl(g) + simplify_impl(graph = g) Output IGRAPH U--- 3 2 -- + edges: @@ -2047,7 +2083,7 @@ --- Code - simplify_impl(g, remove.multiple = FALSE, remove.loops = FALSE) + simplify_impl(graph = g, remove.multiple = FALSE, remove.loops = FALSE) Output IGRAPH U--- 3 2 -- + edges: @@ -2064,14 +2100,14 @@ # transitivity_undirected_impl basic Code - transitivity_undirected_impl(g) + transitivity_undirected_impl(graph = g) Output [1] 0 --- Code - transitivity_undirected_impl(g, mode = "zero") + transitivity_undirected_impl(graph = g, mode = "zero") Output [1] 0 @@ -2086,14 +2122,14 @@ # transitivity_local_undirected_impl basic Code - transitivity_local_undirected_impl(g) + transitivity_local_undirected_impl(graph = g) Output [1] NaN 0 NaN --- Code - transitivity_local_undirected_impl(g, mode = "zero") + transitivity_local_undirected_impl(graph = g, mode = "zero") Output [1] 0 0 0 @@ -2108,14 +2144,14 @@ # transitivity_avglocal_undirected_impl basic Code - transitivity_avglocal_undirected_impl(g) + transitivity_avglocal_undirected_impl(graph = g) Output [1] 0 --- Code - transitivity_avglocal_undirected_impl(g, mode = "zero") + transitivity_avglocal_undirected_impl(graph = g, mode = "zero") Output [1] 0 @@ -2130,7 +2166,7 @@ # transitivity_barrat_impl basic Code - transitivity_barrat_impl(g) + transitivity_barrat_impl(graph = g) Condition Warning in `transitivity_barrat_impl()`: At vendor/cigraph/src/properties/triangles.c:913 : No weights given for Barrat's transitivity, unweighted version is used. @@ -2140,7 +2176,7 @@ --- Code - transitivity_barrat_impl(g, mode = "zero") + transitivity_barrat_impl(graph = g, mode = "zero") Condition Warning in `transitivity_barrat_impl()`: At vendor/cigraph/src/properties/triangles.c:913 : No weights given for Barrat's transitivity, unweighted version is used. @@ -2158,14 +2194,14 @@ # ecc_impl basic Code - ecc_impl(g) + ecc_impl(graph = g) Output [1] NaN 0 NaN --- Code - ecc_impl(g, k = 3, offset = TRUE, normalize = FALSE) + ecc_impl(graph = g, k = 3, offset = TRUE, normalize = FALSE) Output [1] 1 1 1 @@ -2180,14 +2216,14 @@ # reciprocity_impl basic Code - reciprocity_impl(g) + reciprocity_impl(graph = g) Output [1] 1 --- Code - reciprocity_impl(g, ignore.loops = FALSE, mode = "ratio") + reciprocity_impl(graph = g, ignore.loops = FALSE, mode = "ratio") Output [1] 1 @@ -2202,14 +2238,14 @@ # maxdegree_impl basic Code - maxdegree_impl(g) + maxdegree_impl(graph = g) Output [1] 2 --- Code - maxdegree_impl(g, mode = "in", loops = FALSE) + maxdegree_impl(graph = g, mode = "in", loops = FALSE) Output [1] 2 @@ -2224,14 +2260,14 @@ # density_impl basic Code - density_impl(g) + density_impl(graph = g) Output [1] 0.6666667 --- Code - density_impl(g, loops = TRUE) + density_impl(graph = g, loops = TRUE) Output [1] 0.3333333 @@ -2246,14 +2282,14 @@ # mean_degree_impl basic Code - mean_degree_impl(g) + mean_degree_impl(graph = g) Output [1] 1.333333 --- Code - mean_degree_impl(g, loops = FALSE) + mean_degree_impl(graph = g, loops = FALSE) Output [1] 1.333333 @@ -2268,14 +2304,14 @@ # feedback_arc_set_impl basic Code - feedback_arc_set_impl(g) + feedback_arc_set_impl(graph = g) Output + 0/2 edges: --- Code - feedback_arc_set_impl(g, algo = "exact_ip") + feedback_arc_set_impl(graph = g, algo = "exact_ip") Output + 0/2 edges: @@ -2290,7 +2326,7 @@ # feedback_vertex_set_impl basic Code - feedback_vertex_set_impl(g) + feedback_vertex_set_impl(graph = g) Output + 0/3 vertices: @@ -2305,7 +2341,7 @@ # is_loop_impl basic Code - is_loop_impl(g) + is_loop_impl(graph = g) Output [1] FALSE FALSE @@ -2320,7 +2356,7 @@ # is_dag_impl basic Code - is_dag_impl(g) + is_dag_impl(graph = g) Output [1] FALSE @@ -2335,7 +2371,7 @@ # is_acyclic_impl basic Code - is_acyclic_impl(g) + is_acyclic_impl(graph = g) Output [1] TRUE @@ -2350,7 +2386,7 @@ # is_simple_impl basic Code - is_simple_impl(g) + is_simple_impl(graph = g) Output [1] TRUE @@ -2365,7 +2401,7 @@ # is_multiple_impl basic Code - is_multiple_impl(g) + is_multiple_impl(graph = g) Output [1] FALSE FALSE @@ -2380,7 +2416,7 @@ # has_loop_impl basic Code - has_loop_impl(g) + has_loop_impl(graph = g) Output [1] FALSE @@ -2395,7 +2431,7 @@ # has_multiple_impl basic Code - has_multiple_impl(g) + has_multiple_impl(graph = g) Output [1] FALSE @@ -2410,7 +2446,7 @@ # count_loops_impl basic Code - count_loops_impl(g) + count_loops_impl(graph = g) Output [1] 0 @@ -2425,7 +2461,7 @@ # count_multiple_impl basic Code - count_multiple_impl(g) + count_multiple_impl(graph = g) Output [1] 1 1 @@ -2440,7 +2476,7 @@ # is_perfect_impl basic Code - is_perfect_impl(g) + is_perfect_impl(graph = g) Output [1] TRUE @@ -2455,7 +2491,7 @@ # eigenvector_centrality_impl basic Code - eigenvector_centrality_impl(g) + eigenvector_centrality_impl(graph = g) Output $vector [1] 0.7071068 1.0000000 0.7071068 @@ -2529,7 +2565,7 @@ --- Code - eigenvector_centrality_impl(g, directed = TRUE, scale = FALSE) + eigenvector_centrality_impl(graph = g, directed = TRUE, scale = FALSE) Output $vector [1] 0.5000000 0.7071068 0.5000000 @@ -2611,7 +2647,7 @@ # hub_and_authority_scores_impl basic Code - hub_and_authority_scores_impl(g) + hub_and_authority_scores_impl(graph = g) Output $hub [1] 1 1 1 1 1 @@ -2688,7 +2724,7 @@ --- Code - hub_and_authority_scores_impl(g, scale = FALSE) + hub_and_authority_scores_impl(graph = g, scale = FALSE) Output $hub [1] 0.4472136 0.4472136 0.4472136 0.4472136 0.4472136 @@ -2773,7 +2809,7 @@ # unfold_tree_impl basic Code - unfold_tree_impl(g, roots = 1) + unfold_tree_impl(graph = g, roots = 1) Output $tree IGRAPH U--- 3 2 -- @@ -2787,7 +2823,7 @@ --- Code - unfold_tree_impl(g, mode = "in", roots = 1) + unfold_tree_impl(graph = g, mode = "in", roots = 1) Output $tree IGRAPH U--- 3 2 -- @@ -2809,14 +2845,14 @@ # is_mutual_impl basic Code - is_mutual_impl(g) + is_mutual_impl(graph = g) Output [1] TRUE TRUE --- Code - is_mutual_impl(g, loops = FALSE) + is_mutual_impl(graph = g, loops = FALSE) Output [1] TRUE TRUE @@ -2831,14 +2867,14 @@ # has_mutual_impl basic Code - has_mutual_impl(g) + has_mutual_impl(graph = g) Output [1] TRUE --- Code - has_mutual_impl(g, loops = FALSE) + has_mutual_impl(graph = g, loops = FALSE) Output [1] TRUE @@ -2853,7 +2889,7 @@ # maximum_cardinality_search_impl basic Code - maximum_cardinality_search_impl(g) + maximum_cardinality_search_impl(graph = g) Output $alpha [1] 3 2 1 @@ -2874,7 +2910,7 @@ # avg_nearest_neighbor_degree_impl basic Code - avg_nearest_neighbor_degree_impl(g) + avg_nearest_neighbor_degree_impl(graph = g) Output $knn [1] 2 1 2 @@ -2886,7 +2922,7 @@ --- Code - avg_nearest_neighbor_degree_impl(g, mode = "in", neighbor.degree.mode = "out") + avg_nearest_neighbor_degree_impl(graph = g, mode = "in", neighbor.degree.mode = "out") Output $knn [1] 2 1 2 @@ -2906,14 +2942,14 @@ # degree_correlation_vector_impl basic Code - degree_correlation_vector_impl(g) + degree_correlation_vector_impl(graph = g) Output [1] NaN 2 1 --- Code - degree_correlation_vector_impl(g, from.mode = "in", to.mode = "out", + degree_correlation_vector_impl(graph = g, from.mode = "in", to.mode = "out", directed.neighbors = FALSE) Output [1] NaN 2 1 @@ -2929,15 +2965,15 @@ # rich_club_sequence_impl basic Code - rich_club_sequence_impl(g, vertex.order = 1:3) + rich_club_sequence_impl(graph = g, vertex.order = 1:3) Output [1] 0.6666667 1.0000000 NaN --- Code - rich_club_sequence_impl(g, vertex.order = 1:3, normalized = FALSE, loops = TRUE, - directed = FALSE) + rich_club_sequence_impl(graph = g, vertex.order = 1:3, normalized = FALSE, + loops = TRUE, directed = FALSE) Output [1] 2 1 0 @@ -2952,14 +2988,14 @@ # strength_impl basic Code - strength_impl(g) + strength_impl(graph = g) Output [1] 1 2 1 --- Code - strength_impl(g, mode = "in", loops = FALSE) + strength_impl(graph = g, mode = "in", loops = FALSE) Output [1] 1 2 1 @@ -2974,14 +3010,14 @@ # centralization_impl basic Code - centralization_impl(c(1, 2, 3)) + centralization_impl(scores = c(1, 2, 3)) Output [1] Inf --- Code - centralization_impl(c(1, 2, 3), theoretical.max = 2, normalized = FALSE) + centralization_impl(scores = c(1, 2, 3), theoretical.max = 2, normalized = FALSE) Output [1] 3 @@ -2996,7 +3032,7 @@ # centralization_degree_impl basic Code - centralization_degree_impl(g) + centralization_degree_impl(graph = g) Output $res [1] 1 2 1 @@ -3011,7 +3047,7 @@ --- Code - centralization_degree_impl(g, mode = "in", loops = FALSE, normalized = FALSE) + centralization_degree_impl(graph = g, mode = "in", loops = FALSE, normalized = FALSE) Output $res [1] 1 2 1 @@ -3056,7 +3092,7 @@ # centralization_betweenness_impl basic Code - centralization_betweenness_impl(g) + centralization_betweenness_impl(graph = g) Output $res [1] 0 1 0 @@ -3071,7 +3107,7 @@ --- Code - centralization_betweenness_impl(g, directed = FALSE, normalized = FALSE) + centralization_betweenness_impl(graph = g, directed = FALSE, normalized = FALSE) Output $res [1] 0 1 0 @@ -3116,7 +3152,7 @@ # centralization_closeness_impl basic Code - centralization_closeness_impl(g) + centralization_closeness_impl(graph = g) Output $res [1] 0.6666667 1.0000000 0.6666667 @@ -3131,7 +3167,7 @@ --- Code - centralization_closeness_impl(g, mode = "in", normalized = FALSE) + centralization_closeness_impl(graph = g, mode = "in", normalized = FALSE) Output $res [1] 0.6666667 1.0000000 0.6666667 @@ -3176,7 +3212,7 @@ # centralization_eigenvector_centrality_impl basic Code - centralization_eigenvector_centrality_impl(g) + centralization_eigenvector_centrality_impl(graph = g) Output $vector [1] 0.7071068 1.0000000 0.7071068 @@ -3256,7 +3292,8 @@ --- Code - centralization_eigenvector_centrality_impl(g, directed = TRUE, normalized = FALSE) + centralization_eigenvector_centrality_impl(graph = g, directed = TRUE, + normalized = FALSE) Output $vector [1] 0.7071068 1.0000000 0.7071068 @@ -3366,14 +3403,15 @@ # assortativity_nominal_impl basic Code - assortativity_nominal_impl(g, c(1, 2, 1)) + assortativity_nominal_impl(graph = g, types = c(1, 2, 1)) Output [1] -1 --- Code - assortativity_nominal_impl(g, c(1, 2, 1), directed = FALSE, normalized = FALSE) + assortativity_nominal_impl(graph = g, types = c(1, 2, 1), directed = FALSE, + normalized = FALSE) Output [1] -0.5 @@ -3388,14 +3426,15 @@ # assortativity_impl basic Code - assortativity_impl(g, c(1, 2, 1)) + assortativity_impl(graph = g, values = c(1, 2, 1)) Output [1] -1 --- Code - assortativity_impl(g, c(1, 2, 1), directed = FALSE, normalized = FALSE) + assortativity_impl(graph = g, values = c(1, 2, 1), directed = FALSE, + normalized = FALSE) Output [1] -0.25 @@ -3410,14 +3449,14 @@ # assortativity_degree_impl basic Code - assortativity_degree_impl(g) + assortativity_degree_impl(graph = g) Output [1] -1 --- Code - assortativity_degree_impl(g, directed = FALSE) + assortativity_degree_impl(graph = g, directed = FALSE) Output [1] -1 @@ -3432,7 +3471,7 @@ # joint_degree_matrix_impl basic Code - joint_degree_matrix_impl(g) + joint_degree_matrix_impl(graph = g) Output [,1] [,2] [1,] 0 2 @@ -3441,7 +3480,7 @@ --- Code - joint_degree_matrix_impl(g, max.out.degree = 2, max.in.degree = 2) + joint_degree_matrix_impl(graph = g, max.out.degree = 2, max.in.degree = 2) Output [,1] [,2] [1,] 0 2 @@ -3458,7 +3497,7 @@ # joint_degree_distribution_impl basic Code - joint_degree_distribution_impl(g) + joint_degree_distribution_impl(graph = g) Output [,1] [,2] [,3] [1,] 0 0.0 0.0 @@ -3468,7 +3507,7 @@ --- Code - joint_degree_distribution_impl(g, from.mode = "in", to.mode = "out", + joint_degree_distribution_impl(graph = g, from.mode = "in", to.mode = "out", directed.neighbors = FALSE, normalized = FALSE, max.from.degree = 2, max.to.degree = 2) Output @@ -3488,7 +3527,7 @@ # joint_type_distribution_impl basic Code - joint_type_distribution_impl(g, from.types = c(1, 2, 1)) + joint_type_distribution_impl(graph = g, from.types = c(1, 2, 1)) Output [,1] [,2] [1,] 0.0 0.5 @@ -3497,8 +3536,8 @@ --- Code - joint_type_distribution_impl(g, from.types = c(1, 2, 1), to.types = c(1, 2, 1), - directed = FALSE, normalized = FALSE) + joint_type_distribution_impl(graph = g, from.types = c(1, 2, 1), to.types = c(1, + 2, 1), directed = FALSE, normalized = FALSE) Output [,1] [,2] [1,] 0 2 @@ -3515,7 +3554,7 @@ # contract_vertices_impl basic Code - contract_vertices_impl(g, c(1, 1, 2)) + contract_vertices_impl(graph = g, mapping = c(1, 1, 2)) Output IGRAPH U--- 2 2 -- + edges: @@ -3532,14 +3571,14 @@ # eccentricity_dijkstra_impl basic Code - eccentricity_dijkstra_impl(g) + eccentricity_dijkstra_impl(graph = g) Output [1] 2 1 2 --- Code - eccentricity_dijkstra_impl(g, mode = "in") + eccentricity_dijkstra_impl(graph = g, mode = "in") Output [1] 2 1 2 @@ -3554,7 +3593,7 @@ # graph_center_dijkstra_impl basic Code - graph_center_dijkstra_impl(g) + graph_center_dijkstra_impl(graph = g) Output + 1/3 vertex: [1] 2 @@ -3562,7 +3601,7 @@ --- Code - graph_center_dijkstra_impl(g, mode = "in") + graph_center_dijkstra_impl(graph = g, mode = "in") Output + 1/3 vertex: [1] 2 @@ -3578,14 +3617,14 @@ # radius_dijkstra_impl basic Code - radius_dijkstra_impl(g) + radius_dijkstra_impl(graph = g) Output [1] 1 --- Code - radius_dijkstra_impl(g, mode = "in") + radius_dijkstra_impl(graph = g, mode = "in") Output [1] 1 @@ -3600,7 +3639,7 @@ # pseudo_diameter_impl basic Code - pseudo_diameter_impl(g, 1) + pseudo_diameter_impl(graph = g, start.vid = 1) Output $diameter [1] 2 @@ -3615,7 +3654,7 @@ --- Code - pseudo_diameter_impl(g, 1, directed = FALSE, unconnected = FALSE) + pseudo_diameter_impl(graph = g, start.vid = 1, directed = FALSE, unconnected = FALSE) Output $diameter [1] 2 @@ -3638,7 +3677,7 @@ # pseudo_diameter_dijkstra_impl basic Code - pseudo_diameter_dijkstra_impl(g, start.vid = 1) + pseudo_diameter_dijkstra_impl(graph = g, start.vid = 1) Output $diameter [1] 2 @@ -3653,7 +3692,8 @@ --- Code - pseudo_diameter_dijkstra_impl(g, start.vid = 1, directed = FALSE, unconnected = FALSE) + pseudo_diameter_dijkstra_impl(graph = g, start.vid = 1, directed = FALSE, + unconnected = FALSE) Output $diameter [1] 2 @@ -3676,7 +3716,7 @@ # diversity_impl basic Code - diversity_impl(g) + diversity_impl(graph = g) Output [1] 0.0000000 0.9182958 0.0000000 @@ -3691,7 +3731,7 @@ # random_walk_impl basic Code - random_walk_impl(g, 1, 2) + random_walk_impl(graph = g, start = 1, steps = 2) Output $vertices + 3/3 vertices: @@ -3705,7 +3745,7 @@ --- Code - random_walk_impl(g, 1, 2, mode = "in", stuck = "error") + random_walk_impl(graph = g, start = 1, steps = 2, mode = "in", stuck = "error") Output $vertices + 3/3 vertices: @@ -3727,14 +3767,14 @@ # global_efficiency_impl basic Code - global_efficiency_impl(g) + global_efficiency_impl(graph = g) Output [1] 0.8333333 --- Code - global_efficiency_impl(g, directed = FALSE) + global_efficiency_impl(graph = g, directed = FALSE) Output [1] 0.8333333 @@ -3749,14 +3789,14 @@ # local_efficiency_impl basic Code - local_efficiency_impl(g) + local_efficiency_impl(graph = g) Output [1] 0 0 0 --- Code - local_efficiency_impl(g, directed = FALSE, mode = "in") + local_efficiency_impl(graph = g, directed = FALSE, mode = "in") Output [1] 0 0 0 @@ -3771,14 +3811,14 @@ # average_local_efficiency_impl basic Code - average_local_efficiency_impl(g) + average_local_efficiency_impl(graph = g) Output [1] 0 --- Code - average_local_efficiency_impl(g, directed = FALSE, mode = "in") + average_local_efficiency_impl(graph = g, directed = FALSE, mode = "in") Output [1] 0 @@ -3793,7 +3833,7 @@ # transitive_closure_dag_impl basic Code - transitive_closure_dag_impl(g) + transitive_closure_dag_impl(graph = g) Output IGRAPH D--- 3 3 -- + edges: @@ -3810,7 +3850,7 @@ # transitive_closure_impl basic Code - transitive_closure_impl(g) + transitive_closure_impl(graph = g) Output IGRAPH U--- 3 3 -- + edges: @@ -3827,7 +3867,7 @@ # trussness_impl basic Code - trussness_impl(g) + trussness_impl(graph = g) Output [1] 2 2 @@ -3842,14 +3882,15 @@ # is_graphical_impl basic Code - is_graphical_impl(c(2, 2, 2)) + is_graphical_impl(out.deg = c(2, 2, 2)) Output [1] TRUE --- Code - is_graphical_impl(c(2, 2, 2), c(1, 1, 1), allowed.edge.types = "all") + is_graphical_impl(out.deg = c(2, 2, 2), in.deg = c(1, 1, 1), + allowed.edge.types = "all") Output [1] FALSE @@ -3866,7 +3907,7 @@ # bfs_simple_impl basic Code - bfs_simple_impl(g, 1) + bfs_simple_impl(graph = g, root = 1) Output $order + 3/3 vertices: @@ -3882,7 +3923,7 @@ --- Code - bfs_simple_impl(g, 1, mode = "in") + bfs_simple_impl(graph = g, root = 1, mode = "in") Output $order + 3/3 vertices: @@ -3906,7 +3947,7 @@ # bipartite_projection_size_impl basic Code - bipartite_projection_size_impl(g) + bipartite_projection_size_impl(graph = g) Output $vcount1 [1] 2 @@ -3932,7 +3973,7 @@ # biadjacency_impl basic Code - biadjacency_impl(m) + biadjacency_impl(incidence = m) Output $graph IGRAPH U--- 5 4 -- @@ -3946,7 +3987,7 @@ --- Code - biadjacency_impl(m, directed = TRUE, mode = "in", multiple = TRUE) + biadjacency_impl(incidence = m, directed = TRUE, mode = "in", multiple = TRUE) Output $graph IGRAPH D--- 5 4 -- @@ -3970,7 +4011,7 @@ # get_biadjacency_impl basic Code - get_biadjacency_impl(g, c(TRUE, FALSE, TRUE)) + get_biadjacency_impl(graph = g, types = c(TRUE, FALSE, TRUE)) Output $res [,1] [,2] @@ -3994,7 +4035,7 @@ # is_bipartite_impl basic Code - is_bipartite_impl(g) + is_bipartite_impl(graph = g) Output $res [1] TRUE @@ -4014,7 +4055,7 @@ # bipartite_game_gnp_impl basic Code - bipartite_game_gnp_impl(2, 2, 0.5) + bipartite_game_gnp_impl(n1 = 2, n2 = 2, p = 0.5) Output $graph IGRAPH U--- 4 4 -- @@ -4028,7 +4069,7 @@ --- Code - bipartite_game_gnp_impl(2, 2, 0.5, directed = TRUE, mode = "in") + bipartite_game_gnp_impl(n1 = 2, n2 = 2, p = 0.5, directed = TRUE, mode = "in") Output $graph IGRAPH D--- 4 1 -- @@ -4050,7 +4091,7 @@ # bipartite_game_gnm_impl basic Code - bipartite_game_gnm_impl(2, 2, 1) + bipartite_game_gnm_impl(n1 = 2, n2 = 2, m = 1) Output $graph IGRAPH U--- 4 1 -- @@ -4064,7 +4105,7 @@ --- Code - bipartite_game_gnm_impl(2, 2, 1, directed = TRUE, mode = "in") + bipartite_game_gnm_impl(n1 = 2, n2 = 2, m = 1, directed = TRUE, mode = "in") Output $graph IGRAPH D--- 4 1 -- @@ -4086,7 +4127,7 @@ # get_laplacian_impl basic Code - get_laplacian_impl(g) + get_laplacian_impl(graph = g) Output [,1] [,2] [,3] [1,] 1 -1 0 @@ -4096,8 +4137,8 @@ --- Code - get_laplacian_impl(g, mode = "in", normalization = "symmetric", weights = c(1, - 2)) + get_laplacian_impl(graph = g, mode = "in", normalization = "symmetric", + weights = c(1, 2)) Output [,1] [,2] [,3] [1,] 1.0000000 -0.5773503 0.0000000 @@ -4115,7 +4156,7 @@ # get_laplacian_sparse_impl basic Code - get_laplacian_sparse_impl(g) + get_laplacian_sparse_impl(graph = g) Output $type [1] "triplet" @@ -4138,8 +4179,8 @@ --- Code - get_laplacian_sparse_impl(g, mode = "in", normalization = "symmetric", weights = c( - 1, 2)) + get_laplacian_sparse_impl(graph = g, mode = "in", normalization = "symmetric", + weights = c(1, 2)) Output $type [1] "triplet" @@ -4170,14 +4211,14 @@ # connected_components_impl basic Code - connected_components_impl(g) + connected_components_impl(graph = g) Output [1] 0 0 0 --- Code - connected_components_impl(g, mode = "strong", details = TRUE) + connected_components_impl(graph = g, mode = "strong", details = TRUE) Output $membership [1] 0 0 0 @@ -4200,14 +4241,14 @@ # is_connected_impl basic Code - is_connected_impl(g) + is_connected_impl(graph = g) Output [1] TRUE --- Code - is_connected_impl(g, mode = "strong") + is_connected_impl(graph = g, mode = "strong") Output [1] TRUE @@ -4222,7 +4263,7 @@ # articulation_points_impl basic Code - articulation_points_impl(g) + articulation_points_impl(graph = g) Output + 1/3 vertex: [1] 2 @@ -4238,7 +4279,7 @@ # biconnected_components_impl basic Code - biconnected_components_impl(g) + biconnected_components_impl(graph = g) Output $no [1] 2 @@ -4293,7 +4334,7 @@ # bridges_impl basic Code - bridges_impl(g) + bridges_impl(graph = g) Output + 2/2 edges: [1] 2--3 1--2 @@ -4309,7 +4350,7 @@ # is_biconnected_impl basic Code - is_biconnected_impl(g) + is_biconnected_impl(graph = g) Output [1] FALSE @@ -4324,14 +4365,14 @@ # count_reachable_impl basic Code - count_reachable_impl(g, mode = "out") + count_reachable_impl(graph = g, mode = "out") Output [1] 5 5 5 5 5 --- Code - count_reachable_impl(g, mode = "in") + count_reachable_impl(graph = g, mode = "in") Output [1] 5 5 5 5 5 @@ -4346,7 +4387,7 @@ # bond_percolation_impl basic Code - bond_percolation_impl(g) + bond_percolation_impl(graph = g) Output $giant_size numeric(0) @@ -4366,7 +4407,7 @@ # site_percolation_impl basic Code - site_percolation_impl(g) + site_percolation_impl(graph = g) Output $giant_size numeric(0) @@ -4386,7 +4427,7 @@ # edgelist_percolation_impl basic Code - edgelist_percolation_impl(matrix(c(1, 2, 2, 3), ncol = 2)) + edgelist_percolation_impl(edges = matrix(c(1, 2, 2, 3), ncol = 2)) Output $giant_size [1] 2 3 @@ -4406,14 +4447,14 @@ # is_clique_impl basic Code - is_clique_impl(g, 1:2) + is_clique_impl(graph = g, candidate = 1:2) Output [1] TRUE --- Code - is_clique_impl(g, 1:2, directed = TRUE) + is_clique_impl(graph = g, candidate = 1:2, directed = TRUE) Output [1] TRUE @@ -4428,7 +4469,7 @@ # cliques_impl basic Code - cliques_impl(g) + cliques_impl(graph = g) Output [[1]] + 1/3 vertex: @@ -4454,7 +4495,7 @@ --- Code - cliques_impl(g, min = 2, max = 2) + cliques_impl(graph = g, min = 2, max = 2) Output [[1]] + 2/3 vertices: @@ -4476,14 +4517,14 @@ # clique_size_hist_impl basic Code - clique_size_hist_impl(g) + clique_size_hist_impl(graph = g) Output [1] 3 2 --- Code - clique_size_hist_impl(g, min.size = 2, max.size = 2) + clique_size_hist_impl(graph = g, min.size = 2, max.size = 2) Output [1] 0 2 @@ -4498,7 +4539,7 @@ # largest_cliques_impl basic Code - largest_cliques_impl(g) + largest_cliques_impl(graph = g) Output [[1]] + 2/3 vertices: @@ -4520,14 +4561,14 @@ # maximal_cliques_hist_impl basic Code - maximal_cliques_hist_impl(g) + maximal_cliques_hist_impl(graph = g) Output [1] 0 2 --- Code - maximal_cliques_hist_impl(g, min.size = 2, max.size = 2) + maximal_cliques_hist_impl(graph = g, min.size = 2, max.size = 2) Output [1] 0 2 @@ -4542,7 +4583,7 @@ # clique_number_impl basic Code - clique_number_impl(g) + clique_number_impl(graph = g) Output [1] 2 @@ -4557,7 +4598,7 @@ # weighted_cliques_impl basic Code - weighted_cliques_impl(g) + weighted_cliques_impl(graph = g) Output [[1]] + 1/3 vertex: @@ -4583,7 +4624,7 @@ --- Code - weighted_cliques_impl(g, vertex.weights = c(1, 2, 3), min.weight = 1, + weighted_cliques_impl(graph = g, vertex.weights = c(1, 2, 3), min.weight = 1, max.weight = 3, maximal = TRUE) Output [[1]] @@ -4602,7 +4643,7 @@ # largest_weighted_cliques_impl basic Code - largest_weighted_cliques_impl(g) + largest_weighted_cliques_impl(graph = g) Output [[1]] + 2/3 vertices: @@ -4616,7 +4657,7 @@ --- Code - largest_weighted_cliques_impl(g, vertex.weights = c(1, 2, 3)) + largest_weighted_cliques_impl(graph = g, vertex.weights = c(1, 2, 3)) Output [[1]] + 2/3 vertices: @@ -4634,14 +4675,14 @@ # weighted_clique_number_impl basic Code - weighted_clique_number_impl(g) + weighted_clique_number_impl(graph = g) Output [1] 2 --- Code - weighted_clique_number_impl(g, vertex.weights = c(1, 2, 3)) + weighted_clique_number_impl(graph = g, vertex.weights = c(1, 2, 3)) Output [1] 5 @@ -4656,7 +4697,7 @@ # is_independent_vertex_set_impl basic Code - is_independent_vertex_set_impl(g, 1:2) + is_independent_vertex_set_impl(graph = g, candidate = 1:2) Output [1] FALSE @@ -4671,7 +4712,7 @@ # layout_random_impl basic Code - layout_random_impl(g) + layout_random_impl(graph = g) Output [,1] [,2] [1,] 0.91714717 0.7003783 @@ -4689,7 +4730,7 @@ # layout_circle_impl basic Code - layout_circle_impl(g) + layout_circle_impl(graph = g) Output [,1] [,2] [1,] 1.0 0.0000000 @@ -4699,7 +4740,7 @@ --- Code - layout_circle_impl(g, order = 1:3) + layout_circle_impl(graph = g, order = 1:3) Output [,1] [,2] [1,] 1.0 0.0000000 @@ -4717,7 +4758,7 @@ # layout_star_impl basic Code - round(layout_star_impl(g), 4) + round(layout_star_impl(graph = g), 4) Output [,1] [,2] [1,] 0 0 @@ -4727,7 +4768,7 @@ --- Code - round(layout_star_impl(g, center = 1, order = 3:1), 4) + round(layout_star_impl(graph = g, center = 1, order = 3:1), 4) Output [,1] [,2] [1,] 0 0 @@ -4745,7 +4786,7 @@ # layout_grid_impl basic Code - layout_grid_impl(g) + layout_grid_impl(graph = g) Output [,1] [,2] [1,] 0 0 @@ -4755,7 +4796,7 @@ --- Code - layout_grid_impl(g, width = 2) + layout_grid_impl(graph = g, width = 2) Output [,1] [,2] [1,] 0 0 @@ -4773,7 +4814,7 @@ # layout_grid_3d_impl basic Code - layout_grid_3d_impl(g) + layout_grid_3d_impl(graph = g) Output [,1] [,2] [,3] [1,] 0 0 0 @@ -4783,7 +4824,7 @@ --- Code - layout_grid_3d_impl(g, width = 2, height = 2) + layout_grid_3d_impl(graph = g, width = 2, height = 2) Output [,1] [,2] [,3] [1,] 0 0 0 @@ -4801,7 +4842,7 @@ # roots_for_tree_layout_impl basic Code - roots_for_tree_layout_impl(g, mode = "out", heuristic = 1) + roots_for_tree_layout_impl(graph = g, mode = "out", heuristic = 1) Output + 1/3 vertex: [1] 2 @@ -4817,7 +4858,7 @@ # layout_random_3d_impl basic Code - layout_random_3d_impl(g) + layout_random_3d_impl(graph = g) Output [,1] [,2] [,3] [1,] 0.91714717 0.7003783 0.7338074 @@ -4835,7 +4876,7 @@ # layout_sphere_impl basic Code - layout_sphere_impl(g) + layout_sphere_impl(graph = g) Output [,1] [,2] [,3] [1,] 0.0000000 0.0000000 -1 @@ -4853,7 +4894,7 @@ # layout_sugiyama_impl basic Code - layout_sugiyama_impl(g) + layout_sugiyama_impl(graph = g) Output $res [,1] [,2] @@ -4873,7 +4914,7 @@ --- Code - layout_sugiyama_impl(g, layers = 1:3, hgap = 2, vgap = 2, maxiter = 10, + layout_sugiyama_impl(graph = g, layers = 1:3, hgap = 2, vgap = 2, maxiter = 10, weights = c(1, 2)) Output $res @@ -4902,7 +4943,7 @@ # layout_mds_impl basic Code - layout_mds_impl(g) + layout_mds_impl(graph = g) Output [,1] [,2] [1,] 1 2.807594e-08 @@ -4912,7 +4953,7 @@ --- Code - layout_mds_impl(g, dist = matrix(1:9, nrow = 3), dim = 3) + layout_mds_impl(graph = g, dist = matrix(1:9, nrow = 3), dim = 3) Output [,1] [,2] [,3] [1,] -2.907521 2.32638426 1.444979 @@ -4930,7 +4971,7 @@ # layout_bipartite_impl basic Code - layout_bipartite_impl(g, types = c(TRUE, FALSE, TRUE)) + layout_bipartite_impl(graph = g, types = c(TRUE, FALSE, TRUE)) Output [,1] [,2] [1,] 0.0 0 @@ -4940,7 +4981,7 @@ --- Code - layout_bipartite_impl(g, types = c(TRUE, FALSE, TRUE), hgap = 2, vgap = 2, + layout_bipartite_impl(graph = g, types = c(TRUE, FALSE, TRUE), hgap = 2, vgap = 2, maxiter = 10) Output [,1] [,2] @@ -4959,7 +5000,7 @@ # layout_gem_impl basic Code - layout_gem_impl(g, res = matrix(0, nrow = 3, ncol = 2)) + layout_gem_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2)) Output [,1] [,2] [1,] 200.18284 -69.23950 @@ -4969,7 +5010,7 @@ --- Code - layout_gem_impl(g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE, + layout_gem_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE, maxiter = 10, temp.max = 2, temp.min = 0.1, temp.init = 1) Output [,1] [,2] @@ -4988,7 +5029,7 @@ # layout_davidson_harel_impl basic Code - layout_davidson_harel_impl(g, res = matrix(0, nrow = 3, ncol = 2)) + layout_davidson_harel_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2)) Output [,1] [,2] [1,] 1.152116 0.9424808 @@ -4998,8 +5039,8 @@ --- Code - layout_davidson_harel_impl(g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE, - maxiter = 10, fineiter = 5, cool.fact = 0.5, weight.node.dist = 2, + layout_davidson_harel_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2), + use.seed = TRUE, maxiter = 10, fineiter = 5, cool.fact = 0.5, weight.node.dist = 2, weight.border = 1, weight.edge.lengths = 0.1, weight.edge.crossings = 0.2, weight.node.edge.dist = 0.3) Output @@ -5019,7 +5060,7 @@ # layout_umap_impl basic Code - layout_umap_impl(g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE) + layout_umap_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE) Output [,1] [,2] [1,] 0 0 @@ -5029,7 +5070,7 @@ --- Code - layout_umap_impl(g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE, + layout_umap_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE, distances = 1:3, min.dist = 0.1, epochs = 10, distances.are.weights = TRUE) Output [,1] [,2] @@ -5048,7 +5089,7 @@ # layout_umap_3d_impl basic Code - layout_umap_3d_impl(g, res = matrix(0, nrow = 3, ncol = 3), use.see = TRUE) + layout_umap_3d_impl(graph = g, res = matrix(0, nrow = 3, ncol = 3), use.seed = TRUE) Output [,1] [,2] [,3] [1,] 0 0 0 @@ -5058,7 +5099,7 @@ --- Code - layout_umap_3d_impl(g, res = matrix(0, nrow = 3, ncol = 3), use.seed = TRUE, + layout_umap_3d_impl(graph = g, res = matrix(0, nrow = 3, ncol = 3), use.seed = TRUE, distances = 1:3, min.dist = 0.1, epochs = 10, distances.are.weights = TRUE) Output [,1] [,2] [,3] @@ -5077,7 +5118,7 @@ # layout_umap_compute_weights_impl basic Code - layout_umap_compute_weights_impl(g, distances = 1:2, weights = 1:3) + layout_umap_compute_weights_impl(graph = g, distances = 1:2, weights = 1:3) Output [1] 1 1 @@ -5092,7 +5133,7 @@ # layout_align_impl basic Code - layout_align_impl(g, layout = matrix(0, nrow = 3, ncol = 2)) + layout_align_impl(graph = g, layout = matrix(0, nrow = 3, ncol = 2)) Output [,1] [,2] [1,] 0 0 @@ -5110,7 +5151,7 @@ # similarity_dice_impl basic Code - similarity_dice_impl(g) + similarity_dice_impl(graph = g) Output [,1] [,2] [,3] [1,] 1 0 1 @@ -5120,7 +5161,7 @@ --- Code - similarity_dice_impl(g, vids = 1:2, mode = "in", loops = TRUE) + similarity_dice_impl(graph = g, vids = 1:2, mode = "in", loops = TRUE) Output [,1] [,2] [1,] 1.0 0.8 @@ -5137,14 +5178,14 @@ # similarity_dice_es_impl basic Code - similarity_dice_es_impl(g) + similarity_dice_es_impl(graph = g) Output [1] 0 0 --- Code - similarity_dice_es_impl(g, es = 1:2, mode = "in", loops = TRUE) + similarity_dice_es_impl(graph = g, es = 1:2, mode = "in", loops = TRUE) Output [1] 0.8 0.8 @@ -5159,15 +5200,15 @@ # similarity_dice_pairs_impl basic Code - similarity_dice_pairs_impl(g, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) + similarity_dice_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) Output [1] 0 0 --- Code - similarity_dice_pairs_impl(g, pairs = matrix(c(1, 2, 2, 3), ncol = 2), mode = "in", - loops = TRUE) + similarity_dice_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2), + mode = "in", loops = TRUE) Output [1] 0.6666667 0.8000000 @@ -5182,7 +5223,7 @@ # similarity_inverse_log_weighted_impl basic Code - similarity_inverse_log_weighted_impl(g) + similarity_inverse_log_weighted_impl(graph = g) Output [,1] [,2] [,3] [1,] 0.000000 0 1.442695 @@ -5192,7 +5233,7 @@ --- Code - similarity_inverse_log_weighted_impl(g, vids = 1:2, mode = "in") + similarity_inverse_log_weighted_impl(graph = g, vids = 1:2, mode = "in") Output [,1] [,2] [,3] [1,] 0 0 1.442695 @@ -5209,7 +5250,7 @@ # similarity_jaccard_impl basic Code - similarity_jaccard_impl(g) + similarity_jaccard_impl(graph = g) Output [,1] [,2] [,3] [1,] 1 0 1 @@ -5219,7 +5260,7 @@ --- Code - similarity_jaccard_impl(g, vids = 1:2, mode = "in", loops = TRUE) + similarity_jaccard_impl(graph = g, vids = 1:2, mode = "in", loops = TRUE) Output [,1] [,2] [1,] 1.0000000 0.6666667 @@ -5236,14 +5277,14 @@ # similarity_jaccard_es_impl basic Code - similarity_jaccard_es_impl(g) + similarity_jaccard_es_impl(graph = g) Output [1] 0 0 --- Code - similarity_jaccard_es_impl(g, es = 1:2, mode = "in", loops = TRUE) + similarity_jaccard_es_impl(graph = g, es = 1:2, mode = "in", loops = TRUE) Output [1] 0.6666667 0.6666667 @@ -5258,15 +5299,15 @@ # similarity_jaccard_pairs_impl basic Code - similarity_jaccard_pairs_impl(g, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) + similarity_jaccard_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) Output [1] 0 0 --- Code - similarity_jaccard_pairs_impl(g, pairs = matrix(c(1, 2, 2, 3), ncol = 2), mode = "in", - loops = TRUE) + similarity_jaccard_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2), + mode = "in", loops = TRUE) Output [1] 0.5000000 0.6666667 @@ -5281,14 +5322,14 @@ # compare_communities_impl basic Code - compare_communities_impl(c(1, 2, 1), c(2, 1, 2)) + compare_communities_impl(comm1 = c(1, 2, 1), comm2 = c(2, 1, 2)) Output [1] 0 --- Code - compare_communities_impl(c(1, 2, 1), c(2, 1, 2), method = "nmi") + compare_communities_impl(comm1 = c(1, 2, 1), comm2 = c(2, 1, 2), method = "nmi") Output [1] 1 @@ -5305,15 +5346,15 @@ # modularity_impl basic Code - modularity_impl(g, membership = c(1, 2, 1)) + modularity_impl(graph = g, membership = c(1, 2, 1)) Output [1] -0.5 --- Code - modularity_impl(g, membership = c(1, 2, 1), weights = c(1, 2), resolution = 0.5, - directed = FALSE) + modularity_impl(graph = g, membership = c(1, 2, 1), weights = c(1, 2), + resolution = 0.5, directed = FALSE) Output [1] -0.25 @@ -5328,7 +5369,7 @@ # modularity_matrix_impl basic Code - modularity_matrix_impl(g) + modularity_matrix_impl(graph = g) Output [,1] [,2] [,3] [1,] -0.25 0.5 -0.25 @@ -5338,7 +5379,8 @@ --- Code - modularity_matrix_impl(g, weights = c(1, 2), resolution = 0.5, directed = FALSE) + modularity_matrix_impl(graph = g, weights = c(1, 2), resolution = 0.5, + directed = FALSE) Output [,1] [,2] [,3] [1,] -0.08333333 0.75 -0.1666667 @@ -5356,7 +5398,7 @@ # community_fluid_communities_impl basic Code - community_fluid_communities_impl(g, no.of.communities = 2) + community_fluid_communities_impl(graph = g, no.of.communities = 2) Output [1] 1 0 0 @@ -5371,15 +5413,15 @@ # community_label_propagation_impl basic Code - community_label_propagation_impl(g) + community_label_propagation_impl(graph = g) Output [1] 0 0 0 --- Code - community_label_propagation_impl(g, mode = "in", weights = c(1, 2), initial = 1: - 3, fixed = c(TRUE, FALSE, TRUE)) + community_label_propagation_impl(graph = g, mode = "in", weights = c(1, 2), + initial = 1:3, fixed = c(TRUE, FALSE, TRUE)) Output [1] 0 1 1 @@ -5394,7 +5436,7 @@ # community_multilevel_impl basic Code - community_multilevel_impl(g) + community_multilevel_impl(graph = g) Output $membership [1] 0 0 0 @@ -5410,7 +5452,7 @@ --- Code - community_multilevel_impl(g, weights = c(1, 2), resolution = 0.5) + community_multilevel_impl(graph = g, weights = c(1, 2), resolution = 0.5) Output $membership [1] 0 0 0 @@ -5434,7 +5476,7 @@ # community_optimal_modularity_impl basic Code - community_optimal_modularity_impl(g) + community_optimal_modularity_impl(graph = g) Output $modularity [1] 0 @@ -5446,7 +5488,7 @@ --- Code - community_optimal_modularity_impl(g, weights = c(1, 2)) + community_optimal_modularity_impl(graph = g, weights = c(1, 2)) Output $modularity [1] 1.850372e-17 @@ -5466,7 +5508,7 @@ # community_leiden_impl basic Code - community_leiden_impl(g, weights = c(1, 2), vertex.weights = c(1, 2, 3), + community_leiden_impl(graph = g, weights = c(1, 2), vertex.weights = c(1, 2, 3), resolution = 0.5, beta = 0.1, start = TRUE, n.iterations = 1, membership = 1:3) Output $membership @@ -5490,7 +5532,7 @@ # split_join_distance_impl basic Code - split_join_distance_impl(c(1, 2, 1), c(2, 1, 2)) + split_join_distance_impl(comm1 = c(1, 2, 1), comm2 = c(2, 1, 2)) Output $distance12 [1] 0 @@ -5512,7 +5554,7 @@ # community_infomap_impl basic Code - community_infomap_impl(g) + community_infomap_impl(graph = g) Output $membership [1] 0 0 0 @@ -5524,7 +5566,7 @@ --- Code - community_infomap_impl(g, e.weights = c(1, 2), v.weights = c(1, 2, 3), + community_infomap_impl(graph = g, e.weights = c(1, 2), v.weights = c(1, 2, 3), nb.trials = 2) Output $membership @@ -5545,7 +5587,7 @@ # graphlets_impl basic Code - graphlets_impl(g) + graphlets_impl(graph = g) Output $cliques $cliques[[1]] @@ -5564,7 +5606,7 @@ --- Code - graphlets_impl(g, weights = c(3, 4), niter = 10) + graphlets_impl(graph = g, weights = c(3, 4), niter = 10) Output $cliques $cliques[[1]] @@ -5591,7 +5633,7 @@ # hrg_fit_impl basic Code - hrg_fit_impl(g1) + hrg_fit_impl(graph = g1) Output $left [1] -2 0 @@ -5620,7 +5662,7 @@ # hrg_sample_impl basic Code - hrg_sample_impl(hrg_model) + hrg_sample_impl(hrg = hrg_model) Output IGRAPH U--- 10 45 -- + edges: @@ -5641,7 +5683,7 @@ # hrg_sample_many_impl basic Code - hrg_sample_many_impl(hrg_model, num.samples = 2) + hrg_sample_many_impl(hrg = hrg_model, num.samples = 2) Output [[1]] IGRAPH U--- 10 45 -- @@ -5672,7 +5714,7 @@ # hrg_game_impl basic Code - hrg_game_impl(hrg_model) + hrg_game_impl(hrg = hrg_model) Output IGRAPH U--- 10 45 -- Hierarchical random graph model + attr: name (g/c) @@ -5710,7 +5752,7 @@ # hrg_create_impl basic Code - hrg_create_impl(g, prob = rep(0.5, 2)) + hrg_create_impl(graph = g, prob = rep(0.5, 2)) Output Hierarchical random graph, at level 3: g1 p=0.5 1 @@ -5727,7 +5769,7 @@ # hrg_resize_impl basic Code - hrg_resize_impl(hrg_model, newsize = 5) + hrg_resize_impl(hrg = hrg_model, newsize = 5) Output $left [1] 0 -9 -6 -2 @@ -5756,7 +5798,7 @@ # hrg_size_impl basic Code - hrg_size_impl(hrg_model) + hrg_size_impl(hrg = hrg_model) Output [1] 10 @@ -5771,7 +5813,7 @@ # from_hrg_dendrogram_impl basic Code - from_hrg_dendrogram_impl(hrg_model) + from_hrg_dendrogram_impl(hrg = hrg_model) Output $graph IGRAPH D--- 19 18 -- @@ -5794,7 +5836,7 @@ # get_adjacency_sparse_impl basic Code - get_adjacency_sparse_impl(g) + get_adjacency_sparse_impl(graph = g) Output $type [1] "triplet" @@ -5817,7 +5859,7 @@ --- Code - get_adjacency_sparse_impl(g, type = "upper", weights = c(1, 2), loops = "none") + get_adjacency_sparse_impl(graph = g, type = "upper", weights = c(1, 2), loops = "none") Output $type [1] "triplet" @@ -5848,7 +5890,7 @@ # get_stochastic_impl basic Code - get_stochastic_impl(g) + get_stochastic_impl(graph = g) Output [,1] [,2] [,3] [1,] 0.0 1 0.0 @@ -5858,7 +5900,7 @@ --- Code - get_stochastic_impl(g, column.wise = TRUE, weights = c(1, 2)) + get_stochastic_impl(graph = g, column.wise = TRUE, weights = c(1, 2)) Output [,1] [,2] [,3] [1,] 0 0.3333333 0 @@ -5876,7 +5918,7 @@ # get_stochastic_sparse_impl basic Code - get_stochastic_sparse_impl(g) + get_stochastic_sparse_impl(graph = g) Output $type [1] "triplet" @@ -5899,7 +5941,7 @@ --- Code - get_stochastic_sparse_impl(g, column.wise = TRUE, weights = c(1, 2)) + get_stochastic_sparse_impl(graph = g, column.wise = TRUE, weights = c(1, 2)) Output $type [1] "triplet" @@ -5930,7 +5972,7 @@ # to_directed_impl basic Code - to_directed_impl(g) + to_directed_impl(graph = g) Output IGRAPH D--- 3 4 -- + edges: @@ -5939,7 +5981,7 @@ --- Code - to_directed_impl(g, mode = "acyclic") + to_directed_impl(graph = g, mode = "acyclic") Output IGRAPH D--- 3 2 -- + edges: @@ -5956,7 +5998,7 @@ # to_undirected_impl basic Code - to_undirected_impl(g) + to_undirected_impl(graph = g) Output IGRAPH U--- 3 2 -- + edges: @@ -5965,7 +6007,7 @@ --- Code - to_undirected_impl(g, mode = "mutual", edge.attr.comb = "sum") + to_undirected_impl(graph = g, mode = "mutual", edge.attr.comb = "sum") Output IGRAPH U--- 3 2 -- + edges: @@ -5982,14 +6024,14 @@ # motifs_randesu_impl basic Code - motifs_randesu_impl(g) + motifs_randesu_impl(graph = g) Output [1] NaN NaN 1 0 --- Code - motifs_randesu_impl(g, size = 4, cut.prob = rep(0.1, 4)) + motifs_randesu_impl(graph = g, size = 4, cut.prob = rep(0.1, 4)) Output [1] NaN NaN NaN NaN 0 NaN 0 0 0 0 0 @@ -6004,15 +6046,15 @@ # motifs_randesu_estimate_impl basic Code - motifs_randesu_estimate_impl(g, size = 3, sample.size = 2) + motifs_randesu_estimate_impl(graph = g, size = 3, sample.size = 2) Output [1] 3 --- Code - motifs_randesu_estimate_impl(g, size = 4, cut.prob = rep(0.1, 4), sample.size = 2, - sample = 1:2) + motifs_randesu_estimate_impl(graph = g, size = 4, cut.prob = rep(0.1, 4), + sample.size = 2, sample = 1:2) Output [1] 3 @@ -6027,14 +6069,14 @@ # motifs_randesu_no_impl basic Code - motifs_randesu_no_impl(g) + motifs_randesu_no_impl(graph = g) Output [1] 1 --- Code - motifs_randesu_no_impl(g, size = 4, cut.prob = c(0.1, 0.1, 0.1, 0.1)) + motifs_randesu_no_impl(graph = g, size = 4, cut.prob = c(0.1, 0.1, 0.1, 0.1)) Output [1] 0 @@ -6049,7 +6091,7 @@ # dyad_census_impl basic Code - dyad_census_impl(g) + dyad_census_impl(graph = g) Output $mut [1] 2 @@ -6072,7 +6114,7 @@ # triad_census_impl basic Code - triad_census_impl(g) + triad_census_impl(graph = g) Condition Warning in `triad_census_impl()`: At vendor/cigraph/src/misc/motifs.c:1157 : Triad census called on an undirected graph. All connections will be treated as mutual. @@ -6090,14 +6132,14 @@ # count_adjacent_triangles_impl basic Code - count_adjacent_triangles_impl(g) + count_adjacent_triangles_impl(graph = g) Output [1] 0 0 0 --- Code - count_adjacent_triangles_impl(g, vids = 1:2) + count_adjacent_triangles_impl(graph = g, vids = 1:2) Output [1] 0 0 @@ -6112,7 +6154,7 @@ # count_triangles_impl basic Code - count_triangles_impl(g) + count_triangles_impl(graph = g) Output [1] 0 @@ -6127,14 +6169,14 @@ # local_scan_0_impl basic Code - local_scan_0_impl(g) + local_scan_0_impl(graph = g) Output [1] 1 2 1 --- Code - local_scan_0_impl(g, weights = c(1, 2), mode = "in") + local_scan_0_impl(graph = g, weights = c(1, 2), mode = "in") Output [1] 1 3 2 @@ -6149,14 +6191,14 @@ # local_scan_0_them_impl basic Code - local_scan_0_them_impl(g1, g2) + local_scan_0_them_impl(us = g1, them = g2) Output [1] 1 2 1 --- Code - local_scan_0_them_impl(g1, g2, weights.them = c(1, 2), mode = "in") + local_scan_0_them_impl(us = g1, them = g2, weights.them = c(1, 2), mode = "in") Output [1] 1 3 2 @@ -6171,14 +6213,14 @@ # local_scan_1_ecount_impl basic Code - local_scan_1_ecount_impl(g) + local_scan_1_ecount_impl(graph = g) Output [1] 1 2 1 --- Code - local_scan_1_ecount_impl(g, weights = c(1, 2), mode = "in") + local_scan_1_ecount_impl(graph = g, weights = c(1, 2), mode = "in") Output [1] 1 3 2 @@ -6193,14 +6235,14 @@ # local_scan_1_ecount_them_impl basic Code - local_scan_1_ecount_them_impl(g1, g2) + local_scan_1_ecount_them_impl(us = g1, them = g2) Output [1] 1 2 1 --- Code - local_scan_1_ecount_them_impl(g1, g2, weights.them = c(1, 2), mode = "in") + local_scan_1_ecount_them_impl(us = g1, them = g2, weights.them = c(1, 2), mode = "in") Output [1] 1 3 2 @@ -6215,14 +6257,14 @@ # local_scan_k_ecount_impl basic Code - local_scan_k_ecount_impl(g, k = 1) + local_scan_k_ecount_impl(graph = g, k = 1) Output [1] 1 2 1 --- Code - local_scan_k_ecount_impl(g, k = 1, weights = c(1, 2), mode = "in") + local_scan_k_ecount_impl(graph = g, k = 1, weights = c(1, 2), mode = "in") Output [1] 1 3 2 @@ -6237,14 +6279,15 @@ # local_scan_k_ecount_them_impl basic Code - local_scan_k_ecount_them_impl(g1, g2, k = 1) + local_scan_k_ecount_them_impl(us = g1, them = g2, k = 1) Output [1] 1 2 1 --- Code - local_scan_k_ecount_them_impl(g1, g2, k = 1, weights.them = c(1, 2), mode = "in") + local_scan_k_ecount_them_impl(us = g1, them = g2, k = 1, weights.them = c(1, 2), + mode = "in") Output [1] 1 3 2 @@ -6259,15 +6302,16 @@ # local_scan_neighborhood_ecount_impl basic Code - local_scan_neighborhood_ecount_impl(g, neighborhoods = list(1:2, 2:3, 2:4, 2)) + local_scan_neighborhood_ecount_impl(graph = g, neighborhoods = list(1:2, 2:3, 2: + 4, 2)) Output [1] 1 1 2 0 --- Code - local_scan_neighborhood_ecount_impl(g, weights = c(1, 2, 3), neighborhoods = list( - 1:2, 1:3, 2:4, 1)) + local_scan_neighborhood_ecount_impl(graph = g, weights = c(1, 2, 3), + neighborhoods = list(1:2, 1:3, 2:4, 1)) Output [1] 1 3 5 0 @@ -6282,15 +6326,15 @@ # local_scan_subset_ecount_impl basic Code - local_scan_subset_ecount_impl(g, subsets = list(c(1, 2), c(2, 3))) + local_scan_subset_ecount_impl(graph = g, subsets = list(c(1, 2), c(2, 3))) Output [1] 1 1 --- Code - local_scan_subset_ecount_impl(g, weights = c(1, 2, 3), subsets = list(c(1, 2), - c(2, 3))) + local_scan_subset_ecount_impl(graph = g, weights = c(1, 2, 3), subsets = list(c( + 1, 2), c(2, 3))) Output [1] 1 2 @@ -6305,7 +6349,7 @@ # list_triangles_impl basic Code - list_triangles_impl(g) + list_triangles_impl(graph = g) Output + 0/3 vertices: @@ -6320,7 +6364,7 @@ # join_impl basic Code - join_impl(g1, g2) + join_impl(left = g1, right = g2) Output IGRAPH U--- 6 13 -- + edges: @@ -6337,7 +6381,7 @@ # induced_subgraph_map_impl basic Code - induced_subgraph_map_impl(g, 1:2, impl = "auto") + induced_subgraph_map_impl(graph = g, vids = 1:2, impl = "auto") Output $res IGRAPH U--- 2 1 -- @@ -6354,7 +6398,7 @@ --- Code - induced_subgraph_map_impl(g, 1:2, impl = "copy_and_delete") + induced_subgraph_map_impl(graph = g, vids = 1:2, impl = "copy_and_delete") Output $res IGRAPH U--- 2 1 -- @@ -6379,7 +6423,7 @@ # mycielskian_impl basic Code - mycielskian_impl(g) + mycielskian_impl(graph = g) Output IGRAPH U--- 7 9 -- + edges: @@ -6388,7 +6432,7 @@ --- Code - mycielskian_impl(g, k = 2) + mycielskian_impl(graph = g, k = 2) Output IGRAPH U--- 15 34 -- + edges: @@ -6408,7 +6452,7 @@ # product_impl basic Code - product_impl(g1, g2) + product_impl(g1 = g1, g2 = g2) Output IGRAPH U--- 9 12 -- + edges: @@ -6417,7 +6461,7 @@ --- Code - product_impl(g1, g2, type = "tensor") + product_impl(g1 = g1, g2 = g2, type = "tensor") Output IGRAPH U--- 9 8 -- + edges: @@ -6434,7 +6478,7 @@ # rooted_product_impl basic Code - rooted_product_impl(g1, g2, root = 1) + rooted_product_impl(g1 = g1, g2 = g2, root = 1) Output IGRAPH U--- 9 8 -- + edges: @@ -6451,7 +6495,7 @@ # gomory_hu_tree_impl basic Code - gomory_hu_tree_impl(g) + gomory_hu_tree_impl(graph = g) Output $tree IGRAPH U--- 3 2 -- @@ -6465,7 +6509,7 @@ --- Code - gomory_hu_tree_impl(g, capacity = c(1, 2)) + gomory_hu_tree_impl(graph = g, capacity = c(1, 2)) Output $tree IGRAPH U--- 3 2 -- @@ -6487,7 +6531,7 @@ # maxflow_impl basic Code - maxflow_impl(g, source = 1, target = 3) + maxflow_impl(graph = g, source = 1, target = 3) Output $value [1] 1 @@ -6528,7 +6572,7 @@ --- Code - maxflow_impl(g, source = 1, target = 3, capacity = c(1, 2)) + maxflow_impl(graph = g, source = 1, target = 3, capacity = c(1, 2)) Output $value [1] 1 @@ -6577,7 +6621,7 @@ # residual_graph_impl basic Code - residual_graph_impl(g, capacity = c(1, 2), flow = c(1, 2)) + residual_graph_impl(graph = g, capacity = c(1, 2), flow = c(1, 2)) Output $residual IGRAPH D--- 3 0 -- @@ -6598,7 +6642,7 @@ # reverse_residual_graph_impl basic Code - reverse_residual_graph_impl(g, capacity = c(1, 2), flow = c(1, 2)) + reverse_residual_graph_impl(graph = g, capacity = c(1, 2), flow = c(1, 2)) Output IGRAPH D--- 3 2 -- + edges: @@ -6615,7 +6659,7 @@ # st_mincut_impl basic Code - st_mincut_impl(g, source = 1, target = 3) + st_mincut_impl(graph = g, source = 1, target = 3) Output $value [1] 1 @@ -6636,7 +6680,7 @@ --- Code - st_mincut_impl(g, source = 1, target = 3, capacity = c(1, 2)) + st_mincut_impl(graph = g, source = 1, target = 3, capacity = c(1, 2)) Output $value [1] 1 @@ -6665,7 +6709,7 @@ # dominator_tree_impl basic Code - dominator_tree_impl(g, root = 1) + dominator_tree_impl(graph = g, root = 1) Output $dom [1] 0 1 2 @@ -6682,7 +6726,7 @@ --- Code - dominator_tree_impl(g, root = 1, mode = "in") + dominator_tree_impl(graph = g, root = 1, mode = "in") Output $dom [1] 0 -1 -1 @@ -6707,7 +6751,7 @@ # all_st_cuts_impl basic Code - all_st_cuts_impl(g, source = 1, target = 3) + all_st_cuts_impl(graph = g, source = 1, target = 3) Output $cuts $cuts[[1]] @@ -6741,7 +6785,7 @@ # all_st_mincuts_impl basic Code - all_st_mincuts_impl(g, source = 1, target = 3) + all_st_mincuts_impl(graph = g, source = 1, target = 3) Output $value [1] 1 @@ -6770,7 +6814,7 @@ --- Code - all_st_mincuts_impl(g, source = 1, target = 3, capacity = c(1, 2)) + all_st_mincuts_impl(graph = g, source = 1, target = 3, capacity = c(1, 2)) Output $value [1] 1 @@ -6799,7 +6843,7 @@ # even_tarjan_reduction_impl basic Code - even_tarjan_reduction_impl(g) + even_tarjan_reduction_impl(graph = g) Output $graphbar IGRAPH D--- 6 7 -- @@ -6821,7 +6865,7 @@ # is_separator_impl basic Code - is_separator_impl(g, 1:2) + is_separator_impl(graph = g, candidate = 1:2) Output [1] FALSE @@ -6836,7 +6880,7 @@ # is_minimal_separator_impl basic Code - is_minimal_separator_impl(g, 1:2) + is_minimal_separator_impl(graph = g, candidate = 1:2) Output [1] FALSE @@ -6851,7 +6895,7 @@ # all_minimal_st_separators_impl basic Code - all_minimal_st_separators_impl(g) + all_minimal_st_separators_impl(graph = g) Output [[1]] + 1/3 vertex: @@ -6869,7 +6913,7 @@ # minimum_size_separators_impl basic Code - minimum_size_separators_impl(g) + minimum_size_separators_impl(graph = g) Output [[1]] + 1/3 vertex: @@ -6887,7 +6931,7 @@ # isoclass_impl basic Code - isoclass_impl(g) + isoclass_impl(graph = g) Output [1] 2 @@ -6902,7 +6946,7 @@ # isomorphic_impl basic Code - isomorphic_impl(g1, g2) + isomorphic_impl(graph1 = g1, graph2 = g2) Output [1] TRUE @@ -6917,7 +6961,7 @@ # isoclass_subgraph_impl basic Code - isoclass_subgraph_impl(g, c(1, 2, 3)) + isoclass_subgraph_impl(graph = g, vids = c(1, 2, 3)) Output [1] 2 @@ -6960,7 +7004,7 @@ # isomorphic_vf2_impl basic Code - isomorphic_vf2_impl(g1, g2) + isomorphic_vf2_impl(graph1 = g1, graph2 = g2) Output $iso [1] TRUE @@ -6975,8 +7019,8 @@ --- Code - isomorphic_vf2_impl(g1, g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c(1, 2, - 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) + isomorphic_vf2_impl(graph1 = g1, graph2 = g2, vertex.color1 = c(1, 2, 3), + vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) Output $iso [1] TRUE @@ -6999,15 +7043,15 @@ # count_isomorphisms_vf2_impl basic Code - count_isomorphisms_vf2_impl(g1, g2) + count_isomorphisms_vf2_impl(graph1 = g1, graph2 = g2) Output [1] 2 --- Code - count_isomorphisms_vf2_impl(g1, g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c( - 1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) + count_isomorphisms_vf2_impl(graph1 = g1, graph2 = g2, vertex.color1 = c(1, 2, 3), + vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) Output [1] 1 @@ -7022,7 +7066,7 @@ # get_isomorphisms_vf2_impl basic Code - get_isomorphisms_vf2_impl(g1, g2) + get_isomorphisms_vf2_impl(graph1 = g1, graph2 = g2) Output [[1]] [1] 0 1 2 @@ -7034,8 +7078,8 @@ --- Code - get_isomorphisms_vf2_impl(g1, g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c( - 1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) + get_isomorphisms_vf2_impl(graph1 = g1, graph2 = g2, vertex.color1 = c(1, 2, 3), + vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) Output [[1]] [1] 0 1 2 @@ -7052,7 +7096,7 @@ # subisomorphic_impl basic Code - subisomorphic_impl(g1, g2) + subisomorphic_impl(graph1 = g1, graph2 = g2) Output [1] TRUE @@ -7067,7 +7111,7 @@ # subisomorphic_vf2_impl basic Code - subisomorphic_vf2_impl(g1, g2) + subisomorphic_vf2_impl(graph1 = g1, graph2 = g2) Output $iso [1] TRUE @@ -7082,8 +7126,8 @@ --- Code - subisomorphic_vf2_impl(g1, g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c(1, - 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) + subisomorphic_vf2_impl(graph1 = g1, graph2 = g2, vertex.color1 = c(1, 2, 3), + vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) Output $iso [1] TRUE @@ -7106,15 +7150,15 @@ # count_subisomorphisms_vf2_impl basic Code - count_subisomorphisms_vf2_impl(g1, g2) + count_subisomorphisms_vf2_impl(graph1 = g1, graph2 = g2) Output [1] 2 --- Code - count_subisomorphisms_vf2_impl(g1, g2, vertex.color1 = c(1, 2, 3), - vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) + count_subisomorphisms_vf2_impl(graph1 = g1, graph2 = g2, vertex.color1 = c(1, 2, + 3), vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) Output [1] 1 @@ -7129,7 +7173,7 @@ # get_subisomorphisms_vf2_impl basic Code - get_subisomorphisms_vf2_impl(g1, g2) + get_subisomorphisms_vf2_impl(graph1 = g1, graph2 = g2) Output [[1]] [1] 0 1 2 @@ -7141,8 +7185,8 @@ --- Code - get_subisomorphisms_vf2_impl(g1, g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c( - 1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) + get_subisomorphisms_vf2_impl(graph1 = g1, graph2 = g2, vertex.color1 = c(1, 2, + 3), vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2)) Output [[1]] [1] 0 1 2 @@ -7159,7 +7203,7 @@ # canonical_permutation_impl basic Code - canonical_permutation_impl(g) + canonical_permutation_impl(graph = g) Output $labeling [1] 2 3 1 @@ -7188,7 +7232,7 @@ --- Code - canonical_permutation_impl(g, colors = c(1, 2, 3), sh = "fl") + canonical_permutation_impl(graph = g, colors = c(1, 2, 3), sh = "fl") Output $labeling [1] 1 2 3 @@ -7225,7 +7269,7 @@ # permute_vertices_impl basic Code - permute_vertices_impl(g, permutation = 3:1) + permute_vertices_impl(graph = g, permutation = 3:1) Output IGRAPH U--- 3 2 -- + edges: @@ -7242,7 +7286,7 @@ # isomorphic_bliss_impl basic Code - isomorphic_bliss_impl(g1, g2) + isomorphic_bliss_impl(graph1 = g1, graph2 = g2) Output $iso [1] TRUE @@ -7297,7 +7341,8 @@ --- Code - isomorphic_bliss_impl(g1, g2, colors1 = c(1, 2, 3), colors2 = c(1, 2, 3), sh = "fl") + isomorphic_bliss_impl(graph1 = g1, graph2 = g2, colors1 = c(1, 2, 3), colors2 = c( + 1, 2, 3), sh = "fl") Output $iso [1] TRUE @@ -7360,7 +7405,7 @@ # count_automorphisms_impl basic Code - count_automorphisms_impl(g) + count_automorphisms_impl(graph = g) Output $nof_nodes [1] 3 @@ -7384,7 +7429,7 @@ --- Code - count_automorphisms_impl(g, colors = c(1, 2, 3), sh = "fl") + count_automorphisms_impl(graph = g, colors = c(1, 2, 3), sh = "fl") Output $nof_nodes [1] 1 @@ -7416,7 +7461,7 @@ # automorphism_group_impl basic Code - automorphism_group_impl(g) + automorphism_group_impl(graph = g) Output [[1]] + 3/3 vertices: @@ -7426,7 +7471,7 @@ --- Code - automorphism_group_impl(g, colors = c(1, 2, 3), sh = "fl", details = TRUE) + automorphism_group_impl(graph = g, colors = c(1, 2, 3), sh = "fl", details = TRUE) Output $generators list() @@ -7463,7 +7508,7 @@ # simplify_and_colorize_impl basic Code - simplify_and_colorize_impl(g) + simplify_and_colorize_impl(graph = g) Output $res IGRAPH U--- 3 2 -- @@ -7488,14 +7533,14 @@ # graph_count_impl basic Code - graph_count_impl(3) + graph_count_impl(n = 3) Output [1] 4 --- Code - graph_count_impl(3, directed = TRUE) + graph_count_impl(n = 3, directed = TRUE) Output [1] 16 @@ -7512,14 +7557,14 @@ # is_matching_impl basic Code - is_matching_impl(g, matching = 1:2) + is_matching_impl(graph = g, matching = 1:2) Output [1] FALSE --- Code - is_matching_impl(g, types = c(TRUE, FALSE, TRUE), matching = 1:2) + is_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE), matching = 1:2) Output [1] FALSE @@ -7534,14 +7579,15 @@ # is_maximal_matching_impl basic Code - is_maximal_matching_impl(g, matching = 1:2) + is_maximal_matching_impl(graph = g, matching = 1:2) Output [1] FALSE --- Code - is_maximal_matching_impl(g, types = c(TRUE, FALSE, TRUE), matching = 1:2) + is_maximal_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE), matching = 1: + 2) Output [1] FALSE @@ -7556,7 +7602,7 @@ # maximum_bipartite_matching_impl basic Code - maximum_bipartite_matching_impl(g, types = c(TRUE, FALSE, TRUE)) + maximum_bipartite_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE)) Output $matching_size [1] 1 @@ -7571,8 +7617,8 @@ --- Code - maximum_bipartite_matching_impl(g, types = c(TRUE, FALSE, TRUE), weights = c(1, - 2), eps = 1e-05) + maximum_bipartite_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE), + weights = c(1, 2), eps = 1e-05) Output $matching_size [1] 1 @@ -7595,7 +7641,7 @@ # adjacency_spectral_embedding_impl basic Code - adjacency_spectral_embedding_impl(g, no = 2) + adjacency_spectral_embedding_impl(graph = g, no = 2) Output $X [,1] [,2] @@ -7675,7 +7721,7 @@ --- Code - adjacency_spectral_embedding_impl(g, no = 2, weights = c(1, 2), which = "la", + adjacency_spectral_embedding_impl(graph = g, no = 2, weights = c(1, 2), which = "la", scaled = FALSE, cvec = c(1, 2, 3), options = list(maxiter = 10)) Output $X @@ -7764,7 +7810,7 @@ # laplacian_spectral_embedding_impl basic Code - laplacian_spectral_embedding_impl(g, no = 2) + laplacian_spectral_embedding_impl(graph = g, no = 2) Output $X [,1] [,2] @@ -7852,7 +7898,7 @@ # eigen_adjacency_impl basic Code - eigen_adjacency_impl(g) + eigen_adjacency_impl(graph = g) Output $options $options$bmat @@ -7951,7 +7997,7 @@ # power_law_fit_impl basic Code - power_law_fit_impl(c(1, 2, 3)) + power_law_fit_impl(data = c(1, 2, 3)) Output $continuous [1] FALSE @@ -7972,7 +8018,7 @@ --- Code - power_law_fit_impl(c(1, 2, 3), xmin = 1, force.continuous = TRUE) + power_law_fit_impl(data = c(1, 2, 3), xmin = 1, force.continuous = TRUE) Output $continuous [1] TRUE @@ -8003,7 +8049,7 @@ # sir_impl basic Code - sir_impl(g, beta = 0.1, gamma = 0.1) + sir_impl(graph = g, beta = 0.1, gamma = 0.1) Output [[1]] [[1]]$times @@ -9411,7 +9457,7 @@ --- Code - sir_impl(g, beta = 0.1, gamma = 0.1, no.sim = 2) + sir_impl(graph = g, beta = 0.1, gamma = 0.1, no.sim = 2) Output [[1]] [[1]]$times @@ -9455,7 +9501,7 @@ # convex_hull_2d_impl basic Code - convex_hull_2d_impl(matrix(1:6, ncol = 2)) + convex_hull_2d_impl(data = matrix(1:6, ncol = 2)) Output $resverts [1] 1 3 @@ -9479,7 +9525,7 @@ # dim_select_impl basic Code - dim_select_impl(c(1, 2, 3)) + dim_select_impl(sv = c(1, 2, 3)) Output [1] 1 @@ -9494,7 +9540,7 @@ # solve_lsap_impl basic Code - solve_lsap_impl(matrix(1:4, ncol = 2), n = 2) + solve_lsap_impl(c = matrix(1:4, ncol = 2), n = 2) Output [1] 0 1 @@ -9511,7 +9557,7 @@ # find_cycle_impl basic Code - find_cycle_impl(g) + find_cycle_impl(graph = g) Output $vertices + 0/3 vertices: @@ -9523,7 +9569,7 @@ --- Code - find_cycle_impl(g, mode = "in") + find_cycle_impl(graph = g, mode = "in") Output $vertices + 0/3 vertices: @@ -9543,7 +9589,7 @@ # simple_cycles_impl basic Code - simple_cycles_impl(g) + simple_cycles_impl(graph = g) Output $vertices list() @@ -9555,7 +9601,8 @@ --- Code - simple_cycles_impl(g, mode = "in", min.cycle.length = 2, max.cycle.length = 3) + simple_cycles_impl(graph = g, mode = "in", min.cycle.length = 2, + max.cycle.length = 3) Output $vertices list() @@ -9575,7 +9622,7 @@ # is_eulerian_impl basic Code - is_eulerian_impl(g) + is_eulerian_impl(graph = g) Output $has_path [1] TRUE @@ -9595,7 +9642,7 @@ # eulerian_path_impl basic Code - eulerian_path_impl(g) + eulerian_path_impl(graph = g) Output $epath + 2/2 edges: @@ -9625,7 +9672,7 @@ --- Code - eulerian_cycle_impl(g2) + eulerian_cycle_impl(graph = g2) Output $epath + 4/4 edges: @@ -9647,14 +9694,14 @@ # fundamental_cycles_impl basic Code - fundamental_cycles_impl(g, start = 1) + fundamental_cycles_impl(graph = g, start = 1) Output list() --- Code - fundamental_cycles_impl(g, start = 1, bfs.cutoff = 2, weights = c(1, 2)) + fundamental_cycles_impl(graph = g, start = 1, bfs.cutoff = 2, weights = c(1, 2)) Output list() @@ -9669,15 +9716,15 @@ # minimum_cycle_basis_impl basic Code - minimum_cycle_basis_impl(g) + minimum_cycle_basis_impl(graph = g) Output list() --- Code - minimum_cycle_basis_impl(g, bfs.cutoff = 2, complete = FALSE, use.cycle.order = FALSE, - weights = c(1, 2)) + minimum_cycle_basis_impl(graph = g, bfs.cutoff = 2, complete = FALSE, + use.cycle.order = FALSE, weights = c(1, 2)) Output list() @@ -9692,14 +9739,14 @@ # is_tree_impl basic Code - is_tree_impl(g) + is_tree_impl(graph = g) Output [1] TRUE --- Code - is_tree_impl(g, mode = "in", details = TRUE) + is_tree_impl(graph = g, mode = "in", details = TRUE) Output $res [1] TRUE @@ -9720,14 +9767,14 @@ # is_forest_impl basic Code - is_forest_impl(g) + is_forest_impl(graph = g) Output [1] TRUE --- Code - is_forest_impl(g, mode = "in", details = TRUE) + is_forest_impl(graph = g, mode = "in", details = TRUE) Output $res [1] TRUE @@ -9748,7 +9795,7 @@ # from_prufer_impl basic Code - from_prufer_impl(1:2) + from_prufer_impl(prufer = 1:2) Output IGRAPH U--- 4 3 -- Tree from Prufer sequence + attr: name (g/c), prufer (g/n) @@ -9768,7 +9815,7 @@ # to_prufer_impl basic Code - to_prufer_impl(g) + to_prufer_impl(graph = g) Output [1] 2 @@ -9783,7 +9830,7 @@ # tree_from_parent_vector_impl basic Code - tree_from_parent_vector_impl(c(-1, 1, 2, 3)) + tree_from_parent_vector_impl(parents = c(-1, 1, 2, 3)) Output IGRAPH D--- 4 3 -- + edges: @@ -9792,7 +9839,7 @@ --- Code - tree_from_parent_vector_impl(c(-1, 1, 2, 3), type = "in") + tree_from_parent_vector_impl(parents = c(-1, 1, 2, 3), type = "in") Output IGRAPH D--- 4 3 -- + edges: @@ -9811,7 +9858,7 @@ # is_complete_impl basic Code - is_complete_impl(g) + is_complete_impl(graph = g) Output [1] FALSE @@ -9826,7 +9873,7 @@ # random_spanning_tree_impl basic Code - random_spanning_tree_impl(g, vid = 1) + random_spanning_tree_impl(graph = g, vid = 1) Output + 2/2 edges: [1] 1--2 2--3 @@ -9842,7 +9889,7 @@ # tree_game_impl basic Code - tree_game_impl(3) + tree_game_impl(n = 3) Output IGRAPH U--- 3 2 -- + edges: @@ -9851,7 +9898,7 @@ --- Code - tree_game_impl(3, directed = TRUE, method = "lerw") + tree_game_impl(n = 3, directed = TRUE, method = "lerw") Output IGRAPH D--- 3 2 -- + edges: @@ -9870,14 +9917,14 @@ # vertex_coloring_greedy_impl basic Code - vertex_coloring_greedy_impl(g) + vertex_coloring_greedy_impl(graph = g) Output [1] 2 1 2 --- Code - vertex_coloring_greedy_impl(g, heuristic = "dsatur") + vertex_coloring_greedy_impl(graph = g, heuristic = "dsatur") Output [1] 2 1 2 @@ -9892,7 +9939,7 @@ # is_vertex_coloring_impl basic Code - is_vertex_coloring_impl(g, types = c(1, 2, 3)) + is_vertex_coloring_impl(graph = g, types = c(1, 2, 3)) Output [1] TRUE @@ -9907,7 +9954,7 @@ # is_bipartite_coloring_impl basic Code - is_bipartite_coloring_impl(g, types = c(TRUE, FALSE, TRUE)) + is_bipartite_coloring_impl(graph = g, types = c(TRUE, FALSE, TRUE)) Output [1] TRUE @@ -9922,14 +9969,14 @@ # is_edge_coloring_impl basic Code - is_edge_coloring_impl(g, types = c(1, 2)) + is_edge_coloring_impl(graph = g, types = c(1, 2)) Output [1] TRUE --- Code - is_edge_coloring_impl(g) + is_edge_coloring_impl(graph = g) Output [1] TRUE @@ -9944,16 +9991,16 @@ # deterministic_optimal_imitation_impl basic Code - deterministic_optimal_imitation_impl(g, 1, quantities = c(1, 2, 3), strategies = c( - 1, 2, 3)) + deterministic_optimal_imitation_impl(graph = g, vid = 1, quantities = c(1, 2, 3), + strategies = c(1, 2, 3)) Output [1] 2 2 3 --- Code - deterministic_optimal_imitation_impl(g, 1, optimality = "minimum", quantities = c( - 1, 2, 3), strategies = c(1, 2, 3), mode = "in") + deterministic_optimal_imitation_impl(graph = g, vid = 1, optimality = "minimum", + quantities = c(1, 2, 3), strategies = c(1, 2, 3), mode = "in") Output [1] 1 2 3 @@ -9968,8 +10015,8 @@ # moran_process_impl basic Code - moran_process_impl(g, weights = c(1, 1), quantities = c(1, 2, 3), strategies = c( - 1, 2, 3), mode = "in") + moran_process_impl(graph = g, weights = c(1, 1), quantities = c(1, 2, 3), + strategies = c(1, 2, 3), mode = "in") Output $quantities [1] 1 3 3 @@ -9989,16 +10036,16 @@ # roulette_wheel_imitation_impl basic Code - roulette_wheel_imitation_impl(g, 1, TRUE, quantities = c(1, 2, 3), strategies = c( - 1, 2, 3)) + roulette_wheel_imitation_impl(graph = g, vid = 1, is.local = TRUE, quantities = c( + 1, 2, 3), strategies = c(1, 2, 3)) Output [1] 1 2 3 --- Code - roulette_wheel_imitation_impl(g, 1, FALSE, quantities = c(1, 2, 3), strategies = c( - 1, 2, 3), mode = "in") + roulette_wheel_imitation_impl(graph = g, vid = 1, is.local = FALSE, quantities = c( + 1, 2, 3), strategies = c(1, 2, 3), mode = "in") Output [1] 3 2 3 @@ -10013,16 +10060,16 @@ # stochastic_imitation_impl basic Code - stochastic_imitation_impl(g, 1, algo = 1, quantities = c(1, 2, 3), strategies = c( - 1, 2, 3)) + stochastic_imitation_impl(graph = g, vid = 1, algo = 1, quantities = c(1, 2, 3), + strategies = c(1, 2, 3)) Output [1] 1 2 3 --- Code - stochastic_imitation_impl(g, 1, algo = 2, quantities = c(1, 2, 3), strategies = c( - 1, 2, 3), mode = "in") + stochastic_imitation_impl(graph = g, vid = 1, algo = 2, quantities = c(1, 2, 3), + strategies = c(1, 2, 3), mode = "in") Output [1] 1 2 3 @@ -10037,7 +10084,7 @@ # invalidate_cache_impl basic Code - invalidate_cache_impl(g) + invalidate_cache_impl(graph = g) Output IGRAPH U--- 3 2 -- + edges: @@ -10054,7 +10101,7 @@ # vertex_path_from_edge_path_impl basic Code - vertex_path_from_edge_path_impl(g, start = 1, edge.path = c(1, 2)) + vertex_path_from_edge_path_impl(graph = g, start = 1, edge.path = c(1, 2)) Output + 3/3 vertices: [1] 1 2 3 @@ -10062,7 +10109,7 @@ --- Code - vertex_path_from_edge_path_impl(g, start = 1, edge.path = c(1), mode = "in") + vertex_path_from_edge_path_impl(graph = g, start = 1, edge.path = c(1), mode = "in") Output + 2/3 vertices: [1] 1 2 @@ -10090,3 +10137,271 @@ Error in `version_impl()`: ! unused argument ("invalid") +# ecount_impl basic + + Code + ecount_impl(graph = g) + Output + [1] 0 + +--- + + Code + ecount_impl(graph = g) + Output + [1] 3 + +# ecount_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_directed_impl basic + + Code + is_directed_impl(graph = g) + Output + [1] TRUE + +--- + + Code + is_directed_impl(graph = g) + Output + [1] FALSE + +# is_directed_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# edges_impl basic + + Code + edges_impl(graph = g, eids = E(g)) + Output + [1] 0 1 1 2 2 3 + +--- + + Code + edges_impl(graph = g, eids = c(1, 3)) + Output + [1] 0 1 2 3 + +# edges_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# add_vertices_impl basic + + Code + vcount(g_new) + Output + [1] 5 + +# add_vertices_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# delete_edges_impl basic + + Code + ecount(g_new) + Output + [1] 1 + +# delete_edges_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# delete_vertices_impl basic + + Code + vcount(g_new) + Output + [1] 2 + +# delete_vertices_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# incident_impl basic + + Code + incident_impl(graph = g, vid = 2, mode = "out") + Output + [1] 2 + +--- + + Code + incident_impl(graph = g, vid = 2, mode = "in") + Output + [1] 1 + +--- + + Code + incident_impl(graph = g, vid = 2, mode = "all") + Output + [1] 1 2 + +# incident_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# famous_impl basic + + Code + famous_impl(name = "Zachary") + Output + IGRAPH U--- 34 78 -- + + edges: + [1] 1-- 2 1-- 3 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--11 1--12 + [11] 1--13 1--14 1--18 1--20 1--22 1--32 2-- 3 2-- 4 2-- 8 2--14 + [21] 2--18 2--20 2--22 2--31 3-- 4 3-- 8 3--28 3--29 3--33 3--10 + [31] 3-- 9 3--14 4-- 8 4--13 4--14 5-- 7 5--11 6-- 7 6--11 6--17 + [41] 7--17 9--31 9--33 9--34 10--34 14--34 15--33 15--34 16--33 16--34 + [51] 19--33 19--34 20--34 21--33 21--34 23--33 23--34 24--26 24--28 24--33 + [61] 24--34 24--30 25--26 25--28 25--32 26--32 27--30 27--34 28--34 29--32 + [71] 29--34 30--33 30--34 31--33 31--34 32--33 32--34 33--34 + +# famous_impl errors + + Code + x + Condition + Error in `famous_impl()`: + ! At vendor/cigraph/src/constructors/famous.c:xx : NonexistentGraph is not a known graph. See the documentation for valid graph names. Invalid value + +# constraint_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# cocitation_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# bibcoupling_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# girth_impl basic + + Code + result$girth + Output + [1] 5 + +# girth_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# coreness_impl basic + + Code + coreness_impl(graph = g) + Output + [1] 2 2 2 1 + +# coreness_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# union_impl basic + + Code + union_impl(left = g1, right = g2) + Output + $res + IGRAPH D--- 4 4 -- + + edges: + [1] 1->2 1->3 2->3 3->4 + + $edge_map_left + [1] 1 3 + + $edge_map_right + [1] 2 4 + + +# union_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# intersection_impl basic + + Code + intersection_impl(left = g1, right = g2) + Output + $res + IGRAPH D--- 3 2 -- + + edges: + [1] 1->2 2->3 + + $edge_map_left + [1] 1 2 + + $edge_map_right + [1] 1 2 + + +# intersection_impl errors + + Code + x + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + diff --git a/tests/testthat/_snaps/aaa-auto.new.md b/tests/testthat/_snaps/aaa-auto.new.md new file mode 100644 index 00000000000..5e6fb878844 --- /dev/null +++ b/tests/testthat/_snaps/aaa-auto.new.md @@ -0,0 +1,8 @@ +# version_impl errors + + Code + x + Condition + Error in `version_impl()`: + ! could not find function "version_impl" + diff --git a/tests/testthat/_snaps/operators.md b/tests/testthat/_snaps/operators.md index 7e3a04b7e14..c60e2dc767a 100644 --- a/tests/testthat/_snaps/operators.md +++ b/tests/testthat/_snaps/operators.md @@ -2,3 +2,19 @@ Can't recycle `name` (size 2) to match `foo` (size 3). +# vertices() errors on duplicate attribute names + + Duplicate attribute name in `vertices()`: "name". + +--- + + Duplicate attribute name in `vertices()`: "blop". + +--- + + Duplicate attribute name in `vertices()`: "name". + +--- + + Duplicate attribute names in `vertices()`: "foo" and "bar". + diff --git a/tests/testthat/_snaps/utils-assert-args.md b/tests/testthat/_snaps/utils-assert-args.md index be2c21ee633..88628bf245a 100644 --- a/tests/testthat/_snaps/utils-assert-args.md +++ b/tests/testthat/_snaps/utils-assert-args.md @@ -10,7 +10,7 @@ Must provide a graph object (provided `NULL`). -# igraph.match.arg() works +# igraph_match_arg() works Code cluster_leiden(make_graph("Zachary"), objective_function = "something") diff --git a/tests/testthat/test-aaa-auto.R b/tests/testthat/test-aaa-auto.R index b51a615c7b2..c1a5e38860e 100644 --- a/tests/testthat/test-aaa-auto.R +++ b/tests/testthat/test-aaa-auto.R @@ -1,16 +1,46 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# NOTE: This file tests all auto-generated _impl functions. +# According to the issue, each function should have: +# 1. Snapshot tests (using expect_snapshot) - captures the full output +# 2. Structured tests (using regular expectations) - tests specific aspects +# +# The first several functions demonstrate this pattern with comprehensive +# structured tests. For remaining functions, structured tests should be added +# as they are enhanced or when bugs are found. + # 1. empty_impl test_that("empty_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot(empty_impl()) - expect_snapshot(empty_impl(5, directed = FALSE)) + expect_snapshot(empty_impl( + n = 5, + directed = FALSE + )) + + # Structured tests + g1 <- empty_impl() + expect_s3_class(g1, "igraph") + expect_equal(vcount(g1), 0) + expect_equal(ecount(g1), 0) + expect_true(is_directed(g1)) + + g2 <- empty_impl(n = 5, directed = FALSE) + expect_s3_class(g2, "igraph") + expect_equal(vcount(g2), 5) + expect_equal(ecount(g2), 0) + expect_false(is_directed(g2)) }) test_that("empty_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(empty_impl(-1)) + expect_snapshot_igraph_error(empty_impl( + n = -1 + )) }) # 2. add_edges_impl @@ -18,14 +48,29 @@ test_that("empty_impl errors", { test_that("add_edges_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- empty_impl(3) - expect_snapshot(add_edges_impl(g, c(0, 1, 1, 2))) + g <- empty_impl( + n = 3 + ) + + expect_snapshot(add_edges_impl( + graph = g, + edges = c(0, 1, 1, 2) + )) + + # Structured tests + result <- add_edges_impl(graph = g, edges = c(0, 1, 1, 2)) + expect_s3_class(result, "igraph") + expect_equal(vcount(result), 3) + expect_equal(ecount(result), 2) }) test_that("add_edges_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(add_edges_impl(NULL, c(1, 2))) + expect_snapshot_igraph_error(add_edges_impl( + graph = NULL, + edges = c(1, 2) + )) }) # 3. copy_impl @@ -33,14 +78,28 @@ test_that("add_edges_impl errors", { test_that("copy_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- empty_impl(2) - expect_snapshot(copy_impl(g)) + g <- empty_impl( + n = 2 + ) + + expect_snapshot(copy_impl( + from = g + )) + + # Structured tests + result <- copy_impl(from = g) + expect_s3_class(result, "igraph") + expect_equal(vcount(result), vcount(g)) + expect_equal(ecount(result), ecount(g)) + expect_equal(is_directed(result), is_directed(g)) }) test_that("copy_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(copy_impl(NULL)) + expect_snapshot_igraph_error(copy_impl( + from = NULL + )) }) # 4. delete_vertices_idx_impl @@ -48,14 +107,30 @@ test_that("copy_impl errors", { test_that("delete_vertices_idx_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- empty_impl(3) - expect_snapshot(delete_vertices_idx_impl(g, 1)) + g <- empty_impl( + n = 3 + ) + + expect_snapshot(delete_vertices_idx_impl( + graph = g, + vertices = 1 + )) + + # Structured tests + result <- delete_vertices_idx_impl(graph = g, vertices = 1) + expect_type(result, "list") + expect_named(result, c("graph", "idx", "invidx")) + expect_s3_class(result$graph, "igraph") + expect_equal(vcount(result$graph), 2) }) test_that("delete_vertices_idx_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(delete_vertices_idx_impl(NULL, 1)) + expect_snapshot_igraph_error(delete_vertices_idx_impl( + graph = NULL, + vertices = 1 + )) }) # 5. vcount_impl @@ -63,14 +138,27 @@ test_that("delete_vertices_idx_impl errors", { test_that("vcount_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- empty_impl(4) - expect_snapshot(vcount_impl(g)) + g <- empty_impl( + n = 4 + ) + + expect_snapshot(vcount_impl( + graph = g + )) + + # Structured tests + result <- vcount_impl(graph = g) + expect_type(result, "double") + expect_length(result, 1) + expect_equal(result, 4) }) test_that("vcount_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(vcount_impl(NULL)) + expect_snapshot_igraph_error(vcount_impl( + graph = NULL + )) }) # 6. degree_impl @@ -78,15 +166,31 @@ test_that("vcount_impl errors", { test_that("degree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- empty_impl(3) - expect_snapshot(degree_impl(g)) - expect_snapshot(degree_impl(g, mode = "in")) + g <- empty_impl( + n = 3 + ) + + expect_snapshot(degree_impl( + graph = g + )) + expect_snapshot(degree_impl( + graph = g, + mode = "in" + )) + + # Structured tests + result <- degree_impl(graph = g) + expect_type(result, "double") + expect_length(result, 3) + expect_equal(result, c(0, 0, 0)) }) test_that("degree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(degree_impl(NULL)) + expect_snapshot_igraph_error(degree_impl( + graph = NULL + )) }) # 7. get_all_eids_between_impl @@ -94,14 +198,33 @@ test_that("degree_impl errors", { test_that("get_all_eids_between_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- empty_impl(2) - expect_snapshot(get_all_eids_between_impl(g, 1, 2)) + g <- empty_impl( + n = 2 + ) + + expect_snapshot(get_all_eids_between_impl( + graph = g, + from = 1, + to = 2 + )) + + # Structured tests + result <- get_all_eids_between_impl( + graph = g, + from = 1, + to = 2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("get_all_eids_between_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_all_eids_between_impl(NULL, 1, 2)) + expect_snapshot_igraph_error(get_all_eids_between_impl( + graph = NULL, + from = 1, + to = 2 + )) }) # 8. wheel_impl @@ -109,14 +232,28 @@ test_that("get_all_eids_between_impl errors", { test_that("wheel_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(wheel_impl(5)) - expect_snapshot(wheel_impl(5, mode = "in", center = 2)) + expect_snapshot(wheel_impl( + n = 5 + )) + expect_snapshot(wheel_impl( + n = 5, + mode = "in", + center = 2 + )) + + # Structured tests + result <- wheel_impl( + n = 5 + ) + expect_s3_class(result, "igraph") }) test_that("wheel_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(wheel_impl(-1)) + expect_snapshot_igraph_error(wheel_impl( + n = -1 + )) }) # 9. hypercube_impl @@ -124,14 +261,27 @@ test_that("wheel_impl errors", { test_that("hypercube_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(hypercube_impl(3)) - expect_snapshot(hypercube_impl(3, directed = TRUE)) + expect_snapshot(hypercube_impl( + n = 3 + )) + expect_snapshot(hypercube_impl( + n = 3, + directed = TRUE + )) + + # Structured tests + result <- hypercube_impl( + n = 3 + ) + expect_s3_class(result, "igraph") }) test_that("hypercube_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(hypercube_impl(10000)) + expect_snapshot_igraph_error(hypercube_impl( + n = 10000 + )) }) # 10. square_lattice_impl @@ -139,20 +289,30 @@ test_that("hypercube_impl errors", { test_that("square_lattice_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(square_lattice_impl(c(2, 2))) expect_snapshot(square_lattice_impl( - c(2, 2), + dimvector = c(2, 2) + )) + expect_snapshot(square_lattice_impl( + dimvector = c(2, 2), nei = 2, directed = TRUE, mutual = TRUE, periodic = c(TRUE, TRUE) )) + + # Structured tests + result <- square_lattice_impl( + dimvector = c(2, 2) + ) + expect_s3_class(result, "igraph") }) test_that("square_lattice_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(square_lattice_impl(-1)) + expect_snapshot_igraph_error(square_lattice_impl( + dimvector = -1 + )) }) # 11. triangular_lattice_impl @@ -160,18 +320,28 @@ test_that("square_lattice_impl errors", { test_that("triangular_lattice_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(triangular_lattice_impl(c(2, 2))) expect_snapshot(triangular_lattice_impl( - c(2, 2), + dimvector = c(2, 2) + )) + expect_snapshot(triangular_lattice_impl( + dimvector = c(2, 2), directed = TRUE, mutual = TRUE )) + + # Structured tests + result <- triangular_lattice_impl( + dimvector = c(2, 2) + ) + expect_s3_class(result, "igraph") }) test_that("triangular_lattice_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(triangular_lattice_impl(-1)) + expect_snapshot_igraph_error(triangular_lattice_impl( + dimvector = -1 + )) }) # 12. path_graph_impl @@ -179,14 +349,28 @@ test_that("triangular_lattice_impl errors", { test_that("path_graph_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(path_graph_impl(5)) - expect_snapshot(path_graph_impl(5, directed = TRUE, mutual = TRUE)) + expect_snapshot(path_graph_impl( + n = 5 + )) + expect_snapshot(path_graph_impl( + n = 5, + directed = TRUE, + mutual = TRUE + )) + + # Structured tests + result <- path_graph_impl( + n = 5 + ) + expect_s3_class(result, "igraph") }) test_that("path_graph_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(path_graph_impl(-1)) + expect_snapshot_igraph_error(path_graph_impl( + n = -1 + )) }) # 13. cycle_graph_impl @@ -194,14 +378,28 @@ test_that("path_graph_impl errors", { test_that("cycle_graph_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(cycle_graph_impl(5)) - expect_snapshot(cycle_graph_impl(5, directed = TRUE, mutual = TRUE)) + expect_snapshot(cycle_graph_impl( + n = 5 + )) + expect_snapshot(cycle_graph_impl( + n = 5, + directed = TRUE, + mutual = TRUE + )) + + # Structured tests + result <- cycle_graph_impl( + n = 5 + ) + expect_s3_class(result, "igraph") }) test_that("cycle_graph_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(cycle_graph_impl(-1)) + expect_snapshot_igraph_error(cycle_graph_impl( + n = -1 + )) }) # 14. symmetric_tree_impl @@ -209,14 +407,27 @@ test_that("cycle_graph_impl errors", { test_that("symmetric_tree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(symmetric_tree_impl(3)) - expect_snapshot(symmetric_tree_impl(3, type = "in")) + expect_snapshot(symmetric_tree_impl( + branches = 3 + )) + expect_snapshot(symmetric_tree_impl( + branches = 3, + type = "in" + )) + + # Structured tests + result <- symmetric_tree_impl( + branches = 3 + ) + expect_s3_class(result, "igraph") }) test_that("symmetric_tree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(symmetric_tree_impl(-1)) + expect_snapshot_igraph_error(symmetric_tree_impl( + branches = -1 + )) }) # 15. regular_tree_impl @@ -224,14 +435,28 @@ test_that("symmetric_tree_impl errors", { test_that("regular_tree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(regular_tree_impl(2)) - expect_snapshot(regular_tree_impl(2, k = 4, type = "in")) + expect_snapshot(regular_tree_impl( + h = 2 + )) + expect_snapshot(regular_tree_impl( + h = 2, + k = 4, + type = "in" + )) + + # Structured tests + result <- regular_tree_impl( + h = 2 + ) + expect_s3_class(result, "igraph") }) test_that("regular_tree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(regular_tree_impl(-1)) + expect_snapshot_igraph_error(regular_tree_impl( + h = -1 + )) }) # 16. full_citation_impl @@ -239,14 +464,27 @@ test_that("regular_tree_impl errors", { test_that("full_citation_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(full_citation_impl(5)) - expect_snapshot(full_citation_impl(5, directed = FALSE)) + expect_snapshot(full_citation_impl( + n = 5 + )) + expect_snapshot(full_citation_impl( + n = 5, + directed = FALSE + )) + + # Structured tests + result <- full_citation_impl( + n = 5 + ) + expect_s3_class(result, "igraph") }) test_that("full_citation_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(full_citation_impl(-1)) + expect_snapshot_igraph_error(full_citation_impl( + n = -1 + )) }) # 17. atlas_impl @@ -254,14 +492,26 @@ test_that("full_citation_impl errors", { test_that("atlas_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(atlas_impl(0)) - expect_snapshot(atlas_impl(5)) + expect_snapshot(atlas_impl( + number = 0 + )) + expect_snapshot(atlas_impl( + number = 5 + )) + + # Structured tests + result <- atlas_impl( + number = 0 + ) + expect_s3_class(result, "igraph") }) test_that("atlas_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(atlas_impl(-1)) + expect_snapshot_igraph_error(atlas_impl( + number = -1 + )) }) # 18. extended_chordal_ring_impl @@ -269,18 +519,31 @@ test_that("atlas_impl errors", { test_that("extended_chordal_ring_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(extended_chordal_ring_impl(5, matrix(c(1, 2)))) expect_snapshot(extended_chordal_ring_impl( - 5, - matrix(c(1, 2)), + nodes = 5, + W = matrix(c(1, 2)) + )) + expect_snapshot(extended_chordal_ring_impl( + nodes = 5, + W = matrix(c(1, 2)), directed = TRUE )) + + # Structured tests + result <- extended_chordal_ring_impl( + nodes = 5, + W = matrix(c(1, 2)) + ) + expect_s3_class(result, "igraph") }) test_that("extended_chordal_ring_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(extended_chordal_ring_impl(-1, matrix(c(1, 2)))) + expect_snapshot_igraph_error(extended_chordal_ring_impl( + nodes = -1, + W = matrix(c(1, 2)) + )) }) # 19. graph_power_impl @@ -288,15 +551,35 @@ test_that("extended_chordal_ring_impl errors", { test_that("graph_power_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(5) - expect_snapshot(graph_power_impl(g, 2)) - expect_snapshot(graph_power_impl(g, 2, directed = TRUE)) + g <- path_graph_impl( + n = 5 + ) + + expect_snapshot(graph_power_impl( + graph = g, + order = 2 + )) + expect_snapshot(graph_power_impl( + graph = g, + order = 2, + directed = TRUE + )) + + # Structured tests + result <- graph_power_impl( + graph = g, + order = 2 + ) + expect_s3_class(result, "igraph") }) test_that("graph_power_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(graph_power_impl(NULL, 2)) + expect_snapshot_igraph_error(graph_power_impl( + graph = NULL, + order = 2 + )) }) # 20. linegraph_impl @@ -304,62 +587,127 @@ test_that("graph_power_impl errors", { test_that("linegraph_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(5) - expect_snapshot(linegraph_impl(g)) + g <- path_graph_impl( + n = 5 + ) + + expect_snapshot(linegraph_impl( + graph = g + )) + + # Structured tests + result <- linegraph_impl( + graph = g + ) + expect_s3_class(result, "igraph") }) test_that("linegraph_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(linegraph_impl(NULL)) + expect_snapshot_igraph_error(linegraph_impl( + graph = NULL + )) }) # 21. de_bruijn_impl test_that("de_bruijn_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(de_bruijn_impl(2, 3)) + expect_snapshot(de_bruijn_impl( + m = 2, + n = 3 + )) + + # Structured tests + result <- de_bruijn_impl( + m = 2, + n = 3 + ) + expect_s3_class(result, "igraph") }) test_that("de_bruijn_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(de_bruijn_impl(-1, 3)) + expect_snapshot_igraph_error(de_bruijn_impl( + m = -1, + n = 3 + )) }) # 22. kautz_impl test_that("kautz_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(kautz_impl(2, 3)) + expect_snapshot(kautz_impl( + m = 2, + n = 3 + )) + + # Structured tests + result <- kautz_impl( + m = 2, + n = 3 + ) + expect_s3_class(result, "igraph") }) test_that("kautz_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(kautz_impl(-1, 3)) + expect_snapshot_igraph_error(kautz_impl( + m = -1, + n = 3 + )) }) # 23. lcf_vector_impl test_that("lcf_vector_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(lcf_vector_impl(10, c(3, -3, 4), 2)) + expect_snapshot(lcf_vector_impl( + n = 10, + shifts = c(3, -3, 4), + repeats = 2 + )) + + # Structured tests + result <- lcf_vector_impl( + n = 10, + shifts = c(3, -3, 4), + repeats = 2 + ) + expect_s3_class(result, "igraph") }) test_that("lcf_vector_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(lcf_vector_impl(-1, c(3, -3, 4), 2)) + expect_snapshot_igraph_error(lcf_vector_impl( + n = -1, + shifts = c(3, -3, 4), + repeats = 2 + )) }) # 24. mycielski_graph_impl test_that("mycielski_graph_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(mycielski_graph_impl(3)) + expect_snapshot(mycielski_graph_impl( + k = 3 + )) + + # Structured tests + result <- mycielski_graph_impl( + k = 3 + ) + expect_s3_class(result, "igraph") }) test_that("mycielski_graph_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(mycielski_graph_impl(-1)) + expect_snapshot_igraph_error(mycielski_graph_impl( + k = -1 + )) }) # 25. adjlist_impl @@ -367,80 +715,152 @@ test_that("adjlist_impl basic", { skip_if(Sys.getenv("R_SANITIZER") == "true") withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(adjlist_impl(list(c(2, 3), c(1), c(1)), mode = "out")) + expect_snapshot(adjlist_impl( + adjlist = list( + c(2, 3), + c(1), + c(1) + ), + mode = "out" + )) + + # Structured tests + result <- adjlist_impl( + adjlist = list( + c(2, 3), + c(1), + c(1) + ), + mode = "out" + ) + expect_s3_class(result, "igraph") }) test_that("adjlist_impl errors", { skip_if(Sys.getenv("R_SANITIZER") == "true") withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(adjlist_impl(-1, mode = "out")) + expect_snapshot_igraph_error(adjlist_impl( + adjlist = -1, + mode = "out" + )) }) # 26. full_bipartite_impl test_that("full_bipartite_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(full_bipartite_impl(2, 3)) - expect_snapshot(full_bipartite_impl(2, 3, directed = TRUE, mode = "in")) + expect_snapshot(full_bipartite_impl( + n1 = 2, + n2 = 3 + )) + expect_snapshot(full_bipartite_impl( + n1 = 2, + n2 = 3, + directed = TRUE, + mode = "in" + )) + + # Structured tests + result <- full_bipartite_impl( + n1 = 2, + n2 = 3 + ) + expect_type(result, "list") }) test_that("full_bipartite_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(full_bipartite_impl(-1, 3)) + expect_snapshot_igraph_error(full_bipartite_impl( + n1 = -1, + n2 = 3 + )) }) # 27. full_multipartite_impl test_that("full_multipartite_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(full_multipartite_impl(c(2, 3, 4))) expect_snapshot(full_multipartite_impl( - c(2, 3, 4), + n = c(2, 3, 4) + )) + expect_snapshot(full_multipartite_impl( + n = c(2, 3, 4), directed = TRUE, mode = "in" )) + + # Structured tests + result <- full_multipartite_impl( + n = c(2, 3, 4) + ) + expect_type(result, "list") }) test_that("full_multipartite_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(full_multipartite_impl(-1)) + expect_snapshot_igraph_error(full_multipartite_impl( + n = -1 + )) }) # 28. realize_degree_sequence_impl test_that("realize_degree_sequence_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(realize_degree_sequence_impl(c(2, 2, 2))) expect_snapshot(realize_degree_sequence_impl( - c(2, 2, 2), - c(2, 2, 2), + out.deg = c(2, 2, 2) + )) + expect_snapshot(realize_degree_sequence_impl( + out.deg = c(2, 2, 2), + in.deg = c(2, 2, 2), allowed.edge.types = "simple", method = "largest" )) + + # Structured tests + result <- realize_degree_sequence_impl( + out.deg = c(2, 2, 2) + ) + expect_s3_class(result, "igraph") }) test_that("realize_degree_sequence_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(realize_degree_sequence_impl(-1)) + expect_snapshot_igraph_error(realize_degree_sequence_impl( + out.deg = -1 + )) }) # 29. realize_bipartite_degree_sequence_impl test_that("realize_bipartite_degree_sequence_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(realize_bipartite_degree_sequence_impl(c(2, 2), c(2, 2))) expect_snapshot(realize_bipartite_degree_sequence_impl( - c(2, 2), - c(2, 2), + degrees1 = c(2, 2), + degrees2 = c(2, 2) + )) + expect_snapshot(realize_bipartite_degree_sequence_impl( + degrees1 = c(2, 2), + degrees2 = c(2, 2), allowed.edge.types = "loops", method = "largest" )) + + # Structured tests + result <- realize_bipartite_degree_sequence_impl( + degrees1 = c(2, 2), + degrees2 = c(2, 2) + ) + expect_s3_class(result, "igraph") }) test_that("realize_bipartite_degree_sequence_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - realize_bipartite_degree_sequence_impl(-1, c(2, 2)) + realize_bipartite_degree_sequence_impl( + degrees1 = -1, + degrees2 = c(2, 2) + ) ) }) @@ -448,91 +868,173 @@ test_that("realize_bipartite_degree_sequence_impl errors", { test_that("circulant_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(circulant_impl(5, c(1, 2))) - expect_snapshot(circulant_impl(5, c(1, 2), directed = TRUE)) + expect_snapshot(circulant_impl( + n = 5, + shifts = c(1, 2) + )) + expect_snapshot(circulant_impl( + n = 5, + shifts = c(1, 2), + directed = TRUE + )) + + # Structured tests + result <- circulant_impl( + n = 5, + shifts = c(1, 2) + ) + expect_s3_class(result, "igraph") }) test_that("circulant_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(circulant_impl(-1, c(1, 2))) + expect_snapshot_igraph_error(circulant_impl( + n = -1, + shifts = c(1, 2) + )) }) # 31. generalized_petersen_impl test_that("generalized_petersen_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(generalized_petersen_impl(5, 2)) + expect_snapshot(generalized_petersen_impl( + n = 5, + k = 2 + )) + + # Structured tests + result <- generalized_petersen_impl( + n = 5, + k = 2 + ) + expect_s3_class(result, "igraph") }) test_that("generalized_petersen_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(generalized_petersen_impl(-1, 2)) + expect_snapshot_igraph_error(generalized_petersen_impl( + n = -1, + k = 2 + )) }) # 32. turan_impl test_that("turan_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(turan_impl(5, 2)) + expect_snapshot(turan_impl( + n = 5, + r = 2 + )) + + # Structured tests + result <- turan_impl( + n = 5, + r = 2 + ) + expect_type(result, "list") }) test_that("turan_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(turan_impl(-1, 2)) + expect_snapshot_igraph_error(turan_impl( + n = -1, + r = 2 + )) }) # 33. erdos_renyi_game_gnp_impl test_that("erdos_renyi_game_gnp_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(erdos_renyi_game_gnp_impl(5, 0.5)) expect_snapshot(erdos_renyi_game_gnp_impl( - 5, - 0.5, + n = 5, + p = 0.5 + )) + expect_snapshot(erdos_renyi_game_gnp_impl( + n = 5, + p = 0.5, directed = TRUE, loops = TRUE )) + + # Structured tests + result <- erdos_renyi_game_gnp_impl( + n = 5, + p = 0.5 + ) + expect_s3_class(result, "igraph") }) test_that("erdos_renyi_game_gnp_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(erdos_renyi_game_gnp_impl(-1, 0.5)) + expect_snapshot_igraph_error(erdos_renyi_game_gnp_impl( + n = -1, + p = 0.5 + )) }) # 34. erdos_renyi_game_gnm_impl test_that("erdos_renyi_game_gnm_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(erdos_renyi_game_gnm_impl(5, 3)) expect_snapshot(erdos_renyi_game_gnm_impl( - 5, - 3, + n = 5, + m = 3 + )) + expect_snapshot(erdos_renyi_game_gnm_impl( + n = 5, + m = 3, directed = TRUE, loops = TRUE )) + + # Structured tests + result <- erdos_renyi_game_gnm_impl( + n = 5, + m = 3 + ) + expect_s3_class(result, "igraph") }) test_that("erdos_renyi_game_gnm_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(erdos_renyi_game_gnm_impl(-1, 3)) + expect_snapshot_igraph_error(erdos_renyi_game_gnm_impl( + n = -1, + m = 3 + )) }) # 35. growing_random_game_impl test_that("growing_random_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(growing_random_game_impl(5, 2)) expect_snapshot(growing_random_game_impl( - 5, - 2, + n = 5, + m = 2 + )) + expect_snapshot(growing_random_game_impl( + n = 5, + m = 2, directed = FALSE, citation = TRUE )) + + # Structured tests + result <- growing_random_game_impl( + n = 5, + m = 2 + ) + expect_s3_class(result, "igraph") }) test_that("growing_random_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(growing_random_game_impl(-1, 2)) + expect_snapshot_igraph_error(growing_random_game_impl( + n = -1, + m = 2 + )) }) # 36. preference_game_impl @@ -540,23 +1042,33 @@ test_that("preference_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot(preference_game_impl( - 5, - 2, - c(0.5, 0.5), - FALSE, - matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2) + nodes = 5, + types = 2, + type.dist = c(0.5, 0.5), + fixed.sizes = FALSE, + pref.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2) )) + + # Structured tests + result <- preference_game_impl( + nodes = 5, + types = 2, + type.dist = c(0.5, 0.5), + fixed.sizes = FALSE, + pref.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2) + ) + expect_type(result, "list") }) test_that("preference_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( preference_game_impl( - -1, - 2, - c(0.5, 0.5), - FALSE, - matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2) + nodes = -1, + types = 2, + type.dist = c(0.5, 0.5), + fixed.sizes = FALSE, + pref.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2) ) ) }) @@ -566,23 +1078,33 @@ test_that("asymmetric_preference_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot(asymmetric_preference_game_impl( - 5, - 2, - 2, - matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2), - matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2) + nodes = 5, + out.types = 2, + in.types = 2, + type.dist.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2), + pref.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2) )) + + # Structured tests + result <- asymmetric_preference_game_impl( + nodes = 5, + out.types = 2, + in.types = 2, + type.dist.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2), + pref.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2) + ) + expect_type(result, "list") }) test_that("asymmetric_preference_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( asymmetric_preference_game_impl( - -1, - 2, - 2, - matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2), - matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2) + nodes = -1, + out.types = 2, + in.types = 2, + type.dist.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2), + pref.matrix = matrix(c(0.5, 0.5, 0.5, 0.5), 2, 2) ) ) }) @@ -591,58 +1113,123 @@ test_that("asymmetric_preference_game_impl errors", { test_that("rewire_edges_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(5) - expect_snapshot(rewire_edges_impl(g, 0.5)) + g <- path_graph_impl( + n = 5 + ) + + expect_snapshot(rewire_edges_impl( + graph = g, + prob = 0.5 + )) + + # Structured tests + result <- rewire_edges_impl( + graph = g, + prob = 0.5 + ) + expect_s3_class(result, "igraph") }) test_that("rewire_edges_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(rewire_edges_impl(NULL, 0.5)) + expect_snapshot_igraph_error(rewire_edges_impl( + graph = NULL, + prob = 0.5 + )) }) # 39. rewire_directed_edges_impl test_that("rewire_directed_edges_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(5, directed = TRUE) - expect_snapshot(rewire_directed_edges_impl(g, 0.5)) + g <- path_graph_impl( + n = 5, + directed = TRUE + ) + + expect_snapshot(rewire_directed_edges_impl( + graph = g, + prob = 0.5 + )) + + # Structured tests + result <- rewire_directed_edges_impl( + graph = g, + prob = 0.5 + ) + expect_s3_class(result, "igraph") }) test_that("rewire_directed_edges_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(rewire_directed_edges_impl(NULL, 0.5)) + expect_snapshot_igraph_error(rewire_directed_edges_impl( + graph = NULL, + prob = 0.5 + )) }) # 40. forest_fire_game_impl test_that("forest_fire_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(forest_fire_game_impl(5, 0.5)) expect_snapshot(forest_fire_game_impl( - 5, - 0.5, + nodes = 5, + fw.prob = 0.5 + )) + expect_snapshot(forest_fire_game_impl( + nodes = 5, + fw.prob = 0.5, bw.factor = 0.2, ambs = 2, directed = FALSE )) + + # Structured tests + result <- forest_fire_game_impl( + nodes = 5, + fw.prob = 0.5 + ) + expect_s3_class(result, "igraph") }) test_that("forest_fire_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(forest_fire_game_impl(-1, 0.5)) + expect_snapshot_igraph_error(forest_fire_game_impl( + nodes = -1, + fw.prob = 0.5 + )) }) # 41. simple_interconnected_islands_game_impl test_that("simple_interconnected_islands_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(simple_interconnected_islands_game_impl(2, 3, 0.5, 1)) + expect_snapshot(simple_interconnected_islands_game_impl( + islands.n = 2, + islands.size = 3, + islands.pin = 0.5, + n.inter = 1 + )) + + # Structured tests + result <- simple_interconnected_islands_game_impl( + islands.n = 2, + islands.size = 3, + islands.pin = 0.5, + n.inter = 1 + ) + expect_s3_class(result, "igraph") }) test_that("simple_interconnected_islands_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - simple_interconnected_islands_game_impl(-1, 3, 0.5, 1) + simple_interconnected_islands_game_impl( + islands.n = -1, + islands.size = 3, + islands.pin = 0.5, + n.inter = 1 + ) ) }) @@ -650,58 +1237,97 @@ test_that("simple_interconnected_islands_game_impl errors", { test_that("chung_lu_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(chung_lu_game_impl(c(2, 2, 2))) expect_snapshot(chung_lu_game_impl( - c(1, 2, 3), - c(1, 2, 3), + out.weights = c(2, 2, 2) + )) + expect_snapshot(chung_lu_game_impl( + out.weights = c(1, 2, 3), + in.weights = c(1, 2, 3), loops = FALSE, variant = "maxent" )) + + # Structured tests + result <- chung_lu_game_impl( + out.weights = c(2, 2, 2) + ) + expect_s3_class(result, "igraph") }) test_that("chung_lu_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(chung_lu_game_impl(-1)) + expect_snapshot_igraph_error(chung_lu_game_impl( + out.weights = -1 + )) }) # 43. static_fitness_game_impl test_that("static_fitness_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(static_fitness_game_impl(3, c(1, 2, 3))) expect_snapshot(static_fitness_game_impl( - 3, - c(1, 2, 3), - c(1, 2, 3), + no.of.edges = 3, + fitness.out = c(1, 2, 3) + )) + expect_snapshot(static_fitness_game_impl( + no.of.edges = 3, + fitness.out = c(1, 2, 3), + fitness.in = c(1, 2, 3), loops = TRUE, multiple = TRUE )) + + # Structured tests + result <- static_fitness_game_impl( + no.of.edges = 3, + fitness.out = c(1, 2, 3) + ) + expect_s3_class(result, "igraph") }) test_that("static_fitness_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(static_fitness_game_impl(-1, c(1, 2, 3))) + expect_snapshot_igraph_error(static_fitness_game_impl( + no.of.edges = -1, + fitness.out = c(1, 2, 3) + )) }) # 44. static_power_law_game_impl test_that("static_power_law_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(static_power_law_game_impl(5, 4, 2.5)) expect_snapshot(static_power_law_game_impl( - 5, - 4, - 2.5, + no.of.nodes = 5, + no.of.edges = 4, + exponent.out = 2.5 + )) + expect_snapshot(static_power_law_game_impl( + no.of.nodes = 5, + no.of.edges = 4, + exponent.out = 2.5, exponent.in = 2, loops = TRUE, multiple = TRUE, finite.size.correction = FALSE )) + + # Structured tests + result <- static_power_law_game_impl( + no.of.nodes = 5, + no.of.edges = 4, + exponent.out = 2.5 + ) + expect_s3_class(result, "igraph") }) test_that("static_power_law_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(static_power_law_game_impl(-1, 4, 2.5)) + expect_snapshot_igraph_error(static_power_law_game_impl( + no.of.nodes = -1, + no.of.edges = 4, + exponent.out = 2.5 + )) }) # 45. k_regular_game_impl @@ -709,14 +1335,32 @@ test_that("static_power_law_game_impl errors", { test_that("k_regular_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(k_regular_game_impl(5, 2)) - expect_snapshot(k_regular_game_impl(5, 2, directed = TRUE, multiple = TRUE)) + expect_snapshot(k_regular_game_impl( + no.of.nodes = 5, + k = 2 + )) + expect_snapshot(k_regular_game_impl( + no.of.nodes = 5, + k = 2, + directed = TRUE, + multiple = TRUE + )) + + # Structured tests + result <- k_regular_game_impl( + no.of.nodes = 5, + k = 2 + ) + expect_s3_class(result, "igraph") }) test_that("k_regular_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(k_regular_game_impl(-1, 2)) + expect_snapshot_igraph_error(k_regular_game_impl( + no.of.nodes = -1, + k = 2 + )) }) # 46. sbm_game_impl @@ -724,20 +1368,36 @@ test_that("k_regular_game_impl errors", { test_that("sbm_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(sbm_game_impl(5, matrix(0.5, 2, 2), c(2, 3))) expect_snapshot(sbm_game_impl( - 5, - matrix(0.5, 2, 2), - c(2, 3), + n = 5, + pref.matrix = matrix(0.5, 2, 2), + block.sizes = c(2, 3) + )) + expect_snapshot(sbm_game_impl( + n = 5, + pref.matrix = matrix(0.5, 2, 2), + block.sizes = c(2, 3), directed = TRUE, loops = TRUE )) + + # Structured tests + result <- sbm_game_impl( + n = 5, + pref.matrix = matrix(0.5, 2, 2), + block.sizes = c(2, 3) + ) + expect_s3_class(result, "igraph") }) test_that("sbm_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(sbm_game_impl(-1, matrix(0.5, 2, 2), c(2, 3))) + expect_snapshot_igraph_error(sbm_game_impl( + n = -1, + pref.matrix = matrix(0.5, 2, 2), + block.sizes = c(2, 3) + )) }) # 47. hsbm_game_impl @@ -745,14 +1405,36 @@ test_that("sbm_game_impl errors", { test_that("hsbm_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(hsbm_game_impl(6, 2, c(0.5, 0.5), matrix(1, 2, 2), 0.5)) + expect_snapshot(hsbm_game_impl( + n = 6, + m = 2, + rho = c(0.5, 0.5), + C = matrix(1, 2, 2), + p = 0.5 + )) + + # Structured tests + result <- hsbm_game_impl( + n = 6, + m = 2, + rho = c(0.5, 0.5), + C = matrix(1, 2, 2), + p = 0.5 + ) + expect_s3_class(result, "igraph") }) test_that("hsbm_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - hsbm_game_impl(-1, 2, 0.5, matrix(1, 2, 2), 0.5) + hsbm_game_impl( + n = -1, + m = 2, + rho = 0.5, + C = matrix(1, 2, 2), + p = 0.5 + ) ) }) @@ -776,12 +1458,28 @@ test_that("hsbm_list_game_impl basic", { nrow = 3 ) expect_snapshot(hsbm_list_game_impl( - 100, - list(50, 50), - rho = list(c(3, 3, 4) / 10), - C = list(C), + n = 100, + mlist = list(50, 50), + rholist = list( + c(3, 3, 4) / + 10 + ), + Clist = list(C), p = 1 / 20 )) + + # Structured tests + result <- hsbm_list_game_impl( + n = 100, + mlist = list(50, 50), + rholist = list( + c(3, 3, 4) / + 10 + ), + Clist = list(C), + p = 1 / 20 + ) + expect_s3_class(result, "igraph") }) test_that("hsbm_list_game_impl errors", { @@ -789,11 +1487,14 @@ test_that("hsbm_list_game_impl errors", { local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( hsbm_list_game_impl( - -1, - c(2, 3), - list(0.5, 0.5), - list(matrix(1, 2, 2), matrix(1, 2, 2)), - 0.5 + n = -1, + mlist = c(2, 3), + rholist = list(0.5, 0.5), + Clist = list( + matrix(1, 2, 2), + matrix(1, 2, 2) + ), + p = 0.5 ) ) }) @@ -803,14 +1504,30 @@ test_that("hsbm_list_game_impl errors", { test_that("correlated_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(5) - expect_snapshot(correlated_game_impl(g, 0.5)) -}) + g <- path_graph_impl( + n = 5 + ) -test_that("correlated_game_impl errors", { + expect_snapshot(correlated_game_impl( + old.graph = g, + corr = 0.5 + )) + + # Structured tests + result <- correlated_game_impl( + old.graph = g, + corr = 0.5 + ) + expect_s3_class(result, "igraph") +}) + +test_that("correlated_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(correlated_game_impl(NULL, 0.5)) + expect_snapshot_igraph_error(correlated_game_impl( + old.graph = NULL, + corr = 0.5 + )) }) # 50. correlated_pair_game_impl @@ -818,14 +1535,35 @@ test_that("correlated_game_impl errors", { test_that("correlated_pair_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(correlated_pair_game_impl(5, 0.5, 0.5)) - expect_snapshot(correlated_pair_game_impl(5, 0.5, 0.5, directed = TRUE)) + expect_snapshot(correlated_pair_game_impl( + n = 5, + corr = 0.5, + p = 0.5 + )) + expect_snapshot(correlated_pair_game_impl( + n = 5, + corr = 0.5, + p = 0.5, + directed = TRUE + )) + + # Structured tests + result <- correlated_pair_game_impl( + n = 5, + corr = 0.5, + p = 0.5 + ) + expect_type(result, "list") }) test_that("correlated_pair_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(correlated_pair_game_impl(-1, 0.5, 0.5)) + expect_snapshot_igraph_error(correlated_pair_game_impl( + n = -1, + corr = 0.5, + p = 0.5 + )) }) # 51. dot_product_game_impl @@ -833,14 +1571,27 @@ test_that("correlated_pair_game_impl errors", { test_that("dot_product_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(dot_product_game_impl(matrix(0.5, 5, 2))) - expect_snapshot(dot_product_game_impl(matrix(0.5, 5, 2), directed = TRUE)) + expect_snapshot(dot_product_game_impl( + vecs = matrix(0.5, 5, 2) + )) + expect_snapshot(dot_product_game_impl( + vecs = matrix(0.5, 5, 2), + directed = TRUE + )) + + # Structured tests + result <- dot_product_game_impl( + vecs = matrix(0.5, 5, 2) + ) + expect_s3_class(result, "igraph") }) test_that("dot_product_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(dot_product_game_impl(NULL)) + expect_snapshot_igraph_error(dot_product_game_impl( + vecs = NULL + )) }) # 52. sample_sphere_surface_impl @@ -848,19 +1599,32 @@ test_that("dot_product_game_impl errors", { test_that("sample_sphere_surface_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(sample_sphere_surface_impl(3, 5)) expect_snapshot(sample_sphere_surface_impl( - 3, - 5, + dim = 3, + n = 5 + )) + expect_snapshot(sample_sphere_surface_impl( + dim = 3, + n = 5, radius = 2, positive = FALSE )) + + # Structured tests + result <- sample_sphere_surface_impl( + dim = 3, + n = 5 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("sample_sphere_surface_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(sample_sphere_surface_impl(-1, 5)) + expect_snapshot_igraph_error(sample_sphere_surface_impl( + dim = -1, + n = 5 + )) }) # 53. sample_sphere_volume_impl @@ -868,14 +1632,32 @@ test_that("sample_sphere_surface_impl errors", { test_that("sample_sphere_volume_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(sample_sphere_volume_impl(3, 5)) - expect_snapshot(sample_sphere_volume_impl(3, 5, radius = 2, positive = FALSE)) + expect_snapshot(sample_sphere_volume_impl( + dim = 3, + n = 5 + )) + expect_snapshot(sample_sphere_volume_impl( + dim = 3, + n = 5, + radius = 2, + positive = FALSE + )) + + # Structured tests + result <- sample_sphere_volume_impl( + dim = 3, + n = 5 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("sample_sphere_volume_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(sample_sphere_volume_impl(-1, 5)) + expect_snapshot_igraph_error(sample_sphere_volume_impl( + dim = -1, + n = 5 + )) }) # 54. sample_dirichlet_impl @@ -883,13 +1665,26 @@ test_that("sample_sphere_volume_impl errors", { test_that("sample_dirichlet_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(sample_dirichlet_impl(5, c(1, 1, 1))) + expect_snapshot(sample_dirichlet_impl( + n = 5, + alpha = c(1, 1, 1) + )) + + # Structured tests + result <- sample_dirichlet_impl( + n = 5, + alpha = c(1, 1, 1) + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("sample_dirichlet_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(sample_dirichlet_impl(-1, c(1, 1, 1))) + expect_snapshot_igraph_error(sample_dirichlet_impl( + n = -1, + alpha = c(1, 1, 1) + )) }) # 55. are_adjacent_impl @@ -897,14 +1692,33 @@ test_that("sample_dirichlet_impl errors", { test_that("are_adjacent_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(are_adjacent_impl(g, 1, 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(are_adjacent_impl( + graph = g, + v1 = 1, + v2 = 2 + )) + + # Structured tests + result <- are_adjacent_impl( + graph = g, + v1 = 1, + v2 = 2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("are_adjacent_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(are_adjacent_impl(NULL, 1, 2)) + expect_snapshot_igraph_error(are_adjacent_impl( + graph = NULL, + v1 = 1, + v2 = 2 + )) }) # 56. closeness_impl @@ -912,15 +1726,32 @@ test_that("are_adjacent_impl errors", { test_that("closeness_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(closeness_impl(g)) - expect_snapshot(closeness_impl(g, mode = "in", normalized = TRUE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(closeness_impl( + graph = g + )) + expect_snapshot(closeness_impl( + graph = g, + mode = "in", + normalized = TRUE + )) + + # Structured tests + result <- closeness_impl( + graph = g + ) + expect_type(result, "list") }) test_that("closeness_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(closeness_impl(NULL)) + expect_snapshot_igraph_error(closeness_impl( + graph = NULL + )) }) # 57. closeness_cutoff_impl @@ -928,20 +1759,35 @@ test_that("closeness_impl errors", { test_that("closeness_cutoff_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(closeness_cutoff_impl(g, cutoff = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(closeness_cutoff_impl( + graph = g, + cutoff = 2 + )) expect_snapshot(closeness_cutoff_impl( - g, + graph = g, mode = "in", normalized = TRUE, cutoff = 1 )) + + # Structured tests + result <- closeness_cutoff_impl( + graph = g, + cutoff = 2 + ) + expect_type(result, "list") }) test_that("closeness_cutoff_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(closeness_cutoff_impl(NULL)) + expect_snapshot_igraph_error(closeness_cutoff_impl( + graph = NULL + )) }) # 58. get_shortest_path_impl @@ -949,14 +1795,33 @@ test_that("closeness_cutoff_impl errors", { test_that("get_shortest_path_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_shortest_path_impl(g, 1, 3)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_shortest_path_impl( + graph = g, + from = 1, + to = 3 + )) + + # Structured tests + result <- get_shortest_path_impl( + graph = g, + from = 1, + to = 3 + ) + expect_type(result, "list") }) test_that("get_shortest_path_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_shortest_path_impl(NULL, 1, 3)) + expect_snapshot_igraph_error(get_shortest_path_impl( + graph = NULL, + from = 1, + to = 3 + )) }) # 59. get_shortest_path_bellman_ford_impl @@ -964,14 +1829,33 @@ test_that("get_shortest_path_impl errors", { test_that("get_shortest_path_bellman_ford_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_shortest_path_bellman_ford_impl(g, 1, 3)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_shortest_path_bellman_ford_impl( + graph = g, + from = 1, + to = 3 + )) + + # Structured tests + result <- get_shortest_path_bellman_ford_impl( + graph = g, + from = 1, + to = 3 + ) + expect_type(result, "list") }) test_that("get_shortest_path_bellman_ford_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_shortest_path_bellman_ford_impl(NULL, 1, 3)) + expect_snapshot_igraph_error(get_shortest_path_bellman_ford_impl( + graph = NULL, + from = 1, + to = 3 + )) }) # 60. get_shortest_path_dijkstra_impl @@ -979,14 +1863,33 @@ test_that("get_shortest_path_bellman_ford_impl errors", { test_that("get_shortest_path_dijkstra_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_shortest_path_dijkstra_impl(g, 1, 3)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_shortest_path_dijkstra_impl( + graph = g, + from = 1, + to = 3 + )) + + # Structured tests + result <- get_shortest_path_dijkstra_impl( + graph = g, + from = 1, + to = 3 + ) + expect_type(result, "list") }) test_that("get_shortest_path_dijkstra_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_shortest_path_dijkstra_impl(NULL, 1, 3)) + expect_snapshot_igraph_error(get_shortest_path_dijkstra_impl( + graph = NULL, + from = 1, + to = 3 + )) }) # 61. get_all_shortest_paths_impl @@ -994,14 +1897,33 @@ test_that("get_shortest_path_dijkstra_impl errors", { test_that("get_all_shortest_paths_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_all_shortest_paths_impl(g, 1, 3)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_all_shortest_paths_impl( + graph = g, + from = 1, + to = 3 + )) + + # Structured tests + result <- get_all_shortest_paths_impl( + graph = g, + from = 1, + to = 3 + ) + expect_type(result, "list") }) test_that("get_all_shortest_paths_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_all_shortest_paths_impl(NULL, 1, 3)) + expect_snapshot_igraph_error(get_all_shortest_paths_impl( + graph = NULL, + from = 1, + to = 3 + )) }) # 62. get_all_shortest_paths_dijkstra_impl @@ -1009,15 +1931,34 @@ test_that("get_all_shortest_paths_impl errors", { test_that("get_all_shortest_paths_dijkstra_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_all_shortest_paths_dijkstra_impl(g, 1, 3)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_all_shortest_paths_dijkstra_impl( + graph = g, + from = 1, + to = 3 + )) + + # Structured tests + result <- get_all_shortest_paths_dijkstra_impl( + graph = g, + from = 1, + to = 3 + ) + expect_type(result, "list") }) test_that("get_all_shortest_paths_dijkstra_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - get_all_shortest_paths_dijkstra_impl(NULL, 1, 3) + get_all_shortest_paths_dijkstra_impl( + graph = NULL, + from = 1, + to = 3 + ) ) }) @@ -1026,15 +1967,36 @@ test_that("get_all_shortest_paths_dijkstra_impl errors", { test_that("voronoi_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(voronoi_impl(g, 1)) - expect_snapshot(voronoi_impl(g, 1, mode = "in", tiebreaker = "first")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(voronoi_impl( + graph = g, + generators = 1 + )) + expect_snapshot(voronoi_impl( + graph = g, + generators = 1, + mode = "in", + tiebreaker = "first" + )) + + # Structured tests + result <- voronoi_impl( + graph = g, + generators = 1 + ) + expect_type(result, "list") }) test_that("voronoi_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(voronoi_impl(NULL, 1)) + expect_snapshot_igraph_error(voronoi_impl( + graph = NULL, + generators = 1 + )) }) # 64. get_all_simple_paths_impl @@ -1042,14 +2004,33 @@ test_that("voronoi_impl errors", { test_that("get_all_simple_paths_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_all_simple_paths_impl(g, 1, 3)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_all_simple_paths_impl( + graph = g, + from = 1, + to = 3 + )) + + # Structured tests + result <- get_all_simple_paths_impl( + graph = g, + from = 1, + to = 3 + ) + expect_s3_class(result, "igraph.vs") }) test_that("get_all_simple_paths_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_all_simple_paths_impl(NULL, 1, 3)) + expect_snapshot_igraph_error(get_all_simple_paths_impl( + graph = NULL, + from = 1, + to = 3 + )) }) # 65. get_k_shortest_paths_impl @@ -1057,14 +2038,36 @@ test_that("get_all_simple_paths_impl errors", { test_that("get_k_shortest_paths_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_k_shortest_paths_impl(g, 1, 3, k = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_k_shortest_paths_impl( + graph = g, + from = 1, + to = 3, + k = 2 + )) + + # Structured tests + result <- get_k_shortest_paths_impl( + graph = g, + from = 1, + to = 3, + k = 2 + ) + expect_type(result, "list") }) test_that("get_k_shortest_paths_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_k_shortest_paths_impl(NULL, 1, 3, k = 2)) + expect_snapshot_igraph_error(get_k_shortest_paths_impl( + graph = NULL, + from = 1, + to = 3, + k = 2 + )) }) # 66. get_widest_path_impl @@ -1072,14 +2075,35 @@ test_that("get_k_shortest_paths_impl errors", { test_that("get_widest_path_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_widest_path_impl(g, 1, 3, weights = c(1, 2))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_widest_path_impl( + graph = g, + from = 1, + to = 3, + weights = c(1, 2) + )) + + # Structured tests + result <- get_widest_path_impl( + graph = g, + from = 1, + to = 3, + weights = c(1, 2) + ) + expect_type(result, "list") }) test_that("get_widest_path_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_widest_path_impl(NULL, 1, 3)) + expect_snapshot_igraph_error(get_widest_path_impl( + graph = NULL, + from = 1, + to = 3 + )) }) # 67. get_widest_paths_impl @@ -1087,14 +2111,35 @@ test_that("get_widest_path_impl errors", { test_that("get_widest_paths_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_widest_paths_impl(g, 1, 3, weights = c(1, 2))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_widest_paths_impl( + graph = g, + from = 1, + to = 3, + weights = c(1, 2) + )) + + # Structured tests + result <- get_widest_paths_impl( + graph = g, + from = 1, + to = 3, + weights = c(1, 2) + ) + expect_type(result, "list") }) test_that("get_widest_paths_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_widest_paths_impl(NULL, 1, 3)) + expect_snapshot_igraph_error(get_widest_paths_impl( + graph = NULL, + from = 1, + to = 3 + )) }) # 70. spanner_impl @@ -1102,14 +2147,30 @@ test_that("get_widest_paths_impl errors", { test_that("spanner_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(spanner_impl(g, 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(spanner_impl( + graph = g, + stretch = 2 + )) + + # Structured tests + result <- spanner_impl( + graph = g, + stretch = 2 + ) + expect_s3_class(result, "igraph.es") }) test_that("spanner_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(spanner_impl(NULL, 2)) + expect_snapshot_igraph_error(spanner_impl( + graph = NULL, + stretch = 2 + )) }) # 71. betweenness_cutoff_impl @@ -1117,14 +2178,30 @@ test_that("spanner_impl errors", { test_that("betweenness_cutoff_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(betweenness_cutoff_impl(g, cutoff = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(betweenness_cutoff_impl( + graph = g, + cutoff = 2 + )) + + # Structured tests + result <- betweenness_cutoff_impl( + graph = g, + cutoff = 2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("betweenness_cutoff_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(betweenness_cutoff_impl(NULL, cutoff = 2)) + expect_snapshot_igraph_error(betweenness_cutoff_impl( + graph = NULL, + cutoff = 2 + )) }) # 72. betweenness_subset_impl @@ -1132,14 +2209,27 @@ test_that("betweenness_cutoff_impl errors", { test_that("betweenness_subset_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(betweenness_subset_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(betweenness_subset_impl( + graph = g + )) + + # Structured tests + result <- betweenness_subset_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("betweenness_subset_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(betweenness_subset_impl(NULL)) + expect_snapshot_igraph_error(betweenness_subset_impl( + graph = NULL + )) }) # 73. edge_betweenness_impl @@ -1147,14 +2237,27 @@ test_that("betweenness_subset_impl errors", { test_that("edge_betweenness_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(edge_betweenness_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(edge_betweenness_impl( + graph = g + )) + + # Structured tests + result <- edge_betweenness_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("edge_betweenness_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(edge_betweenness_impl(NULL)) + expect_snapshot_igraph_error(edge_betweenness_impl( + graph = NULL + )) }) # 74. edge_betweenness_cutoff_impl @@ -1162,14 +2265,30 @@ test_that("edge_betweenness_impl errors", { test_that("edge_betweenness_cutoff_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(edge_betweenness_cutoff_impl(g, cutoff = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(edge_betweenness_cutoff_impl( + graph = g, + cutoff = 2 + )) + + # Structured tests + result <- edge_betweenness_cutoff_impl( + graph = g, + cutoff = 2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("edge_betweenness_cutoff_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(edge_betweenness_cutoff_impl(NULL, cutoff = 2)) + expect_snapshot_igraph_error(edge_betweenness_cutoff_impl( + graph = NULL, + cutoff = 2 + )) }) # 75. edge_betweenness_subset_impl @@ -1177,14 +2296,27 @@ test_that("edge_betweenness_cutoff_impl errors", { test_that("edge_betweenness_subset_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(edge_betweenness_subset_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(edge_betweenness_subset_impl( + graph = g + )) + + # Structured tests + result <- edge_betweenness_subset_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("edge_betweenness_subset_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(edge_betweenness_subset_impl(NULL)) + expect_snapshot_igraph_error(edge_betweenness_subset_impl( + graph = NULL + )) }) # 76. harmonic_centrality_cutoff_impl @@ -1192,15 +2324,31 @@ test_that("edge_betweenness_subset_impl errors", { test_that("harmonic_centrality_cutoff_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(harmonic_centrality_cutoff_impl(g, cutoff = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(harmonic_centrality_cutoff_impl( + graph = g, + cutoff = 2 + )) + + # Structured tests + result <- harmonic_centrality_cutoff_impl( + graph = g, + cutoff = 2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("harmonic_centrality_cutoff_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - harmonic_centrality_cutoff_impl(NULL, cutoff = 2) + harmonic_centrality_cutoff_impl( + graph = NULL, + cutoff = 2 + ) ) }) @@ -1209,15 +2357,32 @@ test_that("harmonic_centrality_cutoff_impl errors", { test_that("personalized_pagerank_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(personalized_pagerank_impl(g)) - expect_snapshot(personalized_pagerank_impl(g, algo = "arpack", damping = 0.9)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(personalized_pagerank_impl( + graph = g + )) + expect_snapshot(personalized_pagerank_impl( + graph = g, + algo = "arpack", + damping = 0.9 + )) + + # Structured tests + result <- personalized_pagerank_impl( + graph = g + ) + expect_type(result, "list") }) test_that("personalized_pagerank_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(personalized_pagerank_impl(NULL)) + expect_snapshot_igraph_error(personalized_pagerank_impl( + graph = NULL + )) }) # 78. personalized_pagerank_vs_impl @@ -1225,21 +2390,37 @@ test_that("personalized_pagerank_impl errors", { test_that("personalized_pagerank_vs_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(personalized_pagerank_vs_impl(g, reset.vids = 1)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(personalized_pagerank_vs_impl( + graph = g, + reset.vids = 1 + )) expect_snapshot(personalized_pagerank_vs_impl( - g, + graph = g, algo = "arpack", reset.vids = 1, details = TRUE )) + + # Structured tests + result <- personalized_pagerank_vs_impl( + graph = g, + reset.vids = 1 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("personalized_pagerank_vs_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - personalized_pagerank_vs_impl(NULL, reset.vids = 1) + personalized_pagerank_vs_impl( + graph = NULL, + reset.vids = 1 + ) ) }) @@ -1248,14 +2429,30 @@ test_that("personalized_pagerank_vs_impl errors", { test_that("induced_subgraph_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(induced_subgraph_impl(g, 1:2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(induced_subgraph_impl( + graph = g, + vids = 1:2 + )) + + # Structured tests + result <- induced_subgraph_impl( + graph = g, + vids = 1:2 + ) + expect_s3_class(result, "igraph") }) test_that("induced_subgraph_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(induced_subgraph_impl(NULL, 1:2)) + expect_snapshot_igraph_error(induced_subgraph_impl( + graph = NULL, + vids = 1:2 + )) }) # 80. subgraph_from_edges_impl @@ -1263,14 +2460,30 @@ test_that("induced_subgraph_impl errors", { test_that("subgraph_from_edges_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(subgraph_from_edges_impl(g, 1)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(subgraph_from_edges_impl( + graph = g, + eids = 1 + )) + + # Structured tests + result <- subgraph_from_edges_impl( + graph = g, + eids = 1 + ) + expect_s3_class(result, "igraph") }) test_that("subgraph_from_edges_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(subgraph_from_edges_impl(NULL, 1)) + expect_snapshot_igraph_error(subgraph_from_edges_impl( + graph = NULL, + eids = 1 + )) }) # 81. reverse_edges_impl @@ -1278,14 +2491,27 @@ test_that("subgraph_from_edges_impl errors", { test_that("reverse_edges_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(reverse_edges_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(reverse_edges_impl( + graph = g + )) + + # Structured tests + result <- reverse_edges_impl( + graph = g + ) + expect_s3_class(result, "igraph") }) test_that("reverse_edges_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(reverse_edges_impl(NULL)) + expect_snapshot_igraph_error(reverse_edges_impl( + graph = NULL + )) }) # and much more halucination before... @@ -1297,15 +2523,31 @@ test_that("reverse_edges_impl errors", { test_that("path_length_hist_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(path_length_hist_impl(g)) - expect_snapshot(path_length_hist_impl(g, directed = FALSE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(path_length_hist_impl( + graph = g + )) + expect_snapshot(path_length_hist_impl( + graph = g, + directed = FALSE + )) + + # Structured tests + result <- path_length_hist_impl( + graph = g + ) + expect_type(result, "list") }) test_that("path_length_hist_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(path_length_hist_impl(NULL)) + expect_snapshot_igraph_error(path_length_hist_impl( + graph = NULL + )) }) # 102. simplify_impl @@ -1313,19 +2555,32 @@ test_that("path_length_hist_impl errors", { test_that("simplify_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(simplify_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(simplify_impl( + graph = g + )) expect_snapshot(simplify_impl( - g, + graph = g, remove.multiple = FALSE, remove.loops = FALSE )) + + # Structured tests + result <- simplify_impl( + graph = g + ) + expect_s3_class(result, "igraph") }) test_that("simplify_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(simplify_impl(NULL)) + expect_snapshot_igraph_error(simplify_impl( + graph = NULL + )) }) # 103. transitivity_undirected_impl @@ -1333,15 +2588,31 @@ test_that("simplify_impl errors", { test_that("transitivity_undirected_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(transitivity_undirected_impl(g)) - expect_snapshot(transitivity_undirected_impl(g, mode = "zero")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(transitivity_undirected_impl( + graph = g + )) + expect_snapshot(transitivity_undirected_impl( + graph = g, + mode = "zero" + )) + + # Structured tests + result <- transitivity_undirected_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("transitivity_undirected_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(transitivity_undirected_impl(NULL)) + expect_snapshot_igraph_error(transitivity_undirected_impl( + graph = NULL + )) }) # 104. transitivity_local_undirected_impl @@ -1349,15 +2620,31 @@ test_that("transitivity_undirected_impl errors", { test_that("transitivity_local_undirected_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(transitivity_local_undirected_impl(g)) - expect_snapshot(transitivity_local_undirected_impl(g, mode = "zero")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(transitivity_local_undirected_impl( + graph = g + )) + expect_snapshot(transitivity_local_undirected_impl( + graph = g, + mode = "zero" + )) + + # Structured tests + result <- transitivity_local_undirected_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("transitivity_local_undirected_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(transitivity_local_undirected_impl(NULL)) + expect_snapshot_igraph_error(transitivity_local_undirected_impl( + graph = NULL + )) }) # 105. transitivity_avglocal_undirected_impl @@ -1365,15 +2652,31 @@ test_that("transitivity_local_undirected_impl errors", { test_that("transitivity_avglocal_undirected_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(transitivity_avglocal_undirected_impl(g)) - expect_snapshot(transitivity_avglocal_undirected_impl(g, mode = "zero")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(transitivity_avglocal_undirected_impl( + graph = g + )) + expect_snapshot(transitivity_avglocal_undirected_impl( + graph = g, + mode = "zero" + )) + + # Structured tests + result <- transitivity_avglocal_undirected_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("transitivity_avglocal_undirected_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(transitivity_avglocal_undirected_impl(NULL)) + expect_snapshot_igraph_error(transitivity_avglocal_undirected_impl( + graph = NULL + )) }) # 106. transitivity_barrat_impl @@ -1381,15 +2684,31 @@ test_that("transitivity_avglocal_undirected_impl errors", { test_that("transitivity_barrat_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(transitivity_barrat_impl(g)) - expect_snapshot(transitivity_barrat_impl(g, mode = "zero")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(transitivity_barrat_impl( + graph = g + )) + expect_snapshot(transitivity_barrat_impl( + graph = g, + mode = "zero" + )) + + # Structured tests + result <- transitivity_barrat_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("transitivity_barrat_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(transitivity_barrat_impl(NULL)) + expect_snapshot_igraph_error(transitivity_barrat_impl( + graph = NULL + )) }) # 107. ecc_impl @@ -1397,15 +2716,33 @@ test_that("transitivity_barrat_impl errors", { test_that("ecc_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(4) - expect_snapshot(ecc_impl(g)) - expect_snapshot(ecc_impl(g, k = 3, offset = TRUE, normalize = FALSE)) + g <- path_graph_impl( + n = 4 + ) + + expect_snapshot(ecc_impl( + graph = g + )) + expect_snapshot(ecc_impl( + graph = g, + k = 3, + offset = TRUE, + normalize = FALSE + )) + + # Structured tests + result <- ecc_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("ecc_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(ecc_impl(NULL)) + expect_snapshot_igraph_error(ecc_impl( + graph = NULL + )) }) # 108. reciprocity_impl @@ -1413,15 +2750,32 @@ test_that("ecc_impl errors", { test_that("reciprocity_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(reciprocity_impl(g)) - expect_snapshot(reciprocity_impl(g, ignore.loops = FALSE, mode = "ratio")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(reciprocity_impl( + graph = g + )) + expect_snapshot(reciprocity_impl( + graph = g, + ignore.loops = FALSE, + mode = "ratio" + )) + + # Structured tests + result <- reciprocity_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("reciprocity_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(reciprocity_impl(NULL)) + expect_snapshot_igraph_error(reciprocity_impl( + graph = NULL + )) }) # 109. maxdegree_impl @@ -1429,15 +2783,32 @@ test_that("reciprocity_impl errors", { test_that("maxdegree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(maxdegree_impl(g)) - expect_snapshot(maxdegree_impl(g, mode = "in", loops = FALSE)) -}) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(maxdegree_impl( + graph = g + )) + expect_snapshot(maxdegree_impl( + graph = g, + mode = "in", + loops = FALSE + )) + + # Structured tests + result <- maxdegree_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) +}) test_that("maxdegree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(maxdegree_impl(NULL)) + expect_snapshot_igraph_error(maxdegree_impl( + graph = NULL + )) }) # 110. density_impl @@ -1445,15 +2816,31 @@ test_that("maxdegree_impl errors", { test_that("density_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(density_impl(g)) - expect_snapshot(density_impl(g, loops = TRUE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(density_impl( + graph = g + )) + expect_snapshot(density_impl( + graph = g, + loops = TRUE + )) + + # Structured tests + result <- density_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("density_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(density_impl(NULL)) + expect_snapshot_igraph_error(density_impl( + graph = NULL + )) }) # 111. mean_degree_impl @@ -1461,15 +2848,31 @@ test_that("density_impl errors", { test_that("mean_degree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(mean_degree_impl(g)) - expect_snapshot(mean_degree_impl(g, loops = FALSE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(mean_degree_impl( + graph = g + )) + expect_snapshot(mean_degree_impl( + graph = g, + loops = FALSE + )) + + # Structured tests + result <- mean_degree_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("mean_degree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(mean_degree_impl(NULL)) + expect_snapshot_igraph_error(mean_degree_impl( + graph = NULL + )) }) # 112. feedback_arc_set_impl @@ -1477,15 +2880,31 @@ test_that("mean_degree_impl errors", { test_that("feedback_arc_set_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(feedback_arc_set_impl(g)) - expect_snapshot(feedback_arc_set_impl(g, algo = "exact_ip")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(feedback_arc_set_impl( + graph = g + )) + expect_snapshot(feedback_arc_set_impl( + graph = g, + algo = "exact_ip" + )) + + # Structured tests + result <- feedback_arc_set_impl( + graph = g + ) + expect_s3_class(result, "igraph.es") }) test_that("feedback_arc_set_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(feedback_arc_set_impl(NULL)) + expect_snapshot_igraph_error(feedback_arc_set_impl( + graph = NULL + )) }) # 113. feedback_vertex_set_impl @@ -1493,14 +2912,27 @@ test_that("feedback_arc_set_impl errors", { test_that("feedback_vertex_set_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(feedback_vertex_set_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(feedback_vertex_set_impl( + graph = g + )) + + # Structured tests + result <- feedback_vertex_set_impl( + graph = g + ) + expect_s3_class(result, "igraph.vs") }) test_that("feedback_vertex_set_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(feedback_vertex_set_impl(NULL)) + expect_snapshot_igraph_error(feedback_vertex_set_impl( + graph = NULL + )) }) # 114. is_loop_impl @@ -1508,14 +2940,27 @@ test_that("feedback_vertex_set_impl errors", { test_that("is_loop_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_loop_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_loop_impl( + graph = g + )) + + # Structured tests + result <- is_loop_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_loop_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_loop_impl(NULL)) + expect_snapshot_igraph_error(is_loop_impl( + graph = NULL + )) }) # 115. is_dag_impl @@ -1523,14 +2968,27 @@ test_that("is_loop_impl errors", { test_that("is_dag_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_dag_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_dag_impl( + graph = g + )) + + # Structured tests + result <- is_dag_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_dag_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_dag_impl(NULL)) + expect_snapshot_igraph_error(is_dag_impl( + graph = NULL + )) }) # 116. is_acyclic_impl @@ -1538,14 +2996,27 @@ test_that("is_dag_impl errors", { test_that("is_acyclic_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_acyclic_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_acyclic_impl( + graph = g + )) + + # Structured tests + result <- is_acyclic_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_acyclic_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_acyclic_impl(NULL)) + expect_snapshot_igraph_error(is_acyclic_impl( + graph = NULL + )) }) # 117. is_simple_impl @@ -1553,14 +3024,27 @@ test_that("is_acyclic_impl errors", { test_that("is_simple_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_simple_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_simple_impl( + graph = g + )) + + # Structured tests + result <- is_simple_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_simple_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_simple_impl(NULL)) + expect_snapshot_igraph_error(is_simple_impl( + graph = NULL + )) }) # 118. is_multiple_impl @@ -1568,14 +3052,27 @@ test_that("is_simple_impl errors", { test_that("is_multiple_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_multiple_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_multiple_impl( + graph = g + )) + + # Structured tests + result <- is_multiple_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_multiple_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_multiple_impl(NULL)) + expect_snapshot_igraph_error(is_multiple_impl( + graph = NULL + )) }) # 119. has_loop_impl @@ -1583,14 +3080,27 @@ test_that("is_multiple_impl errors", { test_that("has_loop_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(has_loop_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(has_loop_impl( + graph = g + )) + + # Structured tests + result <- has_loop_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("has_loop_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(has_loop_impl(NULL)) + expect_snapshot_igraph_error(has_loop_impl( + graph = NULL + )) }) # 120. has_multiple_impl @@ -1598,14 +3108,27 @@ test_that("has_loop_impl errors", { test_that("has_multiple_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(has_multiple_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(has_multiple_impl( + graph = g + )) + + # Structured tests + result <- has_multiple_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("has_multiple_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(has_multiple_impl(NULL)) + expect_snapshot_igraph_error(has_multiple_impl( + graph = NULL + )) }) # 121. count_loops_impl @@ -1613,14 +3136,27 @@ test_that("has_multiple_impl errors", { test_that("count_loops_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(count_loops_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(count_loops_impl( + graph = g + )) + + # Structured tests + result <- count_loops_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("count_loops_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(count_loops_impl(NULL)) + expect_snapshot_igraph_error(count_loops_impl( + graph = NULL + )) }) # 122. count_multiple_impl @@ -1628,14 +3164,27 @@ test_that("count_loops_impl errors", { test_that("count_multiple_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(count_multiple_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(count_multiple_impl( + graph = g + )) + + # Structured tests + result <- count_multiple_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("count_multiple_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(count_multiple_impl(NULL)) + expect_snapshot_igraph_error(count_multiple_impl( + graph = NULL + )) }) # 123. is_perfect_impl @@ -1643,14 +3192,27 @@ test_that("count_multiple_impl errors", { test_that("is_perfect_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_perfect_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_perfect_impl( + graph = g + )) + + # Structured tests + result <- is_perfect_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_perfect_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_perfect_impl(NULL)) + expect_snapshot_igraph_error(is_perfect_impl( + graph = NULL + )) }) # 124. eigenvector_centrality_impl @@ -1658,19 +3220,32 @@ test_that("is_perfect_impl errors", { test_that("eigenvector_centrality_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(eigenvector_centrality_impl(g)) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(eigenvector_centrality_impl( - g, + graph = g + )) + expect_snapshot(eigenvector_centrality_impl( + graph = g, directed = TRUE, scale = FALSE )) + + # Structured tests + result <- eigenvector_centrality_impl( + graph = g + ) + expect_type(result, "list") }) test_that("eigenvector_centrality_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(eigenvector_centrality_impl(NULL)) + expect_snapshot_igraph_error(eigenvector_centrality_impl( + graph = NULL + )) }) # 125. hub_and_authority_scores_impl @@ -1679,14 +3254,27 @@ test_that("hub_and_authority_scores_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) g <- make_full_graph(5) - expect_snapshot(hub_and_authority_scores_impl(g)) - expect_snapshot(hub_and_authority_scores_impl(g, scale = FALSE)) + expect_snapshot(hub_and_authority_scores_impl( + graph = g + )) + expect_snapshot(hub_and_authority_scores_impl( + graph = g, + scale = FALSE + )) + + # Structured tests + result <- hub_and_authority_scores_impl( + graph = g + ) + expect_type(result, "list") }) test_that("hub_and_authority_scores_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(hub_and_authority_scores_impl(NULL)) + expect_snapshot_igraph_error(hub_and_authority_scores_impl( + graph = NULL + )) }) # 126. unfold_tree_impl @@ -1694,15 +3282,35 @@ test_that("hub_and_authority_scores_impl errors", { test_that("unfold_tree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(unfold_tree_impl(g, roots = 1)) - expect_snapshot(unfold_tree_impl(g, mode = "in", roots = 1)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(unfold_tree_impl( + graph = g, + roots = 1 + )) + expect_snapshot(unfold_tree_impl( + graph = g, + mode = "in", + roots = 1 + )) + + # Structured tests + result <- unfold_tree_impl( + graph = g, + roots = 1 + ) + expect_type(result, "list") }) test_that("unfold_tree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(unfold_tree_impl(NULL, roots = 1)) + expect_snapshot_igraph_error(unfold_tree_impl( + graph = NULL, + roots = 1 + )) }) # 127. is_mutual_impl @@ -1710,15 +3318,31 @@ test_that("unfold_tree_impl errors", { test_that("is_mutual_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_mutual_impl(g)) - expect_snapshot(is_mutual_impl(g, loops = FALSE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_mutual_impl( + graph = g + )) + expect_snapshot(is_mutual_impl( + graph = g, + loops = FALSE + )) + + # Structured tests + result <- is_mutual_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_mutual_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_mutual_impl(NULL)) + expect_snapshot_igraph_error(is_mutual_impl( + graph = NULL + )) }) # 128. has_mutual_impl @@ -1726,15 +3350,31 @@ test_that("is_mutual_impl errors", { test_that("has_mutual_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(has_mutual_impl(g)) - expect_snapshot(has_mutual_impl(g, loops = FALSE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(has_mutual_impl( + graph = g + )) + expect_snapshot(has_mutual_impl( + graph = g, + loops = FALSE + )) + + # Structured tests + result <- has_mutual_impl( + graph = g + ) + expect_type(result, "logical") }) test_that("has_mutual_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(has_mutual_impl(NULL)) + expect_snapshot_igraph_error(has_mutual_impl( + graph = NULL + )) }) # 129. maximum_cardinality_search_impl @@ -1742,14 +3382,27 @@ test_that("has_mutual_impl errors", { test_that("maximum_cardinality_search_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(maximum_cardinality_search_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(maximum_cardinality_search_impl( + graph = g + )) + + # Structured tests + result <- maximum_cardinality_search_impl( + graph = g + ) + expect_type(result, "list") }) test_that("maximum_cardinality_search_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(maximum_cardinality_search_impl(NULL)) + expect_snapshot_igraph_error(maximum_cardinality_search_impl( + graph = NULL + )) }) # 130. avg_nearest_neighbor_degree_impl @@ -1757,19 +3410,32 @@ test_that("maximum_cardinality_search_impl errors", { test_that("avg_nearest_neighbor_degree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(avg_nearest_neighbor_degree_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(avg_nearest_neighbor_degree_impl( + graph = g + )) expect_snapshot(avg_nearest_neighbor_degree_impl( - g, + graph = g, mode = "in", neighbor.degree.mode = "out" )) + + # Structured tests + result <- avg_nearest_neighbor_degree_impl( + graph = g + ) + expect_type(result, "list") }) test_that("avg_nearest_neighbor_degree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(avg_nearest_neighbor_degree_impl(NULL)) + expect_snapshot_igraph_error(avg_nearest_neighbor_degree_impl( + graph = NULL + )) }) # 131. degree_correlation_vector_impl @@ -1777,20 +3443,33 @@ test_that("avg_nearest_neighbor_degree_impl errors", { test_that("degree_correlation_vector_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(degree_correlation_vector_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(degree_correlation_vector_impl( + graph = g + )) expect_snapshot(degree_correlation_vector_impl( - g, + graph = g, from.mode = "in", to.mode = "out", directed.neighbors = FALSE )) + + # Structured tests + result <- degree_correlation_vector_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("degree_correlation_vector_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(degree_correlation_vector_impl(NULL)) + expect_snapshot_igraph_error(degree_correlation_vector_impl( + graph = NULL + )) }) # 132. rich_club_sequence_impl @@ -1798,22 +3477,38 @@ test_that("degree_correlation_vector_impl errors", { test_that("rich_club_sequence_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(rich_club_sequence_impl(g, vertex.order = 1:3)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(rich_club_sequence_impl( + graph = g, + vertex.order = 1:3 + )) expect_snapshot(rich_club_sequence_impl( - g, + graph = g, vertex.order = 1:3, normalized = FALSE, loops = TRUE, directed = FALSE )) + + # Structured tests + result <- rich_club_sequence_impl( + graph = g, + vertex.order = 1:3 + ) + expect_true(is.numeric(result)) }) test_that("rich_club_sequence_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - rich_club_sequence_impl(NULL, vertex.order = 1:3) + rich_club_sequence_impl( + graph = NULL, + vertex.order = 1:3 + ) ) }) @@ -1822,15 +3517,32 @@ test_that("rich_club_sequence_impl errors", { test_that("strength_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(strength_impl(g)) - expect_snapshot(strength_impl(g, mode = "in", loops = FALSE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(strength_impl( + graph = g + )) + expect_snapshot(strength_impl( + graph = g, + mode = "in", + loops = FALSE + )) + + # Structured tests + result <- strength_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("strength_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(strength_impl(NULL)) + expect_snapshot_igraph_error(strength_impl( + graph = NULL + )) }) # 134. centralization_impl @@ -1838,18 +3550,28 @@ test_that("strength_impl errors", { test_that("centralization_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(centralization_impl(c(1, 2, 3))) expect_snapshot(centralization_impl( - c(1, 2, 3), + scores = c(1, 2, 3) + )) + expect_snapshot(centralization_impl( + scores = c(1, 2, 3), theoretical.max = 2, normalized = FALSE )) + + # Structured tests + result <- centralization_impl( + scores = c(1, 2, 3) + ) + expect_true(is.numeric(result)) }) test_that("centralization_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(centralization_impl(package_version("1.2.3"))) + expect_snapshot_igraph_error(centralization_impl( + scores = package_version("1.2.3") + )) }) # 135. centralization_degree_impl @@ -1857,20 +3579,33 @@ test_that("centralization_impl errors", { test_that("centralization_degree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(centralization_degree_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(centralization_degree_impl( + graph = g + )) expect_snapshot(centralization_degree_impl( - g, + graph = g, mode = "in", loops = FALSE, normalized = FALSE )) + + # Structured tests + result <- centralization_degree_impl( + graph = g + ) + expect_type(result, "list") }) test_that("centralization_degree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(centralization_degree_impl(NULL)) + expect_snapshot_igraph_error(centralization_degree_impl( + graph = NULL + )) }) # 136. centralization_degree_tmax_impl @@ -1878,19 +3613,32 @@ test_that("centralization_degree_impl errors", { test_that("centralization_degree_tmax_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(centralization_degree_tmax_impl(nodes = 3, loops = TRUE)) + expect_snapshot(centralization_degree_tmax_impl( + nodes = 3, + loops = TRUE + )) expect_snapshot(centralization_degree_tmax_impl( nodes = 3, mode = "in", loops = FALSE )) + + # Structured tests + result <- centralization_degree_tmax_impl( + nodes = 3, + loops = TRUE + ) + expect_true(is.numeric(result)) }) test_that("centralization_degree_tmax_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - centralization_degree_tmax_impl(nodes = -1, loops = TRUE) + centralization_degree_tmax_impl( + nodes = -1, + loops = TRUE + ) ) }) @@ -1899,19 +3647,32 @@ test_that("centralization_degree_tmax_impl errors", { test_that("centralization_betweenness_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(centralization_betweenness_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(centralization_betweenness_impl( + graph = g + )) expect_snapshot(centralization_betweenness_impl( - g, + graph = g, directed = FALSE, normalized = FALSE )) + + # Structured tests + result <- centralization_betweenness_impl( + graph = g + ) + expect_type(result, "list") }) test_that("centralization_betweenness_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(centralization_betweenness_impl(NULL)) + expect_snapshot_igraph_error(centralization_betweenness_impl( + graph = NULL + )) }) # 138. centralization_betweenness_tmax_impl @@ -1927,13 +3688,23 @@ test_that("centralization_betweenness_tmax_impl basic", { nodes = 3, directed = FALSE )) + + # Structured tests + result <- centralization_betweenness_tmax_impl( + nodes = 3, + directed = TRUE + ) + expect_true(is.numeric(result)) }) test_that("centralization_betweenness_tmax_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - centralization_betweenness_tmax_impl(nodes = -1, directed = TRUE) + centralization_betweenness_tmax_impl( + nodes = -1, + directed = TRUE + ) ) }) @@ -1942,19 +3713,32 @@ test_that("centralization_betweenness_tmax_impl errors", { test_that("centralization_closeness_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(centralization_closeness_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(centralization_closeness_impl( + graph = g + )) expect_snapshot(centralization_closeness_impl( - g, + graph = g, mode = "in", normalized = FALSE )) + + # Structured tests + result <- centralization_closeness_impl( + graph = g + ) + expect_type(result, "list") }) test_that("centralization_closeness_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(centralization_closeness_impl(NULL)) + expect_snapshot_igraph_error(centralization_closeness_impl( + graph = NULL + )) }) # 140. centralization_closeness_tmax_impl @@ -1962,14 +3746,27 @@ test_that("centralization_closeness_impl errors", { test_that("centralization_closeness_tmax_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(centralization_closeness_tmax_impl(nodes = 3)) - expect_snapshot(centralization_closeness_tmax_impl(nodes = 3, mode = "in")) + expect_snapshot(centralization_closeness_tmax_impl( + nodes = 3 + )) + expect_snapshot(centralization_closeness_tmax_impl( + nodes = 3, + mode = "in" + )) + + # Structured tests + result <- centralization_closeness_tmax_impl( + nodes = 3 + ) + expect_true(is.numeric(result)) }) test_that("centralization_closeness_tmax_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(centralization_closeness_tmax_impl(nodes = -1)) + expect_snapshot_igraph_error(centralization_closeness_tmax_impl( + nodes = -1 + )) }) # 141. centralization_eigenvector_centrality_impl @@ -1977,20 +3774,33 @@ test_that("centralization_closeness_tmax_impl errors", { test_that("centralization_eigenvector_centrality_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(centralization_eigenvector_centrality_impl(g)) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(centralization_eigenvector_centrality_impl( - g, + graph = g + )) + expect_snapshot(centralization_eigenvector_centrality_impl( + graph = g, directed = TRUE, normalized = FALSE )) + + # Structured tests + result <- centralization_eigenvector_centrality_impl( + graph = g + ) + expect_type(result, "list") }) test_that("centralization_eigenvector_centrality_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - centralization_eigenvector_centrality_impl(NULL) + centralization_eigenvector_centrality_impl( + graph = NULL + ) ) }) @@ -1999,18 +3809,28 @@ test_that("centralization_eigenvector_centrality_impl errors", { test_that("centralization_eigenvector_centrality_tmax_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(centralization_eigenvector_centrality_tmax_impl(nodes = 3)) + expect_snapshot(centralization_eigenvector_centrality_tmax_impl( + nodes = 3 + )) expect_snapshot(centralization_eigenvector_centrality_tmax_impl( nodes = 3, directed = TRUE )) + + # Structured tests + result <- centralization_eigenvector_centrality_tmax_impl( + nodes = 3 + ) + expect_true(is.numeric(result)) }) test_that("centralization_eigenvector_centrality_tmax_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - centralization_eigenvector_centrality_tmax_impl(nodes = -1) + centralization_eigenvector_centrality_tmax_impl( + nodes = -1 + ) ) }) @@ -2019,20 +3839,36 @@ test_that("centralization_eigenvector_centrality_tmax_impl errors", { test_that("assortativity_nominal_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(assortativity_nominal_impl(g, c(1, 2, 1))) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(assortativity_nominal_impl( - g, - c(1, 2, 1), + graph = g, + types = c(1, 2, 1) + )) + expect_snapshot(assortativity_nominal_impl( + graph = g, + types = c(1, 2, 1), directed = FALSE, normalized = FALSE )) + + # Structured tests + result <- assortativity_nominal_impl( + graph = g, + types = c(1, 2, 1) + ) + expect_true(is.numeric(result)) }) test_that("assortativity_nominal_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(assortativity_nominal_impl(NULL, c(1, 2, 1))) + expect_snapshot_igraph_error(assortativity_nominal_impl( + graph = NULL, + types = c(1, 2, 1) + )) }) # 144. assortativity_impl @@ -2040,20 +3876,36 @@ test_that("assortativity_nominal_impl errors", { test_that("assortativity_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(assortativity_impl(g, c(1, 2, 1))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(assortativity_impl( + graph = g, + values = c(1, 2, 1) + )) expect_snapshot(assortativity_impl( - g, - c(1, 2, 1), + graph = g, + values = c(1, 2, 1), directed = FALSE, normalized = FALSE )) + + # Structured tests + result <- assortativity_impl( + graph = g, + values = c(1, 2, 1) + ) + expect_true(is.numeric(result)) }) test_that("assortativity_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(assortativity_impl(NULL, c(1, 2, 1))) + expect_snapshot_igraph_error(assortativity_impl( + graph = NULL, + values = c(1, 2, 1) + )) }) # 145. assortativity_degree_impl @@ -2061,15 +3913,31 @@ test_that("assortativity_impl errors", { test_that("assortativity_degree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(assortativity_degree_impl(g)) - expect_snapshot(assortativity_degree_impl(g, directed = FALSE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(assortativity_degree_impl( + graph = g + )) + expect_snapshot(assortativity_degree_impl( + graph = g, + directed = FALSE + )) + + # Structured tests + result <- assortativity_degree_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("assortativity_degree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(assortativity_degree_impl(NULL)) + expect_snapshot_igraph_error(assortativity_degree_impl( + graph = NULL + )) }) # 146. joint_degree_matrix_impl @@ -2077,19 +3945,32 @@ test_that("assortativity_degree_impl errors", { test_that("joint_degree_matrix_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(joint_degree_matrix_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(joint_degree_matrix_impl( + graph = g + )) expect_snapshot(joint_degree_matrix_impl( - g, + graph = g, max.out.degree = 2, max.in.degree = 2 )) + + # Structured tests + result <- joint_degree_matrix_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("joint_degree_matrix_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(joint_degree_matrix_impl(NULL)) + expect_snapshot_igraph_error(joint_degree_matrix_impl( + graph = NULL + )) }) # 147. joint_degree_distribution_impl @@ -2097,10 +3978,15 @@ test_that("joint_degree_matrix_impl errors", { test_that("joint_degree_distribution_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(joint_degree_distribution_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(joint_degree_distribution_impl( + graph = g + )) expect_snapshot(joint_degree_distribution_impl( - g, + graph = g, from.mode = "in", to.mode = "out", directed.neighbors = FALSE, @@ -2108,12 +3994,20 @@ test_that("joint_degree_distribution_impl basic", { max.from.degree = 2, max.to.degree = 2 )) + + # Structured tests + result <- joint_degree_distribution_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("joint_degree_distribution_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(joint_degree_distribution_impl(NULL)) + expect_snapshot_igraph_error(joint_degree_distribution_impl( + graph = NULL + )) }) # 148. joint_type_distribution_impl @@ -2121,22 +4015,38 @@ test_that("joint_degree_distribution_impl errors", { test_that("joint_type_distribution_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(joint_type_distribution_impl(g, from.types = c(1, 2, 1))) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(joint_type_distribution_impl( - g, + graph = g, + from.types = c(1, 2, 1) + )) + expect_snapshot(joint_type_distribution_impl( + graph = g, from.types = c(1, 2, 1), to.types = c(1, 2, 1), directed = FALSE, normalized = FALSE )) + + # Structured tests + result <- joint_type_distribution_impl( + graph = g, + from.types = c(1, 2, 1) + ) + expect_true(is.numeric(result)) }) test_that("joint_type_distribution_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - joint_type_distribution_impl(NULL, from.types = c(1, 2, 1)) + joint_type_distribution_impl( + graph = NULL, + from.types = c(1, 2, 1) + ) ) }) @@ -2145,14 +4055,30 @@ test_that("joint_type_distribution_impl errors", { test_that("contract_vertices_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(contract_vertices_impl(g, c(1, 1, 2))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(contract_vertices_impl( + graph = g, + mapping = c(1, 1, 2) + )) + + # Structured tests + result <- contract_vertices_impl( + graph = g, + mapping = c(1, 1, 2) + ) + expect_s3_class(result, "igraph") }) test_that("contract_vertices_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(contract_vertices_impl(NULL, c(1, 1, 2))) + expect_snapshot_igraph_error(contract_vertices_impl( + graph = NULL, + mapping = c(1, 1, 2) + )) }) # 150. eccentricity_dijkstra_impl @@ -2160,15 +4086,31 @@ test_that("contract_vertices_impl errors", { test_that("eccentricity_dijkstra_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(eccentricity_dijkstra_impl(g)) - expect_snapshot(eccentricity_dijkstra_impl(g, mode = "in")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(eccentricity_dijkstra_impl( + graph = g + )) + expect_snapshot(eccentricity_dijkstra_impl( + graph = g, + mode = "in" + )) + + # Structured tests + result <- eccentricity_dijkstra_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("eccentricity_dijkstra_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(eccentricity_dijkstra_impl(NULL)) + expect_snapshot_igraph_error(eccentricity_dijkstra_impl( + graph = NULL + )) }) # 151. graph_center_dijkstra_impl @@ -2176,15 +4118,31 @@ test_that("eccentricity_dijkstra_impl errors", { test_that("graph_center_dijkstra_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(graph_center_dijkstra_impl(g)) - expect_snapshot(graph_center_dijkstra_impl(g, mode = "in")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(graph_center_dijkstra_impl( + graph = g + )) + expect_snapshot(graph_center_dijkstra_impl( + graph = g, + mode = "in" + )) + + # Structured tests + result <- graph_center_dijkstra_impl( + graph = g + ) + expect_s3_class(result, "igraph.vs") }) test_that("graph_center_dijkstra_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(graph_center_dijkstra_impl(NULL)) + expect_snapshot_igraph_error(graph_center_dijkstra_impl( + graph = NULL + )) }) # 152. radius_dijkstra_impl @@ -2192,15 +4150,31 @@ test_that("graph_center_dijkstra_impl errors", { test_that("radius_dijkstra_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(radius_dijkstra_impl(g)) - expect_snapshot(radius_dijkstra_impl(g, mode = "in")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(radius_dijkstra_impl( + graph = g + )) + expect_snapshot(radius_dijkstra_impl( + graph = g, + mode = "in" + )) + + # Structured tests + result <- radius_dijkstra_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("radius_dijkstra_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(radius_dijkstra_impl(NULL)) + expect_snapshot_igraph_error(radius_dijkstra_impl( + graph = NULL + )) }) # 153. pseudo_diameter_impl @@ -2208,20 +4182,36 @@ test_that("radius_dijkstra_impl errors", { test_that("pseudo_diameter_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(pseudo_diameter_impl(g, 1)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(pseudo_diameter_impl( + graph = g, + start.vid = 1 + )) expect_snapshot(pseudo_diameter_impl( - g, - 1, + graph = g, + start.vid = 1, directed = FALSE, unconnected = FALSE )) + + # Structured tests + result <- pseudo_diameter_impl( + graph = g, + start.vid = 1 + ) + expect_type(result, "list") }) test_that("pseudo_diameter_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(pseudo_diameter_impl(NULL, 1)) + expect_snapshot_igraph_error(pseudo_diameter_impl( + graph = NULL, + start.vid = 1 + )) }) # 154. pseudo_diameter_dijkstra_impl @@ -2229,21 +4219,37 @@ test_that("pseudo_diameter_impl errors", { test_that("pseudo_diameter_dijkstra_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(pseudo_diameter_dijkstra_impl(g, start.vid = 1)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(pseudo_diameter_dijkstra_impl( + graph = g, + start.vid = 1 + )) expect_snapshot(pseudo_diameter_dijkstra_impl( - g, + graph = g, start.vid = 1, directed = FALSE, unconnected = FALSE )) + + # Structured tests + result <- pseudo_diameter_dijkstra_impl( + graph = g, + start.vid = 1 + ) + expect_type(result, "list") }) test_that("pseudo_diameter_dijkstra_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - pseudo_diameter_dijkstra_impl(NULL, start.vid = 1) + pseudo_diameter_dijkstra_impl( + graph = NULL, + start.vid = 1 + ) ) }) @@ -2252,15 +4258,28 @@ test_that("pseudo_diameter_dijkstra_impl errors", { test_that("diversity_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + E(g)$weight <- c(1, 2) - expect_snapshot(diversity_impl(g)) + expect_snapshot(diversity_impl( + graph = g + )) + + # Structured tests + result <- diversity_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("diversity_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(diversity_impl(NULL)) + expect_snapshot_igraph_error(diversity_impl( + graph = NULL + )) }) # 156. random_walk_impl @@ -2268,15 +4287,40 @@ test_that("diversity_impl errors", { test_that("random_walk_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(random_walk_impl(g, 1, 2)) - expect_snapshot(random_walk_impl(g, 1, 2, mode = "in", stuck = "error")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(random_walk_impl( + graph = g, + start = 1, + steps = 2 + )) + expect_snapshot(random_walk_impl( + graph = g, + start = 1, + steps = 2, + mode = "in", + stuck = "error" + )) + + # Structured tests + result <- random_walk_impl( + graph = g, + start = 1, + steps = 2 + ) + expect_type(result, "list") }) test_that("random_walk_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(random_walk_impl(NULL, 1, 2)) + expect_snapshot_igraph_error(random_walk_impl( + graph = NULL, + start = 1, + steps = 2 + )) }) # 157. global_efficiency_impl @@ -2284,15 +4328,31 @@ test_that("random_walk_impl errors", { test_that("global_efficiency_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(global_efficiency_impl(g)) - expect_snapshot(global_efficiency_impl(g, directed = FALSE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(global_efficiency_impl( + graph = g + )) + expect_snapshot(global_efficiency_impl( + graph = g, + directed = FALSE + )) + + # Structured tests + result <- global_efficiency_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("global_efficiency_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(global_efficiency_impl(NULL)) + expect_snapshot_igraph_error(global_efficiency_impl( + graph = NULL + )) }) # 158. local_efficiency_impl @@ -2300,15 +4360,32 @@ test_that("global_efficiency_impl errors", { test_that("local_efficiency_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(local_efficiency_impl(g)) - expect_snapshot(local_efficiency_impl(g, directed = FALSE, mode = "in")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(local_efficiency_impl( + graph = g + )) + expect_snapshot(local_efficiency_impl( + graph = g, + directed = FALSE, + mode = "in" + )) + + # Structured tests + result <- local_efficiency_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("local_efficiency_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(local_efficiency_impl(NULL)) + expect_snapshot_igraph_error(local_efficiency_impl( + graph = NULL + )) }) # 159. average_local_efficiency_impl @@ -2316,19 +4393,32 @@ test_that("local_efficiency_impl errors", { test_that("average_local_efficiency_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(average_local_efficiency_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(average_local_efficiency_impl( + graph = g + )) expect_snapshot(average_local_efficiency_impl( - g, + graph = g, directed = FALSE, mode = "in" )) + + # Structured tests + result <- average_local_efficiency_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("average_local_efficiency_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(average_local_efficiency_impl(NULL)) + expect_snapshot_igraph_error(average_local_efficiency_impl( + graph = NULL + )) }) # 160. transitive_closure_dag_impl @@ -2336,14 +4426,28 @@ test_that("average_local_efficiency_impl errors", { test_that("transitive_closure_dag_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3, directed = TRUE) - expect_snapshot(transitive_closure_dag_impl(g)) + g <- path_graph_impl( + n = 3, + directed = TRUE + ) + + expect_snapshot(transitive_closure_dag_impl( + graph = g + )) + + # Structured tests + result <- transitive_closure_dag_impl( + graph = g + ) + expect_s3_class(result, "igraph") }) test_that("transitive_closure_dag_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(transitive_closure_dag_impl(NULL)) + expect_snapshot_igraph_error(transitive_closure_dag_impl( + graph = NULL + )) }) # 161. transitive_closure_impl @@ -2351,14 +4455,27 @@ test_that("transitive_closure_dag_impl errors", { test_that("transitive_closure_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(transitive_closure_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(transitive_closure_impl( + graph = g + )) + + # Structured tests + result <- transitive_closure_impl( + graph = g + ) + expect_s3_class(result, "igraph") }) test_that("transitive_closure_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(transitive_closure_impl(NULL)) + expect_snapshot_igraph_error(transitive_closure_impl( + graph = NULL + )) }) # 162. trussness_impl @@ -2366,14 +4483,27 @@ test_that("transitive_closure_impl errors", { test_that("trussness_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(trussness_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(trussness_impl( + graph = g + )) + + # Structured tests + result <- trussness_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("trussness_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(trussness_impl(NULL)) + expect_snapshot_igraph_error(trussness_impl( + graph = NULL + )) }) # 163. is_graphical_impl @@ -2381,18 +4511,28 @@ test_that("trussness_impl errors", { test_that("is_graphical_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(is_graphical_impl(c(2, 2, 2))) expect_snapshot(is_graphical_impl( - c(2, 2, 2), - c(1, 1, 1), + out.deg = c(2, 2, 2) + )) + expect_snapshot(is_graphical_impl( + out.deg = c(2, 2, 2), + in.deg = c(1, 1, 1), allowed.edge.types = "all" )) + + # Structured tests + result <- is_graphical_impl( + out.deg = c(2, 2, 2) + ) + expect_type(result, "logical") }) test_that("is_graphical_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_graphical_impl("a")) + expect_snapshot_igraph_error(is_graphical_impl( + out.deg = "a" + )) }) # 164. bfs_simple_impl @@ -2400,15 +4540,35 @@ test_that("is_graphical_impl errors", { test_that("bfs_simple_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(bfs_simple_impl(g, 1)) - expect_snapshot(bfs_simple_impl(g, 1, mode = "in")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(bfs_simple_impl( + graph = g, + root = 1 + )) + expect_snapshot(bfs_simple_impl( + graph = g, + root = 1, + mode = "in" + )) + + # Structured tests + result <- bfs_simple_impl( + graph = g, + root = 1 + ) + expect_type(result, "list") }) test_that("bfs_simple_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(bfs_simple_impl(NULL, 1)) + expect_snapshot_igraph_error(bfs_simple_impl( + graph = NULL, + root = 1 + )) }) # 165. bipartite_projection_size_impl @@ -2416,15 +4576,28 @@ test_that("bfs_simple_impl errors", { test_that("bipartite_projection_size_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(4) + g <- path_graph_impl( + n = 4 + ) + V(g)$type <- c(TRUE, FALSE, TRUE, FALSE) - expect_snapshot(bipartite_projection_size_impl(g)) + expect_snapshot(bipartite_projection_size_impl( + graph = g + )) + + # Structured tests + result <- bipartite_projection_size_impl( + graph = g + ) + expect_type(result, "list") }) test_that("bipartite_projection_size_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(bipartite_projection_size_impl(NULL)) + expect_snapshot_igraph_error(bipartite_projection_size_impl( + graph = NULL + )) }) # 166. biadjacency_impl @@ -2433,19 +4606,29 @@ test_that("biadjacency_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) m <- matrix(c(1, 0, 1, 0, 1, 1), nrow = 2) - expect_snapshot(biadjacency_impl(m)) expect_snapshot(biadjacency_impl( - m, + incidence = m + )) + expect_snapshot(biadjacency_impl( + incidence = m, directed = TRUE, mode = "in", multiple = TRUE )) + + # Structured tests + result <- biadjacency_impl( + incidence = m + ) + expect_type(result, "list") }) test_that("biadjacency_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(biadjacency_impl("a")) + expect_snapshot_igraph_error(biadjacency_impl( + incidence = "a" + )) }) # 167. get_biadjacency_impl @@ -2453,15 +4636,31 @@ test_that("biadjacency_impl errors", { test_that("get_biadjacency_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_biadjacency_impl(g, c(TRUE, FALSE, TRUE))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_biadjacency_impl( + graph = g, + types = c(TRUE, FALSE, TRUE) + )) + + # Structured tests + result <- get_biadjacency_impl( + graph = g, + types = c(TRUE, FALSE, TRUE) + ) + expect_type(result, "list") }) test_that("get_biadjacency_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - get_biadjacency_impl(NULL, c(TRUE, FALSE, TRUE)) + get_biadjacency_impl( + graph = NULL, + types = c(TRUE, FALSE, TRUE) + ) ) }) @@ -2470,14 +4669,27 @@ test_that("get_biadjacency_impl errors", { test_that("is_bipartite_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_bipartite_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_bipartite_impl( + graph = g + )) + + # Structured tests + result <- is_bipartite_impl( + graph = g + ) + expect_type(result, "list") }) test_that("is_bipartite_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_bipartite_impl(NULL)) + expect_snapshot_igraph_error(is_bipartite_impl( + graph = NULL + )) }) # 169. bipartite_game_gnp_impl @@ -2485,20 +4697,36 @@ test_that("is_bipartite_impl errors", { test_that("bipartite_game_gnp_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(bipartite_game_gnp_impl(2, 2, 0.5)) expect_snapshot(bipartite_game_gnp_impl( - 2, - 2, - 0.5, + n1 = 2, + n2 = 2, + p = 0.5 + )) + expect_snapshot(bipartite_game_gnp_impl( + n1 = 2, + n2 = 2, + p = 0.5, directed = TRUE, mode = "in" )) + + # Structured tests + result <- bipartite_game_gnp_impl( + n1 = 2, + n2 = 2, + p = 0.5 + ) + expect_type(result, "list") }) test_that("bipartite_game_gnp_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(bipartite_game_gnp_impl(-1, 2, 0.5)) + expect_snapshot_igraph_error(bipartite_game_gnp_impl( + n1 = -1, + n2 = 2, + p = 0.5 + )) }) # 170. bipartite_game_gnm_impl @@ -2506,20 +4734,36 @@ test_that("bipartite_game_gnp_impl errors", { test_that("bipartite_game_gnm_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(bipartite_game_gnm_impl(2, 2, 1)) expect_snapshot(bipartite_game_gnm_impl( - 2, - 2, - 1, + n1 = 2, + n2 = 2, + m = 1 + )) + expect_snapshot(bipartite_game_gnm_impl( + n1 = 2, + n2 = 2, + m = 1, directed = TRUE, mode = "in" )) + + # Structured tests + result <- bipartite_game_gnm_impl( + n1 = 2, + n2 = 2, + m = 1 + ) + expect_type(result, "list") }) test_that("bipartite_game_gnm_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(bipartite_game_gnm_impl(-1, 2, 1)) + expect_snapshot_igraph_error(bipartite_game_gnm_impl( + n1 = -1, + n2 = 2, + m = 1 + )) }) # 171. get_laplacian_impl @@ -2527,20 +4771,33 @@ test_that("bipartite_game_gnm_impl errors", { test_that("get_laplacian_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_laplacian_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_laplacian_impl( + graph = g + )) expect_snapshot(get_laplacian_impl( - g, + graph = g, mode = "in", normalization = "symmetric", weights = c(1, 2) )) + + # Structured tests + result <- get_laplacian_impl( + graph = g + ) + expect_true(is.numeric(result) || is.matrix(result)) }) test_that("get_laplacian_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_laplacian_impl(NULL)) + expect_snapshot_igraph_error(get_laplacian_impl( + graph = NULL + )) }) # 172. get_laplacian_sparse_impl @@ -2548,20 +4805,33 @@ test_that("get_laplacian_impl errors", { test_that("get_laplacian_sparse_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_laplacian_sparse_impl(g)) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(get_laplacian_sparse_impl( - g, + graph = g + )) + expect_snapshot(get_laplacian_sparse_impl( + graph = g, mode = "in", normalization = "symmetric", weights = c(1, 2) )) + + # Structured tests + result <- get_laplacian_sparse_impl( + graph = g + ) + expect_s3_class(result, "igraph.tmp.sparse") }) test_that("get_laplacian_sparse_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_laplacian_sparse_impl(NULL)) + expect_snapshot_igraph_error(get_laplacian_sparse_impl( + graph = NULL + )) }) # 173. connected_components_impl @@ -2569,15 +4839,32 @@ test_that("get_laplacian_sparse_impl errors", { test_that("connected_components_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(connected_components_impl(g)) - expect_snapshot(connected_components_impl(g, mode = "strong", details = TRUE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(connected_components_impl( + graph = g + )) + expect_snapshot(connected_components_impl( + graph = g, + mode = "strong", + details = TRUE + )) + + # Structured tests + result <- connected_components_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("connected_components_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(connected_components_impl(NULL)) + expect_snapshot_igraph_error(connected_components_impl( + graph = NULL + )) }) # 174. is_connected_impl @@ -2585,15 +4872,31 @@ test_that("connected_components_impl errors", { test_that("is_connected_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_connected_impl(g)) - expect_snapshot(is_connected_impl(g, mode = "strong")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_connected_impl( + graph = g + )) + expect_snapshot(is_connected_impl( + graph = g, + mode = "strong" + )) + + # Structured tests + result <- is_connected_impl( + graph = g + ) + expect_type(result, "logical") }) test_that("is_connected_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_connected_impl(NULL)) + expect_snapshot_igraph_error(is_connected_impl( + graph = NULL + )) }) # 175. articulation_points_impl @@ -2601,14 +4904,27 @@ test_that("is_connected_impl errors", { test_that("articulation_points_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(articulation_points_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(articulation_points_impl( + graph = g + )) + + # Structured tests + result <- articulation_points_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("articulation_points_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(articulation_points_impl(NULL)) + expect_snapshot_igraph_error(articulation_points_impl( + graph = NULL + )) }) # 176. biconnected_components_impl @@ -2616,14 +4932,27 @@ test_that("articulation_points_impl errors", { test_that("biconnected_components_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(biconnected_components_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(biconnected_components_impl( + graph = g + )) + + # Structured tests + result <- biconnected_components_impl( + graph = g + ) + expect_type(result, "list") }) test_that("biconnected_components_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(biconnected_components_impl(NULL)) + expect_snapshot_igraph_error(biconnected_components_impl( + graph = NULL + )) }) # 177. bridges_impl @@ -2631,14 +4960,27 @@ test_that("biconnected_components_impl errors", { test_that("bridges_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(bridges_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(bridges_impl( + graph = g + )) + + # Structured tests + result <- bridges_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("bridges_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(bridges_impl(NULL)) + expect_snapshot_igraph_error(bridges_impl( + graph = NULL + )) }) # 178. is_biconnected_impl @@ -2646,14 +4988,27 @@ test_that("bridges_impl errors", { test_that("is_biconnected_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_biconnected_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_biconnected_impl( + graph = g + )) + + # Structured tests + result <- is_biconnected_impl( + graph = g + ) + expect_type(result, "logical") }) test_that("is_biconnected_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_biconnected_impl(NULL)) + expect_snapshot_igraph_error(is_biconnected_impl( + graph = NULL + )) }) # 179. count_reachable_impl @@ -2661,15 +5016,34 @@ test_that("is_biconnected_impl errors", { test_that("count_reachable_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(5) - expect_snapshot(count_reachable_impl(g, mode = "out")) - expect_snapshot(count_reachable_impl(g, mode = "in")) + g <- path_graph_impl( + n = 5 + ) + + expect_snapshot(count_reachable_impl( + graph = g, + mode = "out" + )) + expect_snapshot(count_reachable_impl( + graph = g, + mode = "in" + )) + + # Structured tests + result <- count_reachable_impl( + graph = g, + mode = "out" + ) + expect_true(is.numeric(result)) }) test_that("count_reachable_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(count_reachable_impl(NULL, mode = "out")) + expect_snapshot_igraph_error(count_reachable_impl( + graph = NULL, + mode = "out" + )) }) # 180. bond_percolation_impl @@ -2677,14 +5051,27 @@ test_that("count_reachable_impl errors", { test_that("bond_percolation_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(bond_percolation_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(bond_percolation_impl( + graph = g + )) + + # Structured tests + result <- bond_percolation_impl( + graph = g + ) + expect_type(result, "list") }) test_that("bond_percolation_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(bond_percolation_impl(NULL)) + expect_snapshot_igraph_error(bond_percolation_impl( + graph = NULL + )) }) # 181. site_percolation_impl @@ -2692,14 +5079,27 @@ test_that("bond_percolation_impl errors", { test_that("site_percolation_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(site_percolation_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(site_percolation_impl( + graph = g + )) + + # Structured tests + result <- site_percolation_impl( + graph = g + ) + expect_type(result, "list") }) test_that("site_percolation_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(site_percolation_impl(NULL)) + expect_snapshot_igraph_error(site_percolation_impl( + graph = NULL + )) }) # 182. edgelist_percolation_impl @@ -2707,13 +5107,23 @@ test_that("site_percolation_impl errors", { test_that("edgelist_percolation_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(edgelist_percolation_impl(matrix(c(1, 2, 2, 3), ncol = 2))) + expect_snapshot(edgelist_percolation_impl( + edges = matrix(c(1, 2, 2, 3), ncol = 2) + )) + + # Structured tests + result <- edgelist_percolation_impl( + edges = matrix(c(1, 2, 2, 3), ncol = 2) + ) + expect_type(result, "list") }) test_that("edgelist_percolation_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(edgelist_percolation_impl("a")) + expect_snapshot_igraph_error(edgelist_percolation_impl( + edges = "a" + )) }) # 183. is_clique_impl @@ -2721,15 +5131,35 @@ test_that("edgelist_percolation_impl errors", { test_that("is_clique_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_clique_impl(g, 1:2)) - expect_snapshot(is_clique_impl(g, 1:2, directed = TRUE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_clique_impl( + graph = g, + candidate = 1:2 + )) + expect_snapshot(is_clique_impl( + graph = g, + candidate = 1:2, + directed = TRUE + )) + + # Structured tests + result <- is_clique_impl( + graph = g, + candidate = 1:2 + ) + expect_type(result, "logical") }) test_that("is_clique_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_clique_impl(NULL, 1:2)) + expect_snapshot_igraph_error(is_clique_impl( + graph = NULL, + candidate = 1:2 + )) }) # 184. cliques_impl @@ -2737,15 +5167,32 @@ test_that("is_clique_impl errors", { test_that("cliques_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(cliques_impl(g)) - expect_snapshot(cliques_impl(g, min = 2, max = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(cliques_impl( + graph = g + )) + expect_snapshot(cliques_impl( + graph = g, + min = 2, + max = 2 + )) + + # Structured tests + result <- cliques_impl( + graph = g + ) + expect_type(result, "list") }) test_that("cliques_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(cliques_impl(NULL)) + expect_snapshot_igraph_error(cliques_impl( + graph = NULL + )) }) # 185. clique_size_hist_impl @@ -2753,15 +5200,32 @@ test_that("cliques_impl errors", { test_that("clique_size_hist_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(clique_size_hist_impl(g)) - expect_snapshot(clique_size_hist_impl(g, min.size = 2, max.size = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(clique_size_hist_impl( + graph = g + )) + expect_snapshot(clique_size_hist_impl( + graph = g, + min.size = 2, + max.size = 2 + )) + + # Structured tests + result <- clique_size_hist_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("clique_size_hist_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(clique_size_hist_impl(NULL)) + expect_snapshot_igraph_error(clique_size_hist_impl( + graph = NULL + )) }) # 186. largest_cliques_impl @@ -2769,14 +5233,27 @@ test_that("clique_size_hist_impl errors", { test_that("largest_cliques_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(largest_cliques_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(largest_cliques_impl( + graph = g + )) + + # Structured tests + result <- largest_cliques_impl( + graph = g + ) + expect_type(result, "list") }) test_that("largest_cliques_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(largest_cliques_impl(NULL)) + expect_snapshot_igraph_error(largest_cliques_impl( + graph = NULL + )) }) # 187. maximal_cliques_hist_impl @@ -2784,15 +5261,32 @@ test_that("largest_cliques_impl errors", { test_that("maximal_cliques_hist_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(maximal_cliques_hist_impl(g)) - expect_snapshot(maximal_cliques_hist_impl(g, min.size = 2, max.size = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(maximal_cliques_hist_impl( + graph = g + )) + expect_snapshot(maximal_cliques_hist_impl( + graph = g, + min.size = 2, + max.size = 2 + )) + + # Structured tests + result <- maximal_cliques_hist_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("maximal_cliques_hist_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(maximal_cliques_hist_impl(NULL)) + expect_snapshot_igraph_error(maximal_cliques_hist_impl( + graph = NULL + )) }) # 188. clique_number_impl @@ -2800,14 +5294,27 @@ test_that("maximal_cliques_hist_impl errors", { test_that("clique_number_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(clique_number_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(clique_number_impl( + graph = g + )) + + # Structured tests + result <- clique_number_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("clique_number_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(clique_number_impl(NULL)) + expect_snapshot_igraph_error(clique_number_impl( + graph = NULL + )) }) # 189. weighted_cliques_impl @@ -2815,21 +5322,34 @@ test_that("clique_number_impl errors", { test_that("weighted_cliques_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(weighted_cliques_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(weighted_cliques_impl( + graph = g + )) expect_snapshot(weighted_cliques_impl( - g, + graph = g, vertex.weights = c(1, 2, 3), min.weight = 1, max.weight = 3, maximal = TRUE )) + + # Structured tests + result <- weighted_cliques_impl( + graph = g + ) + expect_type(result, "list") }) test_that("weighted_cliques_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(weighted_cliques_impl(NULL)) + expect_snapshot_igraph_error(weighted_cliques_impl( + graph = NULL + )) }) # 190. largest_weighted_cliques_impl @@ -2837,15 +5357,31 @@ test_that("weighted_cliques_impl errors", { test_that("largest_weighted_cliques_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(largest_weighted_cliques_impl(g)) - expect_snapshot(largest_weighted_cliques_impl(g, vertex.weights = c(1, 2, 3))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(largest_weighted_cliques_impl( + graph = g + )) + expect_snapshot(largest_weighted_cliques_impl( + graph = g, + vertex.weights = c(1, 2, 3) + )) + + # Structured tests + result <- largest_weighted_cliques_impl( + graph = g + ) + expect_type(result, "list") }) test_that("largest_weighted_cliques_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(largest_weighted_cliques_impl(NULL)) + expect_snapshot_igraph_error(largest_weighted_cliques_impl( + graph = NULL + )) }) # 191. weighted_clique_number_impl @@ -2853,15 +5389,31 @@ test_that("largest_weighted_cliques_impl errors", { test_that("weighted_clique_number_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(weighted_clique_number_impl(g)) - expect_snapshot(weighted_clique_number_impl(g, vertex.weights = c(1, 2, 3))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(weighted_clique_number_impl( + graph = g + )) + expect_snapshot(weighted_clique_number_impl( + graph = g, + vertex.weights = c(1, 2, 3) + )) + + # Structured tests + result <- weighted_clique_number_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("weighted_clique_number_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(weighted_clique_number_impl(NULL)) + expect_snapshot_igraph_error(weighted_clique_number_impl( + graph = NULL + )) }) # 192. is_independent_vertex_set_impl @@ -2869,14 +5421,30 @@ test_that("weighted_clique_number_impl errors", { test_that("is_independent_vertex_set_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_independent_vertex_set_impl(g, 1:2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_independent_vertex_set_impl( + graph = g, + candidate = 1:2 + )) + + # Structured tests + result <- is_independent_vertex_set_impl( + graph = g, + candidate = 1:2 + ) + expect_type(result, "logical") }) test_that("is_independent_vertex_set_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_independent_vertex_set_impl(NULL, 1:2)) + expect_snapshot_igraph_error(is_independent_vertex_set_impl( + graph = NULL, + candidate = 1:2 + )) }) # 193. layout_random_impl @@ -2884,14 +5452,27 @@ test_that("is_independent_vertex_set_impl errors", { test_that("layout_random_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_random_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_random_impl( + graph = g + )) + + # Structured tests + result <- layout_random_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("layout_random_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(layout_random_impl(NULL)) + expect_snapshot_igraph_error(layout_random_impl( + graph = NULL + )) }) # 194. layout_circle_impl @@ -2899,15 +5480,31 @@ test_that("layout_random_impl errors", { test_that("layout_circle_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_circle_impl(g)) - expect_snapshot(layout_circle_impl(g, order = 1:3)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_circle_impl( + graph = g + )) + expect_snapshot(layout_circle_impl( + graph = g, + order = 1:3 + )) + + # Structured tests + result <- layout_circle_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("layout_circle_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(layout_circle_impl(NULL)) + expect_snapshot_igraph_error(layout_circle_impl( + graph = NULL + )) }) # 195. layout_star_impl @@ -2915,15 +5512,41 @@ test_that("layout_circle_impl errors", { test_that("layout_star_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(round(layout_star_impl(g), 4)) - expect_snapshot(round(layout_star_impl(g, center = 1, order = 3:1), 4)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(round( + layout_star_impl( + graph = g + ), + 4 + )) + expect_snapshot(round( + layout_star_impl( + graph = g, + center = 1, + order = 3:1 + ), + 4 + )) + + # Structured tests + result <- round( + layout_star_impl( + graph = g + ), + 4 + ) + expect_true(is.numeric(result)) }) test_that("layout_star_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(layout_star_impl(NULL)) + expect_snapshot_igraph_error(layout_star_impl( + graph = NULL + )) }) # 196. layout_grid_impl @@ -2931,15 +5554,31 @@ test_that("layout_star_impl errors", { test_that("layout_grid_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_grid_impl(g)) - expect_snapshot(layout_grid_impl(g, width = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_grid_impl( + graph = g + )) + expect_snapshot(layout_grid_impl( + graph = g, + width = 2 + )) + + # Structured tests + result <- layout_grid_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("layout_grid_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(layout_grid_impl(NULL)) + expect_snapshot_igraph_error(layout_grid_impl( + graph = NULL + )) }) # 197. layout_grid_3d_impl @@ -2947,15 +5586,32 @@ test_that("layout_grid_impl errors", { test_that("layout_grid_3d_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_grid_3d_impl(g)) - expect_snapshot(layout_grid_3d_impl(g, width = 2, height = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_grid_3d_impl( + graph = g + )) + expect_snapshot(layout_grid_3d_impl( + graph = g, + width = 2, + height = 2 + )) + + # Structured tests + result <- layout_grid_3d_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("layout_grid_3d_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(layout_grid_3d_impl(NULL)) + expect_snapshot_igraph_error(layout_grid_3d_impl( + graph = NULL + )) }) # 198. roots_for_tree_layout_impl @@ -2963,15 +5619,34 @@ test_that("layout_grid_3d_impl errors", { test_that("roots_for_tree_layout_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(roots_for_tree_layout_impl(g, mode = "out", heuristic = 1)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(roots_for_tree_layout_impl( + graph = g, + mode = "out", + heuristic = 1 + )) + + # Structured tests + result <- roots_for_tree_layout_impl( + graph = g, + mode = "out", + heuristic = 1 + ) + expect_s3_class(result, "igraph.vs") }) test_that("roots_for_tree_layout_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - roots_for_tree_layout_impl(NULL, mode = "out", heuristic = 1) + roots_for_tree_layout_impl( + graph = NULL, + mode = "out", + heuristic = 1 + ) ) }) @@ -2980,14 +5655,27 @@ test_that("roots_for_tree_layout_impl errors", { test_that("layout_random_3d_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_random_3d_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_random_3d_impl( + graph = g + )) + + # Structured tests + result <- layout_random_3d_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("layout_random_3d_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(layout_random_3d_impl(NULL)) + expect_snapshot_igraph_error(layout_random_3d_impl( + graph = NULL + )) }) # 200. layout_sphere_impl @@ -2995,14 +5683,27 @@ test_that("layout_random_3d_impl errors", { test_that("layout_sphere_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_sphere_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_sphere_impl( + graph = g + )) + + # Structured tests + result <- layout_sphere_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("layout_sphere_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(layout_sphere_impl(NULL)) + expect_snapshot_igraph_error(layout_sphere_impl( + graph = NULL + )) }) # 201. layout_sugiyama_impl @@ -3010,22 +5711,35 @@ test_that("layout_sphere_impl errors", { test_that("layout_sugiyama_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_sugiyama_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_sugiyama_impl( + graph = g + )) expect_snapshot(layout_sugiyama_impl( - g, + graph = g, layers = 1:3, hgap = 2, vgap = 2, maxiter = 10, weights = c(1, 2) )) + + # Structured tests + result <- layout_sugiyama_impl( + graph = g + ) + expect_type(result, "list") }) test_that("layout_sugiyama_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(layout_sugiyama_impl(NULL)) + expect_snapshot_igraph_error(layout_sugiyama_impl( + graph = NULL + )) }) # 202. layout_mds_impl @@ -3033,15 +5747,32 @@ test_that("layout_sugiyama_impl errors", { test_that("layout_mds_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_mds_impl(g)) - expect_snapshot(layout_mds_impl(g, dist = matrix(1:9, nrow = 3), dim = 3)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_mds_impl( + graph = g + )) + expect_snapshot(layout_mds_impl( + graph = g, + dist = matrix(1:9, nrow = 3), + dim = 3 + )) + + # Structured tests + result <- layout_mds_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("layout_mds_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(layout_mds_impl(NULL)) + expect_snapshot_igraph_error(layout_mds_impl( + graph = NULL + )) }) # 203. layout_bipartite_impl @@ -3049,22 +5780,38 @@ test_that("layout_mds_impl errors", { test_that("layout_bipartite_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_bipartite_impl(g, types = c(TRUE, FALSE, TRUE))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_bipartite_impl( + graph = g, + types = c(TRUE, FALSE, TRUE) + )) expect_snapshot(layout_bipartite_impl( - g, + graph = g, types = c(TRUE, FALSE, TRUE), hgap = 2, vgap = 2, maxiter = 10 )) + + # Structured tests + result <- layout_bipartite_impl( + graph = g, + types = c(TRUE, FALSE, TRUE) + ) + expect_true(is.numeric(result)) }) test_that("layout_bipartite_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - layout_bipartite_impl(NULL, types = c(TRUE, FALSE, TRUE)) + layout_bipartite_impl( + graph = NULL, + types = c(TRUE, FALSE, TRUE) + ) ) }) @@ -3073,10 +5820,16 @@ test_that("layout_bipartite_impl errors", { test_that("layout_gem_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_gem_impl(g, res = matrix(0, nrow = 3, ncol = 2))) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(layout_gem_impl( - g, + graph = g, + res = matrix(0, nrow = 3, ncol = 2) + )) + expect_snapshot(layout_gem_impl( + graph = g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE, maxiter = 10, @@ -3084,13 +5837,23 @@ test_that("layout_gem_impl basic", { temp.min = 0.1, temp.init = 1 )) + + # Structured tests + result <- layout_gem_impl( + graph = g, + res = matrix(0, nrow = 3, ncol = 2) + ) + expect_true(is.numeric(result)) }) test_that("layout_gem_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - layout_gem_impl(NULL, res = matrix(0, nrow = 3, ncol = 2)) + layout_gem_impl( + graph = NULL, + res = matrix(0, nrow = 3, ncol = 2) + ) ) }) @@ -3099,13 +5862,16 @@ test_that("layout_gem_impl errors", { test_that("layout_davidson_harel_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(layout_davidson_harel_impl( - g, + graph = g, res = matrix(0, nrow = 3, ncol = 2) )) expect_snapshot(layout_davidson_harel_impl( - g, + graph = g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE, maxiter = 10, @@ -3117,13 +5883,23 @@ test_that("layout_davidson_harel_impl basic", { weight.edge.crossings = 0.2, weight.node.edge.dist = 0.3 )) + + # Structured tests + result <- layout_davidson_harel_impl( + graph = g, + res = matrix(0, nrow = 3, ncol = 2) + ) + expect_true(is.numeric(result)) }) test_that("layout_davidson_harel_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - layout_davidson_harel_impl(NULL, res = matrix(0, nrow = 3, ncol = 2)) + layout_davidson_harel_impl( + graph = NULL, + res = matrix(0, nrow = 3, ncol = 2) + ) ) }) @@ -3132,14 +5908,17 @@ test_that("layout_davidson_harel_impl errors", { test_that("layout_umap_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(layout_umap_impl( - g, + graph = g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE )) expect_snapshot(layout_umap_impl( - g, + graph = g, res = matrix(0, nrow = 3, ncol = 2), use.seed = TRUE, distances = 1:3, @@ -3147,13 +5926,24 @@ test_that("layout_umap_impl basic", { epochs = 10, distances.are.weights = TRUE )) + + # Structured tests + result <- layout_umap_impl( + graph = g, + res = matrix(0, nrow = 3, ncol = 2), + use.seed = TRUE + ) + expect_true(is.numeric(result)) }) test_that("layout_umap_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - layout_umap_impl(NULL, res = matrix(0, nrow = 3, ncol = 2)) + layout_umap_impl( + graph = NULL, + res = matrix(0, nrow = 3, ncol = 2) + ) ) }) @@ -3162,14 +5952,17 @@ test_that("layout_umap_impl errors", { test_that("layout_umap_3d_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(layout_umap_3d_impl( - g, + graph = g, res = matrix(0, nrow = 3, ncol = 3), - use.see = TRUE + use.seed = TRUE )) expect_snapshot(layout_umap_3d_impl( - g, + graph = g, res = matrix(0, nrow = 3, ncol = 3), use.seed = TRUE, distances = 1:3, @@ -3177,13 +5970,24 @@ test_that("layout_umap_3d_impl basic", { epochs = 10, distances.are.weights = TRUE )) + + # Structured tests + result <- layout_umap_3d_impl( + graph = g, + res = matrix(0, nrow = 3, ncol = 3), + use.seed = TRUE + ) + expect_true(is.numeric(result)) }) test_that("layout_umap_3d_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - layout_umap_3d_impl(NULL, res = matrix(0, nrow = 3, ncol = 3)) + layout_umap_3d_impl( + graph = NULL, + res = matrix(0, nrow = 3, ncol = 3) + ) ) }) @@ -3192,19 +5996,34 @@ test_that("layout_umap_3d_impl errors", { test_that("layout_umap_compute_weights_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(layout_umap_compute_weights_impl( - g, + graph = g, distances = 1:2, weights = 1:3 )) + + # Structured tests + result <- layout_umap_compute_weights_impl( + graph = g, + distances = 1:2, + weights = 1:3 + ) + expect_true(is.numeric(result)) }) test_that("layout_umap_compute_weights_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - layout_umap_compute_weights_impl(NULL, distances = 1:3, weights = 1:3) + layout_umap_compute_weights_impl( + graph = NULL, + distances = 1:3, + weights = 1:3 + ) ) }) @@ -3213,15 +6032,31 @@ test_that("layout_umap_compute_weights_impl errors", { test_that("layout_align_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(layout_align_impl(g, layout = matrix(0, nrow = 3, ncol = 2))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_align_impl( + graph = g, + layout = matrix(0, nrow = 3, ncol = 2) + )) + + # Structured tests + result <- layout_align_impl( + graph = g, + layout = matrix(0, nrow = 3, ncol = 2) + ) + expect_true(is.numeric(result)) }) test_that("layout_align_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - layout_align_impl(NULL, layout = matrix(0, nrow = 3, ncol = 2)) + layout_align_impl( + graph = NULL, + layout = matrix(0, nrow = 3, ncol = 2) + ) ) }) @@ -3230,20 +6065,33 @@ test_that("layout_align_impl errors", { test_that("similarity_dice_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(similarity_dice_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(similarity_dice_impl( + graph = g + )) expect_snapshot(similarity_dice_impl( - g, + graph = g, vids = 1:2, mode = "in", loops = TRUE )) + + # Structured tests + result <- similarity_dice_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("similarity_dice_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(similarity_dice_impl(NULL)) + expect_snapshot_igraph_error(similarity_dice_impl( + graph = NULL + )) }) # 211. similarity_dice_es_impl @@ -3251,20 +6099,33 @@ test_that("similarity_dice_impl errors", { test_that("similarity_dice_es_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(similarity_dice_es_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(similarity_dice_es_impl( + graph = g + )) expect_snapshot(similarity_dice_es_impl( - g, + graph = g, es = 1:2, mode = "in", loops = TRUE )) + + # Structured tests + result <- similarity_dice_es_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("similarity_dice_es_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(similarity_dice_es_impl(NULL)) + expect_snapshot_igraph_error(similarity_dice_es_impl( + graph = NULL + )) }) # 212. similarity_dice_pairs_impl @@ -3272,24 +6133,37 @@ test_that("similarity_dice_es_impl errors", { test_that("similarity_dice_pairs_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(4) + g <- path_graph_impl( + n = 4 + ) + expect_snapshot(similarity_dice_pairs_impl( - g, + graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2) )) expect_snapshot(similarity_dice_pairs_impl( - g, + graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2), mode = "in", loops = TRUE )) + + # Structured tests + result <- similarity_dice_pairs_impl( + graph = g, + pairs = matrix(c(1, 2, 2, 3), ncol = 2) + ) + expect_true(is.numeric(result)) }) test_that("similarity_dice_pairs_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - similarity_dice_pairs_impl(NULL, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) + similarity_dice_pairs_impl( + graph = NULL, + pairs = matrix(c(1, 2, 2, 3), ncol = 2) + ) ) }) @@ -3298,19 +6172,32 @@ test_that("similarity_dice_pairs_impl errors", { test_that("similarity_inverse_log_weighted_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(similarity_inverse_log_weighted_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(similarity_inverse_log_weighted_impl( + graph = g + )) expect_snapshot(similarity_inverse_log_weighted_impl( - g, + graph = g, vids = 1:2, mode = "in" )) + + # Structured tests + result <- similarity_inverse_log_weighted_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("similarity_inverse_log_weighted_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(similarity_inverse_log_weighted_impl(NULL)) + expect_snapshot_igraph_error(similarity_inverse_log_weighted_impl( + graph = NULL + )) }) # 214. similarity_jaccard_impl @@ -3318,20 +6205,33 @@ test_that("similarity_inverse_log_weighted_impl errors", { test_that("similarity_jaccard_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(similarity_jaccard_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(similarity_jaccard_impl( + graph = g + )) expect_snapshot(similarity_jaccard_impl( - g, + graph = g, vids = 1:2, mode = "in", loops = TRUE )) + + # Structured tests + result <- similarity_jaccard_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("similarity_jaccard_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(similarity_jaccard_impl(NULL)) + expect_snapshot_igraph_error(similarity_jaccard_impl( + graph = NULL + )) }) # 215. similarity_jaccard_es_impl @@ -3339,20 +6239,33 @@ test_that("similarity_jaccard_impl errors", { test_that("similarity_jaccard_es_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(similarity_jaccard_es_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(similarity_jaccard_es_impl( + graph = g + )) expect_snapshot(similarity_jaccard_es_impl( - g, + graph = g, es = 1:2, mode = "in", loops = TRUE )) + + # Structured tests + result <- similarity_jaccard_es_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("similarity_jaccard_es_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(similarity_jaccard_es_impl(NULL)) + expect_snapshot_igraph_error(similarity_jaccard_es_impl( + graph = NULL + )) }) # 216. similarity_jaccard_pairs_impl @@ -3360,24 +6273,37 @@ test_that("similarity_jaccard_es_impl errors", { test_that("similarity_jaccard_pairs_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(4) + g <- path_graph_impl( + n = 4 + ) + expect_snapshot(similarity_jaccard_pairs_impl( - g, + graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2) )) expect_snapshot(similarity_jaccard_pairs_impl( - g, + graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2), mode = "in", loops = TRUE )) + + # Structured tests + result <- similarity_jaccard_pairs_impl( + graph = g, + pairs = matrix(c(1, 2, 2, 3), ncol = 2) + ) + expect_true(is.numeric(result)) }) test_that("similarity_jaccard_pairs_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - similarity_jaccard_pairs_impl(NULL, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) + similarity_jaccard_pairs_impl( + graph = NULL, + pairs = matrix(c(1, 2, 2, 3), ncol = 2) + ) ) }) @@ -3386,18 +6312,31 @@ test_that("similarity_jaccard_pairs_impl errors", { test_that("compare_communities_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(compare_communities_impl(c(1, 2, 1), c(2, 1, 2))) expect_snapshot(compare_communities_impl( - c(1, 2, 1), - c(2, 1, 2), + comm1 = c(1, 2, 1), + comm2 = c(2, 1, 2) + )) + expect_snapshot(compare_communities_impl( + comm1 = c(1, 2, 1), + comm2 = c(2, 1, 2), method = "nmi" )) + + # Structured tests + result <- compare_communities_impl( + comm1 = c(1, 2, 1), + comm2 = c(2, 1, 2) + ) + expect_true(is.numeric(result)) }) test_that("compare_communities_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(compare_communities_impl("a", c(2, 1, 2))) + expect_snapshot_igraph_error(compare_communities_impl( + comm1 = "a", + comm2 = c(2, 1, 2) + )) }) # 218. modularity_impl @@ -3405,21 +6344,37 @@ test_that("compare_communities_impl errors", { test_that("modularity_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(modularity_impl(g, membership = c(1, 2, 1))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(modularity_impl( + graph = g, + membership = c(1, 2, 1) + )) expect_snapshot(modularity_impl( - g, + graph = g, membership = c(1, 2, 1), weights = c(1, 2), resolution = 0.5, directed = FALSE )) + + # Structured tests + result <- modularity_impl( + graph = g, + membership = c(1, 2, 1) + ) + expect_true(is.numeric(result)) }) test_that("modularity_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(modularity_impl(NULL, membership = c(1, 2, 1))) + expect_snapshot_igraph_error(modularity_impl( + graph = NULL, + membership = c(1, 2, 1) + )) }) # 219. modularity_matrix_impl @@ -3427,20 +6382,33 @@ test_that("modularity_impl errors", { test_that("modularity_matrix_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(modularity_matrix_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(modularity_matrix_impl( + graph = g + )) expect_snapshot(modularity_matrix_impl( - g, + graph = g, weights = c(1, 2), resolution = 0.5, directed = FALSE )) + + # Structured tests + result <- modularity_matrix_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("modularity_matrix_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(modularity_matrix_impl(NULL)) + expect_snapshot_igraph_error(modularity_matrix_impl( + graph = NULL + )) }) # 220. community_fluid_communities_impl @@ -3448,15 +6416,31 @@ test_that("modularity_matrix_impl errors", { test_that("community_fluid_communities_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(community_fluid_communities_impl(g, no.of.communities = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(community_fluid_communities_impl( + graph = g, + no.of.communities = 2 + )) + + # Structured tests + result <- community_fluid_communities_impl( + graph = g, + no.of.communities = 2 + ) + expect_true(is.numeric(result)) }) test_that("community_fluid_communities_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - community_fluid_communities_impl(NULL, no.of.communities = 2) + community_fluid_communities_impl( + graph = NULL, + no.of.communities = 2 + ) ) }) @@ -3465,21 +6449,34 @@ test_that("community_fluid_communities_impl errors", { test_that("community_label_propagation_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(community_label_propagation_impl(g)) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(community_label_propagation_impl( - g, - mode = "in", + graph = g + )) + expect_snapshot(community_label_propagation_impl( + graph = g, + mode = "in", weights = c(1, 2), initial = 1:3, fixed = c(TRUE, FALSE, TRUE) )) + + # Structured tests + result <- community_label_propagation_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("community_label_propagation_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(community_label_propagation_impl(NULL)) + expect_snapshot_igraph_error(community_label_propagation_impl( + graph = NULL + )) }) # 222. community_multilevel_impl @@ -3487,19 +6484,32 @@ test_that("community_label_propagation_impl errors", { test_that("community_multilevel_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(community_multilevel_impl(g)) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(community_multilevel_impl( - g, + graph = g + )) + expect_snapshot(community_multilevel_impl( + graph = g, weights = c(1, 2), resolution = 0.5 )) + + # Structured tests + result <- community_multilevel_impl( + graph = g + ) + expect_type(result, "list") }) test_that("community_multilevel_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(community_multilevel_impl(NULL)) + expect_snapshot_igraph_error(community_multilevel_impl( + graph = NULL + )) }) # 223. community_optimal_modularity_impl @@ -3507,15 +6517,31 @@ test_that("community_multilevel_impl errors", { test_that("community_optimal_modularity_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(community_optimal_modularity_impl(g)) - expect_snapshot(community_optimal_modularity_impl(g, weights = c(1, 2))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(community_optimal_modularity_impl( + graph = g + )) + expect_snapshot(community_optimal_modularity_impl( + graph = g, + weights = c(1, 2) + )) + + # Structured tests + result <- community_optimal_modularity_impl( + graph = g + ) + expect_type(result, "list") }) test_that("community_optimal_modularity_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(community_optimal_modularity_impl(NULL)) + expect_snapshot_igraph_error(community_optimal_modularity_impl( + graph = NULL + )) }) # 224. community_leiden_impl @@ -3523,9 +6549,12 @@ test_that("community_optimal_modularity_impl errors", { test_that("community_leiden_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(community_leiden_impl( - g, + graph = g, weights = c(1, 2), vertex.weights = c(1, 2, 3), resolution = 0.5, @@ -3534,12 +6563,28 @@ test_that("community_leiden_impl basic", { n.iterations = 1, membership = 1:3 )) + + # Structured tests + result <- community_leiden_impl( + graph = g, + weights = c(1, 2), + vertex.weights = c(1, 2, 3), + resolution = 0.5, + beta = 0.1, + start = TRUE, + n.iterations = 1, + membership = 1:3 + ) + expect_type(result, "list") }) test_that("community_leiden_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(community_leiden_impl(NULL, resolution = 1)) + expect_snapshot_igraph_error(community_leiden_impl( + graph = NULL, + resolution = 1 + )) }) # 225. split_join_distance_impl @@ -3547,13 +6592,26 @@ test_that("community_leiden_impl errors", { test_that("split_join_distance_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(split_join_distance_impl(c(1, 2, 1), c(2, 1, 2))) + expect_snapshot(split_join_distance_impl( + comm1 = c(1, 2, 1), + comm2 = c(2, 1, 2) + )) + + # Structured tests + result <- split_join_distance_impl( + comm1 = c(1, 2, 1), + comm2 = c(2, 1, 2) + ) + expect_type(result, "list") }) test_that("split_join_distance_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(split_join_distance_impl("a", c(2, 1, 2))) + expect_snapshot_igraph_error(split_join_distance_impl( + comm1 = "a", + comm2 = c(2, 1, 2) + )) }) # 226. community_infomap_impl @@ -3561,20 +6619,33 @@ test_that("split_join_distance_impl errors", { test_that("community_infomap_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(community_infomap_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(community_infomap_impl( + graph = g + )) expect_snapshot(community_infomap_impl( - g, + graph = g, e.weights = c(1, 2), v.weights = c(1, 2, 3), nb.trials = 2 )) + + # Structured tests + result <- community_infomap_impl( + graph = g + ) + expect_type(result, "list") }) test_that("community_infomap_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(community_infomap_impl(NULL)) + expect_snapshot_igraph_error(community_infomap_impl( + graph = NULL + )) }) # 227. graphlets_impl @@ -3582,16 +6653,33 @@ test_that("community_infomap_impl errors", { test_that("graphlets_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + E(g)$weight <- 1:2 - expect_snapshot(graphlets_impl(g)) - expect_snapshot(graphlets_impl(g, weights = c(3, 4), niter = 10)) + expect_snapshot(graphlets_impl( + graph = g + )) + expect_snapshot(graphlets_impl( + graph = g, + weights = c(3, 4), + niter = 10 + )) + + # Structured tests + result <- graphlets_impl( + graph = g + ) + expect_type(result, "list") }) test_that("graphlets_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(graphlets_impl(NULL)) + expect_snapshot_igraph_error(graphlets_impl( + graph = NULL + )) }) # 228. hrg_fit_impl @@ -3599,14 +6687,27 @@ test_that("graphlets_impl errors", { test_that("hrg_fit_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - expect_snapshot(hrg_fit_impl(g1)) + g1 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(hrg_fit_impl( + graph = g1 + )) + + # Structured tests + result <- hrg_fit_impl( + graph = g1 + ) + expect_type(result, "list") }) test_that("hrg_fit_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(hrg_fit_impl(NULL)) + expect_snapshot_igraph_error(hrg_fit_impl( + graph = NULL + )) }) # 229. hrg_sample_impl @@ -3617,14 +6718,24 @@ test_that("hrg_sample_impl basic", { local_igraph_options(print.id = FALSE) g <- make_full_graph(10) hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - expect_snapshot(hrg_sample_impl(hrg_model)) + expect_snapshot(hrg_sample_impl( + hrg = hrg_model + )) + + # Structured tests + result <- hrg_sample_impl( + hrg = hrg_model + ) + expect_type(result, "list") }) test_that("hrg_sample_impl errors", { skip_if(Sys.getenv("R_SANITIZER") == "true") withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(hrg_sample_impl(NULL)) + expect_snapshot_igraph_error(hrg_sample_impl( + hrg = NULL + )) }) # 230. hrg_sample_many_impl @@ -3635,14 +6746,27 @@ test_that("hrg_sample_many_impl basic", { local_igraph_options(print.id = FALSE) g <- make_full_graph(10) hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - expect_snapshot(hrg_sample_many_impl(hrg_model, num.samples = 2)) + expect_snapshot(hrg_sample_many_impl( + hrg = hrg_model, + num.samples = 2 + )) + + # Structured tests + result <- hrg_sample_many_impl( + hrg = hrg_model, + num.samples = 2 + ) + expect_type(result, "list") }) test_that("hrg_sample_many_impl errors", { skip_if(Sys.getenv("R_SANITIZER") == "true") withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(hrg_sample_many_impl(NULL, num.samples = 2)) + expect_snapshot_igraph_error(hrg_sample_many_impl( + hrg = NULL, + num.samples = 2 + )) }) # 231. hrg_game_impl @@ -3653,14 +6777,24 @@ test_that("hrg_game_impl basic", { local_igraph_options(print.id = FALSE) g <- make_full_graph(10) hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - expect_snapshot(hrg_game_impl(hrg_model)) + expect_snapshot(hrg_game_impl( + hrg = hrg_model + )) + + # Structured tests + result <- hrg_game_impl( + hrg = hrg_model + ) + expect_s3_class(result, "igraph") }) test_that("hrg_game_impl errors", { skip_if(Sys.getenv("R_SANITIZER") == "true") withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(hrg_game_impl(NULL)) + expect_snapshot_igraph_error(hrg_game_impl( + hrg = NULL + )) }) # 232. hrg_consensus_impl @@ -3677,7 +6811,9 @@ test_that("hrg_game_impl errors", { test_that("hrg_consensus_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(hrg_consensus_impl(NULL)) + expect_snapshot_igraph_error(hrg_consensus_impl( + graph = NULL + )) }) # 233. hrg_predict_impl @@ -3694,7 +6830,9 @@ test_that("hrg_consensus_impl errors", { test_that("hrg_predict_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(hrg_predict_impl(NULL)) + expect_snapshot_igraph_error(hrg_predict_impl( + graph = NULL + )) }) # 234. hrg_create_impl @@ -3703,14 +6841,27 @@ test_that("hrg_create_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) g <- make_tree(5) - expect_snapshot(hrg_create_impl(g, prob = rep(0.5, 2))) + expect_snapshot(hrg_create_impl( + graph = g, + prob = rep(0.5, 2) + )) + + # Structured tests + result <- hrg_create_impl( + graph = g, + prob = rep(0.5, 2) + ) + expect_type(result, "list") }) test_that("hrg_create_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) g <- make_full_graph(4, directed = TRUE) - expect_snapshot_igraph_error(hrg_create_impl(g, prob = 0.5)) + expect_snapshot_igraph_error(hrg_create_impl( + graph = g, + prob = 0.5 + )) }) # 235. hrg_resize_impl @@ -3721,14 +6872,27 @@ test_that("hrg_resize_impl basic", { local_igraph_options(print.id = FALSE) g <- make_full_graph(10) hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - expect_snapshot(hrg_resize_impl(hrg_model, newsize = 5)) + expect_snapshot(hrg_resize_impl( + hrg = hrg_model, + newsize = 5 + )) + + # Structured tests + result <- hrg_resize_impl( + hrg = hrg_model, + newsize = 5 + ) + expect_type(result, "list") }) test_that("hrg_resize_impl errors", { skip_if(Sys.getenv("R_SANITIZER") == "true") withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(hrg_resize_impl(-1, newsize = 2)) + expect_snapshot_igraph_error(hrg_resize_impl( + hrg = -1, + newsize = 2 + )) }) # 236. hrg_size_impl @@ -3739,14 +6903,24 @@ test_that("hrg_size_impl basic", { local_igraph_options(print.id = FALSE) g <- make_full_graph(10) hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - expect_snapshot(hrg_size_impl(hrg_model)) + expect_snapshot(hrg_size_impl( + hrg = hrg_model + )) + + # Structured tests + result <- hrg_size_impl( + hrg = hrg_model + ) + expect_true(is.numeric(result)) }) test_that("hrg_size_impl errors", { skip_if(Sys.getenv("R_SANITIZER") == "true") withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(hrg_size_impl(-1)) + expect_snapshot_igraph_error(hrg_size_impl( + hrg = -1 + )) }) # 237. from_hrg_dendrogram_impl @@ -3756,13 +6930,23 @@ test_that("from_hrg_dendrogram_impl basic", { local_igraph_options(print.id = FALSE) g <- make_full_graph(10) hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - expect_snapshot(from_hrg_dendrogram_impl(hrg_model)) + expect_snapshot(from_hrg_dendrogram_impl( + hrg = hrg_model + )) + + # Structured tests + result <- from_hrg_dendrogram_impl( + hrg = hrg_model + ) + expect_type(result, "list") }) test_that("from_hrg_dendrogram_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(from_hrg_dendrogram_impl(-1)) + expect_snapshot_igraph_error(from_hrg_dendrogram_impl( + hrg = -1 + )) }) # 238. get_adjacency_sparse_impl @@ -3770,20 +6954,33 @@ test_that("from_hrg_dendrogram_impl errors", { test_that("get_adjacency_sparse_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_adjacency_sparse_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_adjacency_sparse_impl( + graph = g + )) expect_snapshot(get_adjacency_sparse_impl( - g, + graph = g, type = "upper", weights = c(1, 2), loops = "none" )) + + # Structured tests + result <- get_adjacency_sparse_impl( + graph = g + ) + expect_s3_class(result, "igraph.tmp.sparse") }) test_that("get_adjacency_sparse_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_adjacency_sparse_impl(NULL)) + expect_snapshot_igraph_error(get_adjacency_sparse_impl( + graph = NULL + )) }) # 239. get_stochastic_impl @@ -3791,15 +6988,32 @@ test_that("get_adjacency_sparse_impl errors", { test_that("get_stochastic_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_stochastic_impl(g)) - expect_snapshot(get_stochastic_impl(g, column.wise = TRUE, weights = c(1, 2))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_stochastic_impl( + graph = g + )) + expect_snapshot(get_stochastic_impl( + graph = g, + column.wise = TRUE, + weights = c(1, 2) + )) + + # Structured tests + result <- get_stochastic_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("get_stochastic_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_stochastic_impl(NULL)) + expect_snapshot_igraph_error(get_stochastic_impl( + graph = NULL + )) }) # 240. get_stochastic_sparse_impl @@ -3807,19 +7021,32 @@ test_that("get_stochastic_impl errors", { test_that("get_stochastic_sparse_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(get_stochastic_sparse_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_stochastic_sparse_impl( + graph = g + )) expect_snapshot(get_stochastic_sparse_impl( - g, + graph = g, column.wise = TRUE, weights = c(1, 2) )) + + # Structured tests + result <- get_stochastic_sparse_impl( + graph = g + ) + expect_s3_class(result, "igraph.tmp.sparse") }) test_that("get_stochastic_sparse_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(get_stochastic_sparse_impl(NULL)) + expect_snapshot_igraph_error(get_stochastic_sparse_impl( + graph = NULL + )) }) # 241. to_directed_impl @@ -3827,15 +7054,31 @@ test_that("get_stochastic_sparse_impl errors", { test_that("to_directed_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(to_directed_impl(g)) - expect_snapshot(to_directed_impl(g, mode = "acyclic")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(to_directed_impl( + graph = g + )) + expect_snapshot(to_directed_impl( + graph = g, + mode = "acyclic" + )) + + # Structured tests + result <- to_directed_impl( + graph = g + ) + expect_s3_class(result, "igraph") }) test_that("to_directed_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(to_directed_impl(NULL)) + expect_snapshot_igraph_error(to_directed_impl( + graph = NULL + )) }) # 242. to_undirected_impl @@ -3843,19 +7086,32 @@ test_that("to_directed_impl errors", { test_that("to_undirected_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(to_undirected_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(to_undirected_impl( + graph = g + )) expect_snapshot(to_undirected_impl( - g, + graph = g, mode = "mutual", edge.attr.comb = "sum" )) + + # Structured tests + result <- to_undirected_impl( + graph = g + ) + expect_s3_class(result, "igraph") }) test_that("to_undirected_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(to_undirected_impl(NULL)) + expect_snapshot_igraph_error(to_undirected_impl( + graph = NULL + )) }) # 243. motifs_randesu_impl @@ -3863,15 +7119,32 @@ test_that("to_undirected_impl errors", { test_that("motifs_randesu_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(motifs_randesu_impl(g)) - expect_snapshot(motifs_randesu_impl(g, size = 4, cut.prob = rep(0.1, 4))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(motifs_randesu_impl( + graph = g + )) + expect_snapshot(motifs_randesu_impl( + graph = g, + size = 4, + cut.prob = rep(0.1, 4) + )) + + # Structured tests + result <- motifs_randesu_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("motifs_randesu_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(motifs_randesu_impl(NULL)) + expect_snapshot_igraph_error(motifs_randesu_impl( + graph = NULL + )) }) # 244. motifs_randesu_estimate_impl @@ -3879,22 +7152,41 @@ test_that("motifs_randesu_impl errors", { test_that("motifs_randesu_estimate_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(6) - expect_snapshot(motifs_randesu_estimate_impl(g, size = 3, sample.size = 2)) + g <- path_graph_impl( + n = 6 + ) + + expect_snapshot(motifs_randesu_estimate_impl( + graph = g, + size = 3, + sample.size = 2 + )) expect_snapshot(motifs_randesu_estimate_impl( - g, + graph = g, size = 4, cut.prob = rep(0.1, 4), sample.size = 2, sample = 1:2 )) + + # Structured tests + result <- motifs_randesu_estimate_impl( + graph = g, + size = 3, + sample.size = 2 + ) + expect_true(is.numeric(result)) }) test_that("motifs_randesu_estimate_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - motifs_randesu_estimate_impl(NULL, size = 3, sample.size = 2) + motifs_randesu_estimate_impl( + graph = NULL, + size = 3, + sample.size = 2 + ) ) }) @@ -3903,21 +7195,39 @@ test_that("motifs_randesu_estimate_impl errors", { test_that("motifs_randesu_no_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(motifs_randesu_no_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(motifs_randesu_no_impl( + graph = g + )) expect_snapshot(motifs_randesu_no_impl( - g, + graph = g, size = 4, cut.prob = c(0.1, 0.1, 0.1, 0.1) )) + + # Structured tests + result <- motifs_randesu_no_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("motifs_randesu_no_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error( - motifs_randesu_no_impl(g, size = 3, cut.prob = c(0.1)) + motifs_randesu_no_impl( + graph = g, + size = 3, + cut.prob = c(0.1) + ) ) }) @@ -3926,14 +7236,27 @@ test_that("motifs_randesu_no_impl errors", { test_that("dyad_census_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(dyad_census_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(dyad_census_impl( + graph = g + )) + + # Structured tests + result <- dyad_census_impl( + graph = g + ) + expect_type(result, "list") }) test_that("dyad_census_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(dyad_census_impl(NULL)) + expect_snapshot_igraph_error(dyad_census_impl( + graph = NULL + )) }) # 247. triad_census_impl @@ -3941,14 +7264,27 @@ test_that("dyad_census_impl errors", { test_that("triad_census_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(triad_census_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(triad_census_impl( + graph = g + )) + + # Structured tests + result <- triad_census_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("triad_census_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(triad_census_impl(NULL)) + expect_snapshot_igraph_error(triad_census_impl( + graph = NULL + )) }) # 248. count_adjacent_triangles_impl @@ -3956,15 +7292,31 @@ test_that("triad_census_impl errors", { test_that("count_adjacent_triangles_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(count_adjacent_triangles_impl(g)) - expect_snapshot(count_adjacent_triangles_impl(g, vids = 1:2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(count_adjacent_triangles_impl( + graph = g + )) + expect_snapshot(count_adjacent_triangles_impl( + graph = g, + vids = 1:2 + )) + + # Structured tests + result <- count_adjacent_triangles_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("count_adjacent_triangles_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(count_adjacent_triangles_impl(NULL)) + expect_snapshot_igraph_error(count_adjacent_triangles_impl( + graph = NULL + )) }) # 249. count_triangles_impl @@ -3972,14 +7324,27 @@ test_that("count_adjacent_triangles_impl errors", { test_that("count_triangles_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(count_triangles_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(count_triangles_impl( + graph = g + )) + + # Structured tests + result <- count_triangles_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("count_triangles_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(count_triangles_impl(NULL)) + expect_snapshot_igraph_error(count_triangles_impl( + graph = NULL + )) }) # 250. local_scan_0_impl @@ -3987,15 +7352,32 @@ test_that("count_triangles_impl errors", { test_that("local_scan_0_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(local_scan_0_impl(g)) - expect_snapshot(local_scan_0_impl(g, weights = c(1, 2), mode = "in")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(local_scan_0_impl( + graph = g + )) + expect_snapshot(local_scan_0_impl( + graph = g, + weights = c(1, 2), + mode = "in" + )) + + # Structured tests + result <- local_scan_0_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("local_scan_0_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(local_scan_0_impl(NULL)) + expect_snapshot_igraph_error(local_scan_0_impl( + graph = NULL + )) }) # 251. local_scan_0_them_impl @@ -4003,22 +7385,41 @@ test_that("local_scan_0_impl errors", { test_that("local_scan_0_them_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(local_scan_0_them_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(local_scan_0_them_impl( + us = g1, + them = g2 + )) expect_snapshot(local_scan_0_them_impl( - g1, - g2, + us = g1, + them = g2, weights.them = c(1, 2), mode = "in" )) + + # Structured tests + result <- local_scan_0_them_impl( + us = g1, + them = g2 + ) + expect_true(is.numeric(result)) }) test_that("local_scan_0_them_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - local_scan_0_them_impl(NULL, path_graph_impl(3)) + local_scan_0_them_impl( + us = NULL, + them = path_graph_impl(3) + ) ) }) @@ -4027,15 +7428,32 @@ test_that("local_scan_0_them_impl errors", { test_that("local_scan_1_ecount_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(local_scan_1_ecount_impl(g)) - expect_snapshot(local_scan_1_ecount_impl(g, weights = c(1, 2), mode = "in")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(local_scan_1_ecount_impl( + graph = g + )) + expect_snapshot(local_scan_1_ecount_impl( + graph = g, + weights = c(1, 2), + mode = "in" + )) + + # Structured tests + result <- local_scan_1_ecount_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("local_scan_1_ecount_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(local_scan_1_ecount_impl(NULL)) + expect_snapshot_igraph_error(local_scan_1_ecount_impl( + graph = NULL + )) }) # 253. local_scan_1_ecount_them_impl @@ -4043,22 +7461,41 @@ test_that("local_scan_1_ecount_impl errors", { test_that("local_scan_1_ecount_them_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(local_scan_1_ecount_them_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + expect_snapshot(local_scan_1_ecount_them_impl( - g1, - g2, + us = g1, + them = g2 + )) + expect_snapshot(local_scan_1_ecount_them_impl( + us = g1, + them = g2, weights.them = c(1, 2), mode = "in" )) + + # Structured tests + result <- local_scan_1_ecount_them_impl( + us = g1, + them = g2 + ) + expect_true(is.numeric(result)) }) test_that("local_scan_1_ecount_them_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - local_scan_1_ecount_them_impl(NULL, path_graph_impl(3)) + local_scan_1_ecount_them_impl( + us = NULL, + them = path_graph_impl(3) + ) ) }) @@ -4067,20 +7504,36 @@ test_that("local_scan_1_ecount_them_impl errors", { test_that("local_scan_k_ecount_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(local_scan_k_ecount_impl(g, k = 1)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(local_scan_k_ecount_impl( + graph = g, + k = 1 + )) expect_snapshot(local_scan_k_ecount_impl( - g, + graph = g, k = 1, weights = c(1, 2), mode = "in" )) + + # Structured tests + result <- local_scan_k_ecount_impl( + graph = g, + k = 1 + ) + expect_true(is.numeric(result)) }) test_that("local_scan_k_ecount_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(local_scan_k_ecount_impl(NULL, k = 1)) + expect_snapshot_igraph_error(local_scan_k_ecount_impl( + graph = NULL, + k = 1 + )) }) # 255. local_scan_k_ecount_them_impl @@ -4088,23 +7541,45 @@ test_that("local_scan_k_ecount_impl errors", { test_that("local_scan_k_ecount_them_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(local_scan_k_ecount_them_impl(g1, g2, k = 1)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + expect_snapshot(local_scan_k_ecount_them_impl( - g1, - g2, + us = g1, + them = g2, + k = 1 + )) + expect_snapshot(local_scan_k_ecount_them_impl( + us = g1, + them = g2, k = 1, weights.them = c(1, 2), mode = "in" )) + + # Structured tests + result <- local_scan_k_ecount_them_impl( + us = g1, + them = g2, + k = 1 + ) + expect_true(is.numeric(result)) }) test_that("local_scan_k_ecount_them_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - local_scan_k_ecount_them_impl(NULL, path_graph_impl(3), k = 1) + local_scan_k_ecount_them_impl( + us = NULL, + them = path_graph_impl(3), + k = 1 + ) ) }) @@ -4113,23 +7588,36 @@ test_that("local_scan_k_ecount_them_impl errors", { test_that("local_scan_neighborhood_ecount_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(4) + g <- path_graph_impl( + n = 4 + ) + expect_snapshot(local_scan_neighborhood_ecount_impl( - g, + graph = g, neighborhoods = list(1:2, 2:3, 2:4, 2) )) expect_snapshot(local_scan_neighborhood_ecount_impl( - g, + graph = g, weights = c(1, 2, 3), neighborhoods = list(1:2, 1:3, 2:4, 1) )) + + # Structured tests + result <- local_scan_neighborhood_ecount_impl( + graph = g, + neighborhoods = list(1:2, 2:3, 2:4, 2) + ) + expect_true(is.numeric(result)) }) test_that("local_scan_neighborhood_ecount_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - local_scan_neighborhood_ecount_impl(NULL, neighborhoods = list(1:2, 2:3)) + local_scan_neighborhood_ecount_impl( + graph = NULL, + neighborhoods = list(1:2, 2:3) + ) ) }) @@ -4138,24 +7626,49 @@ test_that("local_scan_neighborhood_ecount_impl errors", { test_that("local_scan_subset_ecount_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(4) + g <- path_graph_impl( + n = 4 + ) + expect_snapshot(local_scan_subset_ecount_impl( - g, - subsets = list(c(1.0, 2.0), c(2.0, 3.0)) + graph = g, + subsets = list( + c(1, 2), + c(2, 3) + ) )) expect_snapshot(local_scan_subset_ecount_impl( - g, - weights = c(1.0, 2.0, 3.0), - subsets = list(c(1.0, 2.0), c(2.0, 3.0)) + graph = g, + weights = c(1, 2, 3), + subsets = list( + c(1, 2), + c(2, 3) + ) )) + + # Structured tests + result <- local_scan_subset_ecount_impl( + graph = g, + subsets = list( + c(1, 2), + c(2, 3) + ) + ) + expect_true(is.numeric(result)) }) test_that("local_scan_subset_ecount_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(4) + g <- path_graph_impl( + n = 4 + ) + expect_snapshot_igraph_error( - local_scan_subset_ecount_impl(g, subsets = list(1:2, letters[2:3])) + local_scan_subset_ecount_impl( + graph = g, + subsets = list(1:2, letters[2:3]) + ) ) }) @@ -4164,14 +7677,27 @@ test_that("local_scan_subset_ecount_impl errors", { test_that("list_triangles_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(list_triangles_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(list_triangles_impl( + graph = g + )) + + # Structured tests + result <- list_triangles_impl( + graph = g + ) + expect_s3_class(result, "igraph.vs") }) test_that("list_triangles_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(list_triangles_impl(NULL)) + expect_snapshot_igraph_error(list_triangles_impl( + graph = NULL + )) }) # 259. join_impl @@ -4179,15 +7705,34 @@ test_that("list_triangles_impl errors", { test_that("join_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(join_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(join_impl( + left = g1, + right = g2 + )) + + # Structured tests + result <- join_impl( + left = g1, + right = g2 + ) + expect_s3_class(result, "igraph") }) test_that("join_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(join_impl(NULL, path_graph_impl(3))) + expect_snapshot_igraph_error(join_impl( + left = NULL, + right = path_graph_impl(3) + )) }) # 260. induced_subgraph_map_impl @@ -4195,16 +7740,39 @@ test_that("join_impl errors", { test_that("induced_subgraph_map_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(induced_subgraph_map_impl(g, 1:2, impl = "auto")) - expect_snapshot(induced_subgraph_map_impl(g, 1:2, impl = "copy_and_delete")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(induced_subgraph_map_impl( + graph = g, + vids = 1:2, + impl = "auto" + )) + expect_snapshot(induced_subgraph_map_impl( + graph = g, + vids = 1:2, + impl = "copy_and_delete" + )) + + # Structured tests + result <- induced_subgraph_map_impl( + graph = g, + vids = 1:2, + impl = "auto" + ) + expect_type(result, "list") }) test_that("induced_subgraph_map_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - induced_subgraph_map_impl(NULL, 1:2, impl = "auto") + induced_subgraph_map_impl( + graph = NULL, + vids = 1:2, + impl = "auto" + ) ) }) @@ -4213,15 +7781,31 @@ test_that("induced_subgraph_map_impl errors", { test_that("mycielskian_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(mycielskian_impl(g)) - expect_snapshot(mycielskian_impl(g, k = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(mycielskian_impl( + graph = g + )) + expect_snapshot(mycielskian_impl( + graph = g, + k = 2 + )) + + # Structured tests + result <- mycielskian_impl( + graph = g + ) + expect_s3_class(result, "igraph") }) test_that("mycielskian_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(mycielskian_impl(NULL)) + expect_snapshot_igraph_error(mycielskian_impl( + graph = NULL + )) }) # 262. product_impl @@ -4229,16 +7813,39 @@ test_that("mycielskian_impl errors", { test_that("product_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(product_impl(g1, g2)) - expect_snapshot(product_impl(g1, g2, type = "tensor")) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(product_impl( + g1 = g1, + g2 = g2 + )) + expect_snapshot(product_impl( + g1 = g1, + g2 = g2, + type = "tensor" + )) + + # Structured tests + result <- product_impl( + g1 = g1, + g2 = g2 + ) + expect_s3_class(result, "igraph") }) test_that("product_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(product_impl(NULL, path_graph_impl(3))) + expect_snapshot_igraph_error(product_impl( + g1 = NULL, + g2 = path_graph_impl(3) + )) }) # 263. rooted_product_impl @@ -4246,16 +7853,38 @@ test_that("product_impl errors", { test_that("rooted_product_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(rooted_product_impl(g1, g2, root = 1)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(rooted_product_impl( + g1 = g1, + g2 = g2, + root = 1 + )) + + # Structured tests + result <- rooted_product_impl( + g1 = g1, + g2 = g2, + root = 1 + ) + expect_s3_class(result, "igraph") }) test_that("rooted_product_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - rooted_product_impl(NULL, path_graph_impl(3), root = 1) + rooted_product_impl( + g1 = NULL, + g2 = path_graph_impl(3), + root = 1 + ) ) }) @@ -4264,15 +7893,31 @@ test_that("rooted_product_impl errors", { test_that("gomory_hu_tree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(gomory_hu_tree_impl(g)) - expect_snapshot(gomory_hu_tree_impl(g, capacity = c(1, 2))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(gomory_hu_tree_impl( + graph = g + )) + expect_snapshot(gomory_hu_tree_impl( + graph = g, + capacity = c(1, 2) + )) + + # Structured tests + result <- gomory_hu_tree_impl( + graph = g + ) + expect_type(result, "list") }) test_that("gomory_hu_tree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(gomory_hu_tree_impl(NULL)) + expect_snapshot_igraph_error(gomory_hu_tree_impl( + graph = NULL + )) }) # 265. maxflow_impl @@ -4280,15 +7925,39 @@ test_that("gomory_hu_tree_impl errors", { test_that("maxflow_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(maxflow_impl(g, source = 1, target = 3)) - expect_snapshot(maxflow_impl(g, source = 1, target = 3, capacity = c(1, 2))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(maxflow_impl( + graph = g, + source = 1, + target = 3 + )) + expect_snapshot(maxflow_impl( + graph = g, + source = 1, + target = 3, + capacity = c(1, 2) + )) + + # Structured tests + result <- maxflow_impl( + graph = g, + source = 1, + target = 3 + ) + expect_type(result, "list") }) test_that("maxflow_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(maxflow_impl(NULL, source = 1, target = 3)) + expect_snapshot_igraph_error(maxflow_impl( + graph = NULL, + source = 1, + target = 3 + )) }) # 266. residual_graph_impl @@ -4296,15 +7965,34 @@ test_that("maxflow_impl errors", { test_that("residual_graph_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(residual_graph_impl(g, capacity = c(1, 2), flow = c(1, 2))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(residual_graph_impl( + graph = g, + capacity = c(1, 2), + flow = c(1, 2) + )) + + # Structured tests + result <- residual_graph_impl( + graph = g, + capacity = c(1, 2), + flow = c(1, 2) + ) + expect_type(result, "list") }) test_that("residual_graph_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - residual_graph_impl(NULL, capacity = c(1, 2), flow = c(1, 2)) + residual_graph_impl( + graph = NULL, + capacity = c(1, 2), + flow = c(1, 2) + ) ) }) @@ -4313,19 +8001,34 @@ test_that("residual_graph_impl errors", { test_that("reverse_residual_graph_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(reverse_residual_graph_impl( - g, + graph = g, capacity = c(1, 2), flow = c(1, 2) )) + + # Structured tests + result <- reverse_residual_graph_impl( + graph = g, + capacity = c(1, 2), + flow = c(1, 2) + ) + expect_s3_class(result, "igraph") }) test_that("reverse_residual_graph_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - reverse_residual_graph_impl(NULL, capacity = c(1, 2), flow = c(1, 2)) + reverse_residual_graph_impl( + graph = NULL, + capacity = c(1, 2), + flow = c(1, 2) + ) ) }) @@ -4334,15 +8037,39 @@ test_that("reverse_residual_graph_impl errors", { test_that("st_mincut_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(st_mincut_impl(g, source = 1, target = 3)) - expect_snapshot(st_mincut_impl(g, source = 1, target = 3, capacity = c(1, 2))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(st_mincut_impl( + graph = g, + source = 1, + target = 3 + )) + expect_snapshot(st_mincut_impl( + graph = g, + source = 1, + target = 3, + capacity = c(1, 2) + )) + + # Structured tests + result <- st_mincut_impl( + graph = g, + source = 1, + target = 3 + ) + expect_type(result, "list") }) test_that("st_mincut_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(st_mincut_impl(NULL, source = 1, target = 3)) + expect_snapshot_igraph_error(st_mincut_impl( + graph = NULL, + source = 1, + target = 3 + )) }) # 269. dominator_tree_impl @@ -4350,15 +8077,36 @@ test_that("st_mincut_impl errors", { test_that("dominator_tree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3, directed = TRUE) - expect_snapshot(dominator_tree_impl(g, root = 1)) - expect_snapshot(dominator_tree_impl(g, root = 1, mode = "in")) + g <- path_graph_impl( + n = 3, + directed = TRUE + ) + + expect_snapshot(dominator_tree_impl( + graph = g, + root = 1 + )) + expect_snapshot(dominator_tree_impl( + graph = g, + root = 1, + mode = "in" + )) + + # Structured tests + result <- dominator_tree_impl( + graph = g, + root = 1 + ) + expect_type(result, "list") }) test_that("dominator_tree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(dominator_tree_impl(NULL, root = 1)) + expect_snapshot_igraph_error(dominator_tree_impl( + graph = NULL, + root = 1 + )) }) # 270. all_st_cuts_impl @@ -4366,14 +8114,34 @@ test_that("dominator_tree_impl errors", { test_that("all_st_cuts_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3, directed = TRUE) - expect_snapshot(all_st_cuts_impl(g, source = 1, target = 3)) + g <- path_graph_impl( + n = 3, + directed = TRUE + ) + + expect_snapshot(all_st_cuts_impl( + graph = g, + source = 1, + target = 3 + )) + + # Structured tests + result <- all_st_cuts_impl( + graph = g, + source = 1, + target = 3 + ) + expect_type(result, "list") }) test_that("all_st_cuts_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(all_st_cuts_impl(NULL, source = 1, target = 3)) + expect_snapshot_igraph_error(all_st_cuts_impl( + graph = NULL, + source = 1, + target = 3 + )) }) # 271. all_st_mincuts_impl @@ -4381,21 +8149,41 @@ test_that("all_st_cuts_impl errors", { test_that("all_st_mincuts_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3, directed = TRUE) - expect_snapshot(all_st_mincuts_impl(g, source = 1, target = 3)) + g <- path_graph_impl( + n = 3, + directed = TRUE + ) + + expect_snapshot(all_st_mincuts_impl( + graph = g, + source = 1, + target = 3 + )) expect_snapshot(all_st_mincuts_impl( - g, + graph = g, source = 1, target = 3, capacity = c(1, 2) )) + + # Structured tests + result <- all_st_mincuts_impl( + graph = g, + source = 1, + target = 3 + ) + expect_type(result, "list") }) test_that("all_st_mincuts_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - all_st_mincuts_impl(NULL, source = 1, target = 3) + all_st_mincuts_impl( + graph = NULL, + source = 1, + target = 3 + ) ) }) @@ -4404,14 +8192,27 @@ test_that("all_st_mincuts_impl errors", { test_that("even_tarjan_reduction_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(even_tarjan_reduction_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(even_tarjan_reduction_impl( + graph = g + )) + + # Structured tests + result <- even_tarjan_reduction_impl( + graph = g + ) + expect_type(result, "list") }) test_that("even_tarjan_reduction_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(even_tarjan_reduction_impl(NULL)) + expect_snapshot_igraph_error(even_tarjan_reduction_impl( + graph = NULL + )) }) # 273. is_separator_impl @@ -4419,14 +8220,30 @@ test_that("even_tarjan_reduction_impl errors", { test_that("is_separator_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_separator_impl(g, 1:2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_separator_impl( + graph = g, + candidate = 1:2 + )) + + # Structured tests + result <- is_separator_impl( + graph = g, + candidate = 1:2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_separator_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_separator_impl(NULL, 1:2)) + expect_snapshot_igraph_error(is_separator_impl( + graph = NULL, + candidate = 1:2 + )) }) # 274. is_minimal_separator_impl @@ -4434,14 +8251,30 @@ test_that("is_separator_impl errors", { test_that("is_minimal_separator_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_minimal_separator_impl(g, 1:2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_minimal_separator_impl( + graph = g, + candidate = 1:2 + )) + + # Structured tests + result <- is_minimal_separator_impl( + graph = g, + candidate = 1:2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_minimal_separator_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_minimal_separator_impl(NULL, 1:2)) + expect_snapshot_igraph_error(is_minimal_separator_impl( + graph = NULL, + candidate = 1:2 + )) }) # 275. all_minimal_st_separators_impl @@ -4449,14 +8282,27 @@ test_that("is_minimal_separator_impl errors", { test_that("all_minimal_st_separators_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(all_minimal_st_separators_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(all_minimal_st_separators_impl( + graph = g + )) + + # Structured tests + result <- all_minimal_st_separators_impl( + graph = g + ) + expect_type(result, "list") }) test_that("all_minimal_st_separators_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(all_minimal_st_separators_impl(NULL)) + expect_snapshot_igraph_error(all_minimal_st_separators_impl( + graph = NULL + )) }) # 276. minimum_size_separators_impl @@ -4464,14 +8310,27 @@ test_that("all_minimal_st_separators_impl errors", { test_that("minimum_size_separators_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(minimum_size_separators_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(minimum_size_separators_impl( + graph = g + )) + + # Structured tests + result <- minimum_size_separators_impl( + graph = g + ) + expect_type(result, "list") }) test_that("minimum_size_separators_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(minimum_size_separators_impl(NULL)) + expect_snapshot_igraph_error(minimum_size_separators_impl( + graph = NULL + )) }) # 277. isoclass_impl @@ -4479,14 +8338,27 @@ test_that("minimum_size_separators_impl errors", { test_that("isoclass_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(isoclass_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(isoclass_impl( + graph = g + )) + + # Structured tests + result <- isoclass_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("isoclass_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(isoclass_impl(NULL)) + expect_snapshot_igraph_error(isoclass_impl( + graph = NULL + )) }) # 278. isomorphic_impl @@ -4494,15 +8366,34 @@ test_that("isoclass_impl errors", { test_that("isomorphic_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(isomorphic_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(isomorphic_impl( + graph1 = g1, + graph2 = g2 + )) + + # Structured tests + result <- isomorphic_impl( + graph1 = g1, + graph2 = g2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("isomorphic_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(isomorphic_impl(NULL, path_graph_impl(3))) + expect_snapshot_igraph_error(isomorphic_impl( + graph1 = NULL, + graph2 = path_graph_impl(3) + )) }) # 279. isoclass_subgraph_impl @@ -4510,14 +8401,30 @@ test_that("isomorphic_impl errors", { test_that("isoclass_subgraph_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(5) - expect_snapshot(isoclass_subgraph_impl(g, c(1, 2, 3))) + g <- path_graph_impl( + n = 5 + ) + + expect_snapshot(isoclass_subgraph_impl( + graph = g, + vids = c(1, 2, 3) + )) + + # Structured tests + result <- isoclass_subgraph_impl( + graph = g, + vids = c(1, 2, 3) + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("isoclass_subgraph_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(isoclass_subgraph_impl(NULL, 1:2)) + expect_snapshot_igraph_error(isoclass_subgraph_impl( + graph = NULL, + vids = 1:2 + )) }) # 280. isoclass_create_impl @@ -4525,14 +8432,31 @@ test_that("isoclass_subgraph_impl errors", { test_that("isoclass_create_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(isoclass_create_impl(size = 3, number = 1)) - expect_snapshot(isoclass_create_impl(size = 3, number = 1, directed = FALSE)) + expect_snapshot(isoclass_create_impl( + size = 3, + number = 1 + )) + expect_snapshot(isoclass_create_impl( + size = 3, + number = 1, + directed = FALSE + )) + + # Structured tests + result <- isoclass_create_impl( + size = 3, + number = 1 + ) + expect_s3_class(result, "igraph") }) test_that("isoclass_create_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(isoclass_create_impl("a", 1)) + expect_snapshot_igraph_error(isoclass_create_impl( + size = "a", + number = 1 + )) }) # 281. isomorphic_vf2_impl @@ -4540,23 +8464,42 @@ test_that("isoclass_create_impl errors", { test_that("isomorphic_vf2_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(isomorphic_vf2_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(isomorphic_vf2_impl( + graph1 = g1, + graph2 = g2 + )) expect_snapshot(isomorphic_vf2_impl( - g1, - g2, + graph1 = g1, + graph2 = g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2) )) + + # Structured tests + result <- isomorphic_vf2_impl( + graph1 = g1, + graph2 = g2 + ) + expect_type(result, "list") }) test_that("isomorphic_vf2_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(isomorphic_vf2_impl(NULL, path_graph_impl(3))) + expect_snapshot_igraph_error(isomorphic_vf2_impl( + graph1 = NULL, + graph2 = path_graph_impl(3) + )) }) # 282. get_isomorphisms_vf2_callback_impl @@ -4567,24 +8510,43 @@ test_that("isomorphic_vf2_impl errors", { test_that("count_isomorphisms_vf2_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(count_isomorphisms_vf2_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(count_isomorphisms_vf2_impl( + graph1 = g1, + graph2 = g2 + )) expect_snapshot(count_isomorphisms_vf2_impl( - g1, - g2, + graph1 = g1, + graph2 = g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2) )) + + # Structured tests + result <- count_isomorphisms_vf2_impl( + graph1 = g1, + graph2 = g2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("count_isomorphisms_vf2_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - count_isomorphisms_vf2_impl(NULL, path_graph_impl(3)) + count_isomorphisms_vf2_impl( + graph1 = NULL, + graph2 = path_graph_impl(3) + ) ) }) @@ -4593,24 +8555,43 @@ test_that("count_isomorphisms_vf2_impl errors", { test_that("get_isomorphisms_vf2_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(get_isomorphisms_vf2_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + expect_snapshot(get_isomorphisms_vf2_impl( - g1, - g2, + graph1 = g1, + graph2 = g2 + )) + expect_snapshot(get_isomorphisms_vf2_impl( + graph1 = g1, + graph2 = g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2) )) + + # Structured tests + result <- get_isomorphisms_vf2_impl( + graph1 = g1, + graph2 = g2 + ) + expect_type(result, "list") }) test_that("get_isomorphisms_vf2_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - get_isomorphisms_vf2_impl(NULL, path_graph_impl(3)) + get_isomorphisms_vf2_impl( + graph1 = NULL, + graph2 = path_graph_impl(3) + ) ) }) @@ -4619,15 +8600,34 @@ test_that("get_isomorphisms_vf2_impl errors", { test_that("subisomorphic_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(subisomorphic_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(subisomorphic_impl( + graph1 = g1, + graph2 = g2 + )) + + # Structured tests + result <- subisomorphic_impl( + graph1 = g1, + graph2 = g2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("subisomorphic_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(subisomorphic_impl(NULL, path_graph_impl(3))) + expect_snapshot_igraph_error(subisomorphic_impl( + graph1 = NULL, + graph2 = path_graph_impl(3) + )) }) # 286. subisomorphic_vf2_impl @@ -4635,24 +8635,43 @@ test_that("subisomorphic_impl errors", { test_that("subisomorphic_vf2_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(subisomorphic_vf2_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(subisomorphic_vf2_impl( + graph1 = g1, + graph2 = g2 + )) expect_snapshot(subisomorphic_vf2_impl( - g1, - g2, + graph1 = g1, + graph2 = g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2) )) + + # Structured tests + result <- subisomorphic_vf2_impl( + graph1 = g1, + graph2 = g2 + ) + expect_type(result, "list") }) test_that("subisomorphic_vf2_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - subisomorphic_vf2_impl(NULL, path_graph_impl(3)) + subisomorphic_vf2_impl( + graph1 = NULL, + graph2 = path_graph_impl(3) + ) ) }) @@ -4661,24 +8680,43 @@ test_that("subisomorphic_vf2_impl errors", { test_that("count_subisomorphisms_vf2_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(count_subisomorphisms_vf2_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(count_subisomorphisms_vf2_impl( + graph1 = g1, + graph2 = g2 + )) expect_snapshot(count_subisomorphisms_vf2_impl( - g1, - g2, + graph1 = g1, + graph2 = g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2) )) + + # Structured tests + result <- count_subisomorphisms_vf2_impl( + graph1 = g1, + graph2 = g2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("count_subisomorphisms_vf2_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - count_subisomorphisms_vf2_impl(NULL, path_graph_impl(3)) + count_subisomorphisms_vf2_impl( + graph1 = NULL, + graph2 = path_graph_impl(3) + ) ) }) @@ -4687,24 +8725,43 @@ test_that("count_subisomorphisms_vf2_impl errors", { test_that("get_subisomorphisms_vf2_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(get_subisomorphisms_vf2_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_subisomorphisms_vf2_impl( + graph1 = g1, + graph2 = g2 + )) expect_snapshot(get_subisomorphisms_vf2_impl( - g1, - g2, + graph1 = g1, + graph2 = g2, vertex.color1 = c(1, 2, 3), vertex.color2 = c(1, 2, 3), edge.color1 = c(1, 2), edge.color2 = c(1, 2) )) + + # Structured tests + result <- get_subisomorphisms_vf2_impl( + graph1 = g1, + graph2 = g2 + ) + expect_type(result, "list") }) test_that("get_subisomorphisms_vf2_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - get_subisomorphisms_vf2_impl(NULL, path_graph_impl(3)) + get_subisomorphisms_vf2_impl( + graph1 = NULL, + graph2 = path_graph_impl(3) + ) ) }) @@ -4713,15 +8770,32 @@ test_that("get_subisomorphisms_vf2_impl errors", { test_that("canonical_permutation_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(canonical_permutation_impl(g)) - expect_snapshot(canonical_permutation_impl(g, colors = c(1, 2, 3), sh = "fl")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(canonical_permutation_impl( + graph = g + )) + expect_snapshot(canonical_permutation_impl( + graph = g, + colors = c(1, 2, 3), + sh = "fl" + )) + + # Structured tests + result <- canonical_permutation_impl( + graph = g + ) + expect_type(result, "list") }) test_that("canonical_permutation_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(canonical_permutation_impl(NULL)) + expect_snapshot_igraph_error(canonical_permutation_impl( + graph = NULL + )) }) # 290. permute_vertices_impl @@ -4729,14 +8803,30 @@ test_that("canonical_permutation_impl errors", { test_that("permute_vertices_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(permute_vertices_impl(g, permutation = 3:1)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(permute_vertices_impl( + graph = g, + permutation = 3:1 + )) + + # Structured tests + result <- permute_vertices_impl( + graph = g, + permutation = 3:1 + ) + expect_s3_class(result, "igraph") }) test_that("permute_vertices_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(permute_vertices_impl(NULL, permutation = 3:1)) + expect_snapshot_igraph_error(permute_vertices_impl( + graph = NULL, + permutation = 3:1 + )) }) # 291. isomorphic_bliss_impl @@ -4744,22 +8834,41 @@ test_that("permute_vertices_impl errors", { test_that("isomorphic_bliss_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - g2 <- path_graph_impl(3) - expect_snapshot(isomorphic_bliss_impl(g1, g2)) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(isomorphic_bliss_impl( + graph1 = g1, + graph2 = g2 + )) expect_snapshot(isomorphic_bliss_impl( - g1, - g2, + graph1 = g1, + graph2 = g2, colors1 = c(1, 2, 3), colors2 = c(1, 2, 3), sh = "fl" )) + + # Structured tests + result <- isomorphic_bliss_impl( + graph1 = g1, + graph2 = g2 + ) + expect_type(result, "list") }) test_that("isomorphic_bliss_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(isomorphic_bliss_impl(NULL, path_graph_impl(3))) + expect_snapshot_igraph_error(isomorphic_bliss_impl( + graph1 = NULL, + graph2 = path_graph_impl(3) + )) }) # 292. count_automorphisms_impl @@ -4767,15 +8876,32 @@ test_that("isomorphic_bliss_impl errors", { test_that("count_automorphisms_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(count_automorphisms_impl(g)) - expect_snapshot(count_automorphisms_impl(g, colors = c(1, 2, 3), sh = "fl")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(count_automorphisms_impl( + graph = g + )) + expect_snapshot(count_automorphisms_impl( + graph = g, + colors = c(1, 2, 3), + sh = "fl" + )) + + # Structured tests + result <- count_automorphisms_impl( + graph = g + ) + expect_type(result, "list") }) test_that("count_automorphisms_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(count_automorphisms_impl(NULL)) + expect_snapshot_igraph_error(count_automorphisms_impl( + graph = NULL + )) }) # 293. automorphism_group_impl @@ -4783,20 +8909,33 @@ test_that("count_automorphisms_impl errors", { test_that("automorphism_group_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(automorphism_group_impl(g)) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(automorphism_group_impl( - g, + graph = g + )) + expect_snapshot(automorphism_group_impl( + graph = g, colors = c(1, 2, 3), sh = "fl", details = TRUE )) + + # Structured tests + result <- automorphism_group_impl( + graph = g + ) + expect_type(result, "list") }) test_that("automorphism_group_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(automorphism_group_impl(NULL)) + expect_snapshot_igraph_error(automorphism_group_impl( + graph = NULL + )) }) # 294. simplify_and_colorize_impl @@ -4804,14 +8943,27 @@ test_that("automorphism_group_impl errors", { test_that("simplify_and_colorize_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(simplify_and_colorize_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(simplify_and_colorize_impl( + graph = g + )) + + # Structured tests + result <- simplify_and_colorize_impl( + graph = g + ) + expect_type(result, "list") }) test_that("simplify_and_colorize_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(simplify_and_colorize_impl(NULL)) + expect_snapshot_igraph_error(simplify_and_colorize_impl( + graph = NULL + )) }) # 295. graph_count_impl @@ -4819,14 +8971,27 @@ test_that("simplify_and_colorize_impl errors", { test_that("graph_count_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(graph_count_impl(3)) - expect_snapshot(graph_count_impl(3, directed = TRUE)) + expect_snapshot(graph_count_impl( + n = 3 + )) + expect_snapshot(graph_count_impl( + n = 3, + directed = TRUE + )) + + # Structured tests + result <- graph_count_impl( + n = 3 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("graph_count_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(graph_count_impl("a")) + expect_snapshot_igraph_error(graph_count_impl( + n = "a" + )) }) # 296. is_matching_impl @@ -4834,19 +8999,35 @@ test_that("graph_count_impl errors", { test_that("is_matching_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_matching_impl(g, matching = 1:2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_matching_impl( + graph = g, + matching = 1:2 + )) expect_snapshot(is_matching_impl( - g, + graph = g, types = c(TRUE, FALSE, TRUE), matching = 1:2 )) + + # Structured tests + result <- is_matching_impl( + graph = g, + matching = 1:2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_matching_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_matching_impl(NULL, matching = 1:2)) + expect_snapshot_igraph_error(is_matching_impl( + graph = NULL, + matching = 1:2 + )) }) # 297. is_maximal_matching_impl @@ -4854,19 +9035,35 @@ test_that("is_matching_impl errors", { test_that("is_maximal_matching_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_maximal_matching_impl(g, matching = 1:2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_maximal_matching_impl( + graph = g, + matching = 1:2 + )) expect_snapshot(is_maximal_matching_impl( - g, + graph = g, types = c(TRUE, FALSE, TRUE), matching = 1:2 )) + + # Structured tests + result <- is_maximal_matching_impl( + graph = g, + matching = 1:2 + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_maximal_matching_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_maximal_matching_impl(NULL, matching = 1:2)) + expect_snapshot_igraph_error(is_maximal_matching_impl( + graph = NULL, + matching = 1:2 + )) }) # 298. maximum_bipartite_matching_impl @@ -4874,24 +9071,37 @@ test_that("is_maximal_matching_impl errors", { test_that("maximum_bipartite_matching_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(maximum_bipartite_matching_impl( - g, + graph = g, types = c(TRUE, FALSE, TRUE) )) expect_snapshot(maximum_bipartite_matching_impl( - g, + graph = g, types = c(TRUE, FALSE, TRUE), weights = c(1, 2), - eps = 1e-5 + eps = 1e-05 )) + + # Structured tests + result <- maximum_bipartite_matching_impl( + graph = g, + types = c(TRUE, FALSE, TRUE) + ) + expect_type(result, "list") }) test_that("maximum_bipartite_matching_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - maximum_bipartite_matching_impl(NULL, types = c(TRUE, FALSE, TRUE)) + maximum_bipartite_matching_impl( + graph = NULL, + types = c(TRUE, FALSE, TRUE) + ) ) }) @@ -4900,10 +9110,16 @@ test_that("maximum_bipartite_matching_impl errors", { test_that("adjacency_spectral_embedding_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(adjacency_spectral_embedding_impl(g, no = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(adjacency_spectral_embedding_impl( + graph = g, + no = 2 + )) expect_snapshot(adjacency_spectral_embedding_impl( - g, + graph = g, no = 2, weights = c(1, 2), which = "la", @@ -4911,12 +9127,22 @@ test_that("adjacency_spectral_embedding_impl basic", { cvec = c(1, 2, 3), options = list(maxiter = 10) )) + + # Structured tests + result <- adjacency_spectral_embedding_impl( + graph = g, + no = 2 + ) + expect_type(result, "list") }) test_that("adjacency_spectral_embedding_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(adjacency_spectral_embedding_impl(NULL, no = 2)) + expect_snapshot_igraph_error(adjacency_spectral_embedding_impl( + graph = NULL, + no = 2 + )) }) # 300. laplacian_spectral_embedding_impl @@ -4924,14 +9150,30 @@ test_that("adjacency_spectral_embedding_impl errors", { test_that("laplacian_spectral_embedding_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(laplacian_spectral_embedding_impl(g, no = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(laplacian_spectral_embedding_impl( + graph = g, + no = 2 + )) + + # Structured tests + result <- laplacian_spectral_embedding_impl( + graph = g, + no = 2 + ) + expect_type(result, "list") }) test_that("laplacian_spectral_embedding_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(laplacian_spectral_embedding_impl(NULL, no = 2)) + expect_snapshot_igraph_error(laplacian_spectral_embedding_impl( + graph = NULL, + no = 2 + )) }) # 301. eigen_adjacency_impl @@ -4939,22 +9181,35 @@ test_that("laplacian_spectral_embedding_impl errors", { test_that("eigen_adjacency_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(eigen_adjacency_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(eigen_adjacency_impl( + graph = g + )) expect_snapshot_igraph_error( eigen_adjacency_impl( - g, + graph = g, algorithm = "lapack", which = list(which = "LA"), options = list(maxiter = 10) ) ) + + # Structured tests + result <- eigen_adjacency_impl( + graph = g + ) + expect_type(result, "list") }) test_that("eigen_adjacency_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(eigen_adjacency_impl(NULL)) + expect_snapshot_igraph_error(eigen_adjacency_impl( + graph = NULL + )) }) # 302. power_law_fit_impl @@ -4962,18 +9217,28 @@ test_that("eigen_adjacency_impl errors", { test_that("power_law_fit_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(power_law_fit_impl(c(1, 2, 3))) expect_snapshot(power_law_fit_impl( - c(1, 2, 3), + data = c(1, 2, 3) + )) + expect_snapshot(power_law_fit_impl( + data = c(1, 2, 3), xmin = 1, force.continuous = TRUE )) + + # Structured tests + result <- power_law_fit_impl( + data = c(1, 2, 3) + ) + expect_type(result, "list") }) test_that("power_law_fit_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(power_law_fit_impl("a")) + expect_snapshot_igraph_error(power_law_fit_impl( + data = "a" + )) }) # 303. sir_impl @@ -4981,15 +9246,39 @@ test_that("power_law_fit_impl errors", { test_that("sir_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(sir_impl(g, beta = 0.1, gamma = 0.1)) - expect_snapshot(sir_impl(g, beta = 0.1, gamma = 0.1, no.sim = 2)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(sir_impl( + graph = g, + beta = 0.1, + gamma = 0.1 + )) + expect_snapshot(sir_impl( + graph = g, + beta = 0.1, + gamma = 0.1, + no.sim = 2 + )) + + # Structured tests + result <- sir_impl( + graph = g, + beta = 0.1, + gamma = 0.1 + ) + expect_s3_class(result, "sir") }) test_that("sir_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(sir_impl(NULL, beta = 0.1, gamma = 0.1)) + expect_snapshot_igraph_error(sir_impl( + graph = NULL, + beta = 0.1, + gamma = 0.1 + )) }) # 304. convex_hull_2d_impl @@ -4997,13 +9286,23 @@ test_that("sir_impl errors", { test_that("convex_hull_2d_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(convex_hull_2d_impl(matrix(1:6, ncol = 2))) + expect_snapshot(convex_hull_2d_impl( + data = matrix(1:6, ncol = 2) + )) + + # Structured tests + result <- convex_hull_2d_impl( + data = matrix(1:6, ncol = 2) + ) + expect_type(result, "list") }) test_that("convex_hull_2d_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(convex_hull_2d_impl("a")) + expect_snapshot_igraph_error(convex_hull_2d_impl( + data = "a" + )) }) # 305. dim_select_impl @@ -5011,13 +9310,23 @@ test_that("convex_hull_2d_impl errors", { test_that("dim_select_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(dim_select_impl(c(1, 2, 3))) + expect_snapshot(dim_select_impl( + sv = c(1, 2, 3) + )) + + # Structured tests + result <- dim_select_impl( + sv = c(1, 2, 3) + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("dim_select_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(dim_select_impl(NULL)) + expect_snapshot_igraph_error(dim_select_impl( + sv = NULL + )) }) # 306. solve_lsap_impl @@ -5025,13 +9334,26 @@ test_that("dim_select_impl errors", { test_that("solve_lsap_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(solve_lsap_impl(matrix(1:4, ncol = 2), n = 2)) + expect_snapshot(solve_lsap_impl( + c = matrix(1:4, ncol = 2), + n = 2 + )) + + # Structured tests + result <- solve_lsap_impl( + c = matrix(1:4, ncol = 2), + n = 2 + ) + expect_true(is.numeric(result)) }) test_that("solve_lsap_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(solve_lsap_impl("a", n = 2)) + expect_snapshot_igraph_error(solve_lsap_impl( + c = "a", + n = 2 + )) }) # 307. find_cycle_impl @@ -5039,15 +9361,31 @@ test_that("solve_lsap_impl errors", { test_that("find_cycle_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(find_cycle_impl(g)) - expect_snapshot(find_cycle_impl(g, mode = "in")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(find_cycle_impl( + graph = g + )) + expect_snapshot(find_cycle_impl( + graph = g, + mode = "in" + )) + + # Structured tests + result <- find_cycle_impl( + graph = g + ) + expect_type(result, "list") }) test_that("find_cycle_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(find_cycle_impl(NULL)) + expect_snapshot_igraph_error(find_cycle_impl( + graph = NULL + )) }) # 308. simple_cycles_impl @@ -5055,20 +9393,33 @@ test_that("find_cycle_impl errors", { test_that("simple_cycles_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(simple_cycles_impl(g)) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(simple_cycles_impl( - g, + graph = g + )) + expect_snapshot(simple_cycles_impl( + graph = g, mode = "in", min.cycle.length = 2, max.cycle.length = 3 )) + + # Structured tests + result <- simple_cycles_impl( + graph = g + ) + expect_type(result, "list") }) test_that("simple_cycles_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(simple_cycles_impl(NULL)) + expect_snapshot_igraph_error(simple_cycles_impl( + graph = NULL + )) }) # 309. is_eulerian_impl @@ -5076,14 +9427,27 @@ test_that("simple_cycles_impl errors", { test_that("is_eulerian_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_eulerian_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_eulerian_impl( + graph = g + )) + + # Structured tests + result <- is_eulerian_impl( + graph = g + ) + expect_type(result, "list") }) test_that("is_eulerian_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_eulerian_impl(NULL)) + expect_snapshot_igraph_error(is_eulerian_impl( + graph = NULL + )) }) # 310. eulerian_path_impl @@ -5091,14 +9455,27 @@ test_that("is_eulerian_impl errors", { test_that("eulerian_path_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(eulerian_path_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(eulerian_path_impl( + graph = g + )) + + # Structured tests + result <- eulerian_path_impl( + graph = g + ) + expect_type(result, "list") }) test_that("eulerian_path_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(eulerian_path_impl(NULL)) + expect_snapshot_igraph_error(eulerian_path_impl( + graph = NULL + )) }) # 311. eulerian_cycle_impl @@ -5106,16 +9483,34 @@ test_that("eulerian_path_impl errors", { test_that("eulerian_cycle_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g1 <- path_graph_impl(3) - expect_snapshot_igraph_error(eulerian_cycle_impl(g1)) - g2 <- cycle_graph_impl(4) - expect_snapshot(eulerian_cycle_impl(g2)) + g1 <- path_graph_impl( + n = 3 + ) + + expect_snapshot_igraph_error(eulerian_cycle_impl( + graph = g1 + )) + g2 <- cycle_graph_impl( + n = 4 + ) + + expect_snapshot(eulerian_cycle_impl( + graph = g2 + )) + + # Structured tests + result <- eulerian_cycle_impl( + graph = g2 + ) + expect_type(result, "list") }) test_that("eulerian_cycle_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(eulerian_cycle_impl(NULL)) + expect_snapshot_igraph_error(eulerian_cycle_impl( + graph = NULL + )) }) # 312. fundamental_cycles_impl @@ -5123,20 +9518,36 @@ test_that("eulerian_cycle_impl errors", { test_that("fundamental_cycles_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(fundamental_cycles_impl(g, start = 1)) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(fundamental_cycles_impl( - g, + graph = g, + start = 1 + )) + expect_snapshot(fundamental_cycles_impl( + graph = g, start = 1, bfs.cutoff = 2, weights = c(1, 2) )) + + # Structured tests + result <- fundamental_cycles_impl( + graph = g, + start = 1 + ) + expect_type(result, "list") }) test_that("fundamental_cycles_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(fundamental_cycles_impl(NULL, start = 1)) + expect_snapshot_igraph_error(fundamental_cycles_impl( + graph = NULL, + start = 1 + )) }) # 313. minimum_cycle_basis_impl @@ -5144,21 +9555,34 @@ test_that("fundamental_cycles_impl errors", { test_that("minimum_cycle_basis_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(minimum_cycle_basis_impl(g)) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(minimum_cycle_basis_impl( - g, + graph = g + )) + expect_snapshot(minimum_cycle_basis_impl( + graph = g, bfs.cutoff = 2, complete = FALSE, use.cycle.order = FALSE, weights = c(1, 2) )) + + # Structured tests + result <- minimum_cycle_basis_impl( + graph = g + ) + expect_type(result, "list") }) test_that("minimum_cycle_basis_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(minimum_cycle_basis_impl(NULL)) + expect_snapshot_igraph_error(minimum_cycle_basis_impl( + graph = NULL + )) }) # 314. is_tree_impl @@ -5166,15 +9590,32 @@ test_that("minimum_cycle_basis_impl errors", { test_that("is_tree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_tree_impl(g)) - expect_snapshot(is_tree_impl(g, mode = "in", details = TRUE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_tree_impl( + graph = g + )) + expect_snapshot(is_tree_impl( + graph = g, + mode = "in", + details = TRUE + )) + + # Structured tests + result <- is_tree_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_tree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_tree_impl(NULL)) + expect_snapshot_igraph_error(is_tree_impl( + graph = NULL + )) }) # 315. is_forest_impl @@ -5182,15 +9623,32 @@ test_that("is_tree_impl errors", { test_that("is_forest_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_forest_impl(g)) - expect_snapshot(is_forest_impl(g, mode = "in", details = TRUE)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_forest_impl( + graph = g + )) + expect_snapshot(is_forest_impl( + graph = g, + mode = "in", + details = TRUE + )) + + # Structured tests + result <- is_forest_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_forest_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_forest_impl(NULL)) + expect_snapshot_igraph_error(is_forest_impl( + graph = NULL + )) }) # 316. from_prufer_impl @@ -5198,13 +9656,23 @@ test_that("is_forest_impl errors", { test_that("from_prufer_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(from_prufer_impl(1:2)) + expect_snapshot(from_prufer_impl( + prufer = 1:2 + )) + + # Structured tests + result <- from_prufer_impl( + prufer = 1:2 + ) + expect_s3_class(result, "igraph") }) test_that("from_prufer_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(from_prufer_impl("a")) + expect_snapshot_igraph_error(from_prufer_impl( + prufer = "a" + )) }) # 317. to_prufer_impl @@ -5212,14 +9680,27 @@ test_that("from_prufer_impl errors", { test_that("to_prufer_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(to_prufer_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(to_prufer_impl( + graph = g + )) + + # Structured tests + result <- to_prufer_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("to_prufer_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(to_prufer_impl(NULL)) + expect_snapshot_igraph_error(to_prufer_impl( + graph = NULL + )) }) # 318. tree_from_parent_vector_impl @@ -5227,14 +9708,27 @@ test_that("to_prufer_impl errors", { test_that("tree_from_parent_vector_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(tree_from_parent_vector_impl(c(-1, 1, 2, 3))) - expect_snapshot(tree_from_parent_vector_impl(c(-1, 1, 2, 3), type = "in")) + expect_snapshot(tree_from_parent_vector_impl( + parents = c(-1, 1, 2, 3) + )) + expect_snapshot(tree_from_parent_vector_impl( + parents = c(-1, 1, 2, 3), + type = "in" + )) + + # Structured tests + result <- tree_from_parent_vector_impl( + parents = c(-1, 1, 2, 3) + ) + expect_s3_class(result, "igraph") }) test_that("tree_from_parent_vector_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(tree_from_parent_vector_impl("a")) + expect_snapshot_igraph_error(tree_from_parent_vector_impl( + parents = "a" + )) }) # 319. is_complete_impl @@ -5242,14 +9736,27 @@ test_that("tree_from_parent_vector_impl errors", { test_that("is_complete_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_complete_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_complete_impl( + graph = g + )) + + # Structured tests + result <- is_complete_impl( + graph = g + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_complete_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_complete_impl(NULL)) + expect_snapshot_igraph_error(is_complete_impl( + graph = NULL + )) }) # 320. random_spanning_tree_impl @@ -5257,14 +9764,30 @@ test_that("is_complete_impl errors", { test_that("random_spanning_tree_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(random_spanning_tree_impl(g, vid = 1)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(random_spanning_tree_impl( + graph = g, + vid = 1 + )) + + # Structured tests + result <- random_spanning_tree_impl( + graph = g, + vid = 1 + ) + expect_s3_class(result, "igraph.es") }) test_that("random_spanning_tree_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(random_spanning_tree_impl(NULL, vid = 1)) + expect_snapshot_igraph_error(random_spanning_tree_impl( + graph = NULL, + vid = 1 + )) }) # 321. tree_game_impl @@ -5272,14 +9795,28 @@ test_that("random_spanning_tree_impl errors", { test_that("tree_game_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot(tree_game_impl(3)) - expect_snapshot(tree_game_impl(3, directed = TRUE, method = "lerw")) + expect_snapshot(tree_game_impl( + n = 3 + )) + expect_snapshot(tree_game_impl( + n = 3, + directed = TRUE, + method = "lerw" + )) + + # Structured tests + result <- tree_game_impl( + n = 3 + ) + expect_s3_class(result, "igraph") }) test_that("tree_game_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(tree_game_impl("a")) + expect_snapshot_igraph_error(tree_game_impl( + n = "a" + )) }) # 322. vertex_coloring_greedy_impl @@ -5287,15 +9824,31 @@ test_that("tree_game_impl errors", { test_that("vertex_coloring_greedy_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(vertex_coloring_greedy_impl(g)) - expect_snapshot(vertex_coloring_greedy_impl(g, heuristic = "dsatur")) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(vertex_coloring_greedy_impl( + graph = g + )) + expect_snapshot(vertex_coloring_greedy_impl( + graph = g, + heuristic = "dsatur" + )) + + # Structured tests + result <- vertex_coloring_greedy_impl( + graph = g + ) + expect_true(is.numeric(result)) }) test_that("vertex_coloring_greedy_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(vertex_coloring_greedy_impl(NULL)) + expect_snapshot_igraph_error(vertex_coloring_greedy_impl( + graph = NULL + )) }) # 323. is_vertex_coloring_impl @@ -5303,15 +9856,31 @@ test_that("vertex_coloring_greedy_impl errors", { test_that("is_vertex_coloring_impl basic", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_vertex_coloring_impl(g, types = c(1, 2, 3))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_vertex_coloring_impl( + graph = g, + types = c(1, 2, 3) + )) + + # Structured tests + result <- is_vertex_coloring_impl( + graph = g, + types = c(1, 2, 3) + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_vertex_coloring_impl errors", { withr::local_seed(20250909) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - is_vertex_coloring_impl(NULL, types = c(1, 2, 3)) + is_vertex_coloring_impl( + graph = NULL, + types = c(1, 2, 3) + ) ) }) @@ -5330,15 +9899,31 @@ test_that("is_vertex_coloring_impl errors", { test_that("is_bipartite_coloring_impl basic", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(is_bipartite_coloring_impl(g, types = c(TRUE, FALSE, TRUE))) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_bipartite_coloring_impl( + graph = g, + types = c(TRUE, FALSE, TRUE) + )) + + # Structured tests + result <- is_bipartite_coloring_impl( + graph = g, + types = c(TRUE, FALSE, TRUE) + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_bipartite_coloring_impl errors", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - is_bipartite_coloring_impl(NULL, types = c(TRUE, FALSE, TRUE)) + is_bipartite_coloring_impl( + graph = NULL, + types = c(TRUE, FALSE, TRUE) + ) ) }) @@ -5347,16 +9932,34 @@ test_that("is_bipartite_coloring_impl errors", { test_that("is_edge_coloring_impl basic", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + E(g)$color <- c(1, 2) - expect_snapshot(is_edge_coloring_impl(g, types = c(1, 2))) - expect_snapshot(is_edge_coloring_impl(g)) + expect_snapshot(is_edge_coloring_impl( + graph = g, + types = c(1, 2) + )) + expect_snapshot(is_edge_coloring_impl( + graph = g + )) + + # Structured tests + result <- is_edge_coloring_impl( + graph = g, + types = c(1, 2) + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("is_edge_coloring_impl errors", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(is_edge_coloring_impl(NULL, types = c(1, 2))) + expect_snapshot_igraph_error(is_edge_coloring_impl( + graph = NULL, + types = c(1, 2) + )) }) # 327. deterministic_optimal_imitation_impl @@ -5364,21 +9967,33 @@ test_that("is_edge_coloring_impl errors", { test_that("deterministic_optimal_imitation_impl basic", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(deterministic_optimal_imitation_impl( - g, - 1, + graph = g, + vid = 1, quantities = c(1, 2, 3), strategies = c(1, 2, 3) )) expect_snapshot(deterministic_optimal_imitation_impl( - g, - 1, + graph = g, + vid = 1, optimality = "minimum", quantities = c(1, 2, 3), strategies = c(1, 2, 3), mode = "in" )) + + # Structured tests + result <- deterministic_optimal_imitation_impl( + graph = g, + vid = 1, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("deterministic_optimal_imitation_impl errors", { @@ -5386,8 +10001,8 @@ test_that("deterministic_optimal_imitation_impl errors", { local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( deterministic_optimal_imitation_impl( - NULL, - 1, + graph = NULL, + vid = 1, quantities = c(1, 2, 3), strategies = c(1, 2, 3) ) @@ -5399,21 +10014,38 @@ test_that("deterministic_optimal_imitation_impl errors", { test_that("moran_process_impl basic", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(moran_process_impl( - g, + graph = g, weights = c(1, 1), quantities = c(1, 2, 3), strategies = c(1, 2, 3), mode = "in" )) + + # Structured tests + result <- moran_process_impl( + graph = g, + weights = c(1, 1), + quantities = c(1, 2, 3), + strategies = c(1, 2, 3), + mode = "in" + ) + expect_type(result, "list") }) test_that("moran_process_impl errors", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - moran_process_impl(NULL, quantities = c(1, 2, 3), strategies = c(1, 2, 3)) + moran_process_impl( + graph = NULL, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + ) ) }) @@ -5422,22 +10054,35 @@ test_that("moran_process_impl errors", { test_that("roulette_wheel_imitation_impl basic", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(roulette_wheel_imitation_impl( - g, - 1, - TRUE, + graph = g, + vid = 1, + is.local = TRUE, quantities = c(1, 2, 3), strategies = c(1, 2, 3) )) expect_snapshot(roulette_wheel_imitation_impl( - g, - 1, - FALSE, + graph = g, + vid = 1, + is.local = FALSE, quantities = c(1, 2, 3), strategies = c(1, 2, 3), mode = "in" )) + + # Structured tests + result <- roulette_wheel_imitation_impl( + graph = g, + vid = 1, + is.local = TRUE, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("roulette_wheel_imitation_impl errors", { @@ -5445,9 +10090,9 @@ test_that("roulette_wheel_imitation_impl errors", { local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( roulette_wheel_imitation_impl( - NULL, - 1, - TRUE, + graph = NULL, + vid = 1, + is.local = TRUE, quantities = c(1, 2, 3), strategies = c(1, 2, 3) ) @@ -5459,22 +10104,35 @@ test_that("roulette_wheel_imitation_impl errors", { test_that("stochastic_imitation_impl basic", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(stochastic_imitation_impl( - g, - 1, + graph = g, + vid = 1, algo = 1, quantities = c(1, 2, 3), strategies = c(1, 2, 3) )) expect_snapshot(stochastic_imitation_impl( - g, - 1, + graph = g, + vid = 1, algo = 2, quantities = c(1, 2, 3), strategies = c(1, 2, 3), mode = "in" )) + + # Structured tests + result <- stochastic_imitation_impl( + graph = g, + vid = 1, + algo = 1, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + ) + expect_true(is.numeric(result) || is.logical(result)) }) test_that("stochastic_imitation_impl errors", { @@ -5482,8 +10140,8 @@ test_that("stochastic_imitation_impl errors", { local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( stochastic_imitation_impl( - NULL, - 1, + graph = NULL, + vid = 1, algo = 1, quantities = c(1, 2, 3), strategies = c(1, 2, 3) @@ -5496,14 +10154,27 @@ test_that("stochastic_imitation_impl errors", { test_that("invalidate_cache_impl basic", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) - expect_snapshot(invalidate_cache_impl(g)) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(invalidate_cache_impl( + graph = g + )) + + # Structured tests + result <- invalidate_cache_impl( + graph = g + ) + expect_s3_class(result, "igraph") }) test_that("invalidate_cache_impl errors", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) - expect_snapshot_igraph_error(invalidate_cache_impl(NULL)) + expect_snapshot_igraph_error(invalidate_cache_impl( + graph = NULL + )) }) # 332. vertex_path_from_edge_path_impl @@ -5511,25 +10182,40 @@ test_that("invalidate_cache_impl errors", { test_that("vertex_path_from_edge_path_impl basic", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) - g <- path_graph_impl(3) + g <- path_graph_impl( + n = 3 + ) + expect_snapshot(vertex_path_from_edge_path_impl( - g, + graph = g, start = 1, edge.path = c(1, 2) )) expect_snapshot(vertex_path_from_edge_path_impl( - g, + graph = g, start = 1, edge.path = c(1), mode = "in" )) + + # Structured tests + result <- vertex_path_from_edge_path_impl( + graph = g, + start = 1, + edge.path = c(1, 2) + ) + expect_s3_class(result, "igraph.vs") }) test_that("vertex_path_from_edge_path_impl errors", { withr::local_seed(12345) local_igraph_options(print.id = FALSE) expect_snapshot_igraph_error( - vertex_path_from_edge_path_impl(NULL, start = 1, edge.path = c(1, 2)) + vertex_path_from_edge_path_impl( + graph = NULL, + start = 1, + edge.path = c(1, 2) + ) ) }) @@ -5539,13 +10225,358 @@ test_that("version_impl basic", { withr::local_seed(12345) version_impl_clean <- function() { v <- version_impl() + paste(v$major, v$minor, v$subminor, sep = ".") } expect_snapshot(version_impl_clean()) + + # Structured tests + result <- version_impl_clean() + expect_type(result, "character") }) test_that("version_impl errors", { withr::local_seed(12345) # version_impl() has no parameters, so testing with invalid arguments - expect_snapshot_igraph_error(version_impl("invalid")) + expect_snapshot_igraph_error(version_impl( + "invalid" + )) +}) + +# 334. ecount_impl + +test_that("ecount_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_empty_graph(5) + expect_snapshot(ecount_impl( + graph = g + )) + + g <- make_graph(c(1, 2, 2, 3, 3, 4), n = 4, directed = TRUE) + expect_snapshot(ecount_impl( + graph = g + )) +}) + +test_that("ecount_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(ecount_impl( + graph = NULL + )) +}) + +# 335. is_directed_impl + +test_that("is_directed_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_empty_graph(5, directed = TRUE) + expect_snapshot(is_directed_impl( + graph = g + )) + + g <- make_empty_graph(5, directed = FALSE) + expect_snapshot(is_directed_impl( + graph = g + )) +}) + +test_that("is_directed_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(is_directed_impl( + graph = NULL + )) +}) + +# 336. edges_impl + +test_that("edges_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_graph(c(1, 2, 2, 3, 3, 4), n = 4, directed = TRUE) + + # Get all edges + expect_snapshot(edges_impl( + graph = g, + eids = E(g) + )) + + # Get specific edges + expect_snapshot(edges_impl( + graph = g, + eids = c(1, 3) + )) +}) + +test_that("edges_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(edges_impl( + graph = NULL, + eids = 1 + )) +}) + +# 337. add_vertices_impl + +test_that("add_vertices_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_empty_graph(3) + + g_new <- add_vertices_impl( + graph = g, + nv = 2 + ) + expect_snapshot(vcount(g_new)) +}) + +test_that("add_vertices_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(add_vertices_impl( + graph = NULL, + nv = 1 + )) +}) + +# 338. delete_edges_impl + +test_that("delete_edges_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_graph(c(1, 2, 2, 3, 3, 4), n = 4, directed = TRUE) + + g_new <- delete_edges_impl( + graph = g, + edges = c(1, 2) + ) + expect_snapshot(ecount(g_new)) +}) + +test_that("delete_edges_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(delete_edges_impl( + graph = NULL, + edges = 1 + )) +}) + +# 339. delete_vertices_impl + +test_that("delete_vertices_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_graph(c(1, 2, 2, 3, 3, 4), n = 4, directed = TRUE) + + g_new <- delete_vertices_impl( + graph = g, + vertices = c(1, 3) + ) + expect_snapshot(vcount(g_new)) +}) + +test_that("delete_vertices_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(delete_vertices_impl( + graph = NULL, + vertices = 1 + )) +}) + +# 340. incident_impl + +test_that("incident_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE, return.vs.es = FALSE) + g <- make_graph(c(1, 2, 2, 3, 3, 1), n = 3, directed = TRUE) + + expect_snapshot(incident_impl( + graph = g, + vid = 2, + mode = "out" + )) + expect_snapshot(incident_impl( + graph = g, + vid = 2, + mode = "in" + )) + expect_snapshot(incident_impl( + graph = g, + vid = 2, + mode = "all" + )) +}) + +test_that("incident_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(incident_impl( + graph = NULL, + vid = 1 + )) +}) + +test_that("famous_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot(famous_impl( + name = "Zachary" + )) +}) + +test_that("famous_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(famous_impl( + name = "NonexistentGraph" + )) +}) + +# 342. constraint_impl + +test_that("constraint_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_graph(c(1, 2, 2, 3, 3, 1), n = 3, directed = FALSE) + result <- constraint_impl( + graph = g + ) + expect_length(result, 3) +}) + +test_that("constraint_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(constraint_impl( + graph = NULL + )) +}) + +# 343. cocitation_impl + +test_that("cocitation_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_graph(c(1, 2, 1, 3, 2, 4, 3, 4), n = 4, directed = TRUE) + result <- cocitation_impl( + graph = g + ) + expect_true(is.matrix(result)) +}) + +test_that("cocitation_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(cocitation_impl( + graph = NULL + )) +}) + +# 344. bibcoupling_impl + +test_that("bibcoupling_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_graph(c(1, 2, 1, 3, 2, 4, 3, 4), n = 4, directed = TRUE) + result <- bibcoupling_impl( + graph = g + ) + expect_true(is.matrix(result)) +}) + +test_that("bibcoupling_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(bibcoupling_impl( + graph = NULL + )) +}) + +# 345. girth_impl + +test_that("girth_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_ring(5) + result <- girth_impl( + graph = g + ) + expect_snapshot(result$girth) +}) + +test_that("girth_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(girth_impl( + graph = NULL + )) +}) + +# 346. coreness_impl + +test_that("coreness_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g <- make_graph(c(1, 2, 2, 3, 3, 1, 3, 4), n = 4, directed = FALSE) + expect_snapshot(coreness_impl( + graph = g + )) +}) + +test_that("coreness_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(coreness_impl( + graph = NULL + )) +}) + +# 347. union_impl + +test_that("union_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g1 <- make_graph(c(1, 2, 2, 3), n = 3) + g2 <- make_graph(c(1, 3, 3, 4), n = 4) + expect_snapshot(union_impl( + left = g1, + right = g2 + )) +}) + +test_that("union_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(union_impl( + left = NULL, + right = NULL + )) +}) + +# 348. intersection_impl + +test_that("intersection_impl basic", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + g1 <- make_graph(c(1, 2, 2, 3, 1, 3), n = 3) + g2 <- make_graph(c(1, 2, 2, 3), n = 3) + expect_snapshot(intersection_impl( + left = g1, + right = g2 + )) +}) + +test_that("intersection_impl errors", { + withr::local_seed(20250909) + local_igraph_options(print.id = FALSE) + expect_snapshot_igraph_error(intersection_impl( + left = NULL, + right = NULL + )) }) diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index 367e88e0248..41653455073 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -658,6 +658,22 @@ test_that("weighted sparse alpha_centrality() works", { expect_equal(ac3, c(vcount(star), 1, 1, 1, 1, 1, 1, 1, 1, 1)) }) +test_that("alpha_centrality() works with custom weight attribute names", { + star <- make_star(10) + E(star)$myweight <- sample(ecount(star)) + + # Test sparse version with custom attribute name + ac_sparse <- alpha_centrality(star, weights = "myweight", sparse = TRUE) + expect_equal(ac_sparse, c(46, 1, 1, 1, 1, 1, 1, 1, 1, 1)) + + # Test dense version with custom attribute name + ac_dense <- alpha_centrality(star, weights = "myweight", sparse = FALSE) + expect_equal(ac_dense, c(46, 1, 1, 1, 1, 1, 1, 1, 1, 1)) + + # Ensure both versions give the same result + expect_equal(ac_sparse, ac_dense) +}) + test_that("undirected alpha_centrality() works, #653", { g <- make_ring(10) diff --git a/tests/testthat/test-interface.R b/tests/testthat/test-interface.R index d1f5b10ecc1..0d331bda8fc 100644 --- a/tests/testthat/test-interface.R +++ b/tests/testthat/test-interface.R @@ -222,3 +222,29 @@ test_that("get_edge_id() errors correctly for wrong matrices", { mat <- matrix(c(1, 2, 1, 3, 1, 4), nrow = 2, ncol = 3) lifecycle::expect_deprecated(get_edge_ids(g, mat)) }) + +test_that("invalidate_cache works", { + g <- make_ring(10) + + # Cache is populated when calling is_simple() + expect_true(is_simple(g)) + + # Invalidate cache + result <- invalidate_cache(g) + + # Result should be the same after cache invalidation + expect_true(is_simple(result)) + + # Function should return a graph object + expect_true(is_igraph(result)) + + # Graph properties should be preserved + expect_equal(vcount(result), 10) + expect_equal(ecount(result), 10) +}) + +test_that("invalidate_cache errors on invalid input", { + expect_error(invalidate_cache(NULL)) + expect_error(invalidate_cache("not a graph")) + expect_error(invalidate_cache(123)) +}) diff --git a/tests/testthat/test-make.R b/tests/testthat/test-make.R index 396bf65dc43..a9eb1a53d8c 100644 --- a/tests/testthat/test-make.R +++ b/tests/testthat/test-make.R @@ -205,6 +205,47 @@ test_that("make_lattice prints a warning for fractional length)", { expect_identical_graphs(lattice_rounded, lattice_integer) }) +test_that("make_tri_lattice works with 1D (triangular shape)", { + g <- make_tri_lattice(3) + expect_vcount(g, 6) + expect_ecount(g, 9) + expect_false(is_directed(g)) +}) + +test_that("make_tri_lattice works with 2D (quasi-rectangular shape)", { + g <- make_tri_lattice(c(3, 3)) + expect_vcount(g, 9) + expect_ecount(g, 16) + expect_false(is_directed(g)) +}) + +test_that("make_tri_lattice works with 3D (hexagonal shape)", { + g <- make_tri_lattice(c(2, 2, 2)) + expect_vcount(g, 7) + expect_ecount(g, 12) + expect_false(is_directed(g)) +}) + +test_that("make_tri_lattice works with directed and mutual parameters", { + g_undirected <- make_tri_lattice(c(2, 2)) + g_directed <- make_tri_lattice(c(2, 2), directed = TRUE) + g_mutual <- make_tri_lattice(c(2, 2), directed = TRUE, mutual = TRUE) + + expect_false(is_directed(g_undirected)) + expect_true(is_directed(g_directed)) + expect_true(is_directed(g_mutual)) + + # Mutual should have twice the edges + expect_equal(ecount(g_mutual), 2 * ecount(g_undirected)) +}) + +test_that("tri_lattice constructor spec works with make_()", { + g1 <- make_tri_lattice(c(3, 3)) + g2 <- make_(tri_lattice(c(3, 3))) + + expect_identical_graphs(g1, g2) +}) + test_that("make_graph works", { graph_make <- make_graph(1:10) graph_elist <- make_empty_graph(n = 10) + edges(1:10) @@ -298,6 +339,33 @@ test_that("make_chordal_ring works", { expect_equal(degree(chord), rep(6, 15)) }) +test_that("make_circulant works", { + # Test basic circulant graph with shift 1 (should be a ring) + circ <- make_circulant(10, c(1)) + ring <- make_ring(10) + expect_isomorphic(circ, ring) + + # Test circulant graph with multiple shifts + circ2 <- make_circulant(6, c(1, 2)) + expect_vcount(circ2, 6) + # Each vertex should be connected to vertices at distance 1 and 2 + # In undirected graph, degree should be 4 (2 neighbors on each side) + expect_equal(degree(circ2), rep(4, 6)) + + # Test directed circulant graph + circ_dir <- make_circulant(5, c(1, 2), directed = TRUE) + expect_true(is_directed(circ_dir)) + expect_vcount(circ_dir, 5) + # In directed graph, each vertex has out-degree 2 + expect_equal(degree(circ_dir, mode = "out"), rep(2, 5)) + expect_equal(degree(circ_dir, mode = "in"), rep(2, 5)) + + # Test empty shifts + circ_empty <- make_circulant(5, c()) + expect_vcount(circ_empty, 5) + expect_ecount(circ_empty, 0) +}) + test_that("make_line_graph works", { graph_ring_n5 <- make_ring(n = 5) graph_line_n5 <- make_line_graph(graph_ring_n5) @@ -456,3 +524,60 @@ test_that("graph_from_lcf() works", { g2 <- make_graph("Franklin") expect_isomorphic(g1, g2) }) + +test_that("make_full_multipartite() works", { + # Test basic multipartite graph + g <- make_full_multipartite(c(2, 3, 4)) + expect_vcount(g, 9) + expect_ecount(g, 2 * 3 + 2 * 4 + 3 * 4) + expect_true("type" %in% vertex_attr_names(g)) + expect_equal(V(g)$type, c(rep(1, 2), rep(2, 3), rep(3, 4))) + expect_false(is_directed(g)) + + # Test directed multipartite graph + g2 <- make_full_multipartite(c(2, 2), directed = TRUE, mode = "out") + expect_true(is_directed(g2)) + expect_ecount(g2, 4) + + # Test single partition (should have no edges) + g3 <- make_full_multipartite(5) + expect_vcount(g3, 5) + expect_ecount(g3, 0) + + # Test constructor spec form + g4 <- make_(full_multipartite(c(2, 3))) + expect_vcount(g4, 5) + expect_ecount(g4, 6) +}) + +test_that("make_turan() works", { + # Test basic Turán graph + g <- make_turan(10, 3) + expect_vcount(g, 10) + expect_true("type" %in% vertex_attr_names(g)) + expect_false(is_directed(g)) + + # Check partition sizes are balanced + types <- V(g)$type + sizes <- table(types) + expect_equal(max(sizes) - min(sizes), 1) # Should differ by at most 1 + + # Test with n divisible by r + g2 <- make_turan(9, 3) + types2 <- V(g2)$type + sizes2 <- table(types2) + expect_true(all(sizes2 == 3)) # All partitions should have size 3 + + # Test edge cases + g3 <- make_turan(5, 5) # r equals n + expect_vcount(g3, 5) + # When r equals n, each vertex is in its own partition, creating a complete graph + expect_ecount(g3, 10) # Complete graph K5 has 5*4/2 = 10 edges + + g4 <- make_turan(5, 1) # r = 1, single partition, no edges + expect_ecount(g4, 0) + + # Test constructor spec form + g5 <- make_(turan(10, 2)) + expect_vcount(g5, 10) +}) diff --git a/tests/testthat/test-operators.R b/tests/testthat/test-operators.R index afa804d5f16..d38e3ae5a1a 100644 --- a/tests/testthat/test-operators.R +++ b/tests/testthat/test-operators.R @@ -252,6 +252,28 @@ test_that("vertices() works", { expect_snapshot_error(make_empty_graph(1) + vertices("a", "b", foo = 5:7)) }) +test_that("vertices() errors on duplicate attribute names", { + # Test case from issue: vertices("a", name = "c") + expect_snapshot_error( + vertices("a", name = "c", name = "d") + ) + + # Test case from issue: vertices("a", blop = "c", blop = 1) + expect_snapshot_error( + vertices("a", blop = "c", blop = 1) + ) + + # Test with graph addition + expect_snapshot_error( + make_empty_graph(1) + vertices("a", "b", name = "c", name = "d") + ) + + # Test multiple duplicates + expect_snapshot_error( + vertices(foo = 1, foo = 2, bar = 3, bar = 4) + ) +}) + test_that("infix operators work", { g <- make_ring(10) V(g)$name <- letters[1:10] diff --git a/tests/testthat/test-structural-properties.R b/tests/testthat/test-structural-properties.R index f938d495dd0..422e615f969 100644 --- a/tests/testthat/test-structural-properties.R +++ b/tests/testthat/test-structural-properties.R @@ -72,6 +72,34 @@ test_that("max_degree() works", { expect_equal(max_degree(make_empty_graph()), 0) }) +test_that("mean_degree() works", { + # Undirected graph: formula is 2 * edges / vertices + g_undirected <- make_ring(10) + expect_equal(mean_degree(g_undirected), 2) + + # Directed graph: formula is edges / vertices + # This graph has edges 1->2, 2->2 (loop), 2->3, so 3 edges / 3 vertices = 1 + g_directed <- make_graph(c(1, 2, 2, 2, 2, 3), directed = TRUE) + expect_equal(mean_degree(g_directed), 1) + + # Test loops parameter: excluding the self-loop (2->2) + # Without loops: (3 edges - 1 loop) / 3 vertices = 2/3 + expect_equal(mean_degree(g_directed, loops = FALSE), 2 / 3) + + # Empty graph + expect_true(is.nan(mean_degree(make_empty_graph()))) + + # Compare with manual calculation for undirected graph + g_random <- sample_gnp(100, 0.05) + manual_mean <- 2 * ecount(g_random) / vcount(g_random) + expect_equal(mean_degree(g_random), manual_mean) + + # For directed graph + g_directed_random <- sample_gnp(100, 0.05, directed = TRUE) + manual_mean_dir <- ecount(g_directed_random) / vcount(g_directed_random) + expect_equal(mean_degree(g_directed_random), manual_mean_dir) +}) + test_that("BFS uses 1-based root vertex index", { g <- make_ring(3) expect_equal(bfs(g, root = 1)$root, 1) @@ -730,6 +758,50 @@ test_that("a null graph has zero components", { expect_equal(count_components(g), 0L) }) +test_that("count_reachable() works for directed graphs", { + # Directed path graph: 1 -> 2 -> 3 -> 4 -> 5 + g <- make_graph(~ 1 -+ 2 -+ 3 -+ 4 -+ 5) + + # Out mode: count vertices reachable via outgoing edges + out_counts <- count_reachable(g, mode = "out") + expect_equal(out_counts, c(5, 4, 3, 2, 1)) + + # In mode: count vertices from which current vertex is reachable + in_counts <- count_reachable(g, mode = "in") + expect_equal(in_counts, c(1, 2, 3, 4, 5)) + + # All mode: treat as undirected + all_counts <- count_reachable(g, mode = "all") + expect_equal(all_counts, rep(5, 5)) +}) + +test_that("count_reachable() works for undirected graphs", { + # Undirected path graph + g <- make_graph(~ 1 - 2 - 3 - 4 - 5) + + # All vertices are reachable from each other in an undirected path + counts <- count_reachable(g, mode = "out") + expect_equal(counts, rep(5, 5)) +}) + +test_that("count_reachable() works for graphs with multiple components", { + # Graph with three components: 1-2-3, 4-5, 6 + g <- make_graph(~ 1 - 2 - 3, 4 - 5, 6) + + counts <- count_reachable(g, mode = "all") + expect_equal(counts, c(3, 3, 3, 2, 2, 1)) +}) + +test_that("count_reachable() works for empty and single-vertex graphs", { + # Empty graph + g0 <- make_empty_graph(0) + expect_equal(count_reachable(g0, mode = "out"), integer(0)) + + # Single vertex + g1 <- make_empty_graph(1) + expect_equal(count_reachable(g1, mode = "out"), 1L) +}) + test_that("girth() works", { ## No circle in a tree g <- make_tree(1000, 3) @@ -891,6 +963,31 @@ test_that("any_multiple(), count_multiple(), which_multiple() works", { ) }) +test_that("any_loop(), which_loop(), count_loops() works", { + # Graph with loops + g <- make_graph(c(1, 1, 2, 2, 3, 3, 4, 5)) + expect_true(any_loop(g)) + expect_equal(which_loop(g), c(TRUE, TRUE, TRUE, FALSE)) + expect_equal(count_loops(g), 3) + + # Graph without loops + g2 <- make_graph(c(1, 2, 2, 3, 3, 4)) + expect_false(any_loop(g2)) + expect_equal(which_loop(g2), c(FALSE, FALSE, FALSE)) + expect_equal(count_loops(g2), 0) + + # Empty graph + g3 <- make_empty_graph(n = 5) + expect_false(any_loop(g3)) + expect_equal(count_loops(g3), 0) + + # Graph with only loops + g4 <- make_graph(c(1, 1, 2, 2, 3, 3)) + expect_true(any_loop(g4)) + expect_equal(which_loop(g4), c(TRUE, TRUE, TRUE)) + expect_equal(count_loops(g4), 3) +}) + test_that("edge_density works", { g <- sample_gnp(50, 4 / 50) gd <- edge_density(g) diff --git a/tests/testthat/test-topology.R b/tests/testthat/test-topology.R index 12dec658e91..5e19b5bcadb 100644 --- a/tests/testthat/test-topology.R +++ b/tests/testthat/test-topology.R @@ -361,3 +361,70 @@ test_that("subgraph_isomorphisms, vf2", { g3 <- graph_from_literal(X - Y - Z - X) expect_equal(subgraph_isomorphisms(g3, g1, method = "vf2"), list()) }) + +test_that("transitive_closure works for directed graphs", { + # Simple directed path + g <- make_graph(c(1, 2, 2, 3, 3, 4)) + tc <- transitive_closure(g) + + # Should have edges for all reachable pairs + expect_equal(vcount(tc), 4) + expect_equal(ecount(tc), 6) # 1->2, 1->3, 1->4, 2->3, 2->4, 3->4 + expect_true(are_adjacent(tc, 1, 2)) + expect_true(are_adjacent(tc, 1, 3)) + expect_true(are_adjacent(tc, 1, 4)) + expect_true(are_adjacent(tc, 2, 3)) + expect_true(are_adjacent(tc, 2, 4)) + expect_true(are_adjacent(tc, 3, 4)) + + # Check that reverse edges don't exist + expect_false(are_adjacent(tc, 2, 1)) + expect_false(are_adjacent(tc, 3, 1)) +}) + +test_that("transitive_closure works for undirected graphs", { + # Two disconnected components with 2 vertices each + g <- make_graph(c(1, 2, 3, 4), directed = FALSE) + tc <- transitive_closure(g) + + # Each 2-vertex component already forms a complete graph, + # so transitive closure doesn't add new edges + expect_equal(vcount(tc), 4) + expect_equal(ecount(tc), 2) # Same as input: one edge per 2-vertex component + expect_true(are_adjacent(tc, 1, 2)) + expect_true(are_adjacent(tc, 3, 4)) + expect_false(are_adjacent(tc, 1, 3)) + expect_false(are_adjacent(tc, 1, 4)) + + # Test with a path that needs closure + g2 <- make_graph(c(1, 2, 2, 3), directed = FALSE) + tc2 <- transitive_closure(g2) + + # Should create a complete graph (triangle) + expect_equal(vcount(tc2), 3) + expect_equal(ecount(tc2), 3) # Complete graph on 3 vertices + expect_true(are_adjacent(tc2, 1, 2)) + expect_true(are_adjacent(tc2, 2, 3)) + expect_true(are_adjacent(tc2, 1, 3)) # This edge is added by closure +}) + +test_that("transitive_closure handles graphs with cycles", { + # Directed cycle + g <- make_graph(c(1, 2, 2, 3, 3, 1)) + tc <- transitive_closure(g) + + # Should be fully connected + expect_equal(vcount(tc), 3) + expect_equal(ecount(tc), 6) # Complete directed graph on 3 vertices +}) + +test_that("transitive_closure preserves isolated vertices", { + # Graph with isolated vertex + g <- make_graph(c(1, 2, 2, 3), n = 5) + tc <- transitive_closure(g) + + # Isolated vertices should remain + expect_equal(vcount(tc), 5) + expect_equal(degree(tc, 4, mode = "all"), 0) + expect_equal(degree(tc, 5, mode = "all"), 0) +}) diff --git a/tests/testthat/test-utils-assert-args.R b/tests/testthat/test-utils-assert-args.R index 0c5f88f7745..a2984d3a94b 100644 --- a/tests/testthat/test-utils-assert-args.R +++ b/tests/testthat/test-utils-assert-args.R @@ -6,7 +6,7 @@ test_that("ensure_igraph() works", { expect_silent(ensure_igraph(NULL, optional = TRUE)) }) -test_that("igraph.match.arg() works", { +test_that("igraph_match_arg() works", { expect_snapshot( cluster_leiden(make_graph("Zachary"), objective_function = "something"), error = TRUE diff --git a/tests/testthat/testthat-problems.rds b/tests/testthat/testthat-problems.rds deleted file mode 100644 index 95cf1759297..00000000000 Binary files a/tests/testthat/testthat-problems.rds and /dev/null differ diff --git a/tools/ensure-impl-named.R b/tools/ensure-impl-named.R new file mode 100644 index 00000000000..ec4df2e69ab --- /dev/null +++ b/tools/ensure-impl-named.R @@ -0,0 +1,73 @@ +source_files <- + fs::dir_ls("R", glob = "*.R") |> + setdiff("R/aaa-auto.R") + +test_file <- "tests/testthat/test-aaa-auto.R" + +all_files <- c(source_files, test_file) + +# all_files <- test_file + +# all_files <- all_files[1:10] + +pkgload::load_all() +library(tidyverse) + +for (file in all_files) { + cat(sprintf("Processing %s...\n", file)) + + text <- readLines(file) + + data <- + parse(text = text, keep.source = TRUE) |> + utils::getParseData(includeText = TRUE) |> + as_tibble() + + parents <- + data |> + filter(token == "expr", str_detect(text, "_impl$")) |> + filter(row_number() == 1, .by = line1) + + repl_data <- + data[match(parents$parent, data$id), ] |> + mutate(fun = !!parents$text) |> + arrange(desc(line2), desc(col2)) + + for (i in seq_len(nrow(repl_data))) { + repl_line <- repl_data[i, ] + + sub_expr <- parse(text = repl_line$text)[[1]] + print(sub_expr) + + func_def <- get(repl_line$fun, envir = asNamespace("igraph")) + + matched_call <- tryCatch( + rlang::call_match( + sub_expr, + func_def, + dots_expand = FALSE + ), + error = function(e) { + cat("Failed to match call for ", repl_line$fun, "\n") + cat("Original call:\n") + print(sub_expr) + cat("Function definition:\n") + print(func_def) + sub_expr + } + ) + + deparsed <- deparse(matched_call, width.cutoff = 20) + deparsed[[1]] <- sub("(", "(\n ", deparsed[[1]], fixed = TRUE) + print(deparsed) + + # Splice + text <- c( + text[seq2(1, repl_line$line1 - 1)], + paste0(str_sub(text[repl_line$line1], 1, repl_line$col1 - 1), paste(deparsed, collapse = "\n"), str_sub(text[repl_line$line2], repl_line$col2 + 1)), + text[seq2(repl_line$line2 + 1, length(text))] + ) + } + + writeLines(text, con = file) +} diff --git a/tools/py-stimulus/src/stimulus/generators/r.py b/tools/py-stimulus/src/stimulus/generators/r.py index c7101fb12f0..630a963b059 100644 --- a/tools/py-stimulus/src/stimulus/generators/r.py +++ b/tools/py-stimulus/src/stimulus/generators/r.py @@ -60,7 +60,7 @@ def format_switch_statement(code: str) -> str: switch_pattern = r'(switch\([^,]+)(,\s*)([^)]+)(\))' def format_switch_args(match): - prefix = match.group(1) # "switch(igraph.match.arg(mode)" + prefix = match.group(1) # "switch(igraph_match_arg(mode)" comma = match.group(2) # "," args = match.group(3) # the key-value pairs suffix = match.group(4) # ")" @@ -457,6 +457,7 @@ def generate_function(self, function: str, out: IO[str]) -> None: res["inconv"] = self.chunk_inconv(desc) res["call"] = self.chunk_call(desc) res["outconv"] = self.chunk_outconv(desc) + res["ret"] = self.chunk_ret(desc) # Replace into the template text = ( @@ -474,8 +475,7 @@ def generate_function(self, function: str, out: IO[str]) -> None: /* Convert output */ %(outconv)s - UNPROTECT(1); - return(r_result); +%(ret)s }\n""" % res ) @@ -501,6 +501,8 @@ def do_par(spec: ParamSpec) -> str: inout = [do_par(spec) for spec in desc.iter_input_parameters()] inout = ["SEXP " + n for n in inout if n != ""] + + # cpp11 requires an SEXP return value return "SEXP R_" + desc.name + "(" + (", ".join(inout) or "void") + ")" def chunk_declaration(self, desc: FunctionDescriptor) -> str: @@ -531,9 +533,14 @@ def do_par(spec: ParamSpec) -> str: retpars = [spec.name for spec in desc.iter_output_parameters()] return_type_desc = self.get_type_descriptor(desc.return_type) - retdecl = return_type_desc.declare_c_variable("c_result") if not retpars else "" + if retpars or return_type_desc.name in ("VOID", "ERROR"): + retdecl = "" + else: + retdecl = return_type_desc.declare_c_variable("c_result") - if len(retpars) <= 1: + if len(retpars) == 0 and desc.return_type == "ERROR": + res = "\n".join(inout + out + [retdecl]) + elif len(retpars) <= 1: res = "\n".join(inout + out + [retdecl] + ["SEXP r_result;"]) else: res = "\n".join(inout + out + [retdecl] + ["SEXP r_result, r_names;"]) @@ -620,7 +627,7 @@ def chunk_call(self, desc: FunctionDescriptor) -> str: return res - def chunk_outconv(self, spec: FunctionDescriptor) -> str: + def chunk_outconv(self, desc: FunctionDescriptor) -> str: """The output conversions, this is quite difficult. A function may report its results in two ways: by returning it directly or by setting a variable to which a pointer was passed. igraph @@ -655,20 +662,20 @@ def do_par(param: ParamSpec) -> str: return outconv.replace("%C%", cname).replace("%I%", param.name) - outconv = [do_par(param) for param in spec.iter_parameters()] + outconv = [do_par(param) for param in desc.iter_parameters()] outconv = [o for o in outconv if o != ""] # Consider only those parameters that have a corresponding declaration # in C. retpars = [] - for param in spec.iter_output_parameters(): + for param in desc.iter_output_parameters(): type_desc = self.get_type_descriptor(param.type) if type_desc.get_c_type(param.mode) is not None: retpars.append(param) if not retpars: # return the return value of the function - rt = self.get_type_descriptor(spec.return_type) + rt = self.get_type_descriptor(desc.return_type) retconv = indent(rt.get_output_conversion_template_for(ParamMode.OUT)) retconv = retconv.replace("%C%", "c_result").replace("%I%", "r_result") ret = "\n".join(outconv) + "\n" + retconv @@ -699,6 +706,16 @@ def do_par(param: ParamSpec) -> str: return ret + def chunk_ret(self, desc: FunctionDescriptor) -> str: + """Create the return statement. Only unprotect and return if one or more output arguments. + """ + + if len(list(desc.iter_output_parameters())) == 0 and desc.return_type == "ERROR": + # cpp11 requires an SEXP return value + return " return(R_NilValue);" + + return " UNPROTECT(1);\n return(r_result);" + class RInitCodeGenerator(BlockBasedCodeGenerator): def _count_arguments(self, name: str) -> Tuple[int, int]: diff --git a/tools/stimulus/functions-R.yaml b/tools/stimulus/functions-R.yaml index f88aaa9f1aa..7470eaf8f5d 100644 --- a/tools/stimulus/functions-R.yaml +++ b/tools/stimulus/functions-R.yaml @@ -15,19 +15,14 @@ igraph_empty_attrs: IGNORE: RR, RC igraph_add_vertices: - IGNORE: RR, RC, RInit igraph_delete_edges: - IGNORE: RR, RC igraph_delete_vertices: - IGNORE: RR, RC igraph_ecount: - IGNORE: RR, RC igraph_is_directed: - IGNORE: RR, RC igraph_degree: @@ -35,7 +30,6 @@ igraph_edge: IGNORE: RR, RC, RInit igraph_edges: - IGNORE: RR, RC igraph_get_eid: IGNORE: RR, RC, RInit @@ -51,7 +45,6 @@ igraph_get_all_eids_between: DEPS: from ON graph, to ON graph, eids ON graph igraph_incident: - IGNORE: RR, RC igraph_is_same_graph: IGNORE: RR, RC, RInit @@ -97,7 +90,12 @@ igraph_connect_neighborhood: IGNORE: RR, RC igraph_famous: - IGNORE: RR, RC + +igraph_circulant: + R: + GATTR: + name: Circulant graph + GATTR-PARAM: shifts igraph_lcf_vector: R: @@ -119,6 +117,20 @@ igraph_realize_bipartite_degree_sequence: name: Bipartite graph from degree sequence GATTR-PARAM: degrees1, degrees2, allowed_edge_types, method +igraph_full_multipartite: + DEPS: types ON res$graph + R: + GATTR: + name: Full multipartite graph + GATTR-PARAM: n, mode + +igraph_turan: + DEPS: types ON res$graph + R: + GATTR: + name: Turan graph + GATTR-PARAM: n, r + # TODO: temporarily disabled igraph_weighted_sparsemat: IGNORE: RR, RC @@ -354,7 +366,9 @@ igraph_personalized_pagerank_vs: options ON algo, reset_vids ON graph igraph_rewire: - IGNORE: RR, RC + R: + DEFAULTS: + mode: 0L igraph_average_path_length: IGNORE: RR, RC, RInit @@ -367,7 +381,6 @@ igraph_average_path_length_dijkstra: unconn: unconnected igraph_constraint: - IGNORE: RR, RC igraph_maxdegree: PARAM_ORDER: graph, *, vids, ... @@ -384,7 +397,6 @@ igraph_neighborhood_graphs: IGNORE: RR, RC igraph_topological_sorting: - IGNORE: RR, RC igraph_is_loop: PARAM_NAMES: @@ -399,7 +411,6 @@ igraph_count_multiple: es: eids igraph_girth: - IGNORE: RR, RC, RInit igraph_add_edge: IGNORE: RR, RC, RInit @@ -590,7 +601,6 @@ igraph_maximal_cliques_callback: IGNORE: RR, RC, RInit igraph_maximal_cliques_count: - IGNORE: RR, RC, RInit igraph_maximal_cliques_file: IGNORE: RR, RC, RInit @@ -604,13 +614,10 @@ igraph_independent_vertex_sets: IGNORE: RR, RC igraph_largest_independent_vertex_sets: - IGNORE: RR, RC igraph_maximal_independent_vertex_sets: - IGNORE: RR, RC igraph_independence_number: - IGNORE: RR, RC ####################################### # Layouts @@ -654,10 +661,8 @@ igraph_layout_merge_dla: ####################################### igraph_cocitation: - IGNORE: RR, RC igraph_bibcoupling: - IGNORE: RR, RC ####################################### # Community structure @@ -706,10 +711,8 @@ igraph_graphlets: IGNORE: RC igraph_graphlets_candidate_basis: - IGNORE: RR, RC igraph_graphlets_project: - IGNORE: RR, RC, RInit ####################################### # Hierarchical random graphs @@ -735,7 +738,6 @@ igraph_get_adjacency: igraph_get_edgelist: - IGNORE: RR, RC igraph_to_directed: PARAMS: INOUT GRAPH graph, TODIRECTED mode=MUTUAL @@ -754,26 +756,20 @@ igraph_read_graph_lgl: IGNORE: RR, RC igraph_read_graph_pajek: - IGNORE: RR, RC igraph_read_graph_graphml: - IGNORE: RR, RC # TODO: temporarily disabled igraph_read_graph_dimacs_flow: IGNORE: RR, RC igraph_read_graph_graphdb: - IGNORE: RR, RC igraph_read_graph_gml: - IGNORE: RR, RC igraph_read_graph_dl: - IGNORE: RR, RC igraph_write_graph_edgelist: - IGNORE: RR, RC igraph_write_graph_ncol: IGNORE: RR, RC @@ -782,13 +778,10 @@ igraph_write_graph_lgl: IGNORE: RR, RC igraph_write_graph_leda: - IGNORE: RR, RC igraph_write_graph_graphml: - IGNORE: RR, RC igraph_write_graph_pajek: - IGNORE: RR, RC # TODO: temporarily disabled igraph_write_graph_dimacs_flow: @@ -797,11 +790,7 @@ igraph_write_graph_dimacs_flow: INOUT GRAPH graph, OUTFILE outstream, VERTEX source=0, VERTEX target=0, VECTOR capacity -igraph_write_graph_gml: - IGNORE: RR, RC - igraph_write_graph_dot: - IGNORE: RR, RC ####################################### # Motifs @@ -812,31 +801,25 @@ igraph_write_graph_dot: ####################################### igraph_disjoint_union: - IGNORE: RR, RC, RInit igraph_disjoint_union_many: IGNORE: RR, RC, RInit igraph_union: - IGNORE: RR, RC igraph_union_many: IGNORE: RR, RC, RInit igraph_intersection: - IGNORE: RR, RC igraph_intersection_many: IGNORE: RR, RC, RInit igraph_difference: - IGNORE: RR, RC igraph_complementer: - IGNORE: RR, RC igraph_compose: - IGNORE: RR, RC, RInit ####################################### # Maximum flows, minimum cuts @@ -846,10 +829,8 @@ igraph_maxflow_value: IGNORE: RR, RC, RInit igraph_mincut: - IGNORE: RR, RC igraph_mincut_value: - IGNORE: RR, RC igraph_st_mincut_value: IGNORE: RR, RC @@ -858,13 +839,11 @@ igraph_st_vertex_connectivity: IGNORE: RR, RC, RInit igraph_vertex_connectivity: - IGNORE: RR, RC igraph_st_edge_connectivity: IGNORE: RR, RC igraph_edge_connectivity: - IGNORE: RR, RC igraph_edge_disjoint_paths: IGNORE: RR, RC @@ -873,17 +852,14 @@ igraph_vertex_disjoint_paths: IGNORE: RR, RC igraph_adhesion: - IGNORE: RR, RC igraph_cohesion: - IGNORE: RR, RC ####################################### # Listing s-t cuts, separators ####################################### igraph_cohesive_blocks: - IGNORE: RR, RC R: CLASS: cohesiveBlocks @@ -892,7 +868,6 @@ igraph_cohesive_blocks: ####################################### igraph_coreness: - IGNORE: RR, RC ####################################### # Graph isomorphism @@ -947,7 +922,6 @@ igraph_sir: ####################################### igraph_running_mean: - IGNORE: RR, RC igraph_random_sample: IGNORE: RR, RC @@ -1014,10 +988,8 @@ igraph_minimum_spanning_tree: IGNORE: RR, RC, RInit igraph_minimum_spanning_tree_unweighted: - IGNORE: RR, RC igraph_minimum_spanning_tree_prim: - IGNORE: RR, RC igraph_random_spanning_tree: PARAMS: GRAPH graph, OUT EDGE_INDICES res, OPTIONAL VERTEX vid=0 diff --git a/tools/stimulus/types-RC.yaml b/tools/stimulus/types-RC.yaml index 7255680cf41..29f55765538 100644 --- a/tools/stimulus/types-RC.yaml +++ b/tools/stimulus/types-RC.yaml @@ -69,11 +69,20 @@ CSTRING: INOUT: '&%C%' INCONV: IN: |- - %C% = Rf_translateCharUTF8(%I%); + %C% = Rf_translateCharUTF8(STRING_ELT(%I%, 0)); OUTCONV: OUT: |- PROTECT(%I% = Rf_ScalarString(Rf_mkCharLenCE(%C%, strlen(%C%), CE_UTF8))); +INFILE: + CTYPE: FILE* + CALL: + IN: '%C%' + INCONV: + IN: |- + %C% = R_igraph_fopen_read(%I%); + IGRAPH_FINALLY(fclose, %C%); + REAL: CTYPE: igraph_real_t CALL: @@ -104,9 +113,6 @@ BOOLEAN: PROTECT(%I%=NEW_LOGICAL(1)); LOGICAL(%I%)[0]=%C%; -ERROR: - CTYPE: igraph_error_t - INDEX_VECTOR: CALL: '&%C%' CTYPE: igraph_vector_int_t @@ -183,7 +189,16 @@ MATRIX_LIST: CALL: '&%C%' CTYPE: igraph_matrix_list_t INCONV: - IN: R_igraph_SEXP_to_matrixlist(%I%, &%C%); + IN: |- + R_igraph_SEXP_to_matrixlist(%I%, &%C%); + OUT: |- + IGRAPH_R_CHECK(igraph_matrix_list_init(&%C%, 0)); + IGRAPH_FINALLY(igraph_matrix_list_destroy, &%C%); + OUTCONV: + OUT: |- + PROTECT(%I%=R_igraph_matrixlist_to_SEXP(&%C%)); + igraph_matrix_list_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); VECTOR_LIST: CALL: '&%C%' @@ -569,7 +584,7 @@ ARPACKOPT: INCONV: INOUT: R_SEXP_to_igraph_arpack_options(%I%, &%C%); OUTCONV: - INOUT: PROTECT(%I%=R_igraph_arpack_options_to_SEXP(&%C%)); + INOUT: PROTECT(%I%=Rx_igraph_arpack_options_to_SEXP(&%C%)); ARPACKSTORAGE: CALL: '0' @@ -886,7 +901,7 @@ PAGERANKOPT: OUTCONV: INOUT: |- if (%C1% == IGRAPH_PAGERANK_ALGO_ARPACK) { - PROTECT(%I% = R_igraph_arpack_options_to_SEXP(&%C%1)); + PROTECT(%I% = Rx_igraph_arpack_options_to_SEXP(&%C%1)); } else { PROTECT(%I%); } diff --git a/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index 7ce22d4d356..7e415b49a16 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -2,6 +2,10 @@ GRAPH: INCONV: ensure_igraph(%I%) +INFILE: + INCONV: | + check_string(%I%) + INTEGER: DEFAULT: FINEITER: max(10, log2(vcount(graph))) @@ -374,6 +378,11 @@ RECIP: DEFAULT: c("default", "ratio") INCONV: '%I% <- switch_igraph_arg(%I%, "default" = 0L, "ratio" = 1L)' +REWIRING_MODE: + DEFAULT: + SIMPLE: c("simple", "simple_loops") + INCONV: '%I% <- switch_igraph_arg(%I%, "simple" = 0L, "simple_loops" = 1L)' + SPARSEMAT: INCONV: requireNamespace("Matrix", quietly = TRUE); %I% <- as(as(as(%I%, "dMatrix"), "generalMatrix"), "CsparseMatrix") @@ -476,6 +485,11 @@ EDGE_TYPE_SW: %I% <- switch_igraph_arg(%I%, "simple" = 0L, "loop" = 1L, "loops" = 1L, "multi" = 6L, "multiple" = 6L, "all" = 7L) +WRITE_GML_SW: + DEFAULT: + DEFAULT: c("default", "encode_only_quot") + INCONV: '%I% <- switch_igraph_arg(%I%, "default" = 0L, "encode_only_quot" = 1L)' + GRAPH_PRODUCT_TYPE: DEFAULT: CARTESIAN: c("cartesian", "lexicographic", "strong", "tensor", "modular")