diff --git a/.github/workflows/custom/after-install/action.yml b/.github/workflows/custom/after-install/action.yml index f6330fd25bf..85b22604c60 100644 --- a/.github/workflows/custom/after-install/action.yml +++ b/.github/workflows/custom/after-install/action.yml @@ -25,6 +25,13 @@ runs: fi shell: bash + # Every impl's tests sit in test-aaa-.R, mirroring the + # R/aaa-.R that defines the impl + # (handbook/testing/suite/). Fails when a rerun would move a test. + - name: Check that impl tests sit in their category's file + run: Rscript tools/split-aaa-tests.R --check + shell: bash + # The roclet that links the C manual from the reference pages, named in # DESCRIPTION's Roxygen field, is vendored in tools/igraph.r2cdocs # (handbook/architecture/r-layer/documentation/). Only the smoke test diff --git a/DESCRIPTION b/DESCRIPTION index ec05fdc26db..6d751fed53f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -91,7 +91,7 @@ Config/comment/Needs/roxygen2: The roclet igraph.r2cdocs::docs_rd that Config/Needs/website: here, readr, tibble, xmlparsedata, xml2 Config/testthat/edition: 3 Config/testthat/parallel: true -Config/testthat/start-first: aaa-auto, vs-es, scan, vs-operators, weakref, +Config/testthat/start-first: aaa-*, vs-es, scan, vs-operators, weakref, watts.strogatz.game Encoding: UTF-8 Roxygen: list(markdown = TRUE, roclets = c("collate", "namespace", diff --git a/handbook/architecture/r-layer/new-functions/README.md b/handbook/architecture/r-layer/new-functions/README.md index 8743eb0e99d..6803d27ded3 100644 --- a/handbook/architecture/r-layer/new-functions/README.md +++ b/handbook/architecture/r-layer/new-functions/README.md @@ -12,5 +12,5 @@ What a new exported function needs before it merges. [`tools/AGENTS.md`](/tools/AGENTS.md) is the implementation guide. A function exported from the C library is generated, never written by hand ([`stimulus/`](/handbook/architecture/stimulus/README.md)): -its `*_impl()` gets a test in `tests/testthat/test-aaa-auto.R`, +its `*_impl()` gets a test in `tests/testthat/test-aaa-.R` ([the suite](/handbook/testing/suite/README.md)), and a graph constructor prefers `GATTR` and `GATTR-PARAM` in the Stimulus definitions over assigning attributes by hand. diff --git a/handbook/testing/suite/README.md b/handbook/testing/suite/README.md index b33a329dd53..eeb0d25caeb 100644 --- a/handbook/testing/suite/README.md +++ b/handbook/testing/suite/README.md @@ -3,7 +3,10 @@ The testthat suite under `tests/testthat/`. * A test file mirrors its source file: `R/name.R` is tested in `tests/testthat/test-name.R`. -* New functionality comes with tests; a new generated `*_impl()` gets one in `test-aaa-auto.R`. +* New functionality comes with tests; a new generated `*_impl()` gets one in `test-aaa-.R`, + the file mirroring the `R/aaa-.R` that defines it. + [`tools/split-aaa-tests.R`](/tools/split-aaa-tests.R) moves each impl's tests and snapshots to that file, + so rerun it after an impl changes category; CI runs it with `--check` and fails while a test sits elsewhere. * `testthat::test_local(reporter = "check")` runs the suite, and `filter = "name"` one file of it; `devtools::check()` is the final step before a change is done. diff --git a/tests/testthat/_snaps/aaa-auto.md b/tests/testthat/_snaps/aaa-auto.md deleted file mode 100644 index 33291a6c44e..00000000000 --- a/tests/testthat/_snaps/aaa-auto.md +++ /dev/null @@ -1,11879 +0,0 @@ -# empty_impl basic - - Code - empty_impl() - Output - IGRAPH D--- 0 0 -- - + edges: - ---- - - Code - empty_impl(n = 5, directed = FALSE) - Output - IGRAPH U--- 5 0 -- - + edges: - -# empty_impl errors - - Code - empty_impl(n = -1) - Condition - Error in `empty_impl()`: - ! Number of vertices must not be negative. Invalid value - Source: : - -# add_edges_impl basic - - Code - add_edges_impl(graph = g, edges = c(1, 2, 2, 3)) - Output - IGRAPH D--- 3 2 -- - + edges: - [1] 1->2 2->3 - -# add_edges_impl errors - - Code - add_edges_impl(graph = NULL, edges = c(1, 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# copy_impl basic - - Code - copy_impl(from = g) - Output - IGRAPH D--- 2 0 -- - + edges: - -# copy_impl errors - - Code - copy_impl(from = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# delete_vertices_idx_impl basic - - Code - delete_vertices_idx_impl(graph = g, vertices = 1) - Output - $graph - IGRAPH D--- 2 0 -- - + edges: - - $idx - [1] 0 1 2 - - $invidx - [1] 1 2 - - -# delete_vertices_idx_impl errors - - Code - delete_vertices_idx_impl(graph = NULL, vertices = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# vcount_impl basic - - Code - vcount_impl(graph = g) - Output - [1] 4 - -# vcount_impl errors - - Code - vcount_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# degree_impl basic - - Code - degree_impl(graph = g) - Output - [1] 0 0 0 - ---- - - Code - degree_impl(graph = g, mode = "in") - Output - [1] 0 0 0 - -# degree_impl errors - - Code - degree_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_all_eids_between_impl basic - - Code - get_all_eids_between_impl(graph = g, from = 1, to = 2) - Output - + 0/0 edges: - -# get_all_eids_between_impl errors - - Code - get_all_eids_between_impl(graph = NULL, from = 1, to = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# wheel_impl basic - - Code - wheel_impl(n = 5) - Output - IGRAPH D--- 5 8 -- - + edges: - [1] 1->2 1->3 1->4 1->5 2->3 3->4 4->5 5->2 - ---- - - Code - wheel_impl(n = 5, mode = "in", center = 2) - Output - IGRAPH D--- 5 8 -- - + edges: - [1] 1->3 2->3 4->3 5->3 1->2 2->4 4->5 5->1 - -# wheel_impl errors - - Code - wheel_impl(n = -1) - Condition - Error in `wheel_impl()`: - ! Invalid number of vertices. Invalid vertex ID - Source: : - -# hypercube_impl basic - - Code - hypercube_impl(n = 3) - Output - IGRAPH U--- 8 12 -- - + edges: - [1] 1--2 1--3 1--5 2--4 2--6 3--4 3--7 4--8 5--6 5--7 6--8 7--8 - ---- - - Code - hypercube_impl(n = 3, directed = TRUE) - Output - IGRAPH D--- 8 12 -- - + edges: - [1] 1->2 1->3 1->5 2->4 2->6 3->4 3->7 4->8 5->6 5->7 6->8 7->8 - -# hypercube_impl errors - - Code - hypercube_impl(n = 10000) - Condition - Error in `hypercube_impl()`: - ! The requested hypercube graph dimension (10000) is too high. It must be no greater than 57. Invalid value - Source: : - -# square_lattice_impl basic - - Code - square_lattice_impl(dimvector = c(2, 2)) - Output - IGRAPH U--- 4 4 -- - + edges: - [1] 1--2 1--3 2--4 3--4 - ---- - - Code - square_lattice_impl(dimvector = c(2, 2), nei = 2, directed = TRUE, mutual = TRUE, - periodic = c(TRUE, TRUE)) - Output - IGRAPH D--- 4 10 -- - + edges: - [1] 1->2 1->3 2->1 2->4 3->4 3->1 4->3 4->2 1->4 2->3 - -# square_lattice_impl errors - - Code - square_lattice_impl(dimvector = -1) - Condition - Error in `square_lattice_impl()`: - ! Invalid dimension vector. Invalid value - Source: : - -# triangular_lattice_impl basic - - Code - triangular_lattice_impl(dimvector = c(2, 2)) - Output - IGRAPH U--- 4 5 -- - + edges: - [1] 1--2 1--4 1--3 2--4 3--4 - ---- - - Code - triangular_lattice_impl(dimvector = c(2, 2), directed = TRUE, mutual = TRUE) - Output - IGRAPH D--- 4 10 -- - + edges: - [1] 1->2 2->1 1->4 4->1 1->3 3->1 2->4 4->2 3->4 4->3 - -# triangular_lattice_impl errors - - Code - triangular_lattice_impl(dimvector = -1) - Condition - Error in `triangular_lattice_impl()`: - ! Invalid dimension vector. Invalid value - Source: : - -# path_graph_impl basic - - Code - path_graph_impl(n = 5) - Output - IGRAPH U--- 5 4 -- - + edges: - [1] 1--2 2--3 3--4 4--5 - ---- - - Code - path_graph_impl(n = 5, directed = TRUE, mutual = TRUE) - Output - IGRAPH D--- 5 8 -- - + edges: - [1] 1->2 2->1 2->3 3->2 3->4 4->3 4->5 5->4 - -# path_graph_impl errors - - Code - path_graph_impl(n = -1) - Condition - Error in `path_graph_impl()`: - ! The number of vertices must be non-negative, got -1. Invalid value - Source: : - -# cycle_graph_impl basic - - Code - cycle_graph_impl(n = 5) - Output - IGRAPH U--- 5 5 -- - + edges: - [1] 1--2 2--3 3--4 4--5 1--5 - ---- - - Code - cycle_graph_impl(n = 5, directed = TRUE, mutual = TRUE) - Output - IGRAPH D--- 5 10 -- - + edges: - [1] 1->2 2->1 2->3 3->2 3->4 4->3 4->5 5->4 5->1 1->5 - -# cycle_graph_impl errors - - Code - cycle_graph_impl(n = -1) - Condition - Error in `cycle_graph_impl()`: - ! The number of vertices must be non-negative, got -1. Invalid value - Source: : - -# symmetric_tree_impl basic - - Code - symmetric_tree_impl(branches = 3) - Output - IGRAPH D--- 4 3 -- - + edges: - [1] 1->2 1->3 1->4 - ---- - - Code - symmetric_tree_impl(branches = 3, type = "in") - Output - IGRAPH D--- 4 3 -- - + edges: - [1] 2->1 3->1 4->1 - -# symmetric_tree_impl errors - - Code - symmetric_tree_impl(branches = -1) - Condition - Error in `symmetric_tree_impl()`: - ! The number of branches must be positive at each level. Invalid value - Source: : - -# regular_tree_impl basic - - Code - regular_tree_impl(h = 2) - Output - IGRAPH U--- 10 9 -- - + edges: - [1] 1-- 2 1-- 3 1-- 4 2-- 5 2-- 6 3-- 7 3-- 8 4-- 9 4--10 - ---- - - Code - regular_tree_impl(h = 2, k = 4, type = "in") - Output - IGRAPH D--- 17 16 -- - + edges: - [1] 2->1 3->1 4->1 5->1 6->2 7->2 8->2 9->3 10->3 11->3 12->4 13->4 - [13] 14->4 15->5 16->5 17->5 - -# regular_tree_impl errors - - Code - regular_tree_impl(h = -1) - Condition - Error in `regular_tree_impl()`: - ! Height of regular tree must be positive, got -1. Invalid value - Source: : - -# full_citation_impl basic - - Code - full_citation_impl(n = 5) - Output - IGRAPH D--- 5 10 -- - + edges: - [1] 2->1 3->1 3->2 4->1 4->2 4->3 5->1 5->2 5->3 5->4 - ---- - - Code - full_citation_impl(n = 5, directed = FALSE) - Output - IGRAPH U--- 5 10 -- - + edges: - [1] 1--2 1--3 2--3 1--4 2--4 3--4 1--5 2--5 3--5 4--5 - -# full_citation_impl errors - - Code - full_citation_impl(n = -1) - Condition - Error in `full_citation_impl()`: - ! Invalid number of vertices. Invalid value - Source: : - -# atlas_impl basic - - Code - atlas_impl(number = 0) - Output - IGRAPH U--- 0 0 -- - + edges: - ---- - - Code - atlas_impl(number = 5) - Output - IGRAPH U--- 3 1 -- - + edge: - [1] 2--3 - -# atlas_impl errors - - Code - atlas_impl(number = -1) - Condition - Error in `atlas_impl()`: - ! No such graph in atlas. The graph index must be less than 1253. Invalid value - Source: : - -# extended_chordal_ring_impl basic - - Code - extended_chordal_ring_impl(nodes = 5, W = matrix(c(1, 2))) - Output - IGRAPH U--- 5 15 -- - + edges: - [1] 1--2 2--3 3--4 4--5 1--5 1--2 1--3 2--3 2--4 3--4 3--5 4--5 1--4 1--5 2--5 - ---- - - Code - extended_chordal_ring_impl(nodes = 5, W = matrix(c(1, 2)), directed = TRUE) - Output - IGRAPH D--- 5 15 -- - + edges: - [1] 1->2 2->3 3->4 4->5 5->1 1->2 1->3 2->3 2->4 3->4 3->5 4->5 4->1 5->1 5->2 - -# extended_chordal_ring_impl errors - - Code - extended_chordal_ring_impl(nodes = -1, W = matrix(c(1, 2))) - Condition - Error in `extended_chordal_ring_impl()`: - ! An extended chordal ring has at least 3 nodes. Invalid value - Source: : - -# graph_power_impl basic - - Code - graph_power_impl(graph = g, order = 2) - Output - IGRAPH U--- 5 7 -- - + edges: - [1] 1--2 2--3 3--4 4--5 1--3 2--4 3--5 - ---- - - Code - graph_power_impl(graph = g, order = 2, directed = TRUE) - Output - IGRAPH U--- 5 7 -- - + edges: - [1] 1--2 2--3 3--4 4--5 1--3 2--4 3--5 - -# graph_power_impl errors - - Code - graph_power_impl(graph = NULL, order = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# linegraph_impl basic - - Code - linegraph_impl(graph = g) - Output - IGRAPH U--- 4 3 -- - + edges: - [1] 1--2 2--3 3--4 - -# linegraph_impl errors - - Code - linegraph_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# de_bruijn_impl basic - - Code - de_bruijn_impl(m = 2, n = 3) - Output - IGRAPH D--- 8 16 -- - + edges: - [1] 1->1 1->2 2->3 2->4 3->5 3->6 4->7 4->8 5->1 5->2 6->3 6->4 7->5 7->6 8->7 - [16] 8->8 - -# de_bruijn_impl errors - - Code - de_bruijn_impl(m = -1, n = 3) - Condition - Error in `de_bruijn_impl()`: - ! `m' and `n' should be non-negative in a de Bruijn graph. Invalid value - Source: : - -# kautz_impl basic - - Code - kautz_impl(m = 2, n = 3) - Output - IGRAPH D--- 24 48 -- - + edges: - [1] 1-> 9 1->10 2->11 2->12 3->13 3->14 4->15 4->16 5->17 5->18 - [11] 6->19 6->20 7->21 7->22 8->23 8->24 9-> 1 9-> 2 10-> 3 10-> 4 - [21] 11-> 5 11-> 6 12-> 7 12-> 8 13->17 13->18 14->19 14->20 15->21 15->22 - [31] 16->23 16->24 17-> 1 17-> 2 18-> 3 18-> 4 19-> 5 19-> 6 20-> 7 20-> 8 - [41] 21-> 9 21->10 22->11 22->12 23->13 23->14 24->15 24->16 - -# kautz_impl errors - - Code - kautz_impl(m = -1, n = 3) - Condition - Error in `kautz_impl()`: - ! `m' and `n' should be non-negative in a Kautz graph. Invalid value - Source: : - -# lcf_vector_impl basic - - Code - lcf_vector_impl(n = 10, shifts = c(3, -3, 4), repeats = 2) - Output - IGRAPH U--- 10 16 -- LCF graph - + attr: name (g/c) - + edges: - [1] 1-- 2 1-- 4 1--10 2-- 3 2-- 5 2-- 9 3-- 4 3-- 7 4-- 5 4-- 7 5-- 6 6-- 7 - [13] 6--10 7-- 8 8-- 9 9--10 - -# lcf_vector_impl errors - - Code - lcf_vector_impl(n = -1, shifts = c(3, -3, 4), repeats = 2) - Condition - Error in `lcf_vector_impl()`: - ! Number of vertices must not be negative. Invalid value - Source: : - -# mycielski_graph_impl basic - - Code - mycielski_graph_impl(k = 3) - Output - IGRAPH U--- 5 5 -- - + edges: - [1] 1--2 1--4 2--3 3--5 4--5 - -# mycielski_graph_impl errors - - Code - mycielski_graph_impl(k = -1) - Condition - Error in `mycielski_graph_impl()`: - ! The Mycielski graph order must not be negative. Invalid value - Source: : - -# adjlist_impl basic - - Code - adjlist_impl(adjlist = list(c(2, 3), c(1), c(1)), mode = "out") - Output - IGRAPH D--- 3 4 -- - + edges: - [1] 1->2 1->3 2->1 3->1 - -# adjlist_impl errors - - Code - adjlist_impl(adjlist = -1, mode = "out") - Condition - Error in `adjlist_impl()`: - ! Invalid (negative or too large) vertex ID. Invalid vertex ID - Source: : - -# full_bipartite_impl basic - - Code - full_bipartite_impl(n1 = 2, n2 = 3) - Output - $graph - IGRAPH U--- 5 6 -- - + edges: - [1] 1--3 1--4 1--5 2--3 2--4 2--5 - - $types - [1] FALSE FALSE TRUE TRUE TRUE - - ---- - - Code - full_bipartite_impl(n1 = 2, n2 = 3, directed = TRUE, mode = "in") - Output - $graph - IGRAPH D--- 5 6 -- - + edges: - [1] 3->1 4->1 5->1 3->2 4->2 5->2 - - $types - [1] FALSE FALSE TRUE TRUE TRUE - - -# full_bipartite_impl errors - - Code - full_bipartite_impl(n1 = -1, n2 = 3) - Condition - Error in `full_bipartite_impl()`: - ! Invalid number of vertices for bipartite graph. Invalid value - Source: : - -# full_multipartite_impl basic - - Code - full_multipartite_impl(n = c(2, 3, 4)) - Output - $graph - IGRAPH U--- 9 26 -- - + edges: - [1] 1--3 1--4 1--5 1--6 1--7 1--8 1--9 2--3 2--4 2--5 2--6 2--7 2--8 2--9 3--6 - [16] 3--7 3--8 3--9 4--6 4--7 4--8 4--9 5--6 5--7 5--8 5--9 - - $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(n = c(2, 3, 4), directed = TRUE, mode = "in") - Output - $graph - IGRAPH D--- 9 26 -- - + edges: - [1] 3->1 4->1 5->1 6->1 7->1 8->1 9->1 3->2 4->2 5->2 6->2 7->2 8->2 9->2 6->3 - [16] 7->3 8->3 9->3 6->4 7->4 8->4 9->4 6->5 7->5 8->5 9->5 - - $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 - - Code - full_multipartite_impl(n = -1) - Condition - Error in `full_multipartite_impl()`: - ! Number of vertices must not be negative in any partition. Invalid value - Source: : - -# realize_degree_sequence_impl basic - - Code - 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 - | (g/n), method (g/n) - + edges: - [1] 2--3 1--3 1--2 - ---- - - Code - 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 - | (g/n), method (g/n) - + edges: - [1] 1->2 1->3 2->1 2->3 3->1 3->2 - -# realize_degree_sequence_impl errors - - Code - realize_degree_sequence_impl(out_deg = -1) - Condition - Error in `realize_degree_sequence_impl()`: - ! The sum of degrees must be even for an undirected graph. Invalid value - Source: : - -# realize_bipartite_degree_sequence_impl basic - - Code - 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 - | (g/n), method (g/n) - + edges: - [1] 2--3 2--4 1--4 1--3 - ---- - - Code - 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 - | (g/n), method (g/n) - + edges: - [1] 1--3 1--4 2--3 2--4 - -# realize_bipartite_degree_sequence_impl errors - - Code - realize_bipartite_degree_sequence_impl(degrees1 = -1, degrees2 = c(2, 2)) - Condition - Error in `realize_bipartite_degree_sequence_impl()`: - ! The given bidegree sequence cannot be realized as a bipartite simple graph. Invalid value - Source: : - -# circulant_impl basic - - Code - circulant_impl(n = 5, shifts = c(1, 2)) - Output - 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(n = 5, shifts = c(1, 2), directed = TRUE) - Output - 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 - -# circulant_impl errors - - Code - circulant_impl(n = -1, shifts = c(1, 2)) - Condition - Error in `circulant_impl()`: - ! Number of nodes = -1 must be non-negative. Invalid value - Source: : - -# generalized_petersen_impl basic - - Code - generalized_petersen_impl(n = 5, k = 2) - Output - IGRAPH U--- 10 15 -- - + edges: - [1] 1-- 2 1-- 6 6-- 8 2-- 3 2-- 7 7-- 9 3-- 4 3-- 8 8--10 4-- 5 4-- 9 6-- 9 - [13] 1-- 5 5--10 7--10 - -# generalized_petersen_impl errors - - Code - generalized_petersen_impl(n = -1, k = 2) - Condition - Error in `generalized_petersen_impl()`: - ! n = -1 must be at least 3. Invalid value - Source: : - -# turan_impl basic - - Code - turan_impl(n = 5, r = 2) - Output - $graph - IGRAPH U--- 5 6 -- - + edges: - [1] 1--4 1--5 2--4 2--5 3--4 3--5 - - $types - [1] 1 1 1 2 2 - - $name - [1] "Turan graph" - - $n - [1] 5 - - $r - [1] 2 - - -# turan_impl errors - - Code - turan_impl(n = -1, r = 2) - Condition - Error in `turan_impl()`: - ! Number of vertices must not be negative, got -1. Invalid value - Source: : - -# erdos_renyi_game_gnp_impl basic - - Code - erdos_renyi_game_gnp_impl(n = 5, p = 0.5) - Output - IGRAPH U--- 5 7 -- - + edges: - [1] 1--2 1--3 2--3 1--4 2--4 1--5 4--5 - ---- - - Code - erdos_renyi_game_gnp_impl(n = 5, p = 0.5, directed = TRUE, loops = TRUE) - Output - IGRAPH D--- 5 12 -- - + edges: - [1] 2->1 3->1 4->1 2->2 1->3 2->3 4->3 1->4 2->4 5->4 3->5 4->5 - -# erdos_renyi_game_gnp_impl errors - - Code - erdos_renyi_game_gnp_impl(n = -1, p = 0.5) - Condition - Error in `erdos_renyi_game_gnp_impl()`: - ! Invalid number of vertices. Invalid value - Source: : - -# erdos_renyi_game_gnm_impl basic - - Code - erdos_renyi_game_gnm_impl(n = 5, m = 3) - Output - IGRAPH U--- 5 3 -- - + edges: - [1] 3--4 2--5 4--5 - ---- - - Code - erdos_renyi_game_gnm_impl(n = 5, m = 3, directed = TRUE, loops = TRUE) - Output - IGRAPH D--- 5 3 -- - + edges: - [1] 4->3 5->3 3->5 - -# erdos_renyi_game_gnm_impl errors - - Code - erdos_renyi_game_gnm_impl(n = -1, m = 3) - Condition - Error in `erdos_renyi_game_gnm_impl()`: - ! Invalid number of vertices. Invalid value - Source: : - -# growing_random_game_impl basic - - Code - 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) - + edges: - [1] 2->2 1->2 3->3 3->3 3->3 1->2 2->2 5->4 - ---- - - Code - 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) - + edges: - [1] 1--2 1--2 2--3 1--3 1--4 2--4 1--5 4--5 - ---- - - Code - growing_random_game_impl(n = 10, m = 1, directed = TRUE, citation = FALSE) - Output - IGRAPH D--- 10 9 -- Growing random graph - + attr: name (g/c), m (g/n), citation (g/l) - + edges: - [1] 2->2 2->3 4->4 4->4 3->2 1->3 1->8 5->6 5->4 - -# growing_random_game_impl errors - - Code - growing_random_game_impl(n = -1, m = 2) - Condition - Error in `growing_random_game_impl()`: - ! Invalid number of vertices. Invalid value - Source: : - -# preference_game_impl basic - - Code - 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 -- - + edges: - [1] 1--3 3--4 1--4 1--5 - - $node_type_vec - [1] 1 0 0 1 1 - - -# preference_game_impl errors - - Code - preference_game_impl(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)) - Condition - Error in `preference_game_impl()`: - ! The number of vertices must be non-negative. Invalid value - Source: : - -# asymmetric_preference_game_impl basic - - Code - 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 -- - + edges: - [1] 2->4 4->2 5->2 1->3 4->3 4->5 3->1 1->4 1->5 - - $node_type_out_vec - [1] 1 0 1 1 1 - - $node_type_in_vec - [1] 1 0 0 1 1 - - -# asymmetric_preference_game_impl errors - - Code - asymmetric_preference_game_impl(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)) - Condition - Error in `asymmetric_preference_game_impl()`: - ! The number of vertices must not be negative. Invalid value - Source: : - -# rewire_edges_impl basic - - Code - rewire_edges_impl(graph = g, prob = 0.5) - Output - IGRAPH U--- 5 4 -- - + edges: - [1] 2--4 3--4 1--3 2--5 - -# rewire_edges_impl errors - - Code - rewire_edges_impl(graph = NULL, prob = 0.5) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# rewire_directed_edges_impl basic - - Code - rewire_directed_edges_impl(graph = g, prob = 0.5) - Output - IGRAPH D--- 5 4 -- - + edges: - [1] 1->4 2->3 3->2 4->5 - -# rewire_directed_edges_impl errors - - Code - rewire_directed_edges_impl(graph = NULL, prob = 0.5) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# forest_fire_game_impl basic - - Code - 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) - + edges: - [1] 2->1 3->2 4->2 4->1 4->3 5->1 5->2 5->4 5->3 - ---- - - Code - 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) - + edges: - [1] 1--2 1--3 1--4 4--5 - -# forest_fire_game_impl errors - - Code - forest_fire_game_impl(nodes = -1, fw_prob = 0.5) - Condition - Error in `forest_fire_game_impl()`: - ! Insufficient memory for forest fire model. Out of memory - Source: : - -# simple_interconnected_islands_game_impl basic - - Code - 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 - | (g/n), n_inter (g/n) - + edges: - [1] 1--2 1--3 2--3 3--6 5--6 - -# simple_interconnected_islands_game_impl errors - - Code - simple_interconnected_islands_game_impl(islands_n = -1, islands_size = 3, - islands_pin = 0.5, n_inter = 1) - Condition - Error in `simple_interconnected_islands_game_impl()`: - ! Number of islands cannot be negative, got -1. Invalid value - Source: : - -# chung_lu_game_impl basic - - Code - 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) - + edges: - [1] 1--2 1--3 2--2 2--3 3--3 - ---- - - Code - 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) - + edge: - [1] 3->1 - -# chung_lu_game_impl errors - - Code - chung_lu_game_impl(out_weights = -1) - Condition - Error in `chung_lu_game_impl()`: - ! Vertex weights must not be negative in Chung-Lu model, got -1. Invalid value - Source: : - -# static_fitness_game_impl basic - - Code - 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) - + edges: - [1] 1--2 1--3 2--3 - ---- - - Code - 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) - + edges: - [1] 1->2 2->3 1->3 - -# static_fitness_game_impl errors - - Code - static_fitness_game_impl(no_of_edges = -1, fitness_out = c(1, 2, 3)) - Condition - Error in `static_fitness_game_impl()`: - ! Number of edges cannot be negative, got -1. Invalid value - Source: : - -# static_power_law_game_impl basic - - Code - 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), - | multiple (g/l), finite_size_correction (g/l) - + edges: - [1] 1--5 2--4 3--5 4--5 - ---- - - Code - 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), - | multiple (g/l), finite_size_correction (g/l) - + edges: - [1] 1->1 3->5 1->4 5->1 - -# static_power_law_game_impl errors - - Code - static_power_law_game_impl(no_of_nodes = -1, no_of_edges = 4, exponent_out = 2.5) - Condition - Error in `static_power_law_game_impl()`: - ! Number of nodes cannot be negative, got -1. Invalid value - Source: : - -# k_regular_game_impl basic - - Code - 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) - + edges: - [1] 1--3 1--5 2--3 2--4 4--5 - ---- - - Code - 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) - + edges: - [1] 3->4 3->3 2->1 5->5 1->5 4->3 5->2 4->1 1->2 2->4 - -# k_regular_game_impl errors - - Code - k_regular_game_impl(no_of_nodes = -1, k = 2) - Condition - Error in `k_regular_game_impl()`: - ! Number of nodes must be non-negative. Invalid value - Source: : - -# sbm_game_impl basic - - Code - 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) - + edges: - [1] 1--2 1--3 2--3 1--4 1--5 3--5 - ---- - - Code - 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) - + edges: - [1] 1->1 2->1 2->4 1->5 4->1 5->1 5->2 3->3 5->3 3->4 4->4 5->4 3->5 5->5 - -# sbm_game_impl errors - - Code - sbm_game_impl(n = -1, pref_matrix = matrix(0.5, 2, 2), block_sizes = c(2, 3)) - Condition - Error in `sbm_game_impl()`: - ! Sum of the block sizes (5) must equal the number of vertices (-1). Invalid value - Source: : - -# hsbm_game_impl basic - - Code - 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) - + edges: - [1] 1--2 3--4 5--6 1--4 1--5 2--5 1--6 4--5 3--6 - -# hsbm_game_impl errors - - Code - hsbm_game_impl(n = -1, m = 2, rho = 0.5, C = matrix(1, 2, 2), p = 0.5) - Condition - Error in `hsbm_game_impl()`: - ! `n' must be positive for HSBM. Invalid value - Source: : - -# hsbm_list_game_impl basic - - Code - 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) - + edges: - [1] 1-- 2 1-- 3 2-- 3 1-- 4 2-- 4 3-- 4 1-- 5 2-- 5 3-- 5 4-- 5 - [11] 1-- 6 2-- 6 3-- 6 4-- 6 5-- 6 1-- 7 2-- 7 3-- 7 4-- 7 5-- 7 - [21] 6-- 7 1-- 8 2-- 8 3-- 8 4-- 8 5-- 8 6-- 8 7-- 8 1-- 9 2-- 9 - [31] 3-- 9 4-- 9 5-- 9 6-- 9 7-- 9 8-- 9 1--10 2--10 3--10 4--10 - [41] 5--10 6--10 7--10 8--10 9--10 1--11 2--11 3--11 4--11 5--11 - [51] 6--11 7--11 8--11 9--11 10--11 1--12 2--12 3--12 4--12 5--12 - [61] 6--12 7--12 8--12 9--12 10--12 11--12 1--13 2--13 3--13 4--13 - [71] 5--13 6--13 7--13 8--13 9--13 10--13 11--13 12--13 1--14 2--14 - + ... omitted several edges - -# hsbm_list_game_impl errors - - Code - hsbm_list_game_impl(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) - Condition - Error in `hsbm_list_game_impl()`: - ! `n' must be positive for HSBM. Invalid value - Source: : - -# correlated_game_impl basic - - Code - 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) - + edges: - [1] 1--3 3--4 2--5 - -# correlated_game_impl errors - - Code - correlated_game_impl(old_graph = NULL, corr = 0.5) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# correlated_pair_game_impl basic - - Code - correlated_pair_game_impl(n = 5, corr = 0.5, p = 0.5) - Output - $graph1 - IGRAPH U--- 5 7 -- - + edges: - [1] 1--2 1--3 2--3 1--4 2--4 1--5 4--5 - - $graph2 - IGRAPH U--- 5 7 -- - + edges: - [1] 1--2 1--3 2--3 1--4 2--4 1--5 3--5 - - ---- - - Code - correlated_pair_game_impl(n = 5, corr = 0.5, p = 0.5, directed = TRUE) - Output - $graph1 - IGRAPH D--- 5 10 -- - + edges: - [1] 4->1 5->1 2->5 4->2 5->2 3->5 1->4 2->4 4->5 5->4 - - $graph2 - IGRAPH D--- 5 9 -- - + edges: - [1] 1->5 2->1 2->5 4->2 4->3 1->4 2->4 4->5 5->4 - - -# correlated_pair_game_impl errors - - Code - correlated_pair_game_impl(n = -1, corr = 0.5, p = 0.5) - Condition - Error in `correlated_pair_game_impl()`: - ! Invalid number of vertices. Invalid value - Source: : - -# dot_product_game_impl basic - - Code - dot_product_game_impl(vecs = matrix(0.5, 5, 2)) - Condition - Warning in `dot_product_game_impl()`: - Greater than 1 connection probability in dot-product graph. - Source: games/dotproduct.c:90 - Output - IGRAPH U--- 2 1 -- - + edge: - [1] 1--2 - ---- - - Code - dot_product_game_impl(vecs = matrix(0.5, 5, 2), directed = TRUE) - Condition - Warning in `dot_product_game_impl()`: - Greater than 1 connection probability in dot-product graph. - Source: games/dotproduct.c:90 - Output - IGRAPH D--- 2 2 -- - + edges: - [1] 1->2 2->1 - -# dot_product_game_impl errors - - Code - dot_product_game_impl(vecs = NULL) - Condition - Error in `dot_product_game_impl()`: - ! REAL() can only be applied to a 'numeric', not a 'NULL' - -# sample_sphere_surface_impl basic - - Code - 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 - [2,] 0.05165973 0.5261159 0.1145481 0.2979741 0.02649327 - [3,] 0.47443162 0.2229974 0.9830712 0.7128005 0.02500179 - ---- - - Code - 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 - [2,] -1.6787252 1.1329528 -0.7872709 -0.41498660 1.953509 - [3,] -0.9702395 0.7200713 1.7651832 -0.01090904 0.217584 - -# sample_sphere_surface_impl errors - - Code - sample_sphere_surface_impl(dim = -1, n = 5) - Condition - Error in `sample_sphere_surface_impl()`: - ! Sphere must be at least two dimensional to sample from surface. Invalid value - Source: : - -# sample_sphere_volume_impl basic - - Code - 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 - [2,] 0.03948371 0.3914105 0.07855561 0.1939507 0.01943923 - [3,] 0.36260970 0.1659017 0.67417787 0.4639603 0.01834487 - ---- - - Code - 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 - [2,] -0.159619927 0.2402815 -0.1258477 0.1842403 -1.4940836 - [3,] 0.003829883 1.2440192 0.6204597 1.5776103 0.4096058 - -# sample_sphere_volume_impl errors - - Code - sample_sphere_volume_impl(dim = -1, n = 5) - Condition - Error in `sample_sphere_volume_impl()`: - ! Sphere must be at least two dimensional to sample from surface. Invalid value - Source: : - -# sample_dirichlet_impl basic - - Code - 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 - [2,] 0.1093984 0.3461600 0.08924333 0.4251328 0.3561426 - [3,] 0.2608008 0.2369988 0.61481386 0.3316331 0.4921759 - -# sample_dirichlet_impl errors - - Code - sample_dirichlet_impl(n = -1, alpha = c(1, 1, 1)) - Condition - Error in `sample_dirichlet_impl()`: - ! Number of samples should be non-negative, got -1. Invalid value - Source: : - -# are_adjacent_impl basic - - Code - are_adjacent_impl(graph = g, v1 = 1, v2 = 2) - Output - [1] TRUE - -# are_adjacent_impl errors - - Code - are_adjacent_impl(graph = NULL, v1 = 1, v2 = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# closeness_impl basic - - Code - closeness_impl(graph = g) - Output - $res - [1] 0.3333333 0.5000000 0.3333333 - - $reachable_count - [1] 2 2 2 - - $all_reachable - [1] TRUE - - ---- - - Code - closeness_impl(graph = g, mode = "in", normalized = TRUE) - Output - $res - [1] 0.6666667 1.0000000 0.6666667 - - $reachable_count - [1] 2 2 2 - - $all_reachable - [1] TRUE - - ---- - - Code - closeness_impl(graph = g, vids = V(g), mode = c("out", "in", "all", "total")) - Output - $res - [1] 0.1666667 0.1666667 0.1666667 0.1666667 0.1666667 - - $reachable_count - [1] 4 4 4 4 4 - - $all_reachable - [1] TRUE - - -# closeness_impl errors - - Code - closeness_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# closeness_cutoff_impl basic - - Code - closeness_cutoff_impl(graph = g, cutoff = 2) - Output - $res - [1] 0.3333333 0.5000000 0.3333333 - - $reachable_count - [1] 2 2 2 - - $all_reachable - [1] TRUE - - ---- - - Code - closeness_cutoff_impl(graph = g, mode = "in", normalized = TRUE, cutoff = 1) - Output - $res - [1] 1 1 1 - - $reachable_count - [1] 1 2 1 - - $all_reachable - [1] FALSE - - -# closeness_cutoff_impl errors - - Code - closeness_cutoff_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_shortest_path_impl basic - - Code - get_shortest_path_impl(graph = g, from = 1, to = 3) - Output - $vertices - + 3/3 vertices: - [1] 1 2 3 - - $edges - + 2/2 edges: - [1] 1--2 2--3 - - -# get_shortest_path_impl errors - - Code - get_shortest_path_impl(graph = NULL, from = 1, to = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_shortest_path_bellman_ford_impl basic - - Code - get_shortest_path_bellman_ford_impl(graph = g, from = 1, to = 3) - Output - $vertices - + 3/3 vertices: - [1] 1 2 3 - - $edges - + 2/2 edges: - [1] 1--2 2--3 - - -# get_shortest_path_bellman_ford_impl errors - - Code - get_shortest_path_bellman_ford_impl(graph = NULL, from = 1, to = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_shortest_path_dijkstra_impl basic - - Code - get_shortest_path_dijkstra_impl(graph = g, from = 1, to = 3) - Output - $vertices - + 3/3 vertices: - [1] 1 2 3 - - $edges - + 2/2 edges: - [1] 1--2 2--3 - - -# get_shortest_path_dijkstra_impl errors - - Code - get_shortest_path_dijkstra_impl(graph = NULL, from = 1, to = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_all_shortest_paths_impl basic - - Code - get_all_shortest_paths_impl(graph = g, from = 1, to = 3) - Output - $vpaths - $vpaths[[1]] - + 3/3 vertices: - [1] 1 2 3 - - - $epaths - $epaths[[1]] - + 2/2 edges: - [1] 1--2 2--3 - - - $nrgeo - [1] 1 1 1 - - -# get_all_shortest_paths_impl errors - - Code - get_all_shortest_paths_impl(graph = NULL, from = 1, to = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_all_shortest_paths_dijkstra_impl basic - - Code - get_all_shortest_paths_dijkstra_impl(graph = g, from = 1, to = 3) - Output - $vpaths - $vpaths[[1]] - + 3/3 vertices: - [1] 1 2 3 - - - $epaths - $epaths[[1]] - + 2/2 edges: - [1] 1--2 2--3 - - - $nrgeo - [1] 1 1 1 - - -# get_all_shortest_paths_dijkstra_impl errors - - Code - get_all_shortest_paths_dijkstra_impl(graph = NULL, from = 1, to = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# voronoi_impl basic - - Code - voronoi_impl(graph = g, generators = 1) - Output - $membership - [1] 0 0 0 - - $distances - [1] 0 1 2 - - ---- - - Code - voronoi_impl(graph = g, generators = 1, mode = "in", tiebreaker = "first") - Output - $membership - [1] 0 0 0 - - $distances - [1] 0 1 2 - - ---- - - Code - voronoi_impl(graph = g, generators = c(1, 5), mode = c("out", "in", "all")) - Output - $membership - [1] 0 0 0 1 1 1 1 1 0 0 - - $distances - [1] 0 1 2 1 0 1 2 3 2 1 - - -# voronoi_impl errors - - Code - voronoi_impl(graph = NULL, generators = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_all_simple_paths_impl basic - - Code - get_all_simple_paths_impl(graph = g, from = 1, to = 3) - Output - + 3/3 vertices: - [1] 1 2 3 - -# get_all_simple_paths_impl errors - - Code - get_all_simple_paths_impl(graph = NULL, from = 1, to = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_k_shortest_paths_impl basic - - Code - get_k_shortest_paths_impl(graph = g, from = 1, to = 3, k = 2) - Output - $vpaths - $vpaths[[1]] - + 3/3 vertices: - [1] 1 2 3 - - - $epaths - $epaths[[1]] - + 2/2 edges: - [1] 1--2 2--3 - - - -# get_k_shortest_paths_impl errors - - Code - get_k_shortest_paths_impl(graph = NULL, from = 1, to = 3, k = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_widest_path_impl basic - - Code - get_widest_path_impl(graph = g, from = 1, to = 3, weights = c(1, 2)) - Output - $vertices - + 3/3 vertices: - [1] 1 2 3 - - $edges - + 2/2 edges: - [1] 1--2 2--3 - - -# get_widest_path_impl errors - - Code - get_widest_path_impl(graph = NULL, from = 1, to = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_widest_paths_impl basic - - Code - get_widest_paths_impl(graph = g, from = 1, to = 3, weights = c(1, 2)) - Output - $vertices - $vertices[[1]] - + 3/3 vertices: - [1] 1 2 3 - - - $edges - $edges[[1]] - + 2/2 edges: - [1] 1--2 2--3 - - - $parents - [1] -1 0 1 - - $inbound_edges - [1] -1 0 1 - - -# get_widest_paths_impl errors - - Code - get_widest_paths_impl(graph = NULL, from = 1, to = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# spanner_impl basic - - Code - spanner_impl(graph = g, stretch = 2) - Output - + 2/2 edges: - [1] 1--2 2--3 - ---- - - Code - spanner_impl(graph = g, stretch = 2) - Output - + 5/5 edges: - [1] 1--2 2--3 3--4 4--5 1--5 - -# spanner_impl errors - - Code - spanner_impl(graph = NULL, stretch = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# betweenness_cutoff_impl basic - - Code - betweenness_cutoff_impl(graph = g, cutoff = 2) - Output - [1] 0 1 0 - -# betweenness_cutoff_impl errors - - Code - betweenness_cutoff_impl(graph = NULL, cutoff = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# betweenness_subset_impl basic - - Code - betweenness_subset_impl(graph = g) - Output - [1] 0 1 0 - -# betweenness_subset_impl errors - - Code - betweenness_subset_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# edge_betweenness_impl basic - - Code - edge_betweenness_impl(graph = g) - Output - [1] 2 2 - ---- - - Code - edge_betweenness_impl(graph = g, directed = FALSE) - Output - [1] 4 4 4 4 - -# edge_betweenness_impl errors - - Code - edge_betweenness_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# edge_betweenness_cutoff_impl basic - - Code - edge_betweenness_cutoff_impl(graph = g, cutoff = 2) - Output - [1] 2 2 - -# edge_betweenness_cutoff_impl errors - - Code - edge_betweenness_cutoff_impl(graph = NULL, cutoff = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# edge_betweenness_subset_impl basic - - Code - edge_betweenness_subset_impl(graph = g) - Output - [1] 2 2 - -# edge_betweenness_subset_impl errors - - Code - edge_betweenness_subset_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# harmonic_centrality_cutoff_impl basic - - Code - harmonic_centrality_cutoff_impl(graph = g, cutoff = 2) - Output - [1] 1.5 2.0 1.5 - -# harmonic_centrality_cutoff_impl errors - - Code - harmonic_centrality_cutoff_impl(graph = NULL, cutoff = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# personalized_pagerank_impl basic - - Code - personalized_pagerank_impl(graph = g) - Output - $vector - [1] 0.2567568 0.4864865 0.2567568 - - $value - [1] 1 - - $options - NULL - - ---- - - Code - personalized_pagerank_impl(graph = g, algo = "arpack", damping = 0.9) - Output - $vector - [1] 0.2543860 0.4912281 0.2543860 - - $value - [1] 1 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 3 - - $options$which - [1] "LR" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 0 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 1 - - $options$numop - [1] 3 - - $options$numopb - [1] 0 - - $options$numreo - [1] 3 - - - -# personalized_pagerank_impl errors - - Code - personalized_pagerank_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# personalized_pagerank_vs_impl basic - - Code - personalized_pagerank_vs_impl(graph = g, reset_vids = 1) - Output - [1] 0.3452703 0.4594595 0.1952703 - ---- - - Code - personalized_pagerank_vs_impl(graph = g, algo = "arpack", reset_vids = 1, - details = TRUE) - Output - $vector - [1] 0.3452703 0.4594595 0.1952703 - - $value - [1] 1 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 3 - - $options$which - [1] "LR" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 0 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 1 - - $options$numop - [1] 3 - - $options$numopb - [1] 0 - - $options$numreo - [1] 3 - - - -# personalized_pagerank_vs_impl errors - - Code - personalized_pagerank_vs_impl(graph = NULL, reset_vids = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# induced_subgraph_impl basic - - Code - induced_subgraph_impl(graph = g, vids = 1:2) - Output - IGRAPH U--- 2 1 -- - + edge: - [1] 1--2 - -# induced_subgraph_impl errors - - Code - induced_subgraph_impl(graph = NULL, vids = 1:2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# subgraph_from_edges_impl basic - - Code - subgraph_from_edges_impl(graph = g, eids = 1) - Output - IGRAPH U--- 2 1 -- - + edge: - [1] 1--2 - -# subgraph_from_edges_impl errors - - Code - subgraph_from_edges_impl(graph = NULL, eids = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# reverse_edges_impl basic - - Code - reverse_edges_impl(graph = g) - Output - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - -# reverse_edges_impl errors - - Code - reverse_edges_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# path_length_hist_impl basic - - Code - path_length_hist_impl(graph = g) - Output - $res - [1] 2 1 - - $unconnected - [1] 0 - - ---- - - Code - path_length_hist_impl(graph = g, directed = FALSE) - Output - $res - [1] 2 1 - - $unconnected - [1] 0 - - -# path_length_hist_impl errors - - Code - path_length_hist_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# simplify_impl basic - - Code - simplify_impl(graph = g) - Output - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - ---- - - Code - simplify_impl(graph = g, remove_multiple = FALSE, remove_loops = FALSE) - Output - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - -# simplify_impl errors - - Code - simplify_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# transitivity_undirected_impl basic - - Code - transitivity_undirected_impl(graph = g) - Output - [1] 0 - ---- - - Code - transitivity_undirected_impl(graph = g, mode = "zero") - Output - [1] 0 - -# transitivity_undirected_impl errors - - Code - transitivity_undirected_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# transitivity_local_undirected_impl basic - - Code - transitivity_local_undirected_impl(graph = g) - Output - [1] NaN 0 NaN - ---- - - Code - transitivity_local_undirected_impl(graph = g, mode = "zero") - Output - [1] 0 0 0 - -# transitivity_local_undirected_impl errors - - Code - transitivity_local_undirected_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# transitivity_avglocal_undirected_impl basic - - Code - transitivity_avglocal_undirected_impl(graph = g) - Output - [1] 0 - ---- - - Code - transitivity_avglocal_undirected_impl(graph = g, mode = "zero") - Output - [1] 0 - -# transitivity_avglocal_undirected_impl errors - - Code - transitivity_avglocal_undirected_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# transitivity_barrat_impl basic - - Code - transitivity_barrat_impl(graph = g) - Condition - Warning in `transitivity_barrat_impl()`: - No weights given for Barrat's transitivity, unweighted version is used. - Source: properties/triangles.c:913 - Output - [1] NaN 0 NaN - ---- - - Code - transitivity_barrat_impl(graph = g, mode = "zero") - Condition - Warning in `transitivity_barrat_impl()`: - No weights given for Barrat's transitivity, unweighted version is used. - Source: properties/triangles.c:913 - Output - [1] 0 0 0 - -# transitivity_barrat_impl errors - - Code - transitivity_barrat_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# ecc_impl basic - - Code - ecc_impl(graph = g) - Output - [1] NaN 0 NaN - ---- - - Code - ecc_impl(graph = g, k = 3, offset = TRUE, normalize = FALSE) - Output - [1] 1 1 1 - -# ecc_impl errors - - Code - ecc_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# reciprocity_impl basic - - Code - reciprocity_impl(graph = g) - Output - [1] 1 - ---- - - Code - reciprocity_impl(graph = g, ignore_loops = FALSE, mode = "ratio") - Output - [1] 1 - -# reciprocity_impl errors - - Code - reciprocity_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# maxdegree_impl basic - - Code - maxdegree_impl(graph = g) - Output - [1] 2 - ---- - - Code - maxdegree_impl(graph = g, mode = "in", loops = FALSE) - Output - [1] 2 - -# maxdegree_impl errors - - Code - maxdegree_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# density_impl basic - - Code - density_impl(graph = g) - Output - [1] 0.6666667 - ---- - - Code - density_impl(graph = g, loops = TRUE) - Output - [1] 0.3333333 - -# density_impl errors - - Code - density_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# mean_degree_impl basic - - Code - mean_degree_impl(graph = g) - Output - [1] 1.333333 - ---- - - Code - mean_degree_impl(graph = g, loops = FALSE) - Output - [1] 1.333333 - -# mean_degree_impl errors - - Code - mean_degree_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# feedback_arc_set_impl basic - - Code - feedback_arc_set_impl(graph = g) - Output - + 0/2 edges: - ---- - - Code - feedback_arc_set_impl(graph = g, algo = "exact_ip") - Output - + 0/2 edges: - -# feedback_arc_set_impl errors - - Code - feedback_arc_set_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# feedback_vertex_set_impl basic - - Code - feedback_vertex_set_impl(graph = g) - Output - + 0/3 vertices: - -# feedback_vertex_set_impl errors - - Code - feedback_vertex_set_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_loop_impl basic - - Code - is_loop_impl(graph = g) - Output - [1] FALSE FALSE - -# is_loop_impl errors - - Code - is_loop_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_dag_impl basic - - Code - is_dag_impl(graph = g) - Output - [1] FALSE - -# is_dag_impl errors - - Code - is_dag_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_acyclic_impl basic - - Code - is_acyclic_impl(graph = g) - Output - [1] TRUE - -# is_acyclic_impl errors - - Code - is_acyclic_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_simple_impl basic - - Code - is_simple_impl(graph = g) - Output - [1] TRUE - -# is_simple_impl errors - - Code - is_simple_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_multiple_impl basic - - Code - is_multiple_impl(graph = g) - Output - [1] FALSE FALSE - -# is_multiple_impl errors - - Code - is_multiple_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# has_loop_impl basic - - Code - has_loop_impl(graph = g) - Output - [1] FALSE - -# has_loop_impl errors - - Code - has_loop_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# has_multiple_impl basic - - Code - has_multiple_impl(graph = g) - Output - [1] FALSE - -# has_multiple_impl errors - - Code - has_multiple_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# count_loops_impl basic - - Code - count_loops_impl(graph = g) - Output - [1] 0 - -# count_loops_impl errors - - Code - count_loops_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# count_multiple_impl basic - - Code - count_multiple_impl(graph = g) - Output - [1] 1 1 - -# count_multiple_impl errors - - Code - count_multiple_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_perfect_impl basic - - Code - is_perfect_impl(graph = g) - Output - [1] TRUE - -# is_perfect_impl errors - - Code - is_perfect_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# eigenvector_centrality_impl basic - - Code - eigenvector_centrality_impl(graph = g) - Output - $vector - [1] 0.7071068 1.0000000 0.7071068 - - $value - [1] 1.414214 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 3 - - $options$which - [1] "LA" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 0 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 1 - - $options$numop - [1] 3 - - $options$numopb - [1] 0 - - $options$numreo - [1] 3 - - - ---- - - Code - eigenvector_centrality_impl(graph = g, directed = TRUE, scale = FALSE) - Output - $vector - [1] 0.5000000 0.7071068 0.5000000 - - $value - [1] 1.414214 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 3 - - $options$which - [1] "LA" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 0 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 1 - - $options$numop - [1] 3 - - $options$numopb - [1] 0 - - $options$numreo - [1] 3 - - - -# eigenvector_centrality_impl errors - - Code - eigenvector_centrality_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# hub_and_authority_scores_impl basic - - Code - hub_and_authority_scores_impl(graph = g) - Output - $hub - [1] 1 1 1 1 1 - - $authority - [1] 1 1 1 1 1 - - $value - [1] 16 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 5 - - $options$which - [1] "LA" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 0 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 1 - - $options$numop - [1] 4 - - $options$numopb - [1] 0 - - $options$numreo - [1] 4 - - - ---- - - Code - hub_and_authority_scores_impl(graph = g, scale = FALSE) - Output - $hub - [1] 0.4472136 0.4472136 0.4472136 0.4472136 0.4472136 - - $authority - [1] 0.4472136 0.4472136 0.4472136 0.4472136 0.4472136 - - $value - [1] 16 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 5 - - $options$which - [1] "LA" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 0 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 1 - - $options$numop - [1] 4 - - $options$numopb - [1] 0 - - $options$numreo - [1] 4 - - - -# hub_and_authority_scores_impl errors - - Code - hub_and_authority_scores_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# unfold_tree_impl basic - - Code - unfold_tree_impl(graph = g, roots = 1) - Output - $tree - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - - $vertex_index - [1] 1 2 3 - - ---- - - Code - unfold_tree_impl(graph = g, mode = "in", roots = 1) - Output - $tree - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - - $vertex_index - [1] 1 2 3 - - -# unfold_tree_impl errors - - Code - unfold_tree_impl(graph = NULL, roots = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_mutual_impl basic - - Code - is_mutual_impl(graph = g) - Output - [1] TRUE TRUE - ---- - - Code - is_mutual_impl(graph = g, loops = FALSE) - Output - [1] TRUE TRUE - -# is_mutual_impl errors - - Code - is_mutual_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# has_mutual_impl basic - - Code - has_mutual_impl(graph = g) - Output - [1] TRUE - ---- - - Code - has_mutual_impl(graph = g, loops = FALSE) - Output - [1] TRUE - -# has_mutual_impl errors - - Code - has_mutual_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# maximum_cardinality_search_impl basic - - Code - maximum_cardinality_search_impl(graph = g) - Output - $alpha - [1] 3 2 1 - - $alpham1 - + 3/3 vertices: - [1] 3 2 1 - - -# maximum_cardinality_search_impl errors - - Code - maximum_cardinality_search_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# avg_nearest_neighbor_degree_impl basic - - Code - avg_nearest_neighbor_degree_impl(graph = g) - Output - $knn - [1] 2 1 2 - - $knnk - [1] 2 1 - - ---- - - Code - avg_nearest_neighbor_degree_impl(graph = g, mode = "in", neighbor_degree_mode = "out") - Output - $knn - [1] 2 1 2 - - $knnk - [1] 2 1 - - -# avg_nearest_neighbor_degree_impl errors - - Code - avg_nearest_neighbor_degree_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# degree_correlation_vector_impl basic - - Code - degree_correlation_vector_impl(graph = g) - Output - [1] NaN 2 1 - ---- - - Code - degree_correlation_vector_impl(graph = g, from_mode = "in", to_mode = "out", - directed_neighbors = FALSE) - Output - [1] NaN 2 1 - -# degree_correlation_vector_impl errors - - Code - degree_correlation_vector_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# rich_club_sequence_impl basic - - Code - rich_club_sequence_impl(graph = g, vertex_order = 1:3) - Output - [1] 0.6666667 1.0000000 NaN - ---- - - Code - rich_club_sequence_impl(graph = g, vertex_order = 1:3, normalized = FALSE, - loops = TRUE, directed = FALSE) - Output - [1] 2 1 0 - -# rich_club_sequence_impl errors - - Code - rich_club_sequence_impl(graph = NULL, vertex_order = 1:3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# strength_impl basic - - Code - strength_impl(graph = g) - Output - [1] 1 2 1 - ---- - - Code - strength_impl(graph = g, mode = "in", loops = FALSE) - Output - [1] 1 2 1 - -# strength_impl errors - - Code - strength_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# centralization_impl basic - - Code - centralization_impl(scores = c(1, 2, 3)) - Output - [1] Inf - ---- - - Code - centralization_impl(scores = c(1, 2, 3), theoretical_max = 2, normalized = FALSE) - Output - [1] 3 - -# centralization_impl errors - - Code - centralization_impl(scores = package_version("1.2.3")) - Condition - Error in `centralization_impl()`: - ! 'list' object cannot be coerced to type 'double' - -# centralization_degree_impl basic - - Code - centralization_degree_impl(graph = g) - Output - $res - [1] 1 2 1 - - $centralization - [1] 0.3333333 - - $theoretical_max - [1] 6 - - ---- - - Code - centralization_degree_impl(graph = g, mode = "in", loops = FALSE, normalized = FALSE) - Output - $res - [1] 1 2 1 - - $centralization - [1] 2 - - $theoretical_max - [1] 2 - - -# centralization_degree_impl errors - - Code - centralization_degree_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# centralization_degree_tmax_impl basic - - Code - centralization_degree_tmax_impl(nodes = 3, loops = TRUE) - Output - [1] 6 - ---- - - Code - centralization_degree_tmax_impl(nodes = 3, mode = "in", loops = FALSE) - Output - [1] 4 - -# centralization_degree_tmax_impl errors - - Code - centralization_degree_tmax_impl(nodes = -1, loops = TRUE) - Condition - Error in `centralization_degree_tmax_impl()`: - ! Number of vertices must not be negative. Invalid value - Source: : - -# centralization_betweenness_impl basic - - Code - centralization_betweenness_impl(graph = g) - Output - $res - [1] 0 1 0 - - $centralization - [1] 1 - - $theoretical_max - [1] 2 - - ---- - - Code - centralization_betweenness_impl(graph = g, directed = FALSE, normalized = FALSE) - Output - $res - [1] 0 1 0 - - $centralization - [1] 2 - - $theoretical_max - [1] 2 - - -# centralization_betweenness_impl errors - - Code - centralization_betweenness_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# centralization_betweenness_tmax_impl basic - - Code - centralization_betweenness_tmax_impl(nodes = 3, directed = TRUE) - Output - [1] 4 - ---- - - Code - centralization_betweenness_tmax_impl(nodes = 3, directed = FALSE) - Output - [1] 2 - -# centralization_betweenness_tmax_impl errors - - Code - centralization_betweenness_tmax_impl(nodes = -1, directed = TRUE) - Condition - Error in `centralization_betweenness_tmax_impl()`: - ! Number of vertices must not be negative. Invalid value - Source: : - -# centralization_closeness_impl basic - - Code - centralization_closeness_impl(graph = g) - Output - $res - [1] 0.6666667 1.0000000 0.6666667 - - $centralization - [1] 1 - - $theoretical_max - [1] 0.6666667 - - ---- - - Code - centralization_closeness_impl(graph = g, mode = "in", normalized = FALSE) - Output - $res - [1] 0.6666667 1.0000000 0.6666667 - - $centralization - [1] 0.6666667 - - $theoretical_max - [1] 0.6666667 - - -# centralization_closeness_impl errors - - Code - centralization_closeness_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# centralization_closeness_tmax_impl basic - - Code - centralization_closeness_tmax_impl(nodes = 3) - Output - [1] 1.333333 - ---- - - Code - centralization_closeness_tmax_impl(nodes = 3, mode = "in") - Output - [1] 1.333333 - -# centralization_closeness_tmax_impl errors - - Code - centralization_closeness_tmax_impl(nodes = -1) - Condition - Error in `centralization_closeness_tmax_impl()`: - ! Number of vertices must not be negative. Invalid value - Source: : - -# centralization_eigenvector_centrality_impl basic - - Code - centralization_eigenvector_centrality_impl(graph = g) - Output - $vector - [1] 0.7071068 1.0000000 0.7071068 - - $value - [1] 1.414214 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 3 - - $options$which - [1] "LA" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 0 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 1 - - $options$numop - [1] 3 - - $options$numopb - [1] 0 - - $options$numreo - [1] 3 - - - $centralization - [1] 0.5857864 - - $theoretical_max - [1] 1 - - ---- - - Code - centralization_eigenvector_centrality_impl(graph = g, directed = TRUE, - normalized = FALSE) - Output - $vector - [1] 0.7071068 1.0000000 0.7071068 - - $value - [1] 1.414214 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 3 - - $options$which - [1] "LA" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 0 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 1 - - $options$numop - [1] 3 - - $options$numopb - [1] 0 - - $options$numreo - [1] 3 - - - $centralization - [1] 0.5857864 - - $theoretical_max - [1] 1 - - -# centralization_eigenvector_centrality_impl errors - - Code - centralization_eigenvector_centrality_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# centralization_eigenvector_centrality_tmax_impl basic - - Code - centralization_eigenvector_centrality_tmax_impl(nodes = 3) - Output - [1] 1 - ---- - - Code - centralization_eigenvector_centrality_tmax_impl(nodes = 3, directed = TRUE) - Output - [1] 2 - -# centralization_eigenvector_centrality_tmax_impl errors - - Code - centralization_eigenvector_centrality_tmax_impl(nodes = -1) - Condition - Error in `centralization_eigenvector_centrality_tmax_impl()`: - ! Number of vertices must not be negative. Invalid value - Source: : - -# assortativity_nominal_impl basic - - Code - assortativity_nominal_impl(graph = g, types = c(1, 2, 1)) - Output - [1] -1 - ---- - - Code - assortativity_nominal_impl(graph = g, types = c(1, 2, 1), directed = FALSE, - normalized = FALSE) - Output - [1] -0.5 - -# assortativity_nominal_impl errors - - Code - assortativity_nominal_impl(graph = NULL, types = c(1, 2, 1)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# assortativity_impl basic - - Code - assortativity_impl(graph = g, values = c(1, 2, 1)) - Output - [1] -1 - ---- - - Code - assortativity_impl(graph = g, values = c(1, 2, 1), directed = FALSE, - normalized = FALSE) - Output - [1] -0.25 - -# assortativity_impl errors - - Code - assortativity_impl(graph = NULL, values = c(1, 2, 1)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# assortativity_degree_impl basic - - Code - assortativity_degree_impl(graph = g) - Output - [1] -1 - ---- - - Code - assortativity_degree_impl(graph = g, directed = FALSE) - Output - [1] -1 - -# assortativity_degree_impl errors - - Code - assortativity_degree_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# joint_degree_matrix_impl basic - - Code - joint_degree_matrix_impl(graph = g) - Output - [,1] [,2] - [1,] 0 2 - [2,] 2 0 - ---- - - Code - joint_degree_matrix_impl(graph = g, max_out_degree = 2, max_in_degree = 2) - Output - [,1] [,2] - [1,] 0 2 - [2,] 2 0 - -# joint_degree_matrix_impl errors - - Code - joint_degree_matrix_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# joint_degree_distribution_impl basic - - Code - joint_degree_distribution_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] 0 0.0 0.0 - [2,] 0 0.0 0.5 - [3,] 0 0.5 0.0 - ---- - - Code - 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 - [,1] [,2] [,3] - [1,] 0 0 0 - [2,] 0 0 2 - [3,] 0 2 0 - -# joint_degree_distribution_impl errors - - Code - joint_degree_distribution_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# joint_type_distribution_impl basic - - Code - joint_type_distribution_impl(graph = g, from_types = c(1, 2, 1)) - Output - [,1] [,2] - [1,] 0.0 0.5 - [2,] 0.5 0.0 - ---- - - Code - 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 - [2,] 2 0 - -# joint_type_distribution_impl errors - - Code - joint_type_distribution_impl(graph = NULL, from_types = c(1, 2, 1)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# contract_vertices_impl basic - - Code - contract_vertices_impl(graph = g, mapping = c(1, 1, 2)) - Output - IGRAPH U--- 2 2 -- - + edges: - [1] 1--1 1--2 - -# contract_vertices_impl errors - - Code - contract_vertices_impl(graph = NULL, mapping = c(1, 1, 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# eccentricity_dijkstra_impl basic - - Code - eccentricity_dijkstra_impl(graph = g) - Output - [1] 2 1 2 - ---- - - Code - eccentricity_dijkstra_impl(graph = g, mode = "in") - Output - [1] 2 1 2 - -# eccentricity_dijkstra_impl errors - - Code - eccentricity_dijkstra_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# graph_center_dijkstra_impl basic - - Code - graph_center_dijkstra_impl(graph = g) - Output - + 1/3 vertex: - [1] 2 - ---- - - Code - graph_center_dijkstra_impl(graph = g, mode = "in") - Output - + 1/3 vertex: - [1] 2 - -# graph_center_dijkstra_impl errors - - Code - graph_center_dijkstra_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# radius_dijkstra_impl basic - - Code - radius_dijkstra_impl(graph = g) - Output - [1] 1 - ---- - - Code - radius_dijkstra_impl(graph = g, mode = "in") - Output - [1] 1 - -# radius_dijkstra_impl errors - - Code - radius_dijkstra_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# pseudo_diameter_impl basic - - Code - pseudo_diameter_impl(graph = g, start_vid = 1) - Output - $diameter - [1] 2 - - $from - [1] 0 - - $to - [1] 2 - - ---- - - Code - pseudo_diameter_impl(graph = g, start_vid = 1, directed = FALSE, unconnected = FALSE) - Output - $diameter - [1] 2 - - $from - [1] 0 - - $to - [1] 2 - - -# pseudo_diameter_impl errors - - Code - pseudo_diameter_impl(graph = NULL, start_vid = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# pseudo_diameter_dijkstra_impl basic - - Code - pseudo_diameter_dijkstra_impl(graph = g, start_vid = 1) - Output - $diameter - [1] 2 - - $from - [1] 0 - - $to - [1] 2 - - ---- - - Code - pseudo_diameter_dijkstra_impl(graph = g, start_vid = 1, directed = FALSE, - unconnected = FALSE) - Output - $diameter - [1] 2 - - $from - [1] 0 - - $to - [1] 2 - - -# pseudo_diameter_dijkstra_impl errors - - Code - pseudo_diameter_dijkstra_impl(graph = NULL, start_vid = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# diversity_impl basic - - Code - diversity_impl(graph = g) - Output - [1] 0.0000000 0.9182958 0.0000000 - -# diversity_impl errors - - Code - diversity_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# random_walk_impl basic - - Code - random_walk_impl(graph = g, start = 1, steps = 2) - Output - $vertices - + 3/3 vertices: - [1] 1 2 3 - - $edges - + 2/2 edges: - [1] 1--2 2--3 - - ---- - - Code - random_walk_impl(graph = g, start = 1, steps = 2, mode = "in", stuck = "error") - Output - $vertices - + 3/3 vertices: - [1] 1 2 1 - - $edges - + 2/2 edges: - [1] 1--2 1--2 - - -# random_walk_impl errors - - Code - random_walk_impl(graph = NULL, start = 1, steps = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# global_efficiency_impl basic - - Code - global_efficiency_impl(graph = g) - Output - [1] 0.8333333 - ---- - - Code - global_efficiency_impl(graph = g, directed = FALSE) - Output - [1] 0.8333333 - -# global_efficiency_impl errors - - Code - global_efficiency_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# local_efficiency_impl basic - - Code - local_efficiency_impl(graph = g) - Output - [1] 0 0 0 - ---- - - Code - local_efficiency_impl(graph = g, directed = FALSE, mode = "in") - Output - [1] 0 0 0 - -# local_efficiency_impl errors - - Code - local_efficiency_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# average_local_efficiency_impl basic - - Code - average_local_efficiency_impl(graph = g) - Output - [1] 0 - ---- - - Code - average_local_efficiency_impl(graph = g, directed = FALSE, mode = "in") - Output - [1] 0 - -# average_local_efficiency_impl errors - - Code - average_local_efficiency_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# transitive_closure_dag_impl basic - - Code - transitive_closure_dag_impl(graph = g) - Output - IGRAPH D--- 3 3 -- - + edges: - [1] 1->3 1->2 2->3 - -# transitive_closure_dag_impl errors - - Code - transitive_closure_dag_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# transitive_closure_impl basic - - Code - transitive_closure_impl(graph = g) - Output - IGRAPH U--- 3 3 -- - + edges: - [1] 1--2 1--3 2--3 - -# transitive_closure_impl errors - - Code - transitive_closure_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# trussness_impl basic - - Code - trussness_impl(graph = g) - Output - [1] 2 2 - -# trussness_impl errors - - Code - trussness_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_graphical_impl basic - - Code - is_graphical_impl(out_deg = c(2, 2, 2)) - Output - [1] TRUE - ---- - - Code - is_graphical_impl(out_deg = c(2, 2, 2), in_deg = c(1, 1, 1), - allowed_edge_types = "all") - Output - [1] FALSE - -# is_graphical_impl errors - - Code - is_graphical_impl(out_deg = "a") - Condition - Warning in `is_graphical_impl()`: - NAs introduced by coercion - Error in `is_graphical_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# bfs_simple_impl basic - - Code - bfs_simple_impl(graph = g, root = 1) - Output - $order - + 3/3 vertices: - [1] 1 2 3 - - $layers - [1] 0 1 2 3 - - $parents - [1] -1 0 1 - - ---- - - Code - bfs_simple_impl(graph = g, root = 1, mode = "in") - Output - $order - + 3/3 vertices: - [1] 1 2 3 - - $layers - [1] 0 1 2 3 - - $parents - [1] -1 0 1 - - -# bfs_simple_impl errors - - Code - bfs_simple_impl(graph = NULL, root = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# bipartite_projection_size_impl basic - - Code - bipartite_projection_size_impl(graph = g) - Output - $vcount1 - [1] 2 - - $ecount1 - [1] 1 - - $vcount2 - [1] 2 - - $ecount2 - [1] 1 - - -# bipartite_projection_size_impl errors - - Code - bipartite_projection_size_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# biadjacency_impl basic - - Code - biadjacency_impl(incidence = m) - Output - $graph - IGRAPH U--- 5 4 -- - + edges: - [1] 1--3 1--4 1--5 2--5 - - $types - [1] FALSE FALSE TRUE TRUE TRUE - - ---- - - Code - biadjacency_impl(incidence = m, directed = TRUE, mode = "in", multiple = TRUE) - Output - $graph - IGRAPH D--- 5 4 -- - + edges: - [1] 3->1 4->1 5->1 5->2 - - $types - [1] FALSE FALSE TRUE TRUE TRUE - - -# biadjacency_impl errors - - Code - biadjacency_impl(incidence = "a") - Condition - Warning in `biadjacency_impl()`: - NAs introduced by coercion - Error in `biadjacency_impl()`: - ! REAL() can only be applied to a 'numeric', not a 'character' - -# get_biadjacency_impl basic - - Code - get_biadjacency_impl(graph = g, types = c(TRUE, FALSE, TRUE)) - Output - $res - [,1] [,2] - [1,] 1 1 - - $row_ids - [1] 2 - - $col_ids - [1] 1 3 - - -# get_biadjacency_impl errors - - Code - get_biadjacency_impl(graph = NULL, types = c(TRUE, FALSE, TRUE)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_bipartite_impl basic - - Code - is_bipartite_impl(graph = g) - Output - $res - [1] TRUE - - $type - [1] FALSE TRUE FALSE - - -# is_bipartite_impl errors - - Code - is_bipartite_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# bipartite_game_gnp_impl basic - - Code - bipartite_game_gnp_impl(n1 = 2, n2 = 2, p = 0.5) - Output - $graph - IGRAPH U--- 4 4 -- - + edges: - [1] 1--3 2--3 1--4 2--4 - - $types - [1] FALSE FALSE TRUE TRUE - - ---- - - Code - bipartite_game_gnp_impl(n1 = 2, n2 = 2, p = 0.5, directed = TRUE, mode = "in") - Output - $graph - IGRAPH D--- 4 1 -- - + edge: - [1] 3->2 - - $types - [1] FALSE FALSE TRUE TRUE - - -# bipartite_game_gnp_impl errors - - Code - bipartite_game_gnp_impl(n1 = -1, n2 = 2, p = 0.5) - Condition - Error in `bipartite_game_gnp_impl()`: - ! Invalid number of vertices for bipartite graph. Invalid value - Source: : - -# bipartite_game_gnm_impl basic - - Code - bipartite_game_gnm_impl(n1 = 2, n2 = 2, m = 1) - Output - $graph - IGRAPH U--- 4 1 -- - + edge: - [1] 2--4 - - $types - [1] FALSE FALSE TRUE TRUE - - ---- - - Code - bipartite_game_gnm_impl(n1 = 2, n2 = 2, m = 1, directed = TRUE, mode = "in") - Output - $graph - IGRAPH D--- 4 1 -- - + edge: - [1] 3->1 - - $types - [1] FALSE FALSE TRUE TRUE - - -# bipartite_game_gnm_impl errors - - Code - bipartite_game_gnm_impl(n1 = -1, n2 = 2, m = 1) - Condition - Error in `bipartite_game_gnm_impl()`: - ! Invalid number of vertices for bipartite graph. Invalid value - Source: : - -# get_laplacian_impl basic - - Code - get_laplacian_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] 1 -1 0 - [2,] -1 2 -1 - [3,] 0 -1 1 - ---- - - Code - get_laplacian_impl(graph = g, mode = "in", normalization = "symmetric", - weights = c(1, 2)) - Output - [,1] [,2] [,3] - [1,] 1.0000000 -0.5773503 0.0000000 - [2,] -0.5773503 1.0000000 -0.8164966 - [3,] 0.0000000 -0.8164966 1.0000000 - -# get_laplacian_impl errors - - Code - get_laplacian_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_laplacian_sparse_impl basic - - Code - get_laplacian_sparse_impl(graph = g) - Output - $type - [1] "triplet" - - $dim - [1] 3 3 - - $p - [1] 0 1 2 0 1 1 2 - - $i - [1] 0 1 2 1 0 2 1 - - $x - [1] 1 2 1 -1 -1 -1 -1 - - attr(,"class") - [1] "igraph.tmp.sparse" - ---- - - Code - get_laplacian_sparse_impl(graph = g, mode = "in", normalization = "symmetric", - weights = c(1, 2)) - Output - $type - [1] "triplet" - - $dim - [1] 3 3 - - $p - [1] 0 1 2 0 1 1 2 - - $i - [1] 0 1 2 1 0 2 1 - - $x - [1] 1.0000000 1.0000000 1.0000000 -0.5773503 -0.5773503 -0.8164966 -0.8164966 - - attr(,"class") - [1] "igraph.tmp.sparse" - -# get_laplacian_sparse_impl errors - - Code - get_laplacian_sparse_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# connected_components_impl basic - - Code - connected_components_impl(graph = g) - Output - [1] 0 0 0 - ---- - - Code - connected_components_impl(graph = g, mode = "strong", details = TRUE) - Output - $membership - [1] 0 0 0 - - $csize - [1] 3 - - $no - [1] 1 - - -# connected_components_impl errors - - Code - connected_components_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_connected_impl basic - - Code - is_connected_impl(graph = g) - Output - [1] TRUE - ---- - - Code - is_connected_impl(graph = g, mode = "strong") - Output - [1] TRUE - -# is_connected_impl errors - - Code - is_connected_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# articulation_points_impl basic - - Code - articulation_points_impl(graph = g) - Output - + 1/3 vertex: - [1] 2 - -# articulation_points_impl errors - - Code - articulation_points_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# biconnected_components_impl basic - - Code - biconnected_components_impl(graph = g) - Output - $no - [1] 2 - - $tree_edges - $tree_edges[[1]] - + 1/2 edge: - [1] 2--3 - - $tree_edges[[2]] - + 1/2 edge: - [1] 1--2 - - - $component_edges - $component_edges[[1]] - + 1/2 edge: - [1] 2--3 - - $component_edges[[2]] - + 1/2 edge: - [1] 1--2 - - - $components - $components[[1]] - + 2/3 vertices: - [1] 3 2 - - $components[[2]] - + 2/3 vertices: - [1] 2 1 - - - $articulation_points - + 1/3 vertex: - [1] 2 - - -# biconnected_components_impl errors - - Code - biconnected_components_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# bridges_impl basic - - Code - bridges_impl(graph = g) - Output - + 2/2 edges: - [1] 2--3 1--2 - -# bridges_impl errors - - Code - bridges_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_biconnected_impl basic - - Code - is_biconnected_impl(graph = g) - Output - [1] FALSE - -# is_biconnected_impl errors - - Code - is_biconnected_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# count_reachable_impl basic - - Code - count_reachable_impl(graph = g, mode = "out") - Output - [1] 5 5 5 5 5 - ---- - - Code - count_reachable_impl(graph = g, mode = "in") - Output - [1] 5 5 5 5 5 - -# count_reachable_impl errors - - Code - count_reachable_impl(graph = NULL, mode = "out") - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# bond_percolation_impl basic - - Code - bond_percolation_impl(graph = g) - Output - $giant_size - numeric(0) - - $vetex_count - numeric(0) - - -# bond_percolation_impl errors - - Code - bond_percolation_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# site_percolation_impl basic - - Code - site_percolation_impl(graph = g) - Output - $giant_size - [1] 1 2 3 - - $edge_count - [1] 0 1 2 - - -# site_percolation_impl errors - - Code - site_percolation_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# edgelist_percolation_impl basic - - Code - edgelist_percolation_impl(edges = matrix(c(1, 2, 2, 3), ncol = 2)) - Output - $giant_size - [1] 2 3 - - $vertex_count - [1] 2 3 - - -# edgelist_percolation_impl errors - - Code - edgelist_percolation_impl(edges = "a") - Condition - Error in `edges - 1`: - ! non-numeric argument to binary operator - -# is_clique_impl basic - - Code - is_clique_impl(graph = g, candidate = 1:2) - Output - [1] TRUE - ---- - - Code - is_clique_impl(graph = g, candidate = 1:2, directed = TRUE) - Output - [1] TRUE - -# is_clique_impl errors - - Code - is_clique_impl(graph = NULL, candidate = 1:2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# cliques_impl basic - - Code - cliques_impl(graph = g) - Output - [[1]] - + 1/3 vertex: - [1] 2 - - [[2]] - + 1/3 vertex: - [1] 3 - - [[3]] - + 2/3 vertices: - [1] 2 3 - - [[4]] - + 1/3 vertex: - [1] 1 - - [[5]] - + 2/3 vertices: - [1] 1 2 - - ---- - - Code - cliques_impl(graph = g, min = 2, max = 2) - Output - [[1]] - + 2/3 vertices: - [1] 2 3 - - [[2]] - + 2/3 vertices: - [1] 1 2 - - -# cliques_impl errors - - Code - cliques_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# clique_size_hist_impl basic - - Code - clique_size_hist_impl(graph = g) - Output - [1] 3 2 - ---- - - Code - clique_size_hist_impl(graph = g, min_size = 2, max_size = 2) - Output - [1] 0 2 - -# clique_size_hist_impl errors - - Code - clique_size_hist_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# largest_cliques_impl basic - - Code - largest_cliques_impl(graph = g) - Output - [[1]] - + 2/3 vertices: - [1] 1 2 - - [[2]] - + 2/3 vertices: - [1] 2 3 - - -# largest_cliques_impl errors - - Code - largest_cliques_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# maximal_cliques_hist_impl basic - - Code - maximal_cliques_hist_impl(graph = g) - Output - [1] 0 2 - ---- - - Code - maximal_cliques_hist_impl(graph = g, min_size = 2, max_size = 2) - Output - [1] 0 2 - -# maximal_cliques_hist_impl errors - - Code - maximal_cliques_hist_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# clique_number_impl basic - - Code - clique_number_impl(graph = g) - Output - [1] 2 - -# clique_number_impl errors - - Code - clique_number_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# weighted_cliques_impl basic - - Code - weighted_cliques_impl(graph = g) - Output - [[1]] - + 1/3 vertex: - [1] 2 - - [[2]] - + 1/3 vertex: - [1] 3 - - [[3]] - + 2/3 vertices: - [1] 2 3 - - [[4]] - + 1/3 vertex: - [1] 1 - - [[5]] - + 2/3 vertices: - [1] 1 2 - - ---- - - Code - weighted_cliques_impl(graph = g, vertex_weights = c(1, 2, 3), min_weight = 1, - max_weight = 3, maximal = TRUE) - Output - [[1]] - + 2/3 vertices: - [1] 1 2 - - -# weighted_cliques_impl errors - - Code - weighted_cliques_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# largest_weighted_cliques_impl basic - - Code - largest_weighted_cliques_impl(graph = g) - Output - [[1]] - + 2/3 vertices: - [1] 1 2 - - [[2]] - + 2/3 vertices: - [1] 2 3 - - ---- - - Code - largest_weighted_cliques_impl(graph = g, vertex_weights = c(1, 2, 3)) - Output - [[1]] - + 2/3 vertices: - [1] 2 3 - - -# largest_weighted_cliques_impl errors - - Code - largest_weighted_cliques_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# weighted_clique_number_impl basic - - Code - weighted_clique_number_impl(graph = g) - Output - [1] 2 - ---- - - Code - weighted_clique_number_impl(graph = g, vertex_weights = c(1, 2, 3)) - Output - [1] 5 - -# weighted_clique_number_impl errors - - Code - weighted_clique_number_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_independent_vertex_set_impl basic - - Code - is_independent_vertex_set_impl(graph = g, candidate = 1:2) - Output - [1] FALSE - -# is_independent_vertex_set_impl errors - - Code - is_independent_vertex_set_impl(graph = NULL, candidate = 1:2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_random_impl basic - - Code - layout_random_impl(graph = g) - Output - [,1] [,2] - [1,] 0.91714717 0.7003783 - [2,] -0.84358557 0.6509057 - [3,] -0.08120892 -0.8259847 - -# layout_random_impl errors - - Code - layout_random_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_circle_impl basic - - Code - layout_circle_impl(graph = g) - Output - [,1] [,2] - [1,] 1.0 0.0000000 - [2,] -0.5 0.8660254 - [3,] -0.5 -0.8660254 - ---- - - Code - layout_circle_impl(graph = g, order = 1:3) - Output - [,1] [,2] - [1,] 1.0 0.0000000 - [2,] -0.5 0.8660254 - [3,] -0.5 -0.8660254 - -# layout_circle_impl errors - - Code - layout_circle_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_star_impl basic - - Code - round(layout_star_impl(graph = g), 4) - Output - [,1] [,2] - [1,] 0 0 - [2,] 1 0 - [3,] -1 0 - ---- - - Code - round(layout_star_impl(graph = g, center = 1, order = 3:1), 4) - Output - [,1] [,2] - [1,] 0 0 - [2,] -1 0 - [3,] 1 0 - -# layout_star_impl errors - - Code - layout_star_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_grid_impl basic - - Code - layout_grid_impl(graph = g) - Output - [,1] [,2] - [1,] 0 0 - [2,] 1 0 - [3,] 0 1 - ---- - - Code - layout_grid_impl(graph = g, width = 2) - Output - [,1] [,2] - [1,] 0 0 - [2,] 1 0 - [3,] 0 1 - -# layout_grid_impl errors - - Code - layout_grid_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_grid_3d_impl basic - - Code - layout_grid_3d_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] 0 0 0 - [2,] 1 0 0 - [3,] 0 1 0 - ---- - - Code - layout_grid_3d_impl(graph = g, width = 2, height = 2) - Output - [,1] [,2] [,3] - [1,] 0 0 0 - [2,] 1 0 0 - [3,] 0 1 0 - -# layout_grid_3d_impl errors - - Code - layout_grid_3d_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# roots_for_tree_layout_impl basic - - Code - roots_for_tree_layout_impl(graph = g, mode = "out", heuristic = 1) - Output - + 1/3 vertex: - [1] 2 - -# roots_for_tree_layout_impl errors - - Code - roots_for_tree_layout_impl(graph = NULL, mode = "out", heuristic = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_random_3d_impl basic - - Code - layout_random_3d_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] 0.91714717 0.7003783 0.7338074 - [2,] -0.84358557 0.6509057 0.4644714 - [3,] -0.08120892 -0.8259847 0.5240391 - -# layout_random_3d_impl errors - - Code - layout_random_3d_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_sphere_impl basic - - Code - layout_sphere_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] 0.0000000 0.0000000 -1 - [2,] -0.4861377 0.8738822 0 - [3,] 0.0000000 0.0000000 1 - ---- - - Code - layout_sphere_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] 0.0000000 0.0000000 -1.0 - [2,] -0.2461774 0.8302992 -0.5 - [3,] -0.9468790 -0.3215901 0.0 - [4,] 0.5001161 -0.7070246 0.5 - [5,] 0.0000000 0.0000000 1.0 - -# layout_sphere_impl errors - - Code - layout_sphere_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_sugiyama_impl basic - - Code - layout_sugiyama_impl(graph = g) - Output - $res - [,1] [,2] - [1,] 0.0 1 - [2,] 0.5 0 - [3,] 1.0 1 - - $extd_graph - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - - $extd_to_orig_eids - [1] 1 2 - - ---- - - Code - layout_sugiyama_impl(graph = g, layers = 1:3, hgap = 2, vgap = 2, maxiter = 10, - weights = c(1, 2)) - Output - $res - [,1] [,2] - [1,] 0 0 - [2,] 0 2 - [3,] 0 4 - - $extd_graph - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - - $extd_to_orig_eids - [1] 1 2 - - -# layout_sugiyama_impl errors - - Code - layout_sugiyama_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_mds_impl basic - - Code - layout_mds_impl(graph = g) - Output - [,1] [,2] - [1,] 1 2.807594e-08 - [2,] 0 0.000000e+00 - [3,] -1 2.807594e-08 - ---- - - Code - layout_mds_impl(graph = g, dist = matrix(1:9, nrow = 3), dim = 3) - Output - [,1] [,2] [,3] - [1,] -2.907521 2.32638426 1.444979 - [2,] -3.900013 -1.63291106 2.258035 - [3,] 3.975674 0.09951448 3.271816 - -# layout_mds_impl errors - - Code - layout_mds_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_bipartite_impl basic - - Code - layout_bipartite_impl(graph = g, types = c(TRUE, FALSE, TRUE)) - Output - [,1] [,2] - [1,] 0.0 0 - [2,] 0.5 1 - [3,] 1.0 0 - ---- - - Code - layout_bipartite_impl(graph = g, types = c(TRUE, FALSE, TRUE), hgap = 2, vgap = 2, - maxiter = 10) - Output - [,1] [,2] - [1,] 0 0 - [2,] 1 2 - [3,] 2 0 - -# layout_bipartite_impl errors - - Code - layout_bipartite_impl(graph = NULL, types = c(TRUE, FALSE, TRUE)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_gem_impl basic - - Code - layout_gem_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2)) - Output - [,1] [,2] - [1,] 200.18284 -69.23950 - [2,] 86.00346 64.12806 - [3,] 66.22930 -92.94294 - ---- - - Code - 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] - [1,] 1.0114521 -0.1206363 - [2,] -0.2178589 2.9621162 - [3,] -0.7089555 -3.8896500 - -# layout_gem_impl errors - - Code - layout_gem_impl(graph = NULL, res = matrix(0, nrow = 3, ncol = 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_davidson_harel_impl basic - - Code - layout_davidson_harel_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2)) - Output - [,1] [,2] - [1,] 1.152116 0.9424808 - [2,] 2.474361 2.5195497 - [3,] 3.849187 4.0402661 - ---- - - Code - 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 - [,1] [,2] - [1,] -6.609493 -2.155221 - [2,] -8.660255 -3.797365 - [3,] -6.485087 -5.224752 - -# layout_davidson_harel_impl errors - - Code - layout_davidson_harel_impl(graph = NULL, res = matrix(0, nrow = 3, ncol = 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_umap_impl basic - - Code - layout_umap_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2), use_seed = TRUE) - Output - [,1] [,2] - [1,] 0 0 - [2,] 0 0 - [3,] 0 0 - ---- - - Code - 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] - [1,] 0 0 - [2,] 0 0 - [3,] 0 0 - -# layout_umap_impl errors - - Code - layout_umap_impl(graph = NULL, res = matrix(0, nrow = 3, ncol = 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_umap_3d_impl basic - - Code - layout_umap_3d_impl(graph = g, res = matrix(0, nrow = 3, ncol = 3), use_seed = TRUE) - Output - [,1] [,2] [,3] - [1,] 0 0 0 - [2,] 0 0 0 - [3,] 0 0 0 - ---- - - Code - 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] - [1,] 0 0 0 - [2,] 0 0 0 - [3,] 0 0 0 - -# layout_umap_3d_impl errors - - Code - layout_umap_3d_impl(graph = NULL, res = matrix(0, nrow = 3, ncol = 3)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_umap_compute_weights_impl basic - - Code - layout_umap_compute_weights_impl(graph = g, distances = 1:2, weights = 1:3) - Output - [1] 1 1 - -# layout_umap_compute_weights_impl errors - - Code - layout_umap_compute_weights_impl(graph = NULL, distances = 1:3, weights = 1:3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# layout_align_impl basic - - Code - layout_align_impl(graph = g, layout = matrix(0, nrow = 3, ncol = 2)) - Output - [,1] [,2] - [1,] 0 0 - [2,] 0 0 - [3,] 0 0 - -# layout_align_impl errors - - Code - layout_align_impl(graph = NULL, layout = matrix(0, nrow = 3, ncol = 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# similarity_dice_impl basic - - Code - similarity_dice_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] 1 0 1 - [2,] 0 1 0 - [3,] 1 0 1 - ---- - - Code - similarity_dice_impl(graph = g, vids = 1:2, mode = "in", loops = TRUE) - Output - [,1] [,2] - [1,] 1.0 0.8 - [2,] 0.8 1.0 - -# similarity_dice_impl errors - - Code - similarity_dice_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# similarity_dice_es_impl basic - - Code - similarity_dice_es_impl(graph = g) - Output - [1] 0 0 - ---- - - Code - similarity_dice_es_impl(graph = g, es = 1:2, mode = "in", loops = TRUE) - Output - [1] 0.8 0.8 - -# similarity_dice_es_impl errors - - Code - similarity_dice_es_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# similarity_dice_pairs_impl basic - - Code - similarity_dice_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) - Output - [1] 0 0 - ---- - - Code - similarity_dice_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2), - mode = "in", loops = TRUE) - Output - [1] 0.8000000 0.6666667 - -# similarity_dice_pairs_impl errors - - Code - similarity_dice_pairs_impl(graph = NULL, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# similarity_inverse_log_weighted_impl basic - - Code - similarity_inverse_log_weighted_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] 0.000000 0 1.442695 - [2,] 0.000000 0 0.000000 - [3,] 1.442695 0 0.000000 - ---- - - Code - similarity_inverse_log_weighted_impl(graph = g, vids = 1:2, mode = "in") - Output - [,1] [,2] [,3] - [1,] 0 0 1.442695 - [2,] 0 0 0.000000 - -# similarity_inverse_log_weighted_impl errors - - Code - similarity_inverse_log_weighted_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# similarity_jaccard_impl basic - - Code - similarity_jaccard_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] 1 0 1 - [2,] 0 1 0 - [3,] 1 0 1 - ---- - - Code - similarity_jaccard_impl(graph = g, vids = 1:2, mode = "in", loops = TRUE) - Output - [,1] [,2] - [1,] 1.0000000 0.6666667 - [2,] 0.6666667 1.0000000 - -# similarity_jaccard_impl errors - - Code - similarity_jaccard_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# similarity_jaccard_es_impl basic - - Code - similarity_jaccard_es_impl(graph = g) - Output - [1] 0 0 - ---- - - Code - similarity_jaccard_es_impl(graph = g, es = 1:2, mode = "in", loops = TRUE) - Output - [1] 0.6666667 0.6666667 - -# similarity_jaccard_es_impl errors - - Code - similarity_jaccard_es_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# similarity_jaccard_pairs_impl basic - - Code - similarity_jaccard_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) - Output - [1] 0 0 - ---- - - Code - similarity_jaccard_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2), - mode = "in", loops = TRUE) - Output - [1] 0.6666667 0.5000000 - -# similarity_jaccard_pairs_impl errors - - Code - similarity_jaccard_pairs_impl(graph = NULL, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# compare_communities_impl basic - - Code - compare_communities_impl(comm1 = c(1, 2, 1), comm2 = c(2, 1, 2)) - Output - [1] 0 - ---- - - Code - compare_communities_impl(comm1 = c(1, 2, 1), comm2 = c(2, 1, 2), method = "nmi") - Output - [1] 1 - ---- - - Code - compare_communities_impl(comm1 = comm1, comm2 = comm2, method = "vi") - Output - [1] 0.5493061 - -# compare_communities_impl errors - - Code - compare_communities_impl(comm1 = "a", comm2 = c(2, 1, 2)) - Condition - Warning in `compare_communities_impl()`: - NAs introduced by coercion - Error in `compare_communities_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# modularity_impl basic - - Code - modularity_impl(graph = g, membership = c(1, 2, 1)) - Output - [1] -0.5 - ---- - - Code - modularity_impl(graph = g, membership = c(1, 2, 1), weights = c(1, 2), - resolution = 0.5, directed = FALSE) - Output - [1] -0.25 - -# modularity_impl errors - - Code - modularity_impl(graph = NULL, membership = c(1, 2, 1)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# modularity_matrix_impl basic - - Code - modularity_matrix_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] -0.25 0.5 -0.25 - [2,] 0.50 -1.0 0.50 - [3,] -0.25 0.5 -0.25 - ---- - - Code - 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 - [2,] 0.75000000 -0.75 1.5000000 - [3,] -0.16666667 1.50 -0.3333333 - -# modularity_matrix_impl errors - - Code - modularity_matrix_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# community_fluid_communities_impl basic - - Code - community_fluid_communities_impl(graph = g, no_of_communities = 2) - Output - [1] 1 0 0 - -# community_fluid_communities_impl errors - - Code - community_fluid_communities_impl(graph = NULL, no_of_communities = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# community_label_propagation_impl basic - - Code - community_label_propagation_impl(graph = g) - Output - [1] 0 0 0 - ---- - - Code - 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 - -# community_label_propagation_impl errors - - Code - community_label_propagation_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# community_multilevel_impl basic - - Code - community_multilevel_impl(graph = g) - Output - $membership - [1] 0 0 0 - - $memberships - [,1] [,2] [,3] - [1,] 0 0 0 - - $modularity - [1] 0 - - ---- - - Code - community_multilevel_impl(graph = g, weights = c(1, 2), resolution = 0.5) - Output - $membership - [1] 0 0 0 - - $memberships - [,1] [,2] [,3] - [1,] 0 0 0 - - $modularity - [1] 0.5 - - -# community_multilevel_impl errors - - Code - community_multilevel_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# community_optimal_modularity_impl basic - - Code - community_optimal_modularity_impl(graph = g) - Output - $modularity - [1] 0 - - $membership - [1] 0 0 0 - - ---- - - Code - community_optimal_modularity_impl(graph = g, weights = c(1, 2)) - Output - $modularity - [1] 1.850372e-17 - - $membership - [1] 0 0 0 - - -# community_optimal_modularity_impl errors - - Code - community_optimal_modularity_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# community_leiden_impl basic - - Code - 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 - [1] 0 1 2 - - $nb_clusters - [1] 3 - - $quality - [1] -1.166667 - - -# community_leiden_impl errors - - Code - community_leiden_impl(graph = NULL, resolution = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# split_join_distance_impl basic - - Code - split_join_distance_impl(comm1 = c(1, 2, 1), comm2 = c(2, 1, 2)) - Output - $distance12 - [1] 0 - - $distance21 - [1] 0 - - -# split_join_distance_impl errors - - Code - split_join_distance_impl(comm1 = "a", comm2 = c(2, 1, 2)) - Condition - Warning in `split_join_distance_impl()`: - NAs introduced by coercion - Error in `split_join_distance_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# community_infomap_impl basic - - Code - community_infomap_impl(graph = g) - Output - $membership - [1] 0 0 0 - - $codelength - [1] 1.512987 - - ---- - - Code - community_infomap_impl(graph = g, e_weights = c(1, 2), v_weights = c(1, 2, 3), - nb_trials = 2) - Output - $membership - [1] 0 0 0 - - $codelength - [1] 1.462254 - - -# community_infomap_impl errors - - Code - community_infomap_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# graphlets_impl basic - - Code - graphlets_impl(graph = g) - Output - $cliques - $cliques[[1]] - + 2/3 vertices: - [1] 2 3 - - $cliques[[2]] - + 2/3 vertices: - [1] 1 2 - - - $Mu - [1] 0.6665667 0.3332333 - - ---- - - Code - graphlets_impl(graph = g, weights = c(3, 4), niter = 10) - Output - $cliques - $cliques[[1]] - + 2/3 vertices: - [1] 2 3 - - $cliques[[2]] - + 2/3 vertices: - [1] 1 2 - - - $Mu - [1] 1.333233 0.999900 - - -# graphlets_impl errors - - Code - graphlets_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# hrg_fit_impl basic - - Code - hrg_fit_impl(graph = g1) - Output - $left - [1] -2 0 - - $right - [1] 1 2 - - $prob - [1] 1 0 - - $edges - [1] 2 0 - - $vertices - [1] 3 2 - - -# hrg_fit_impl errors - - Code - hrg_fit_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# hrg_sample_impl basic - - Code - hrg_sample_impl(hrg = hrg_model) - Output - IGRAPH U--- 10 45 -- - + edges: - [1] 1-- 2 1-- 3 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--10 2-- 3 2-- 4 2-- 5 - [13] 2-- 6 2-- 7 2-- 8 2-- 9 2--10 3-- 4 3-- 5 3-- 6 3-- 7 3-- 8 3-- 9 3--10 - [25] 4-- 5 4-- 6 4-- 7 4-- 8 4-- 9 4--10 5-- 6 5-- 7 5-- 8 5-- 9 5--10 6-- 7 - [37] 6-- 8 6-- 9 6--10 7-- 8 7-- 9 7--10 8-- 9 8--10 9--10 - -# hrg_sample_impl errors - - Code - hrg_sample_impl(hrg = NULL) - Condition - Error in `hrg_sample_impl()`: - ! At :: Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. - Please restart your R session to avoid crashes or other surprising behavior. - -# hrg_sample_many_impl basic - - Code - hrg_sample_many_impl(hrg = hrg_model, num_samples = 2) - Output - [[1]] - IGRAPH U--- 10 45 -- - + edges: - [1] 1-- 2 1-- 3 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--10 2-- 3 2-- 4 2-- 5 - [13] 2-- 6 2-- 7 2-- 8 2-- 9 2--10 3-- 4 3-- 5 3-- 6 3-- 7 3-- 8 3-- 9 3--10 - [25] 4-- 5 4-- 6 4-- 7 4-- 8 4-- 9 4--10 5-- 6 5-- 7 5-- 8 5-- 9 5--10 6-- 7 - [37] 6-- 8 6-- 9 6--10 7-- 8 7-- 9 7--10 8-- 9 8--10 9--10 - - [[2]] - IGRAPH U--- 10 45 -- - + edges: - [1] 1-- 2 1-- 3 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--10 2-- 3 2-- 4 2-- 5 - [13] 2-- 6 2-- 7 2-- 8 2-- 9 2--10 3-- 4 3-- 5 3-- 6 3-- 7 3-- 8 3-- 9 3--10 - [25] 4-- 5 4-- 6 4-- 7 4-- 8 4-- 9 4--10 5-- 6 5-- 7 5-- 8 5-- 9 5--10 6-- 7 - [37] 6-- 8 6-- 9 6--10 7-- 8 7-- 9 7--10 8-- 9 8--10 9--10 - - -# hrg_sample_many_impl errors - - Code - hrg_sample_many_impl(hrg = NULL, num_samples = 2) - Condition - Error in `hrg_sample_many_impl()`: - ! At :: Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. - Please restart your R session to avoid crashes or other surprising behavior. - -# hrg_game_impl basic - - Code - hrg_game_impl(hrg = hrg_model) - Output - IGRAPH U--- 10 45 -- Hierarchical random graph model - + attr: name (g/c) - + edges: - [1] 1-- 2 1-- 3 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--10 2-- 3 2-- 4 2-- 5 - [13] 2-- 6 2-- 7 2-- 8 2-- 9 2--10 3-- 4 3-- 5 3-- 6 3-- 7 3-- 8 3-- 9 3--10 - [25] 4-- 5 4-- 6 4-- 7 4-- 8 4-- 9 4--10 5-- 6 5-- 7 5-- 8 5-- 9 5--10 6-- 7 - [37] 6-- 8 6-- 9 6--10 7-- 8 7-- 9 7--10 8-- 9 8--10 9--10 - -# hrg_game_impl errors - - Code - hrg_game_impl(hrg = NULL) - Condition - Error in `hrg_game_impl()`: - ! At :: Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. - Please restart your R session to avoid crashes or other surprising behavior. - -# hrg_consensus_impl errors - - Code - hrg_consensus_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# hrg_predict_impl errors - - Code - hrg_predict_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# hrg_create_impl basic - - Code - hrg_create_impl(graph = g, prob = rep(0.5, 2)) - Output - Hierarchical random graph, at level 3: - g1 p=0.5 1 - '- g2 p=0.5 2 3 - -# hrg_create_impl errors - - Code - hrg_create_impl(graph = g, prob = 0.5) - Condition - Error in `hrg_create_impl()`: - ! HRG probability vector size (1) should be equal to the number of internal nodes (2). Invalid value - Source: : - -# hrg_resize_impl basic - - Code - hrg_resize_impl(hrg = hrg_model, newsize = 5) - Output - $left - [1] 0 -9 -6 -2 - - $right - [1] -4 4 7 -8 - - $prob - [1] 1 1 1 1 - - $edges - [1] 9 6 3 14 - - $vertices - [1] 10 7 4 9 - - -# hrg_resize_impl errors - - Code - hrg_resize_impl(hrg = -1, newsize = 2) - Condition - Error in `hrg_resize_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# hrg_size_impl basic - - Code - hrg_size_impl(hrg = hrg_model) - Output - [1] 10 - -# hrg_size_impl errors - - Code - hrg_size_impl(hrg = -1) - Condition - Error in `hrg_size_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# from_hrg_dendrogram_impl basic - - Code - from_hrg_dendrogram_impl(hrg = hrg_model) - Output - $graph - IGRAPH D--- 19 18 -- - + edges: - [1] 11-> 1 11->14 12->19 12-> 5 13->16 13-> 8 14->12 14->18 15-> 3 15-> 6 - [11] 16->15 16->10 17->13 17-> 4 18-> 7 18-> 9 19-> 2 19->17 - - $prob - [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1 1 1 1 1 1 1 1 1 - - -# from_hrg_dendrogram_impl errors - - Code - from_hrg_dendrogram_impl(hrg = -1) - Condition - Error in `from_hrg_dendrogram_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# get_adjacency_sparse_impl basic - - Code - get_adjacency_sparse_impl(graph = g) - Output - $type - [1] "triplet" - - $dim - [1] 3 3 - - $p - [1] 0 1 1 2 - - $i - [1] 1 0 2 1 - - $x - [1] 1 1 1 1 - - attr(,"class") - [1] "igraph.tmp.sparse" - ---- - - Code - get_adjacency_sparse_impl(graph = g, type = "upper", weights = c(1, 2), loops = "none") - Output - $type - [1] "triplet" - - $dim - [1] 3 3 - - $p - [1] 1 2 - - $i - [1] 0 1 - - $x - [1] 1 2 - - attr(,"class") - [1] "igraph.tmp.sparse" - -# get_adjacency_sparse_impl errors - - Code - get_adjacency_sparse_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_stochastic_impl basic - - Code - get_stochastic_impl(graph = g) - Output - [,1] [,2] [,3] - [1,] 0.0 1 0.0 - [2,] 0.5 0 0.5 - [3,] 0.0 1 0.0 - ---- - - Code - get_stochastic_impl(graph = g, column_wise = TRUE, weights = c(1, 2)) - Output - [,1] [,2] [,3] - [1,] 0 0.3333333 0 - [2,] 1 0.0000000 1 - [3,] 0 0.6666667 0 - -# get_stochastic_impl errors - - Code - get_stochastic_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_stochastic_sparse_impl basic - - Code - get_stochastic_sparse_impl(graph = g) - Output - $type - [1] "triplet" - - $dim - [1] 3 3 - - $p - [1] 0 1 1 2 - - $i - [1] 1 0 2 1 - - $x - [1] 0.5 1.0 1.0 0.5 - - attr(,"class") - [1] "igraph.tmp.sparse" - ---- - - Code - get_stochastic_sparse_impl(graph = g, column_wise = TRUE, weights = c(1, 2)) - Output - $type - [1] "triplet" - - $dim - [1] 3 3 - - $p - [1] 0 1 1 2 - - $i - [1] 1 0 2 1 - - $x - [1] 1.0000000 0.3333333 0.6666667 1.0000000 - - attr(,"class") - [1] "igraph.tmp.sparse" - -# get_stochastic_sparse_impl errors - - Code - get_stochastic_sparse_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# to_directed_impl basic - - Code - to_directed_impl(graph = g) - Output - IGRAPH D--- 3 4 -- - + edges: - [1] 1->2 2->3 2->1 3->2 - ---- - - Code - to_directed_impl(graph = g, mode = "acyclic") - Output - IGRAPH D--- 3 2 -- - + edges: - [1] 1->2 2->3 - -# to_directed_impl errors - - Code - to_directed_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# to_undirected_impl basic - - Code - to_undirected_impl(graph = g) - Output - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - ---- - - Code - to_undirected_impl(graph = g, mode = "mutual", edge_attr_comb = "sum") - Output - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - -# to_undirected_impl errors - - Code - to_undirected_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# motifs_randesu_impl basic - - Code - motifs_randesu_impl(graph = g) - Output - [1] NaN NaN 1 0 - ---- - - Code - 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 - -# motifs_randesu_impl errors - - Code - motifs_randesu_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# motifs_randesu_estimate_impl basic - - Code - motifs_randesu_estimate_impl(graph = g, size = 3, sample_size = 2) - Output - [1] 3 - ---- - - Code - motifs_randesu_estimate_impl(graph = g, size = 4, cut_prob = rep(0.1, 4), - sample_size = 2, sample = 1:2) - Output - [1] 3 - -# motifs_randesu_estimate_impl errors - - Code - motifs_randesu_estimate_impl(graph = NULL, size = 3, sample_size = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# motifs_randesu_no_impl basic - - Code - motifs_randesu_no_impl(graph = g) - Output - [1] 1 - ---- - - Code - motifs_randesu_no_impl(graph = g, size = 4, cut_prob = c(0.1, 0.1, 0.1, 0.1)) - Output - [1] 0 - -# motifs_randesu_no_impl errors - - Code - motifs_randesu_no_impl(graph = g, size = 3, cut_prob = c(0.1)) - Condition - Error in `motifs_randesu_no_impl()`: - ! Cut probability vector size (1) must agree with motif size (3). Invalid value - Source: : - -# dyad_census_impl basic - - Code - dyad_census_impl(graph = g) - Output - $mut - [1] 2 - - $asym - [1] 0 - - $null - [1] 1 - - -# dyad_census_impl errors - - Code - dyad_census_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# triad_census_impl basic - - Code - triad_census_impl(graph = g) - Condition - Warning in `triad_census_impl()`: - Triad census called on an undirected graph. All connections will be treated as mutual. - Source: misc/motifs.c:1157 - Output - [1] 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 - -# triad_census_impl errors - - Code - triad_census_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# count_adjacent_triangles_impl basic - - Code - count_adjacent_triangles_impl(graph = g) - Output - [1] 0 0 0 - ---- - - Code - count_adjacent_triangles_impl(graph = g, vids = 1:2) - Output - [1] 0 0 - -# count_adjacent_triangles_impl errors - - Code - count_adjacent_triangles_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# count_triangles_impl basic - - Code - count_triangles_impl(graph = g) - Output - [1] 0 - -# count_triangles_impl errors - - Code - count_triangles_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# local_scan_0_impl basic - - Code - local_scan_0_impl(graph = g) - Output - [1] 1 2 1 - ---- - - Code - local_scan_0_impl(graph = g, weights = c(1, 2), mode = "in") - Output - [1] 1 3 2 - -# local_scan_0_impl errors - - Code - local_scan_0_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# local_scan_0_them_impl basic - - Code - local_scan_0_them_impl(us = g1, them = g2) - Output - [1] 1 2 1 - ---- - - Code - local_scan_0_them_impl(us = g1, them = g2, weights_them = c(1, 2), mode = "in") - Output - [1] 1 3 2 - -# local_scan_0_them_impl errors - - Code - local_scan_0_them_impl(us = NULL, them = them) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# local_scan_1_ecount_impl basic - - Code - local_scan_1_ecount_impl(graph = g) - Output - [1] 1 2 1 - ---- - - Code - local_scan_1_ecount_impl(graph = g, weights = c(1, 2), mode = "in") - Output - [1] 1 3 2 - -# local_scan_1_ecount_impl errors - - Code - local_scan_1_ecount_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# local_scan_1_ecount_them_impl basic - - Code - local_scan_1_ecount_them_impl(us = g1, them = g2) - Output - [1] 1 2 1 - ---- - - Code - local_scan_1_ecount_them_impl(us = g1, them = g2, weights_them = c(1, 2), mode = "in") - Output - [1] 1 3 2 - -# local_scan_1_ecount_them_impl errors - - Code - local_scan_1_ecount_them_impl(us = NULL, them = them) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# local_scan_k_ecount_impl basic - - Code - local_scan_k_ecount_impl(graph = g, k = 1) - Output - [1] 1 2 1 - ---- - - Code - local_scan_k_ecount_impl(graph = g, k = 1, weights = c(1, 2), mode = "in") - Output - [1] 1 3 2 - -# local_scan_k_ecount_impl errors - - Code - local_scan_k_ecount_impl(graph = NULL, k = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# local_scan_k_ecount_them_impl basic - - Code - local_scan_k_ecount_them_impl(us = g1, them = g2, k = 1) - Output - [1] 1 2 1 - ---- - - Code - local_scan_k_ecount_them_impl(us = g1, them = g2, k = 1, weights_them = c(1, 2), - mode = "in") - Output - [1] 1 3 2 - -# local_scan_k_ecount_them_impl errors - - Code - local_scan_k_ecount_them_impl(us = NULL, them = them, k = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# local_scan_neighborhood_ecount_impl basic - - Code - 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(graph = g, weights = c(1, 2, 3), - neighborhoods = list(1:2, 1:3, 2:4, 1)) - Output - [1] 1 3 5 0 - -# local_scan_neighborhood_ecount_impl errors - - Code - local_scan_neighborhood_ecount_impl(graph = NULL, neighborhoods = list(1:2, 2:3)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# local_scan_subset_ecount_impl basic - - Code - 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(graph = g, weights = c(1, 2, 3), subsets = list(c( - 1, 2), c(2, 3))) - Output - [1] 1 2 - -# local_scan_subset_ecount_impl errors - - Code - local_scan_subset_ecount_impl(graph = g, subsets = list(1:2, letters[2:3])) - Condition - Error in `.x - 1`: - ! non-numeric argument to binary operator - -# list_triangles_impl basic - - Code - list_triangles_impl(graph = g) - Output - + 0/3 vertices: - -# list_triangles_impl errors - - Code - list_triangles_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# join_impl basic - - Code - join_impl(left = g1, right = g2) - Output - IGRAPH U--- 6 13 -- - + edges: - [1] 1--2 2--3 4--5 5--6 1--4 1--5 1--6 2--4 2--5 2--6 3--4 3--5 3--6 - -# join_impl errors - - Code - join_impl(left = NULL, right = right) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# induced_subgraph_map_impl basic - - Code - induced_subgraph_map_impl(graph = g, vids = 1:2, impl = "auto") - Output - $res - IGRAPH U--- 2 1 -- - + edge: - [1] 1--2 - - $map - [1] 2 3 1 - - $invmap - [1] 1 2 - - ---- - - Code - induced_subgraph_map_impl(graph = g, vids = 1:2, impl = "copy_and_delete") - Output - $res - IGRAPH U--- 2 1 -- - + edge: - [1] 1--2 - - $map - [1] 2 3 1 - - $invmap - [1] 1 2 - - -# induced_subgraph_map_impl errors - - Code - induced_subgraph_map_impl(graph = NULL, vids = 1:2, impl = "auto") - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# mycielskian_impl basic - - Code - mycielskian_impl(graph = g) - Output - IGRAPH U--- 7 9 -- - + edges: - [1] 1--2 2--3 1--5 2--4 2--6 3--5 4--7 5--7 6--7 - ---- - - Code - mycielskian_impl(graph = g, k = 2) - Output - IGRAPH U--- 15 34 -- - + edges: - [1] 1-- 2 2-- 3 1-- 5 2-- 4 2-- 6 3-- 5 4-- 7 5-- 7 6-- 7 1-- 9 - [11] 2-- 8 2--10 3-- 9 1--12 5-- 8 2--11 4-- 9 2--13 6-- 9 3--12 - [21] 5--10 4--14 7--11 5--14 7--12 6--14 7--13 8--15 9--15 10--15 - [31] 11--15 12--15 13--15 14--15 - -# mycielskian_impl errors - - Code - mycielskian_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# product_impl basic - - Code - product_impl(g1 = g1, g2 = g2) - Output - IGRAPH U--- 9 12 -- - + edges: - [1] 1--4 2--5 3--6 4--7 5--8 6--9 1--2 4--5 7--8 2--3 5--6 8--9 - ---- - - Code - product_impl(g1 = g1, g2 = g2, type = "tensor") - Output - IGRAPH U--- 9 8 -- - + edges: - [1] 1--5 2--4 2--6 3--5 4--8 5--7 5--9 6--8 - -# product_impl errors - - Code - product_impl(g1 = NULL, g2 = g2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# rooted_product_impl basic - - Code - rooted_product_impl(g1 = g1, g2 = g2, root = 1) - Output - IGRAPH U--- 9 8 -- - + edges: - [1] 1--4 4--7 1--2 4--5 7--8 2--3 5--6 8--9 - -# rooted_product_impl errors - - Code - rooted_product_impl(g1 = NULL, g2 = g2, root = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# gomory_hu_tree_impl basic - - Code - gomory_hu_tree_impl(graph = g) - Output - $tree - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - - $flows - [1] 1 1 - - ---- - - Code - gomory_hu_tree_impl(graph = g, capacity = c(1, 2)) - Output - $tree - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - - $flows - [1] 1 2 - - -# gomory_hu_tree_impl errors - - Code - gomory_hu_tree_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# maxflow_impl basic - - Code - maxflow_impl(graph = g, source = 1, target = 3) - Output - $value - [1] 1 - - $flow - [1] 1 1 - - $cut - + 1/2 edge: - [1] 2--3 - - $partition1 - + 2/3 vertices: - [1] 1 2 - - $partition2 - + 1/3 vertex: - [1] 3 - - $stats - $stats$nopush - [1] 1 - - $stats$norelabel - [1] 0 - - $stats$nogap - [1] 0 - - $stats$nogapnodes - [1] 0 - - $stats$nobfs - [1] 1 - - - ---- - - Code - maxflow_impl(graph = g, source = 1, target = 3, capacity = c(1, 2)) - Output - $value - [1] 1 - - $flow - [1] 1 1 - - $cut - + 1/2 edge: - [1] 1--2 - - $partition1 - + 1/3 vertex: - [1] 1 - - $partition2 - + 2/3 vertices: - [1] 2 3 - - $stats - $stats$nopush - [1] 1 - - $stats$norelabel - [1] 0 - - $stats$nogap - [1] 0 - - $stats$nogapnodes - [1] 0 - - $stats$nobfs - [1] 1 - - - -# maxflow_impl errors - - Code - maxflow_impl(graph = NULL, source = 1, target = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# residual_graph_impl basic - - Code - residual_graph_impl(graph = g, capacity = c(1, 2), flow = c(1, 2)) - Output - $residual - IGRAPH D--- 3 0 -- - + edges: - - $residual_capacity - numeric(0) - - -# residual_graph_impl errors - - Code - residual_graph_impl(graph = NULL, capacity = c(1, 2), flow = c(1, 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# reverse_residual_graph_impl basic - - Code - reverse_residual_graph_impl(graph = g, capacity = c(1, 2), flow = c(1, 2)) - Output - IGRAPH D--- 3 2 -- - + edges: - [1] 2->1 3->2 - -# reverse_residual_graph_impl errors - - Code - reverse_residual_graph_impl(graph = NULL, capacity = c(1, 2), flow = c(1, 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# st_mincut_impl basic - - Code - st_mincut_impl(graph = g, source = 1, target = 3) - Output - $value - [1] 1 - - $cut - + 1/2 edge: - [1] 2--3 - - $partition1 - + 2/3 vertices: - [1] 1 2 - - $partition2 - + 1/3 vertex: - [1] 3 - - ---- - - Code - st_mincut_impl(graph = g, source = 1, target = 3, capacity = c(1, 2)) - Output - $value - [1] 1 - - $cut - + 1/2 edge: - [1] 1--2 - - $partition1 - + 1/3 vertex: - [1] 1 - - $partition2 - + 2/3 vertices: - [1] 2 3 - - -# st_mincut_impl errors - - Code - st_mincut_impl(graph = NULL, source = 1, target = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# dominator_tree_impl basic - - Code - dominator_tree_impl(graph = g, root = 1) - Output - $dom - [1] 0 1 2 - - $domtree - IGRAPH D--- 3 2 -- - + edges: - [1] 1->2 2->3 - - $leftout - + 0/3 vertices: - - ---- - - Code - dominator_tree_impl(graph = g, root = 1, mode = "in") - Output - $dom - [1] 0 -1 -1 - - $domtree - IGRAPH D--- 3 0 -- - + edges: - - $leftout - + 2/3 vertices: - [1] 2 3 - - -# dominator_tree_impl errors - - Code - dominator_tree_impl(graph = NULL, root = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# all_st_cuts_impl basic - - Code - all_st_cuts_impl(graph = g, source = 1, target = 3) - Output - $cuts - $cuts[[1]] - + 1/2 edge: - [1] 1->2 - - $cuts[[2]] - + 1/2 edge: - [1] 2->3 - - - $partition1s - $partition1s[[1]] - + 1/3 vertex: - [1] 1 - - $partition1s[[2]] - + 2/3 vertices: - [1] 1 2 - - - -# all_st_cuts_impl errors - - Code - all_st_cuts_impl(graph = NULL, source = 1, target = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# all_st_mincuts_impl basic - - Code - all_st_mincuts_impl(graph = g, source = 1, target = 3) - Output - $value - [1] 1 - - $cuts - $cuts[[1]] - + 1/2 edge: - [1] 1->2 - - $cuts[[2]] - + 1/2 edge: - [1] 2->3 - - - $partition1s - $partition1s[[1]] - + 1/3 vertex: - [1] 1 - - $partition1s[[2]] - + 2/3 vertices: - [1] 1 2 - - - ---- - - Code - all_st_mincuts_impl(graph = g, source = 1, target = 3, capacity = c(1, 2)) - Output - $value - [1] 1 - - $cuts - $cuts[[1]] - + 1/2 edge: - [1] 1->2 - - - $partition1s - $partition1s[[1]] - + 1/3 vertex: - [1] 1 - - - -# all_st_mincuts_impl errors - - Code - all_st_mincuts_impl(graph = NULL, source = 1, target = 3) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# even_tarjan_reduction_impl basic - - Code - even_tarjan_reduction_impl(graph = g) - Output - $graphbar - IGRAPH D--- 6 7 -- - + edges: - [1] 1->4 2->5 3->6 5->1 4->2 6->2 5->3 - - $capacity - [1] 1 1 1 3 3 3 3 - - -# even_tarjan_reduction_impl errors - - Code - even_tarjan_reduction_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_separator_impl basic - - Code - is_separator_impl(graph = g, candidate = 1:2) - Output - [1] FALSE - -# is_separator_impl errors - - Code - is_separator_impl(graph = NULL, candidate = 1:2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_minimal_separator_impl basic - - Code - is_minimal_separator_impl(graph = g, candidate = 1:2) - Output - [1] FALSE - -# is_minimal_separator_impl errors - - Code - is_minimal_separator_impl(graph = NULL, candidate = 1:2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# all_minimal_st_separators_impl basic - - Code - all_minimal_st_separators_impl(graph = g) - Output - [[1]] - + 1/3 vertex: - [1] 2 - - -# all_minimal_st_separators_impl errors - - Code - all_minimal_st_separators_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# minimum_size_separators_impl basic - - Code - minimum_size_separators_impl(graph = g) - Output - [[1]] - + 1/3 vertex: - [1] 2 - - -# minimum_size_separators_impl errors - - Code - minimum_size_separators_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# isoclass_impl basic - - Code - isoclass_impl(graph = g) - Output - [1] 2 - -# isoclass_impl errors - - Code - isoclass_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# isomorphic_impl basic - - Code - isomorphic_impl(graph1 = g1, graph2 = g2) - Output - [1] TRUE - -# isomorphic_impl errors - - Code - isomorphic_impl(graph1 = NULL, graph2 = graph2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# isoclass_subgraph_impl basic - - Code - isoclass_subgraph_impl(graph = g, vids = c(1, 2, 3)) - Output - [1] 2 - -# isoclass_subgraph_impl errors - - Code - isoclass_subgraph_impl(graph = NULL, vids = 1:2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# isoclass_create_impl basic - - Code - isoclass_create_impl(size = 3, number = 1) - Output - IGRAPH D--- 3 1 -- - + edge: - [1] 2->1 - ---- - - Code - isoclass_create_impl(size = 3, number = 1, directed = FALSE) - Output - IGRAPH U--- 3 1 -- - + edge: - [1] 1--2 - -# isoclass_create_impl errors - - Code - isoclass_create_impl(size = "a", number = 1) - Condition - Warning in `isoclass_create_impl()`: - NAs introduced by coercion - Error in `isoclass_create_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# isomorphic_vf2_impl basic - - Code - isomorphic_vf2_impl(graph1 = g1, graph2 = g2) - Output - $iso - [1] TRUE - - $map12 - [1] 1 2 3 - - $map21 - [1] 1 2 3 - - ---- - - Code - 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 - - $map12 - [1] 1 2 3 - - $map21 - [1] 1 2 3 - - -# isomorphic_vf2_impl errors - - Code - isomorphic_vf2_impl(graph1 = NULL, graph2 = graph2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# count_isomorphisms_vf2_impl basic - - Code - count_isomorphisms_vf2_impl(graph1 = g1, graph2 = g2) - Output - [1] 2 - ---- - - Code - 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 - -# count_isomorphisms_vf2_impl errors - - Code - count_isomorphisms_vf2_impl(graph1 = NULL, graph2 = graph2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_isomorphisms_vf2_impl basic - - Code - get_isomorphisms_vf2_impl(graph1 = g1, graph2 = g2) - Output - [[1]] - [1] 0 1 2 - - [[2]] - [1] 2 1 0 - - ---- - - Code - 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 - - -# get_isomorphisms_vf2_impl errors - - Code - get_isomorphisms_vf2_impl(graph1 = NULL, graph2 = graph2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# subisomorphic_impl basic - - Code - subisomorphic_impl(graph1 = g1, graph2 = g2) - Output - [1] TRUE - -# subisomorphic_impl errors - - Code - subisomorphic_impl(graph1 = NULL, graph2 = graph2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# subisomorphic_vf2_impl basic - - Code - subisomorphic_vf2_impl(graph1 = g1, graph2 = g2) - Output - $iso - [1] TRUE - - $map12 - [1] 1 2 3 - - $map21 - [1] 1 2 3 - - ---- - - Code - 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 - - $map12 - [1] 1 2 3 - - $map21 - [1] 1 2 3 - - -# subisomorphic_vf2_impl errors - - Code - subisomorphic_vf2_impl(graph1 = NULL, graph2 = graph2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# count_subisomorphisms_vf2_impl basic - - Code - count_subisomorphisms_vf2_impl(graph1 = g1, graph2 = g2) - Output - [1] 2 - ---- - - Code - 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 - -# count_subisomorphisms_vf2_impl errors - - Code - count_subisomorphisms_vf2_impl(graph1 = NULL, graph2 = graph2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# get_subisomorphisms_vf2_impl basic - - Code - get_subisomorphisms_vf2_impl(graph1 = g1, graph2 = g2) - Output - [[1]] - [1] 0 1 2 - - [[2]] - [1] 2 1 0 - - ---- - - Code - 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 - - -# get_subisomorphisms_vf2_impl errors - - Code - get_subisomorphisms_vf2_impl(graph1 = NULL, graph2 = graph2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# canonical_permutation_impl basic - - Code - canonical_permutation_impl(graph = g) - Output - $labeling - [1] 2 3 1 - - $info - $info$nof_nodes - [1] 3 - - $info$nof_leaf_nodes - [1] 3 - - $info$nof_bad_nodes - [1] 0 - - $info$nof_canupdates - [1] 1 - - $info$max_level - [1] 1 - - $info$group_size - [1] "2" - - - ---- - - Code - canonical_permutation_impl(graph = g, colors = c(1, 2, 3), sh = "fl") - Output - $labeling - [1] 1 2 3 - - $info - $info$nof_nodes - [1] 1 - - $info$nof_leaf_nodes - [1] 1 - - $info$nof_bad_nodes - [1] 0 - - $info$nof_canupdates - [1] 0 - - $info$max_level - [1] 0 - - $info$group_size - [1] "1" - - - -# canonical_permutation_impl errors - - Code - canonical_permutation_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# permute_vertices_impl basic - - Code - permute_vertices_impl(graph = g, permutation = 3:1) - Output - IGRAPH U--- 3 2 -- - + edges: - [1] 2--3 1--2 - -# permute_vertices_impl errors - - Code - permute_vertices_impl(graph = NULL, permutation = 3:1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# isomorphic_bliss_impl basic - - Code - isomorphic_bliss_impl(graph1 = g1, graph2 = g2) - Output - $iso - [1] TRUE - - $map12 - [1] 1 2 3 - - $map21 - [1] 1 2 3 - - $info1 - $info1$nof_nodes - [1] 3 - - $info1$nof_leaf_nodes - [1] 3 - - $info1$nof_bad_nodes - [1] 0 - - $info1$nof_canupdates - [1] 1 - - $info1$max_level - [1] 1 - - $info1$group_size - [1] "2" - - - $info2 - $info2$nof_nodes - [1] 3 - - $info2$nof_leaf_nodes - [1] 3 - - $info2$nof_bad_nodes - [1] 0 - - $info2$nof_canupdates - [1] 1 - - $info2$max_level - [1] 1 - - $info2$group_size - [1] "2" - - - ---- - - Code - isomorphic_bliss_impl(graph1 = g1, graph2 = g2, colors1 = c(1, 2, 3), colors2 = c( - 1, 2, 3), sh = "fl") - Output - $iso - [1] TRUE - - $map12 - [1] 1 2 3 - - $map21 - [1] 1 2 3 - - $info1 - $info1$nof_nodes - [1] 1 - - $info1$nof_leaf_nodes - [1] 1 - - $info1$nof_bad_nodes - [1] 0 - - $info1$nof_canupdates - [1] 0 - - $info1$max_level - [1] 0 - - $info1$group_size - [1] "1" - - - $info2 - $info2$nof_nodes - [1] 1 - - $info2$nof_leaf_nodes - [1] 1 - - $info2$nof_bad_nodes - [1] 0 - - $info2$nof_canupdates - [1] 0 - - $info2$max_level - [1] 0 - - $info2$group_size - [1] "1" - - - -# isomorphic_bliss_impl errors - - Code - isomorphic_bliss_impl(graph1 = NULL, graph2 = graph2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# count_automorphisms_impl basic - - Code - count_automorphisms_impl(graph = g) - Output - $nof_nodes - [1] 3 - - $nof_leaf_nodes - [1] 3 - - $nof_bad_nodes - [1] 0 - - $nof_canupdates - [1] 1 - - $max_level - [1] 1 - - $group_size - [1] "2" - - ---- - - Code - count_automorphisms_impl(graph = g, colors = c(1, 2, 3), sh = "fl") - Output - $nof_nodes - [1] 1 - - $nof_leaf_nodes - [1] 1 - - $nof_bad_nodes - [1] 0 - - $nof_canupdates - [1] 0 - - $max_level - [1] 0 - - $group_size - [1] "1" - - -# count_automorphisms_impl errors - - Code - count_automorphisms_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# automorphism_group_impl basic - - Code - automorphism_group_impl(graph = g) - Output - [[1]] - + 3/3 vertices: - [1] 3 2 1 - - ---- - - Code - automorphism_group_impl(graph = g, colors = c(1, 2, 3), sh = "fl", details = TRUE) - Output - $generators - list() - - $info - $info$nof_nodes - [1] 1 - - $info$nof_leaf_nodes - [1] 1 - - $info$nof_bad_nodes - [1] 0 - - $info$nof_canupdates - [1] 0 - - $info$max_level - [1] 0 - - $info$group_size - [1] "1" - - - -# automorphism_group_impl errors - - Code - automorphism_group_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# simplify_and_colorize_impl basic - - Code - simplify_and_colorize_impl(graph = g) - Output - $res - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - - $vertex_color - [1] 0 0 0 - - $edge_color - [1] 1 1 - - -# simplify_and_colorize_impl errors - - Code - simplify_and_colorize_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# graph_count_impl basic - - Code - graph_count_impl(n = 3) - Output - [1] 4 - ---- - - Code - graph_count_impl(n = 3, directed = TRUE) - Output - [1] 16 - -# graph_count_impl errors - - Code - graph_count_impl(n = "a") - Condition - Warning in `graph_count_impl()`: - NAs introduced by coercion - Error in `graph_count_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# is_matching_impl basic - - Code - is_matching_impl(graph = g, matching = 1:2) - Output - [1] FALSE - ---- - - Code - is_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE), matching = 1:2) - Output - [1] FALSE - -# is_matching_impl errors - - Code - is_matching_impl(graph = NULL, matching = 1:2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_maximal_matching_impl basic - - Code - is_maximal_matching_impl(graph = g, matching = 1:2) - Output - [1] FALSE - ---- - - Code - is_maximal_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE), matching = 1: - 2) - Output - [1] FALSE - -# is_maximal_matching_impl errors - - Code - is_maximal_matching_impl(graph = NULL, matching = 1:2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# maximum_bipartite_matching_impl basic - - Code - maximum_bipartite_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE)) - Output - $matching_size - [1] 1 - - $matching_weight - [1] 1 - - $matching - [1] 2 1 0 - - ---- - - Code - maximum_bipartite_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE), - weights = c(1, 2), eps = 1e-05) - Output - $matching_size - [1] 1 - - $matching_weight - [1] 2 - - $matching - [1] 0 3 2 - - -# maximum_bipartite_matching_impl errors - - Code - maximum_bipartite_matching_impl(graph = NULL, types = c(TRUE, FALSE, TRUE)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# adjacency_spectral_embedding_impl basic - - Code - adjacency_spectral_embedding_impl(graph = g, no = 2) - Output - $X - [,1] [,2] - [1,] 0.6718598 -0.4487712 - [2,] 1.1328501 0.5323058 - [3,] 0.6718598 -0.4487712 - - $Y - [,1] [,2] - [1,] 0.6718598 -0.4487712 - [2,] 1.1328501 0.5323058 - [3,] 0.6718598 -0.4487712 - - $D - [1] 2.1861407 -0.6861407 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 3 - - $options$which - [1] "LM" - - $options$nev - [1] 2 - - $options$tol - [1] 0 - - $options$ncv - [1] 3 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 2 - - $options$numop - [1] 3 - - $options$numopb - [1] 0 - - $options$numreo - [1] 2 - - - ---- - - Code - 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 - [,1] [,2] - [1,] 0.1720265 -0.7864357 - [2,] 0.6311790 -0.3743620 - [3,] 0.7563200 0.4912963 - - $Y - [,1] [,2] - [1,] 0.1720265 -0.7864357 - [2,] 0.6311790 -0.3743620 - [3,] 0.7563200 0.4912963 - - $D - [1] 4.669079 1.476024 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 3 - - $options$which - [1] "LA" - - $options$nev - [1] 2 - - $options$tol - [1] 0 - - $options$ncv - [1] 3 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 10 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 2 - - $options$numop - [1] 3 - - $options$numopb - [1] 0 - - $options$numreo - [1] 2 - - - -# adjacency_spectral_embedding_impl errors - - Code - adjacency_spectral_embedding_impl(graph = NULL, no = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# laplacian_spectral_embedding_impl basic - - Code - laplacian_spectral_embedding_impl(graph = g, no = 2) - Output - $X - [,1] [,2] - [1,] -0.7071068 -0.7071068 - [2,] 1.4142136 0.0000000 - [3,] -0.7071068 0.7071068 - - $Y - [,1] [,2] - [1,] -0.7071068 -0.7071068 - [2,] 1.4142136 0.0000000 - [3,] -0.7071068 0.7071068 - - $D - [1] 3 1 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 3 - - $options$which - [1] "LM" - - $options$nev - [1] 2 - - $options$tol - [1] 0 - - $options$ncv - [1] 3 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 2 - - $options$numop - [1] 3 - - $options$numopb - [1] 0 - - $options$numreo - [1] 3 - - - -# laplacian_spectral_embedding_impl errors - - Code - laplacian_spectral_embedding_impl(graph = NULL, no = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# eigen_adjacency_impl basic - - Code - eigen_adjacency_impl(graph = g) - Output - $options - $options$bmat - [1] "I" - - $options$n - [1] 3 - - $options$which - [1] "LM" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 2 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 0 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 29 - - $options$nconv - [1] 1 - - $options$numop - [1] 30 - - $options$numopb - [1] 0 - - $options$numreo - [1] 16 - - - $values - [1] -1.414214 - - $vectors - [,1] - [1,] -0.5000000 - [2,] 0.7071068 - [3,] -0.5000000 - - $cmplxvalues - complex(0) - - $cmplxvectors - <0 x 0 matrix> - - ---- - - Code - eigen_adjacency_impl(graph = g, algorithm = "lapack", which = list(which = "LA"), - options = list(maxiter = 10)) - Condition - Error in `eigen_adjacency_impl()`: - ! 'LAPACK' algorithm not implemented yet. Unimplemented function call - Source: : - -# eigen_adjacency_impl errors - - Code - eigen_adjacency_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# power_law_fit_impl basic - - Code - power_law_fit_impl(data = c(1, 2, 3)) - Output - $continuous - [1] FALSE - - $alpha - [1] 1.646771 - - $xmin - [1] 1 - - $logLik - [1] -5.272517 - - $KS.stat - [1] 0.2640998 - - ---- - - Code - power_law_fit_impl(data = c(1, 2, 3), xmin = 1, force_continuous = TRUE) - Output - $continuous - [1] TRUE - - $alpha - [1] 2.116221 - - $xmin - [1] 1 - - $logLik - [1] -3.461912 - - $KS.stat - [1] 0.3533555 - - -# power_law_fit_impl errors - - Code - power_law_fit_impl(data = "a") - Condition - Warning in `power_law_fit_impl()`: - NAs introduced by coercion - Error in `power_law_fit_impl()`: - ! xmin must be greater than zero. Invalid value - Source: : - -# sir_impl basic - - Code - sir_impl(graph = g, beta = 0.1, gamma = 0.1) - Output - [[1]] - [[1]]$times - [1] 0.000000 6.326537 8.018361 8.809852 9.405480 17.386752 - - [[1]]$NS - [1] 2 1 0 0 0 0 - - [[1]]$NI - [1] 1 2 3 2 1 0 - - [[1]]$NR - [1] 0 0 0 1 2 3 - - - [[2]] - [[2]]$times - [1] 0.000000 3.674354 13.783038 13.921168 - - [[2]]$NS - [1] 2 1 1 1 - - [[2]]$NI - [1] 1 2 1 0 - - [[2]]$NR - [1] 0 0 1 2 - - - [[3]] - [[3]]$times - [1] 0.000000 3.277542 7.521770 16.781182 18.515742 29.375613 - - [[3]]$NS - [1] 2 1 0 0 0 0 - - [[3]]$NI - [1] 1 2 3 2 1 0 - - [[3]]$NR - [1] 0 0 0 1 2 3 - - - [[4]] - [[4]]$times - [1] 0.0000000 0.3027921 - - [[4]]$NS - [1] 2 2 - - [[4]]$NI - [1] 1 0 - - [[4]]$NR - [1] 0 1 - - - [[5]] - [[5]]$times - [1] 0.000000 3.559451 5.615586 20.582742 - - [[5]]$NS - [1] 2 1 1 1 - - [[5]]$NI - [1] 1 2 1 0 - - [[5]]$NR - [1] 0 0 1 2 - - - [[6]] - [[6]]$times - [1] 0.0000000 0.7300885 0.7328203 1.2536518 1.9258569 5.1406208 - - [[6]]$NS - [1] 2 1 0 0 0 0 - - [[6]]$NI - [1] 1 2 3 2 1 0 - - [[6]]$NR - [1] 0 0 0 1 2 3 - - - [[7]] - [[7]]$times - [1] 0.000000 0.865533 - - [[7]]$NS - [1] 2 2 - - [[7]]$NI - [1] 1 0 - - [[7]]$NR - [1] 0 1 - - - [[8]] - [[8]]$times - [1] 0.00000 10.68605 - - [[8]]$NS - [1] 2 2 - - [[8]]$NI - [1] 1 0 - - [[8]]$NR - [1] 0 1 - - - [[9]] - [[9]]$times - [1] 0.000000 2.185910 7.669126 16.635095 21.440723 23.497554 - - [[9]]$NS - [1] 2 1 0 0 0 0 - - [[9]]$NI - [1] 1 2 3 2 1 0 - - [[9]]$NR - [1] 0 0 0 1 2 3 - - - [[10]] - [[10]]$times - [1] 0.000000 4.105424 4.424244 22.891743 24.099505 32.514828 - - [[10]]$NS - [1] 2 1 1 0 0 0 - - [[10]]$NI - [1] 1 2 1 2 1 0 - - [[10]]$NR - [1] 0 0 1 1 2 3 - - - [[11]] - [[11]]$times - [1] 0.00000 4.93042 21.00935 21.07441 23.37619 41.26694 - - [[11]]$NS - [1] 2 1 0 0 0 0 - - [[11]]$NI - [1] 1 2 3 2 1 0 - - [[11]]$NR - [1] 0 0 0 1 2 3 - - - [[12]] - [[12]]$times - [1] 0.00000 15.47343 26.09187 38.01744 43.76847 50.41068 - - [[12]]$NS - [1] 2 1 0 0 0 0 - - [[12]]$NI - [1] 1 2 3 2 1 0 - - [[12]]$NR - [1] 0 0 0 1 2 3 - - - [[13]] - [[13]]$times - [1] 0.000000 3.540437 - - [[13]]$NS - [1] 2 2 - - [[13]]$NI - [1] 1 0 - - [[13]]$NR - [1] 0 1 - - - [[14]] - [[14]]$times - [1] 0.000000 7.081426 7.638086 11.569527 - - [[14]]$NS - [1] 2 1 1 1 - - [[14]]$NI - [1] 1 2 1 0 - - [[14]]$NR - [1] 0 0 1 2 - - - [[15]] - [[15]]$times - [1] 0.00000 15.60443 15.66654 20.19745 22.11224 42.62196 - - [[15]]$NS - [1] 2 1 0 0 0 0 - - [[15]]$NI - [1] 1 2 3 2 1 0 - - [[15]]$NR - [1] 0 0 0 1 2 3 - - - [[16]] - [[16]]$times - [1] 0.000000 3.239708 17.193626 18.833130 19.040959 35.199892 - - [[16]]$NS - [1] 2 1 1 0 0 0 - - [[16]]$NI - [1] 1 2 1 2 1 0 - - [[16]]$NR - [1] 0 0 1 1 2 3 - - - [[17]] - [[17]]$times - [1] 0.0000000 0.2300489 1.8970602 6.9851496 16.0587095 28.8528567 - - [[17]]$NS - [1] 2 1 0 0 0 0 - - [[17]]$NI - [1] 1 2 3 2 1 0 - - [[17]]$NR - [1] 0 0 0 1 2 3 - - - [[18]] - [[18]]$times - [1] 0.000000 4.674879 5.319832 17.366640 63.357258 86.262883 - - [[18]]$NS - [1] 2 1 1 0 0 0 - - [[18]]$NI - [1] 1 2 1 2 1 0 - - [[18]]$NR - [1] 0 0 1 1 2 3 - - - [[19]] - [[19]]$times - [1] 0.000000 1.972293 - - [[19]]$NS - [1] 2 2 - - [[19]]$NI - [1] 1 0 - - [[19]]$NR - [1] 0 1 - - - [[20]] - [[20]]$times - [1] 0.000000 3.177922 - - [[20]]$NS - [1] 2 2 - - [[20]]$NI - [1] 1 0 - - [[20]]$NR - [1] 0 1 - - - [[21]] - [[21]]$times - [1] 0.000000 1.994279 2.508129 8.208209 28.478526 36.256169 - - [[21]]$NS - [1] 2 1 0 0 0 0 - - [[21]]$NI - [1] 1 2 3 2 1 0 - - [[21]]$NR - [1] 0 0 0 1 2 3 - - - [[22]] - [[22]]$times - [1] 0.000000 5.226609 14.744785 16.304309 - - [[22]]$NS - [1] 2 1 1 1 - - [[22]]$NI - [1] 1 2 1 0 - - [[22]]$NR - [1] 0 0 1 2 - - - [[23]] - [[23]]$times - [1] 0.000000 3.254634 13.673154 21.069828 - - [[23]]$NS - [1] 2 1 1 1 - - [[23]]$NI - [1] 1 2 1 0 - - [[23]]$NR - [1] 0 0 1 2 - - - [[24]] - [[24]]$times - [1] 0.00000 18.01982 18.36106 44.55144 - - [[24]]$NS - [1] 2 1 1 1 - - [[24]]$NI - [1] 1 2 1 0 - - [[24]]$NR - [1] 0 0 1 2 - - - [[25]] - [[25]]$times - [1] 0.00000 18.09036 30.47469 36.51570 - - [[25]]$NS - [1] 2 1 1 1 - - [[25]]$NI - [1] 1 2 1 0 - - [[25]]$NR - [1] 0 0 1 2 - - - [[26]] - [[26]]$times - [1] 0.00000 11.21296 - - [[26]]$NS - [1] 2 2 - - [[26]]$NI - [1] 1 0 - - [[26]]$NR - [1] 0 1 - - - [[27]] - [[27]]$times - [1] 0.000000 1.605373 - - [[27]]$NS - [1] 2 2 - - [[27]]$NI - [1] 1 0 - - [[27]]$NR - [1] 0 1 - - - [[28]] - [[28]]$times - [1] 0.000000 3.448751 12.086502 17.941228 - - [[28]]$NS - [1] 2 1 1 1 - - [[28]]$NI - [1] 1 2 1 0 - - [[28]]$NR - [1] 0 0 1 2 - - - [[29]] - [[29]]$times - [1] 0.000000 8.277924 - - [[29]]$NS - [1] 2 2 - - [[29]]$NI - [1] 1 0 - - [[29]]$NR - [1] 0 1 - - - [[30]] - [[30]]$times - [1] 0.000000 9.146159 - - [[30]]$NS - [1] 2 2 - - [[30]]$NI - [1] 1 0 - - [[30]]$NR - [1] 0 1 - - - [[31]] - [[31]]$times - [1] 0.00000000 0.07833588 - - [[31]]$NS - [1] 2 2 - - [[31]]$NI - [1] 1 0 - - [[31]]$NR - [1] 0 1 - - - [[32]] - [[32]]$times - [1] 0.000000 7.825191 - - [[32]]$NS - [1] 2 2 - - [[32]]$NI - [1] 1 0 - - [[32]]$NR - [1] 0 1 - - - [[33]] - [[33]]$times - [1] 0.0000000 0.4018017 - - [[33]]$NS - [1] 2 2 - - [[33]]$NI - [1] 1 0 - - [[33]]$NR - [1] 0 1 - - - [[34]] - [[34]]$times - [1] 0.000000 1.433794 - - [[34]]$NS - [1] 2 2 - - [[34]]$NI - [1] 1 0 - - [[34]]$NR - [1] 0 1 - - - [[35]] - [[35]]$times - [1] 0.00000000 0.06959151 2.61176819 2.76819228 - - [[35]]$NS - [1] 2 1 1 1 - - [[35]]$NI - [1] 1 2 1 0 - - [[35]]$NR - [1] 0 0 1 2 - - - [[36]] - [[36]]$times - [1] 0.000000 1.539839 17.502742 21.550799 31.779748 59.056912 - - [[36]]$NS - [1] 2 1 0 0 0 0 - - [[36]]$NI - [1] 1 2 3 2 1 0 - - [[36]]$NR - [1] 0 0 0 1 2 3 - - - [[37]] - [[37]]$times - [1] 0.000000 8.878624 - - [[37]]$NS - [1] 2 2 - - [[37]]$NI - [1] 1 0 - - [[37]]$NR - [1] 0 1 - - - [[38]] - [[38]]$times - [1] 0.000000 6.855525 - - [[38]]$NS - [1] 2 2 - - [[38]]$NI - [1] 1 0 - - [[38]]$NR - [1] 0 1 - - - [[39]] - [[39]]$times - [1] 0.000000 2.628739 3.809460 7.051204 - - [[39]]$NS - [1] 2 1 1 1 - - [[39]]$NI - [1] 1 2 1 0 - - [[39]]$NR - [1] 0 0 1 2 - - - [[40]] - [[40]]$times - [1] 0.000000 2.484282 - - [[40]]$NS - [1] 2 2 - - [[40]]$NI - [1] 1 0 - - [[40]]$NR - [1] 0 1 - - - [[41]] - [[41]]$times - [1] 0.0000000 0.8248393 - - [[41]]$NS - [1] 2 2 - - [[41]]$NI - [1] 1 0 - - [[41]]$NR - [1] 0 1 - - - [[42]] - [[42]]$times - [1] 0.000000 2.300359 3.886947 6.810196 7.223496 28.297207 - - [[42]]$NS - [1] 2 1 0 0 0 0 - - [[42]]$NI - [1] 1 2 3 2 1 0 - - [[42]]$NR - [1] 0 0 0 1 2 3 - - - [[43]] - [[43]]$times - [1] 0.00000 5.52241 10.93993 29.15486 - - [[43]]$NS - [1] 2 1 1 1 - - [[43]]$NI - [1] 1 2 1 0 - - [[43]]$NR - [1] 0 0 1 2 - - - [[44]] - [[44]]$times - [1] 0.000000 9.526317 12.154710 21.171748 - - [[44]]$NS - [1] 2 1 1 1 - - [[44]]$NI - [1] 1 2 1 0 - - [[44]]$NR - [1] 0 0 1 2 - - - [[45]] - [[45]]$times - [1] 0.000000 4.448428 - - [[45]]$NS - [1] 2 2 - - [[45]]$NI - [1] 1 0 - - [[45]]$NR - [1] 0 1 - - - [[46]] - [[46]]$times - [1] 0.0000000 0.0560511 - - [[46]]$NS - [1] 2 2 - - [[46]]$NI - [1] 1 0 - - [[46]]$NR - [1] 0 1 - - - [[47]] - [[47]]$times - [1] 0.00000 11.57560 12.20970 12.58732 26.47299 36.19628 - - [[47]]$NS - [1] 2 1 0 0 0 0 - - [[47]]$NI - [1] 1 2 3 2 1 0 - - [[47]]$NR - [1] 0 0 0 1 2 3 - - - [[48]] - [[48]]$times - [1] 0.000000 3.687231 - - [[48]]$NS - [1] 2 2 - - [[48]]$NI - [1] 1 0 - - [[48]]$NR - [1] 0 1 - - - [[49]] - [[49]]$times - [1] 0.0000000 0.3436458 1.0908931 1.4640857 - - [[49]]$NS - [1] 2 1 1 1 - - [[49]]$NI - [1] 1 2 1 0 - - [[49]]$NR - [1] 0 0 1 2 - - - [[50]] - [[50]]$times - [1] 0.000000 1.536136 - - [[50]]$NS - [1] 2 2 - - [[50]]$NI - [1] 1 0 - - [[50]]$NR - [1] 0 1 - - - [[51]] - [[51]]$times - [1] 0.000000 2.021208 - - [[51]]$NS - [1] 2 2 - - [[51]]$NI - [1] 1 0 - - [[51]]$NR - [1] 0 1 - - - [[52]] - [[52]]$times - [1] 0.00000 4.29424 - - [[52]]$NS - [1] 2 2 - - [[52]]$NI - [1] 1 0 - - [[52]]$NR - [1] 0 1 - - - [[53]] - [[53]]$times - [1] 0.000000 1.884908 5.139700 8.417338 12.272436 15.154107 - - [[53]]$NS - [1] 2 1 0 0 0 0 - - [[53]]$NI - [1] 1 2 3 2 1 0 - - [[53]]$NR - [1] 0 0 0 1 2 3 - - - [[54]] - [[54]]$times - [1] 0.0000000 0.1997796 - - [[54]]$NS - [1] 2 2 - - [[54]]$NI - [1] 1 0 - - [[54]]$NR - [1] 0 1 - - - [[55]] - [[55]]$times - [1] 0.0000000 0.1825065 - - [[55]]$NS - [1] 2 2 - - [[55]]$NI - [1] 1 0 - - [[55]]$NR - [1] 0 1 - - - [[56]] - [[56]]$times - [1] 0.000000 1.913698 2.656593 7.598135 - - [[56]]$NS - [1] 2 1 1 1 - - [[56]]$NI - [1] 1 2 1 0 - - [[56]]$NR - [1] 0 0 1 2 - - - [[57]] - [[57]]$times - [1] 0.000000 3.435708 - - [[57]]$NS - [1] 2 2 - - [[57]]$NI - [1] 1 0 - - [[57]]$NR - [1] 0 1 - - - [[58]] - [[58]]$times - [1] 0.000000 0.583133 5.284710 10.065112 18.657681 21.137430 - - [[58]]$NS - [1] 2 1 1 0 0 0 - - [[58]]$NI - [1] 1 2 1 2 1 0 - - [[58]]$NR - [1] 0 0 1 1 2 3 - - - [[59]] - [[59]]$times - [1] 0.000000 8.526031 - - [[59]]$NS - [1] 2 2 - - [[59]]$NI - [1] 1 0 - - [[59]]$NR - [1] 0 1 - - - [[60]] - [[60]]$times - [1] 0.000000 3.470768 - - [[60]]$NS - [1] 2 2 - - [[60]]$NI - [1] 1 0 - - [[60]]$NR - [1] 0 1 - - - [[61]] - [[61]]$times - [1] 0.000000 2.311806 - - [[61]]$NS - [1] 2 2 - - [[61]]$NI - [1] 1 0 - - [[61]]$NR - [1] 0 1 - - - [[62]] - [[62]]$times - [1] 0.000000 5.603495 - - [[62]]$NS - [1] 2 2 - - [[62]]$NI - [1] 1 0 - - [[62]]$NR - [1] 0 1 - - - [[63]] - [[63]]$times - [1] 0.0000000 0.2376974 - - [[63]]$NS - [1] 2 2 - - [[63]]$NI - [1] 1 0 - - [[63]]$NR - [1] 0 1 - - - [[64]] - [[64]]$times - [1] 0.000000 1.164209 4.169140 7.017509 - - [[64]]$NS - [1] 2 1 1 1 - - [[64]]$NI - [1] 1 2 1 0 - - [[64]]$NR - [1] 0 0 1 2 - - - [[65]] - [[65]]$times - [1] 0.000000 6.415227 6.561435 14.007083 - - [[65]]$NS - [1] 2 1 1 1 - - [[65]]$NI - [1] 1 2 1 0 - - [[65]]$NR - [1] 0 0 1 2 - - - [[66]] - [[66]]$times - [1] 0.00000 14.28491 31.69273 39.51170 - - [[66]]$NS - [1] 2 1 1 1 - - [[66]]$NI - [1] 1 2 1 0 - - [[66]]$NR - [1] 0 0 1 2 - - - [[67]] - [[67]]$times - [1] 0.000000 3.592755 4.363836 11.200455 - - [[67]]$NS - [1] 2 1 1 1 - - [[67]]$NI - [1] 1 2 1 0 - - [[67]]$NR - [1] 0 0 1 2 - - - [[68]] - [[68]]$times - [1] 0.000000 8.044133 10.227368 12.702160 16.225120 23.696870 - - [[68]]$NS - [1] 2 1 1 0 0 0 - - [[68]]$NI - [1] 1 2 1 2 1 0 - - [[68]]$NR - [1] 0 0 1 1 2 3 - - - [[69]] - [[69]]$times - [1] 0.000000 3.324148 - - [[69]]$NS - [1] 2 2 - - [[69]]$NI - [1] 1 0 - - [[69]]$NR - [1] 0 1 - - - [[70]] - [[70]]$times - [1] 0.000000 6.316816 - - [[70]]$NS - [1] 2 2 - - [[70]]$NI - [1] 1 0 - - [[70]]$NR - [1] 0 1 - - - [[71]] - [[71]]$times - [1] 0.000000 7.473339 7.757794 15.139281 - - [[71]]$NS - [1] 2 1 1 1 - - [[71]]$NI - [1] 1 2 1 0 - - [[71]]$NR - [1] 0 0 1 2 - - - [[72]] - [[72]]$times - [1] 0.000000 4.073649 6.034897 8.135670 - - [[72]]$NS - [1] 2 1 1 1 - - [[72]]$NI - [1] 1 2 1 0 - - [[72]]$NR - [1] 0 0 1 2 - - - [[73]] - [[73]]$times - [1] 0.00000 1.60059 - - [[73]]$NS - [1] 2 2 - - [[73]]$NI - [1] 1 0 - - [[73]]$NR - [1] 0 1 - - - [[74]] - [[74]]$times - [1] 0.000000 1.497596 - - [[74]]$NS - [1] 2 2 - - [[74]]$NI - [1] 1 0 - - [[74]]$NR - [1] 0 1 - - - [[75]] - [[75]]$times - [1] 0.000000 1.916758 - - [[75]]$NS - [1] 2 2 - - [[75]]$NI - [1] 1 0 - - [[75]]$NR - [1] 0 1 - - - [[76]] - [[76]]$times - [1] 0.0000000 0.8368377 4.1462512 14.4447646 - - [[76]]$NS - [1] 2 1 1 1 - - [[76]]$NI - [1] 1 2 1 0 - - [[76]]$NR - [1] 0 0 1 2 - - - [[77]] - [[77]]$times - [1] 0.000000 8.546053 9.275575 11.920068 14.117820 14.371987 - - [[77]]$NS - [1] 2 1 0 0 0 0 - - [[77]]$NI - [1] 1 2 3 2 1 0 - - [[77]]$NR - [1] 0 0 0 1 2 3 - - - [[78]] - [[78]]$times - [1] 0.000000 2.730273 6.669293 7.301694 14.402306 22.580301 - - [[78]]$NS - [1] 2 1 0 0 0 0 - - [[78]]$NI - [1] 1 2 3 2 1 0 - - [[78]]$NR - [1] 0 0 0 1 2 3 - - - [[79]] - [[79]]$times - [1] 0.00000 13.02458 - - [[79]]$NS - [1] 2 2 - - [[79]]$NI - [1] 1 0 - - [[79]]$NR - [1] 0 1 - - - [[80]] - [[80]]$times - [1] 0.000000 4.655717 10.847343 15.188912 38.570735 51.548959 - - [[80]]$NS - [1] 2 1 0 0 0 0 - - [[80]]$NI - [1] 1 2 3 2 1 0 - - [[80]]$NR - [1] 0 0 0 1 2 3 - - - [[81]] - [[81]]$times - [1] 0.000000 7.919139 12.774389 13.210280 20.037088 27.652380 - - [[81]]$NS - [1] 2 1 0 0 0 0 - - [[81]]$NI - [1] 1 2 3 2 1 0 - - [[81]]$NR - [1] 0 0 0 1 2 3 - - - [[82]] - [[82]]$times - [1] 0.000000 4.565727 4.640174 5.827227 8.181199 13.514984 - - [[82]]$NS - [1] 2 1 0 0 0 0 - - [[82]]$NI - [1] 1 2 3 2 1 0 - - [[82]]$NR - [1] 0 0 0 1 2 3 - - - [[83]] - [[83]]$times - [1] 0.0000000 0.4331829 - - [[83]]$NS - [1] 2 2 - - [[83]]$NI - [1] 1 0 - - [[83]]$NR - [1] 0 1 - - - [[84]] - [[84]]$times - [1] 0.0000000 0.5663187 - - [[84]]$NS - [1] 2 2 - - [[84]]$NI - [1] 1 0 - - [[84]]$NR - [1] 0 1 - - - [[85]] - [[85]]$times - [1] 0.000000 4.717821 7.368033 15.405952 20.251957 28.844191 - - [[85]]$NS - [1] 2 1 0 0 0 0 - - [[85]]$NI - [1] 1 2 3 2 1 0 - - [[85]]$NR - [1] 0 0 0 1 2 3 - - - [[86]] - [[86]]$times - [1] 0.00000 10.41346 13.17259 31.58865 35.49247 39.20284 - - [[86]]$NS - [1] 2 1 1 0 0 0 - - [[86]]$NI - [1] 1 2 1 2 1 0 - - [[86]]$NR - [1] 0 0 1 1 2 3 - - - [[87]] - [[87]]$times - [1] 0.000000 7.800903 - - [[87]]$NS - [1] 2 2 - - [[87]]$NI - [1] 1 0 - - [[87]]$NR - [1] 0 1 - - - [[88]] - [[88]]$times - [1] 0.000000 1.164975 2.214760 3.395779 4.269503 6.277390 - - [[88]]$NS - [1] 2 1 0 0 0 0 - - [[88]]$NI - [1] 1 2 3 2 1 0 - - [[88]]$NR - [1] 0 0 0 1 2 3 - - - [[89]] - [[89]]$times - [1] 0.000000 1.419246 5.241578 10.249121 - - [[89]]$NS - [1] 2 1 1 1 - - [[89]]$NI - [1] 1 2 1 0 - - [[89]]$NR - [1] 0 0 1 2 - - - [[90]] - [[90]]$times - [1] 0.000000 4.015171 - - [[90]]$NS - [1] 2 2 - - [[90]]$NI - [1] 1 0 - - [[90]]$NR - [1] 0 1 - - - [[91]] - [[91]]$times - [1] 0.00000 10.95119 10.95895 13.37237 15.94527 20.47069 - - [[91]]$NS - [1] 2 1 0 0 0 0 - - [[91]]$NI - [1] 1 2 3 2 1 0 - - [[91]]$NR - [1] 0 0 0 1 2 3 - - - [[92]] - [[92]]$times - [1] 0.000000 1.719506 - - [[92]]$NS - [1] 2 2 - - [[92]]$NI - [1] 1 0 - - [[92]]$NR - [1] 0 1 - - - [[93]] - [[93]]$times - [1] 0.00000 20.34997 23.10320 33.53507 37.61908 42.59392 - - [[93]]$NS - [1] 2 1 0 0 0 0 - - [[93]]$NI - [1] 1 2 3 2 1 0 - - [[93]]$NR - [1] 0 0 0 1 2 3 - - - [[94]] - [[94]]$times - [1] 0.000000 2.981562 4.220980 4.501876 5.930935 17.597979 - - [[94]]$NS - [1] 2 1 0 0 0 0 - - [[94]]$NI - [1] 1 2 3 2 1 0 - - [[94]]$NR - [1] 0 0 0 1 2 3 - - - [[95]] - [[95]]$times - [1] 0.0000000 0.8570038 6.2225289 7.4542303 - - [[95]]$NS - [1] 2 1 1 1 - - [[95]]$NI - [1] 1 2 1 0 - - [[95]]$NR - [1] 0 0 1 2 - - - [[96]] - [[96]]$times - [1] 0.00000 10.99346 - - [[96]]$NS - [1] 2 2 - - [[96]]$NI - [1] 1 0 - - [[96]]$NR - [1] 0 1 - - - [[97]] - [[97]]$times - [1] 0.000000 6.324172 10.943694 11.370294 - - [[97]]$NS - [1] 2 1 1 1 - - [[97]]$NI - [1] 1 2 1 0 - - [[97]]$NR - [1] 0 0 1 2 - - - [[98]] - [[98]]$times - [1] 0.00000000 0.07582625 1.04605163 3.19140611 3.57055288 9.94371399 - - [[98]]$NS - [1] 2 1 1 0 0 0 - - [[98]]$NI - [1] 1 2 1 2 1 0 - - [[98]]$NR - [1] 0 0 1 1 2 3 - - - [[99]] - [[99]]$times - [1] 0.000000 1.910419 - - [[99]]$NS - [1] 2 2 - - [[99]]$NI - [1] 1 0 - - [[99]]$NR - [1] 0 1 - - - [[100]] - [[100]]$times - [1] 0.000000 2.446835 - - [[100]]$NS - [1] 2 2 - - [[100]]$NI - [1] 1 0 - - [[100]]$NR - [1] 0 1 - - - attr(,"class") - [1] "sir" - ---- - - Code - sir_impl(graph = g, beta = 0.1, gamma = 0.1, no_sim = 2) - Output - [[1]] - [[1]]$times - [1] 0.0000000 0.5059133 5.9903814 8.4444363 - - [[1]]$NS - [1] 2 1 1 1 - - [[1]]$NI - [1] 1 2 1 0 - - [[1]]$NR - [1] 0 0 1 2 - - - [[2]] - [[2]]$times - [1] 0.000000 4.481524 - - [[2]]$NS - [1] 2 2 - - [[2]]$NI - [1] 1 0 - - [[2]]$NR - [1] 0 1 - - - attr(,"class") - [1] "sir" - -# sir_impl errors - - Code - sir_impl(graph = NULL, beta = 0.1, gamma = 0.1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# convex_hull_2d_impl basic - - Code - convex_hull_2d_impl(data = matrix(1:6, ncol = 2)) - Output - $resverts - [1] 1 3 - - $rescoords - [,1] [,2] - [1,] 1 4 - [2,] 3 6 - - -# convex_hull_2d_impl errors - - Code - convex_hull_2d_impl(data = "a") - Condition - Warning in `convex_hull_2d_impl()`: - NAs introduced by coercion - Error in `convex_hull_2d_impl()`: - ! REAL() can only be applied to a 'numeric', not a 'character' - -# dim_select_impl basic - - Code - dim_select_impl(sv = c(1, 2, 3)) - Output - [1] 1 - -# dim_select_impl errors - - Code - dim_select_impl(sv = NULL) - Condition - Error in `dim_select_impl()`: - ! Need at least one singular value for dimensionality selection. Invalid value - Source: : - -# solve_lsap_impl basic - - Code - solve_lsap_impl(c = matrix(1:4, ncol = 2), n = 2) - Output - [1] 0 1 - -# solve_lsap_impl errors - - Code - solve_lsap_impl(c = "a", n = 2) - Condition - Warning in `solve_lsap_impl()`: - NAs introduced by coercion - Error in `solve_lsap_impl()`: - ! REAL() can only be applied to a 'numeric', not a 'character' - -# find_cycle_impl basic - - Code - find_cycle_impl(graph = g) - Output - $vertices - + 0/3 vertices: - - $edges - + 0/2 edges: - - ---- - - Code - find_cycle_impl(graph = g, mode = "in") - Output - $vertices - + 0/3 vertices: - - $edges - + 0/2 edges: - - -# find_cycle_impl errors - - Code - find_cycle_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# simple_cycles_impl basic - - Code - simple_cycles_impl(graph = g) - Output - $vertices - list() - - $edges - list() - - ---- - - Code - simple_cycles_impl(graph = g, mode = "in", min_cycle_length = 2, - max_cycle_length = 3) - Output - $vertices - list() - - $edges - list() - - -# simple_cycles_impl errors - - Code - simple_cycles_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_eulerian_impl basic - - Code - is_eulerian_impl(graph = g) - Output - $has_path - [1] TRUE - - $has_cycle - [1] FALSE - - -# is_eulerian_impl errors - - Code - is_eulerian_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# eulerian_path_impl basic - - Code - eulerian_path_impl(graph = g) - Output - $epath - + 2/2 edges: - [1] 1--2 2--3 - - $vpath - + 3/3 vertices: - [1] 1 2 3 - - -# eulerian_path_impl errors - - Code - eulerian_path_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# eulerian_cycle_impl basic - - Code - eulerian_cycle_impl(graph = g1) - Condition - Error in `eulerian_cycle_impl()`: - ! The graph does not have an Eulerian cycle. Input problem has no solution - Source: : - ---- - - Code - eulerian_cycle_impl(graph = g2) - Output - $epath - + 4/4 edges: - [1] 1--2 2--3 3--4 1--4 - - $vpath - + 5/4 vertices: - [1] 1 2 3 4 1 - - -# eulerian_cycle_impl errors - - Code - eulerian_cycle_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# fundamental_cycles_impl basic - - Code - fundamental_cycles_impl(graph = g, start = 1) - Output - list() - ---- - - Code - fundamental_cycles_impl(graph = g, start = 1, bfs_cutoff = 2, weights = c(1, 2)) - Output - list() - -# fundamental_cycles_impl errors - - Code - fundamental_cycles_impl(graph = NULL, start = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# minimum_cycle_basis_impl basic - - Code - minimum_cycle_basis_impl(graph = g) - Output - list() - ---- - - Code - minimum_cycle_basis_impl(graph = g, bfs_cutoff = 2, complete = FALSE, - use_cycle_order = FALSE, weights = c(1, 2)) - Output - list() - -# minimum_cycle_basis_impl errors - - Code - minimum_cycle_basis_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_tree_impl basic - - Code - is_tree_impl(graph = g) - Output - [1] TRUE - ---- - - Code - is_tree_impl(graph = g, mode = "in", details = TRUE) - Output - $res - [1] TRUE - - $root - + 1/3 vertex: - [1] 1 - - -# is_tree_impl errors - - Code - is_tree_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_forest_impl basic - - Code - is_forest_impl(graph = g) - Output - [1] TRUE - ---- - - Code - is_forest_impl(graph = g, mode = "in", details = TRUE) - Output - $res - [1] TRUE - - $roots - + 1/3 vertex: - [1] 1 - - -# is_forest_impl errors - - Code - is_forest_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# from_prufer_impl basic - - Code - from_prufer_impl(prufer = 1:2) - Output - IGRAPH U--- 4 3 -- Tree from Prufer sequence - + attr: name (g/c), prufer (g/n) - + edges: - [1] 1--3 1--2 2--4 - -# from_prufer_impl errors - - Code - from_prufer_impl(prufer = "a") - Condition - Warning in `from_prufer_impl()`: - NAs introduced by coercion - Error in `from_prufer_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# to_prufer_impl basic - - Code - to_prufer_impl(graph = g) - Output - [1] 2 - -# to_prufer_impl errors - - Code - to_prufer_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# tree_from_parent_vector_impl basic - - Code - tree_from_parent_vector_impl(parents = c(-1, 1, 2, 3)) - Output - IGRAPH D--- 4 3 -- - + edges: - [1] 1->2 2->3 3->4 - ---- - - Code - tree_from_parent_vector_impl(parents = c(-1, 1, 2, 3), type = "in") - Output - IGRAPH D--- 4 3 -- - + edges: - [1] 2->1 3->2 4->3 - -# tree_from_parent_vector_impl errors - - Code - tree_from_parent_vector_impl(parents = "a") - Condition - Warning in `tree_from_parent_vector_impl()`: - NAs introduced by coercion - Error in `tree_from_parent_vector_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# is_complete_impl basic - - Code - is_complete_impl(graph = g) - Output - [1] FALSE - -# is_complete_impl errors - - Code - is_complete_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# random_spanning_tree_impl basic - - Code - random_spanning_tree_impl(graph = g, vid = 1) - Output - + 2/2 edges: - [1] 1--2 2--3 - -# random_spanning_tree_impl errors - - Code - random_spanning_tree_impl(graph = NULL, vid = 1) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# tree_game_impl basic - - Code - tree_game_impl(n = 3) - Output - IGRAPH U--- 3 2 -- - + edges: - [1] 2--3 1--2 - ---- - - Code - tree_game_impl(n = 3, directed = TRUE, method = "lerw") - Output - IGRAPH D--- 3 2 -- - + edges: - [1] 3->1 1->2 - -# tree_game_impl errors - - Code - tree_game_impl(n = "a") - Condition - Warning in `tree_game_impl()`: - NAs introduced by coercion - Error in `tree_game_impl()`: - ! The value nan is not representable as an integer. Invalid value - Source: : - -# vertex_coloring_greedy_impl basic - - Code - vertex_coloring_greedy_impl(graph = g) - Output - [1] 2 1 2 - ---- - - Code - vertex_coloring_greedy_impl(graph = g, heuristic = "dsatur") - Output - [1] 2 1 2 - -# vertex_coloring_greedy_impl errors - - Code - vertex_coloring_greedy_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_vertex_coloring_impl basic - - Code - is_vertex_coloring_impl(graph = g, types = c(1, 2, 3)) - Output - [1] TRUE - -# is_vertex_coloring_impl errors - - Code - is_vertex_coloring_impl(graph = NULL, types = c(1, 2, 3)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_bipartite_coloring_impl basic - - Code - is_bipartite_coloring_impl(graph = g, types = c(TRUE, FALSE, TRUE)) - Output - [1] TRUE - -# is_bipartite_coloring_impl errors - - Code - is_bipartite_coloring_impl(graph = NULL, types = c(TRUE, FALSE, TRUE)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# is_edge_coloring_impl basic - - Code - is_edge_coloring_impl(graph = g, types = c(1, 2)) - Output - [1] TRUE - ---- - - Code - is_edge_coloring_impl(graph = g) - Output - [1] TRUE - -# is_edge_coloring_impl errors - - Code - is_edge_coloring_impl(graph = NULL, types = c(1, 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# deterministic_optimal_imitation_impl basic - - Code - 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(graph = g, vid = 1, optimality = "minimum", - quantities = c(1, 2, 3), strategies = c(1, 2, 3), mode = "in") - Output - [1] 1 2 3 - -# deterministic_optimal_imitation_impl errors - - Code - deterministic_optimal_imitation_impl(graph = NULL, vid = 1, quantities = c(1, 2, - 3), strategies = c(1, 2, 3)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# moran_process_impl basic - - Code - 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 - - $strategies - [1] 1 3 3 - - -# moran_process_impl errors - - Code - moran_process_impl(graph = NULL, quantities = c(1, 2, 3), strategies = c(1, 2, - 3)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# roulette_wheel_imitation_impl basic - - Code - 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(graph = g, vid = 1, is_local = FALSE, quantities = c( - 1, 2, 3), strategies = c(1, 2, 3), mode = "in") - Output - [1] 3 2 3 - -# roulette_wheel_imitation_impl errors - - Code - roulette_wheel_imitation_impl(graph = NULL, vid = 1, is_local = TRUE, - quantities = c(1, 2, 3), strategies = c(1, 2, 3)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# stochastic_imitation_impl basic - - Code - 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(graph = g, vid = 1, algo = 2, quantities = c(1, 2, 3), - strategies = c(1, 2, 3), mode = "in") - Output - [1] 1 2 3 - -# stochastic_imitation_impl errors - - Code - stochastic_imitation_impl(graph = NULL, vid = 1, algo = 1, quantities = c(1, 2, - 3), strategies = c(1, 2, 3)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# invalidate_cache_impl basic - - Code - invalidate_cache_impl(graph = g) - Output - IGRAPH U--- 3 2 -- - + edges: - [1] 1--2 2--3 - -# invalidate_cache_impl errors - - Code - invalidate_cache_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# vertex_path_from_edge_path_impl basic - - Code - vertex_path_from_edge_path_impl(graph = g, start = 1, edge_path = c(1, 2)) - Output - + 3/3 vertices: - [1] 1 2 3 - ---- - - Code - vertex_path_from_edge_path_impl(graph = g, start = 1, edge_path = c(1), mode = "in") - Output - + 2/3 vertices: - [1] 1 2 - -# vertex_path_from_edge_path_impl errors - - Code - vertex_path_from_edge_path_impl(graph = NULL, start = 1, edge_path = c(1, 2)) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# version_impl basic - - Code - version_impl_clean() - Output - [1] "0.10.17" - -# version_impl errors - - Code - version_impl("invalid") - Condition - 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 - ecount_impl(graph = NULL) - 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 - is_directed_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# edges_impl basic - - Code - edges_impl(graph = g, eids = E(g)) - Output - + 6/4 vertices: - [1] 1 2 2 3 3 4 - ---- - - Code - edges_impl(graph = g, eids = c(1, 3)) - Output - + 4/4 vertices: - [1] 1 2 3 4 - -# edges_impl errors - - Code - edges_impl(graph = NULL, eids = 1) - 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 - add_vertices_impl(graph = NULL, nv = 1) - 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 - delete_edges_impl(graph = NULL, edges = 1) - 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 - delete_vertices_impl(graph = NULL, vertices = 1) - 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/3 edge: - [1] 2->3 - ---- - - Code - incident_impl(graph = g, vid = 2, mode = "in") - Output - + 1/3 edge: - [1] 1->2 - ---- - - Code - incident_impl(graph = g, vid = 2, mode = "all") - Output - + 2/3 edges: - [1] 1->2 2->3 - -# incident_impl errors - - Code - incident_impl(graph = NULL, vid = 1) - 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 - famous_impl(name = "NonexistentGraph") - Condition - Error in `famous_impl()`: - ! NonexistentGraph is not a known graph. See the documentation for valid graph names. Invalid value - Source: : - -# constraint_impl errors - - Code - constraint_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# cocitation_impl errors - - Code - cocitation_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# bibcoupling_impl errors - - Code - bibcoupling_impl(graph = NULL) - 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 - girth_impl(graph = NULL) - 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 - coreness_impl(graph = NULL) - 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 - union_impl(left = NULL, right = NULL) - 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 - intersection_impl(left = NULL, right = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# star_impl basic - - Code - star_impl(n = 5, mode = "out", center = 0) - Output - IGRAPH D--- 5 4 -- - + edges: - [1] 1->2 1->3 1->4 1->5 - ---- - - Code - star_impl(n = 6, mode = "in", center = 1) - Output - IGRAPH D--- 6 5 -- - + edges: - [1] 1->2 3->2 4->2 5->2 6->2 - ---- - - Code - star_impl(n = 4, mode = "undirected", center = 0) - Output - IGRAPH U--- 4 3 -- - + edges: - [1] 1--2 1--3 1--4 - -# ring_impl basic - - Code - ring_impl(n = 5, directed = FALSE, mutual = FALSE, circular = TRUE) - Output - IGRAPH U--- 5 5 -- - + edges: - [1] 1--2 2--3 3--4 4--5 1--5 - ---- - - Code - ring_impl(n = 4, directed = TRUE, mutual = FALSE, circular = FALSE) - Output - IGRAPH D--- 4 3 -- - + edges: - [1] 1->2 2->3 3->4 - -# full_impl basic - - Code - full_impl(n = 4, directed = FALSE, loops = FALSE) - Output - IGRAPH U--- 4 6 -- - + edges: - [1] 1--2 1--3 1--4 2--3 2--4 3--4 - ---- - - Code - full_impl(n = 3, directed = TRUE, loops = FALSE) - Output - IGRAPH D--- 3 6 -- - + edges: - [1] 1->2 1->3 2->1 2->3 3->1 3->2 - -# kary_tree_impl basic - - Code - kary_tree_impl(n = 7, children = 2, type = c("out", "in", "undirected")) - Output - IGRAPH D--- 7 6 -- - + edges: - [1] 1->2 1->3 2->4 2->5 3->6 3->7 - ---- - - Code - kary_tree_impl(n = 10, children = 3, type = c("in", "out", "undirected")) - Output - IGRAPH D--- 10 9 -- - + edges: - [1] 2->1 3->1 4->1 5->2 6->2 7->2 8->3 9->3 10->3 - -# barabasi_game_impl basic - - Code - barabasi_game_impl(n = 10, power = 1, m = 2, directed = FALSE, algo = "bag") - Output - IGRAPH U--- 10 18 -- - + edges: - [1] 1-- 2 1-- 2 2-- 3 1-- 3 2-- 4 2-- 4 2-- 5 2-- 5 4-- 6 2-- 6 2-- 7 1-- 7 - [13] 3-- 8 2-- 8 8-- 9 5-- 9 6--10 5--10 - ---- - - Code - barabasi_game_impl(n = 10, power = 1, m = 2, directed = FALSE, algo = "psumtree") - Output - IGRAPH U--- 10 17 -- - + edges: - [1] 1-- 2 1-- 3 2-- 3 1-- 4 2-- 4 2-- 5 4-- 5 1-- 6 3-- 6 6-- 7 3-- 7 6-- 8 - [13] 2-- 8 3-- 9 5-- 9 2--10 6--10 - -# grg_game_impl basic - - Code - grg_game_impl(nodes = 10, radius = 0.3, torus = FALSE) - Output - $graph - IGRAPH U--- 10 12 -- - + edges: - [1] 3-- 5 3-- 6 5-- 6 5-- 7 5-- 8 6-- 8 7-- 8 7-- 9 7--10 8-- 9 8--10 9--10 - - $x - [1] 0.08565451 0.15145413 0.45222514 0.45939554 0.55956278 0.61872370 - [7] 0.76201957 0.82545284 0.86690370 0.95857358 - - $y - [1] 0.07820721 0.85018913 0.08700766 0.73223568 0.33212277 0.14562638 - [7] 0.53326474 0.32235478 0.49679861 0.31410636 - - -# watts_strogatz_game_impl basic - - Code - watts_strogatz_game_impl(dim = 1, size = 10, nei = 2, p = 0.1) - Output - IGRAPH U--- 10 20 -- - + edges: - [1] 1-- 2 2-- 6 2-- 3 4-- 5 5-- 6 6-- 7 7-- 8 8-- 9 9--10 1--10 1-- 8 1-- 9 - [13] 2--10 2-- 4 3-- 5 4-- 6 5-- 7 6-- 8 7-- 9 8--10 - -# distances_impl basic - - Code - distances_impl(graph = g, from = V(g), to = V(g), mode = c("out", "in", "all", - "total")) - Output - [,1] [,2] [,3] [,4] [,5] - [1,] 0 1 2 2 1 - [2,] 1 0 1 2 2 - [3,] 2 1 0 1 2 - [4,] 2 2 1 0 1 - [5,] 1 2 2 1 0 - -# diameter_impl basic - - Code - diameter_impl(graph = g, directed = FALSE, unconnected = TRUE) - Output - $res - [1] 5 - - $from - [1] 0 - - $to - [1] 5 - - $vertex_path - [1] 0 1 2 3 4 5 - - $edge_path - [1] 0 1 2 3 4 - - -# get_shortest_paths_impl basic - - Code - get_shortest_paths_impl(graph = g, from = 1, to = 3, mode = c("out", "in", - "all", "total")) - Output - $vertices - $vertices[[1]] - + 3/5 vertices: - [1] 1 2 3 - - - $edges - $edges[[1]] - + 2/5 edges: - [1] 1--2 2--3 - - - $parents - [1] -1 0 1 -2 0 - - $inbound_edges - [1] -1 0 1 -1 4 - - -# subcomponent_impl basic - - Code - subcomponent_impl(graph = g, v = 1, mode = c("all", "out", "in")) - Output - + 3/6 vertices, named: - [1] A B C - -# betweenness_impl basic - - Code - betweenness_impl(graph = g, vids = V(g), directed = FALSE) - Output - [1] 6 0 0 0 0 - -# harmonic_centrality_impl basic - - Code - harmonic_centrality_impl(graph = g, vids = V(g), mode = c("out", "in", "all", - "total")) - Output - [1] 4.0 2.5 2.5 2.5 2.5 - -# pagerank_impl basic - - Code - pagerank_impl(graph = g, vids = V(g), directed = TRUE, damping = 0.85) - Output - $vector - [1] 0.2 0.2 0.2 0.2 0.2 - - $value - [1] 1 - - $options - NULL - - -# hub_score_impl basic - - Code - out - Output - $value - [1] 4 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 5 - - $options$which - [1] "LA" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 0 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 1 - - $options$numop - [1] 4 - - $options$numopb - [1] 0 - - $options$numreo - [1] 4 - - - -# authority_score_impl basic - - Code - out - Output - $value - [1] 4 - - $options - $options$bmat - [1] "I" - - $options$n - [1] 5 - - $options$which - [1] "LA" - - $options$nev - [1] 1 - - $options$tol - [1] 0 - - $options$ncv - [1] 0 - - $options$ldv - [1] 0 - - $options$ishift - [1] 1 - - $options$maxiter - [1] 3000 - - $options$nb - [1] 1 - - $options$mode - [1] 1 - - $options$start - [1] 1 - - $options$sigma - [1] 0 - - $options$sigmai - [1] 0 - - $options$info - [1] 0 - - $options$iter - [1] 1 - - $options$nconv - [1] 1 - - $options$numop - [1] 4 - - $options$numopb - [1] 0 - - $options$numreo - [1] 4 - - - -# community_walktrap_impl basic - - Code - community_walktrap_impl(graph = g, steps = 4) - Output - $merges - [,1] [,2] - [1,] 4 5 - [2,] 1 2 - [3,] 3 6 - [4,] 0 7 - [5,] 8 9 - - $modularity - [1] -0.17346939 -0.07142857 0.03061224 0.19387755 0.35714286 0.00000000 - - $membership - [1] 0 0 0 1 1 1 - - -# community_fastgreedy_impl basic - - Code - community_fastgreedy_impl(graph = g) - Output - $merges - [,1] [,2] - [1,] 2 1 - [2,] 0 6 - [3,] 5 4 - [4,] 3 8 - [5,] 9 7 - - $modularity - [1] -1.734694e-01 -7.142857e-02 9.183673e-02 1.938776e-01 3.571429e-01 - [6] 5.551115e-17 - - $membership - [1] 1 1 1 0 0 0 - - -# community_edge_betweenness_impl basic - - Code - community_edge_betweenness_impl(graph = g, directed = FALSE) - Output - $removed_edges - [1] 6 0 1 2 3 4 5 - - $edge_betweenness - [1] 9 1 2 1 1 2 1 - - $merges - [,1] [,2] - [1,] 5 3 - [2,] 6 4 - [3,] 2 0 - [4,] 8 1 - [5,] 7 9 - - $bridges - [1] 7 6 4 3 1 - - $modularity - [1] -0.17346939 -0.09183673 0.09183673 0.17346939 0.35714286 0.00000000 - - $membership - [1] 0 0 0 1 1 1 - - -# community_leading_eigenvector_callback_closure_impl basic - - Code - cat("Result class:\n") - Output - Result class: - Code - print(class(result)) - Output - [1] "igraph.eigenc" - Code - cat("\nMembership length:\n") - Output - - Membership length: - Code - print(length(result$membership)) - Output - [1] 34 - Code - cat("\nModularity:\n") - Output - - Modularity: - Code - print(result$modularity) - Output - [1] 0.3934089 - Code - cat("\nMerges dimensions:\n") - Output - - Merges dimensions: - Code - print(dim(result$merges)) - Output - [1] 3 2 - -# community_leading_eigenvector_callback_closure_impl with start - - Code - cat("Result with start membership:\n") - Output - Result with start membership: - Code - cat("Membership length:\n") - Output - Membership length: - Code - print(length(result$membership)) - Output - [1] 34 - Code - cat("\nModularity:\n") - Output - - Modularity: - Code - print(result$modularity) - Output - [1] 0.2217291 - -# community_leading_eigenvector_callback_closure_impl errors - - Code - community_leading_eigenvector_callback_closure_impl(graph = g, start = TRUE) - Condition - Error in `community_leading_eigenvector_callback_closure_impl()`: - ! Supplied memberhsip vector length does not match number of vertices. Invalid value - Source: : - -# edge_connectivity_impl basic - - Code - edge_connectivity_impl(graph = g) - Output - [1] 2 - -# vertex_connectivity_impl basic - - Code - vertex_connectivity_impl(graph = g) - Output - [1] 2 - -# create_bipartite_impl basic - - Code - create_bipartite_impl(types = c(FALSE, FALSE, TRUE, TRUE), edges = c(0, 2, 0, 3, - 1, 2, 1, 3), directed = FALSE) - Output - IGRAPH U--- 4 4 -- - + edges: - [1] 1--3 1--4 2--3 2--4 - -# bipartite_game_impl basic - - Code - bipartite_game_impl(type = "gnp", n1 = 5, n2 = 5, p = 0.3, directed = FALSE) - Output - $graph - IGRAPH U--- 10 10 -- - + edges: - [1] 1-- 6 2-- 6 4-- 6 5-- 6 1-- 7 4-- 7 4-- 8 3-- 9 3--10 4--10 - - $types - [1] FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE - - ---- - - Code - bipartite_game_impl(type = "gnm", n1 = 5, n2 = 5, m = 10, directed = FALSE) - Output - $graph - IGRAPH U--- 10 10 -- - + edges: - [1] 1-- 6 3-- 7 5-- 7 1-- 8 3-- 8 4-- 8 2-- 9 5-- 9 2--10 3--10 - - $types - [1] FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE - - -# decompose_impl basic - - Code - decompose_impl(graph = g, mode = c("weak", "strong")) - Output - [[1]] - IGRAPH UN-- 3 2 -- - + attr: name (v/c) - + edges (vertex names): - [1] A--B B--C - - [[2]] - IGRAPH UN-- 2 1 -- - + attr: name (v/c) - + edge (vertex names): - [1] D--E - - -# neighborhood_impl basic - - Code - neighborhood_impl(graph = g, order = 1, vids = V(g), mode = c("all", "out", - "in")) - Output - [[1]] - + 3/5 vertices: - [1] 1 2 5 - - [[2]] - + 3/5 vertices: - [1] 2 1 3 - - [[3]] - + 3/5 vertices: - [1] 3 2 4 - - [[4]] - + 3/5 vertices: - [1] 4 3 5 - - [[5]] - + 3/5 vertices: - [1] 5 1 4 - - -# neighborhood_size_impl basic - - Code - neighborhood_size_impl(graph = g, order = 1, vids = V(g), mode = c("all", "out", - "in")) - Output - [1] 3 3 3 3 3 - -# is_chordal_impl basic - - Code - is_chordal_impl(graph = g, alpha = alpha_vec, alpham1 = alpham1_vec) - Output - $chordal - [1] TRUE - - $fillin - numeric(0) - - $newgraph - IGRAPH U--- 4 6 -- Full graph - + attr: name (g/c), loops (g/l) - + edges: - [1] 1--2 1--3 1--4 2--3 2--4 3--4 - - ---- - - Code - is_chordal_impl(graph = g2, alpha = alpha_vec2, alpham1 = alpham1_vec2) - Output - $chordal - [1] FALSE - - $fillin - [1] 1 3 - - $newgraph - IGRAPH U--- 4 5 -- Ring graph - + attr: name (g/c), mutual (g/l), circular (g/l) - + edges: - [1] 1--2 2--3 3--4 1--4 2--4 - - -# get_adjacency_impl basic - - Code - get_adjacency_impl(graph = g, type = c("both", "upper", "lower")) - Output - [,1] [,2] [,3] - [1,] 0 1 1 - [2,] 1 0 1 - [3,] 1 1 0 - -# write_graph_edgelist_impl basic - - Code - content - Output - [1] "0 1" "0 2" "1 2" - -# read_graph_edgelist_impl basic - - Code - read_graph_edgelist_impl(instream = tmp, n = 3, directed = FALSE) - Output - IGRAPH U--- 3 3 -- - + edges: - [1] 1--2 2--3 1--3 - -# degree_sequence_game_impl basic - - Code - degree_sequence_game_impl(out_deg = c(2, 2, 2, 2), method = "configuration") - Output - IGRAPH U--- 4 4 -- - + edges: - [1] 2--4 3--3 1--4 1--2 - ---- - - Code - degree_sequence_game_impl(out_deg = c(2, 2, 2, 2), method = "vl") - Output - IGRAPH U--- 4 4 -- - + edges: - [1] 1--2 1--4 2--3 3--4 - -# connect_neighborhood_impl basic - - Code - connect_neighborhood_impl(graph = g, order = 1, mode = c("all", "out", "in")) - Condition - Warning in `connect_neighborhood_impl()`: - Order smaller than two, graph will be unchanged. - Source: : - Output - IGRAPH U--- 5 5 -- Ring graph - + attr: name (g/c), mutual (g/l), circular (g/l) - + edges: - [1] 1--2 2--3 3--4 4--5 1--5 - -# eccentricity_impl basic - - Code - eccentricity_impl(graph = g, vids = V(g), mode = c("out", "in", "all")) - Output - [1] 2 2 2 2 2 - -# radius_impl basic - - Code - radius_impl(graph = g, mode = c("out", "in", "all")) - Output - [1] 2 - -# graph_center_impl basic - - Code - graph_center_impl(graph = g, mode = c("out", "in", "all")) - Output - + 1/5 vertex: - [1] 1 - -# maximal_cliques_impl basic - - Code - maximal_cliques_impl(graph = g, min_size = 1, max_size = 0) - Output - [[1]] - + 4/4 vertices: - [1] 1 2 4 3 - - -# independent_vertex_sets_impl basic - - Code - independent_vertex_sets_impl(graph = g, min_size = 1, max_size = 0) - Output - [[1]] - + 1/5 vertex: - [1] 1 - - [[2]] - + 1/5 vertex: - [1] 2 - - [[3]] - + 1/5 vertex: - [1] 3 - - [[4]] - + 1/5 vertex: - [1] 4 - - [[5]] - + 1/5 vertex: - [1] 5 - - [[6]] - + 2/5 vertices: - [1] 1 3 - - [[7]] - + 2/5 vertices: - [1] 1 4 - - [[8]] - + 2/5 vertices: - [1] 2 4 - - [[9]] - + 2/5 vertices: - [1] 2 5 - - [[10]] - + 2/5 vertices: - [1] 3 5 - - -# bfs_closure_impl works - - Code - cat("BFS result:\n") - Output - BFS result: - Code - print(result) - Output - $order - + 10/10 vertices: - [1] 1 2 10 3 9 4 8 5 7 6 - - $rank - [1] 0 1 3 5 7 9 8 6 4 2 - - $parents - [1] -1 0 1 2 3 4 7 8 9 0 - - $pred - [1] -1 0 9 8 7 6 4 3 2 1 - - $succ - [1] 1 9 8 7 6 -1 5 4 3 2 - - $dist - [1] 0 1 2 3 4 5 4 3 2 1 - - Code - cat("\nNumber of BFS visits:", length(bfs_visits), "\n") - Output - - Number of BFS visits: 10 - Code - if (length(bfs_visits) > 0) { - cat("First visit:\n") - print(bfs_visits[[1]]) - } - Output - First visit: - vid pred succ rank dist - 1 0 2 1 0 - ---- - - Code - bfs_closure_impl(graph = g, root = 1, mode = "out", unreachable = TRUE, - restricted = NULL, callback = function(args) { - NA - }) - Condition - Error in `bfs_closure_impl()`: - ! Error in R callback function. Failed - Source: : - ---- - - Code - bfs_closure_impl(graph = g, root = 1, mode = "out", unreachable = TRUE, - restricted = NULL, callback = function(args) { - NA - }) - Condition - Error in `bfs_closure_impl()`: - ! Error in R callback function. Failed - Source: : - -# dfs_closure_impl works - - Code - cat("DFS result:\n") - Output - DFS result: - Code - print(result) - Output - $order - + 10/10 vertices: - [1] 1 2 3 4 5 6 7 8 9 10 - - $order_out - + 10/10 vertices: - [1] 10 9 8 7 6 5 4 3 2 1 - - $father - [1] -1 0 1 2 3 4 5 6 7 8 - - $dist - [1] 0 1 2 3 4 5 6 7 8 9 - - Code - cat("\nNumber of DFS IN visits:", length(dfs_in_visits), "\n") - Output - - Number of DFS IN visits: 10 - Code - cat("Number of DFS OUT visits:", length(dfs_out_visits), "\n") - Output - Number of DFS OUT visits: 10 - Code - if (length(dfs_in_visits) > 0) { - cat("First IN visit:\n") - print(dfs_in_visits[[1]]) - } - Output - First IN visit: - vid dist - 1 0 - -# motifs_randesu_callback_closure_impl basic - - Code - cat("Result:\n") - Output - Result: - Code - print(result) - Output - NULL - Code - cat("\nNumber of motifs found:", length(motif_data), "\n") - Output - - Number of motifs found: 1 - Code - cat("First motif:\n") - Output - First motif: - Code - print(motif_data[[1]]) - Output - $vids - [1] 1 3 2 - - $isoclass - [1] 4 - - -# motifs_randesu_callback_closure_impl errors - - Code - motifs_randesu_callback_closure_impl(graph = g, size = 3, cut_prob = NULL, - callback = "not a function") - Condition - Error in `motifs_randesu_callback_closure_impl()`: - ! `callback` must be a function - -# cliques_callback_closure_impl basic - - Code - cat("Result:\n") - Output - Result: - Code - print(result) - Output - NULL - Code - cat("\nNumber of cliques found:", length(clique_data), "\n") - Output - - Number of cliques found: 5 - Code - cat("First clique:\n") - Output - First clique: - Code - print(clique_data[[1]]) - Output - [1] 2 3 4 - -# cliques_callback_closure_impl errors - - Code - cliques_callback_closure_impl(graph = g, min_size = 3, max_size = 4, callback = "not a function") - Condition - Error in `cliques_callback_closure_impl()`: - ! `callback` must be a function - -# maximal_cliques_callback_closure_impl basic - - Code - cat("Result:\n") - Output - Result: - Code - print(result) - Output - NULL - Code - cat("\nNumber of maximal cliques found:", length(clique_data), "\n") - Output - - Number of maximal cliques found: 3 - Code - if (length(clique_data) > 0) { - cat("First maximal clique:\n") - print(clique_data[[1]]) - } - Output - First maximal clique: - [1] 2 1 4 - -# maximal_cliques_callback_closure_impl errors - - Code - maximal_cliques_callback_closure_impl(graph = g, min_size = 3, max_size = 0, - callback = "not a function") - Condition - Error in `maximal_cliques_callback_closure_impl()`: - ! `callback` must be a function - -# simple_cycles_callback_closure_impl basic - - Code - cat("Result:\n") - Output - Result: - Code - print(result) - Output - NULL - Code - cat("\nNumber of cycles found:", length(cycle_data), "\n") - Output - - Number of cycles found: 1 - Code - cat("First cycle:\n") - Output - First cycle: - Code - print(cycle_data[[1]]) - Output - $vertices - [1] 1 2 3 4 - - $edges - [1] 1 2 3 4 - - -# simple_cycles_callback_closure_impl errors - - Code - simple_cycles_callback_closure_impl(graph = g, mode = "out", min_cycle_length = - - 1, max_cycle_length = -1, callback = "not a function") - Condition - Error in `simple_cycles_callback_closure_impl()`: - ! `callback` must be a function - -# get_isomorphisms_vf2_callback_closure_impl basic - - Code - cat("Result:\n") - Output - Result: - Code - print(result) - Output - NULL - Code - cat("\nNumber of isomorphisms found:", length(iso_data), "\n") - Output - - Number of isomorphisms found: 2 - Code - cat("First isomorphism:\n") - Output - First isomorphism: - Code - print(iso_data[[1]]) - Output - $map12 - [1] 1 2 3 4 5 - - $map21 - [1] 1 2 3 4 5 - - -# get_isomorphisms_vf2_callback_closure_impl errors - - Code - get_isomorphisms_vf2_callback_closure_impl(graph1 = g1, graph2 = g2, - vertex_color1 = NULL, vertex_color2 = NULL, edge_color1 = NULL, edge_color2 = NULL, - callback = "not a function") - Condition - Error in `get_isomorphisms_vf2_callback_closure_impl()`: - ! `callback` must be a function - -# get_subisomorphisms_vf2_callback_closure_impl basic - - Code - cat("Result:\n") - Output - Result: - Code - print(result) - Output - NULL - Code - cat("\nNumber of subisomorphisms found:", length(subiso_data), "\n") - Output - - Number of subisomorphisms found: 2 - Code - cat("First subisomorphism:\n") - Output - First subisomorphism: - Code - print(subiso_data[[1]]) - Output - $map12 - [1] 1 2 3 0 0 - - $map21 - [1] 1 2 3 - - -# get_subisomorphisms_vf2_callback_closure_impl errors - - Code - get_subisomorphisms_vf2_callback_closure_impl(graph1 = g1, graph2 = g2, - vertex_color1 = NULL, vertex_color2 = NULL, edge_color1 = NULL, edge_color2 = NULL, - callback = "not a function") - Condition - Error in `get_subisomorphisms_vf2_callback_closure_impl()`: - ! `callback` must be a function - -# sparse_adjacency_impl basic - - Code - sparse_adjacency_impl(adjmatrix = M) - Output - IGRAPH D--- 4 4 -- - + edges: - [1] 4->1 1->2 2->3 3->4 - ---- - - Code - sparse_adjacency_impl(adjmatrix = M_sym, mode = "undirected", loops = "once") - Output - IGRAPH U--- 4 4 -- - + edges: - [1] 1--2 2--3 1--4 3--4 - -# sparse_weighted_adjacency_impl basic - - Code - sparse_weighted_adjacency_impl(adjmatrix = M) - Output - $graph - IGRAPH D--- 4 4 -- - + edges: - [1] 4->1 1->2 2->3 3->4 - - $weights - [1] 0.5 2.5 1.0 3.0 - - ---- - - Code - sparse_weighted_adjacency_impl(adjmatrix = M_sym, mode = "undirected", loops = "once") - Output - $graph - IGRAPH U--- 4 4 -- - + edges: - [1] 1--2 2--3 1--4 3--4 - - $weights - [1] 2.5 1.0 0.5 3.0 - - -# weighted_sparsemat_impl basic - - Code - weighted_sparsemat_impl(A = M, directed = TRUE, attr = "weight", loops = FALSE) - Output - IGRAPH D-W- 4 4 -- - + attr: weight (e/n) - + edges: - [1] 4->1 1->2 2->3 3->4 - -# disjoint_union_many_impl basic - - Code - disjoint_union_many_impl(graphs = list(g1, g2, g3)) - Output - IGRAPH D--- 6 0 -- - + edges: - -# union_many_impl basic - - Code - union_many_impl(graphs = list(g1, g2, g3)) - Output - $res - IGRAPH D--- 3 3 -- - + edges: - [1] 2->3 1->3 1->2 - - $edgemaps - $edgemaps[[1]] - numeric(0) - - $edgemaps[[2]] - [1] 2 0 - - $edgemaps[[3]] - [1] 1 - - - -# intersection_many_impl basic - - Code - intersection_many_impl(graphs = list(g1, g2, g3)) - Output - $res - IGRAPH D--- 3 1 -- - + edge: - [1] 1->2 - - $edgemaps - $edgemaps[[1]] - [1] 0 -1 -1 - - $edgemaps[[2]] - [1] 0 -1 - - $edgemaps[[3]] - [1] 0 - - - -# layout_merge_dla_impl basic - - Code - layout_merge_dla_impl(graphs = list(g1, g2), coords = list(coords1, coords2)) - Output - [,1] [,2] - [1,] -2.279507 0.0000000 - [2,] 0.000000 0.0000000 - [3,] 2.279507 0.0000000 - [4,] -6.893133 -0.8307751 - [5,] -4.613626 -0.8307751 - [6,] -2.334119 -0.8307751 - -# get_eid_impl basic - - Code - get_eid_impl(graph = g, from = 1, to = 2) - Output - + 1/4 edge: - [1] 1->2 - -# get_eid_impl errors - - Code - get_eid_impl(graph = NULL, from = 1, to = 2) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - ---- - - Code - get_eid_impl(graph = g, from = c(1, 2), to = 2) - Condition - Error: - ! `from` must specify exactly one vertex - ---- - - Code - get_eid_impl(graph = g, from = 1, to = integer(0)) - Condition - Error: - ! `to` must specify exactly one vertex - -# community_voronoi_impl basic - - Code - community_voronoi_impl(graph = g) - Output - $membership - [1] 3 3 3 3 0 3 2 2 1 1 - - $generators - + 4/10 vertices: - [1] 2 9 7 1 - - $modularity - [1] 0.2222222 - - -# community_voronoi_impl errors - - Code - community_voronoi_impl(graph = NULL) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - -# subisomorphic_lad_impl errors - - Code - subisomorphic_lad_impl(pattern = NULL, target = g, domains = list(), induced = FALSE, - time_limit = 0) - Condition - Error in `ensure_igraph()`: - ! Must provide a graph object (provided `NULL`). - ---- - - Code - subisomorphic_lad_impl(pattern = g, target = g, domains = "not a list", - induced = FALSE, time_limit = 0) - Condition - Error: - ! `domains` must be a list or NULL - diff --git a/tests/testthat/_snaps/aaa-basic-igraph.md b/tests/testthat/_snaps/aaa-basic-igraph.md new file mode 100644 index 00000000000..e2d5454efa8 --- /dev/null +++ b/tests/testthat/_snaps/aaa-basic-igraph.md @@ -0,0 +1,328 @@ +# empty_impl basic + + Code + empty_impl() + Output + IGRAPH D--- 0 0 -- + + edges: + +--- + + Code + empty_impl(n = 5, directed = FALSE) + Output + IGRAPH U--- 5 0 -- + + edges: + +# empty_impl errors + + Code + empty_impl(n = -1) + Condition + Error in `empty_impl()`: + ! Number of vertices must not be negative. Invalid value + Source: : + +# add_edges_impl basic + + Code + add_edges_impl(graph = g, edges = c(1, 2, 2, 3)) + Output + IGRAPH D--- 3 2 -- + + edges: + [1] 1->2 2->3 + +# add_edges_impl errors + + Code + add_edges_impl(graph = NULL, edges = c(1, 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# copy_impl basic + + Code + copy_impl(from = g) + Output + IGRAPH D--- 2 0 -- + + edges: + +# copy_impl errors + + Code + copy_impl(from = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# delete_vertices_idx_impl basic + + Code + delete_vertices_idx_impl(graph = g, vertices = 1) + Output + $graph + IGRAPH D--- 2 0 -- + + edges: + + $idx + [1] 0 1 2 + + $invidx + [1] 1 2 + + +# delete_vertices_idx_impl errors + + Code + delete_vertices_idx_impl(graph = NULL, vertices = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# vcount_impl basic + + Code + vcount_impl(graph = g) + Output + [1] 4 + +# vcount_impl errors + + Code + vcount_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# degree_impl basic + + Code + degree_impl(graph = g) + Output + [1] 0 0 0 + +--- + + Code + degree_impl(graph = g, mode = "in") + Output + [1] 0 0 0 + +# degree_impl errors + + Code + degree_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_all_eids_between_impl basic + + Code + get_all_eids_between_impl(graph = g, from = 1, to = 2) + Output + + 0/0 edges: + +# get_all_eids_between_impl errors + + Code + get_all_eids_between_impl(graph = NULL, from = 1, to = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# invalidate_cache_impl basic + + Code + invalidate_cache_impl(graph = g) + Output + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + +# invalidate_cache_impl errors + + Code + invalidate_cache_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# ecount_impl basic + + Code + ecount_impl(graph = g) + Output + [1] 0 + +--- + + Code + ecount_impl(graph = g) + Output + [1] 3 + +# ecount_impl errors + + Code + ecount_impl(graph = NULL) + 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 + is_directed_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# edges_impl basic + + Code + edges_impl(graph = g, eids = E(g)) + Output + + 6/4 vertices: + [1] 1 2 2 3 3 4 + +--- + + Code + edges_impl(graph = g, eids = c(1, 3)) + Output + + 4/4 vertices: + [1] 1 2 3 4 + +# edges_impl errors + + Code + edges_impl(graph = NULL, eids = 1) + 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 + add_vertices_impl(graph = NULL, nv = 1) + 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 + delete_edges_impl(graph = NULL, edges = 1) + 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 + delete_vertices_impl(graph = NULL, vertices = 1) + 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/3 edge: + [1] 2->3 + +--- + + Code + incident_impl(graph = g, vid = 2, mode = "in") + Output + + 1/3 edge: + [1] 1->2 + +--- + + Code + incident_impl(graph = g, vid = 2, mode = "all") + Output + + 2/3 edges: + [1] 1->2 2->3 + +# incident_impl errors + + Code + incident_impl(graph = NULL, vid = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_eid_impl basic + + Code + get_eid_impl(graph = g, from = 1, to = 2) + Output + + 1/4 edge: + [1] 1->2 + +# get_eid_impl errors + + Code + get_eid_impl(graph = NULL, from = 1, to = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +--- + + Code + get_eid_impl(graph = g, from = c(1, 2), to = 2) + Condition + Error: + ! `from` must specify exactly one vertex + +--- + + Code + get_eid_impl(graph = g, from = 1, to = integer(0)) + Condition + Error: + ! `to` must specify exactly one vertex + diff --git a/tests/testthat/_snaps/aaa-bipartite.md b/tests/testthat/_snaps/aaa-bipartite.md new file mode 100644 index 00000000000..71bd034b904 --- /dev/null +++ b/tests/testthat/_snaps/aaa-bipartite.md @@ -0,0 +1,257 @@ +# full_bipartite_impl basic + + Code + full_bipartite_impl(n1 = 2, n2 = 3) + Output + $graph + IGRAPH U--- 5 6 -- + + edges: + [1] 1--3 1--4 1--5 2--3 2--4 2--5 + + $types + [1] FALSE FALSE TRUE TRUE TRUE + + +--- + + Code + full_bipartite_impl(n1 = 2, n2 = 3, directed = TRUE, mode = "in") + Output + $graph + IGRAPH D--- 5 6 -- + + edges: + [1] 3->1 4->1 5->1 3->2 4->2 5->2 + + $types + [1] FALSE FALSE TRUE TRUE TRUE + + +# full_bipartite_impl errors + + Code + full_bipartite_impl(n1 = -1, n2 = 3) + Condition + Error in `full_bipartite_impl()`: + ! Invalid number of vertices for bipartite graph. Invalid value + Source: : + +# bipartite_projection_size_impl basic + + Code + bipartite_projection_size_impl(graph = g) + Output + $vcount1 + [1] 2 + + $ecount1 + [1] 1 + + $vcount2 + [1] 2 + + $ecount2 + [1] 1 + + +# bipartite_projection_size_impl errors + + Code + bipartite_projection_size_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# biadjacency_impl basic + + Code + biadjacency_impl(incidence = m) + Output + $graph + IGRAPH U--- 5 4 -- + + edges: + [1] 1--3 1--4 1--5 2--5 + + $types + [1] FALSE FALSE TRUE TRUE TRUE + + +--- + + Code + biadjacency_impl(incidence = m, directed = TRUE, mode = "in", multiple = TRUE) + Output + $graph + IGRAPH D--- 5 4 -- + + edges: + [1] 3->1 4->1 5->1 5->2 + + $types + [1] FALSE FALSE TRUE TRUE TRUE + + +# biadjacency_impl errors + + Code + biadjacency_impl(incidence = "a") + Condition + Warning in `biadjacency_impl()`: + NAs introduced by coercion + Error in `biadjacency_impl()`: + ! REAL() can only be applied to a 'numeric', not a 'character' + +# get_biadjacency_impl basic + + Code + get_biadjacency_impl(graph = g, types = c(TRUE, FALSE, TRUE)) + Output + $res + [,1] [,2] + [1,] 1 1 + + $row_ids + [1] 2 + + $col_ids + [1] 1 3 + + +# get_biadjacency_impl errors + + Code + get_biadjacency_impl(graph = NULL, types = c(TRUE, FALSE, TRUE)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_bipartite_impl basic + + Code + is_bipartite_impl(graph = g) + Output + $res + [1] TRUE + + $type + [1] FALSE TRUE FALSE + + +# is_bipartite_impl errors + + Code + is_bipartite_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# bipartite_game_gnp_impl basic + + Code + bipartite_game_gnp_impl(n1 = 2, n2 = 2, p = 0.5) + Output + $graph + IGRAPH U--- 4 4 -- + + edges: + [1] 1--3 2--3 1--4 2--4 + + $types + [1] FALSE FALSE TRUE TRUE + + +--- + + Code + bipartite_game_gnp_impl(n1 = 2, n2 = 2, p = 0.5, directed = TRUE, mode = "in") + Output + $graph + IGRAPH D--- 4 1 -- + + edge: + [1] 3->2 + + $types + [1] FALSE FALSE TRUE TRUE + + +# bipartite_game_gnp_impl errors + + Code + bipartite_game_gnp_impl(n1 = -1, n2 = 2, p = 0.5) + Condition + Error in `bipartite_game_gnp_impl()`: + ! Invalid number of vertices for bipartite graph. Invalid value + Source: : + +# bipartite_game_gnm_impl basic + + Code + bipartite_game_gnm_impl(n1 = 2, n2 = 2, m = 1) + Output + $graph + IGRAPH U--- 4 1 -- + + edge: + [1] 2--4 + + $types + [1] FALSE FALSE TRUE TRUE + + +--- + + Code + bipartite_game_gnm_impl(n1 = 2, n2 = 2, m = 1, directed = TRUE, mode = "in") + Output + $graph + IGRAPH D--- 4 1 -- + + edge: + [1] 3->1 + + $types + [1] FALSE FALSE TRUE TRUE + + +# bipartite_game_gnm_impl errors + + Code + bipartite_game_gnm_impl(n1 = -1, n2 = 2, m = 1) + Condition + Error in `bipartite_game_gnm_impl()`: + ! Invalid number of vertices for bipartite graph. Invalid value + Source: : + +# create_bipartite_impl basic + + Code + create_bipartite_impl(types = c(FALSE, FALSE, TRUE, TRUE), edges = c(0, 2, 0, 3, + 1, 2, 1, 3), directed = FALSE) + Output + IGRAPH U--- 4 4 -- + + edges: + [1] 1--3 1--4 2--3 2--4 + +# bipartite_game_impl basic + + Code + bipartite_game_impl(type = "gnp", n1 = 5, n2 = 5, p = 0.3, directed = FALSE) + Output + $graph + IGRAPH U--- 10 10 -- + + edges: + [1] 1-- 6 2-- 6 4-- 6 5-- 6 1-- 7 4-- 7 4-- 8 3-- 9 3--10 4--10 + + $types + [1] FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE + + +--- + + Code + bipartite_game_impl(type = "gnm", n1 = 5, n2 = 5, m = 10, directed = FALSE) + Output + $graph + IGRAPH U--- 10 10 -- + + edges: + [1] 1-- 6 3-- 7 5-- 7 1-- 8 3-- 8 4-- 8 2-- 9 5-- 9 2--10 3--10 + + $types + [1] FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE + + diff --git a/tests/testthat/_snaps/aaa-centrality.md b/tests/testthat/_snaps/aaa-centrality.md new file mode 100644 index 00000000000..9ddacdda56d --- /dev/null +++ b/tests/testthat/_snaps/aaa-centrality.md @@ -0,0 +1,1314 @@ +# closeness_impl basic + + Code + closeness_impl(graph = g) + Output + $res + [1] 0.3333333 0.5000000 0.3333333 + + $reachable_count + [1] 2 2 2 + + $all_reachable + [1] TRUE + + +--- + + Code + closeness_impl(graph = g, mode = "in", normalized = TRUE) + Output + $res + [1] 0.6666667 1.0000000 0.6666667 + + $reachable_count + [1] 2 2 2 + + $all_reachable + [1] TRUE + + +--- + + Code + closeness_impl(graph = g, vids = V(g), mode = c("out", "in", "all", "total")) + Output + $res + [1] 0.1666667 0.1666667 0.1666667 0.1666667 0.1666667 + + $reachable_count + [1] 4 4 4 4 4 + + $all_reachable + [1] TRUE + + +# closeness_impl errors + + Code + closeness_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# closeness_cutoff_impl basic + + Code + closeness_cutoff_impl(graph = g, cutoff = 2) + Output + $res + [1] 0.3333333 0.5000000 0.3333333 + + $reachable_count + [1] 2 2 2 + + $all_reachable + [1] TRUE + + +--- + + Code + closeness_cutoff_impl(graph = g, mode = "in", normalized = TRUE, cutoff = 1) + Output + $res + [1] 1 1 1 + + $reachable_count + [1] 1 2 1 + + $all_reachable + [1] FALSE + + +# closeness_cutoff_impl errors + + Code + closeness_cutoff_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# betweenness_cutoff_impl basic + + Code + betweenness_cutoff_impl(graph = g, cutoff = 2) + Output + [1] 0 1 0 + +# betweenness_cutoff_impl errors + + Code + betweenness_cutoff_impl(graph = NULL, cutoff = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# betweenness_subset_impl basic + + Code + betweenness_subset_impl(graph = g) + Output + [1] 0 1 0 + +# betweenness_subset_impl errors + + Code + betweenness_subset_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# edge_betweenness_impl basic + + Code + edge_betweenness_impl(graph = g) + Output + [1] 2 2 + +--- + + Code + edge_betweenness_impl(graph = g, directed = FALSE) + Output + [1] 4 4 4 4 + +# edge_betweenness_impl errors + + Code + edge_betweenness_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# edge_betweenness_cutoff_impl basic + + Code + edge_betweenness_cutoff_impl(graph = g, cutoff = 2) + Output + [1] 2 2 + +# edge_betweenness_cutoff_impl errors + + Code + edge_betweenness_cutoff_impl(graph = NULL, cutoff = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# edge_betweenness_subset_impl basic + + Code + edge_betweenness_subset_impl(graph = g) + Output + [1] 2 2 + +# edge_betweenness_subset_impl errors + + Code + edge_betweenness_subset_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# harmonic_centrality_cutoff_impl basic + + Code + harmonic_centrality_cutoff_impl(graph = g, cutoff = 2) + Output + [1] 1.5 2.0 1.5 + +# harmonic_centrality_cutoff_impl errors + + Code + harmonic_centrality_cutoff_impl(graph = NULL, cutoff = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# personalized_pagerank_impl basic + + Code + personalized_pagerank_impl(graph = g) + Output + $vector + [1] 0.2567568 0.4864865 0.2567568 + + $value + [1] 1 + + $options + NULL + + +--- + + Code + personalized_pagerank_impl(graph = g, algo = "arpack", damping = 0.9) + Output + $vector + [1] 0.2543860 0.4912281 0.2543860 + + $value + [1] 1 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 3 + + $options$which + [1] "LR" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 0 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 1 + + $options$numop + [1] 3 + + $options$numopb + [1] 0 + + $options$numreo + [1] 3 + + + +# personalized_pagerank_impl errors + + Code + personalized_pagerank_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# personalized_pagerank_vs_impl basic + + Code + personalized_pagerank_vs_impl(graph = g, reset_vids = 1) + Output + [1] 0.3452703 0.4594595 0.1952703 + +--- + + Code + personalized_pagerank_vs_impl(graph = g, algo = "arpack", reset_vids = 1, + details = TRUE) + Output + $vector + [1] 0.3452703 0.4594595 0.1952703 + + $value + [1] 1 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 3 + + $options$which + [1] "LR" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 0 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 1 + + $options$numop + [1] 3 + + $options$numopb + [1] 0 + + $options$numreo + [1] 3 + + + +# personalized_pagerank_vs_impl errors + + Code + personalized_pagerank_vs_impl(graph = NULL, reset_vids = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# maxdegree_impl basic + + Code + maxdegree_impl(graph = g) + Output + [1] 2 + +--- + + Code + maxdegree_impl(graph = g, mode = "in", loops = FALSE) + Output + [1] 2 + +# maxdegree_impl errors + + Code + maxdegree_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# eigenvector_centrality_impl basic + + Code + eigenvector_centrality_impl(graph = g) + Output + $vector + [1] 0.7071068 1.0000000 0.7071068 + + $value + [1] 1.414214 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 3 + + $options$which + [1] "LA" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 0 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 1 + + $options$numop + [1] 3 + + $options$numopb + [1] 0 + + $options$numreo + [1] 3 + + + +--- + + Code + eigenvector_centrality_impl(graph = g, directed = TRUE, scale = FALSE) + Output + $vector + [1] 0.5000000 0.7071068 0.5000000 + + $value + [1] 1.414214 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 3 + + $options$which + [1] "LA" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 0 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 1 + + $options$numop + [1] 3 + + $options$numopb + [1] 0 + + $options$numreo + [1] 3 + + + +# eigenvector_centrality_impl errors + + Code + eigenvector_centrality_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# hub_and_authority_scores_impl basic + + Code + hub_and_authority_scores_impl(graph = g) + Output + $hub + [1] 1 1 1 1 1 + + $authority + [1] 1 1 1 1 1 + + $value + [1] 16 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 5 + + $options$which + [1] "LA" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 0 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 1 + + $options$numop + [1] 4 + + $options$numopb + [1] 0 + + $options$numreo + [1] 4 + + + +--- + + Code + hub_and_authority_scores_impl(graph = g, scale = FALSE) + Output + $hub + [1] 0.4472136 0.4472136 0.4472136 0.4472136 0.4472136 + + $authority + [1] 0.4472136 0.4472136 0.4472136 0.4472136 0.4472136 + + $value + [1] 16 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 5 + + $options$which + [1] "LA" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 0 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 1 + + $options$numop + [1] 4 + + $options$numopb + [1] 0 + + $options$numreo + [1] 4 + + + +# hub_and_authority_scores_impl errors + + Code + hub_and_authority_scores_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# strength_impl basic + + Code + strength_impl(graph = g) + Output + [1] 1 2 1 + +--- + + Code + strength_impl(graph = g, mode = "in", loops = FALSE) + Output + [1] 1 2 1 + +# strength_impl errors + + Code + strength_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# centralization_impl basic + + Code + centralization_impl(scores = c(1, 2, 3)) + Output + [1] Inf + +--- + + Code + centralization_impl(scores = c(1, 2, 3), theoretical_max = 2, normalized = FALSE) + Output + [1] 3 + +# centralization_impl errors + + Code + centralization_impl(scores = package_version("1.2.3")) + Condition + Error in `centralization_impl()`: + ! 'list' object cannot be coerced to type 'double' + +# centralization_degree_impl basic + + Code + centralization_degree_impl(graph = g) + Output + $res + [1] 1 2 1 + + $centralization + [1] 0.3333333 + + $theoretical_max + [1] 6 + + +--- + + Code + centralization_degree_impl(graph = g, mode = "in", loops = FALSE, normalized = FALSE) + Output + $res + [1] 1 2 1 + + $centralization + [1] 2 + + $theoretical_max + [1] 2 + + +# centralization_degree_impl errors + + Code + centralization_degree_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# centralization_degree_tmax_impl basic + + Code + centralization_degree_tmax_impl(nodes = 3, loops = TRUE) + Output + [1] 6 + +--- + + Code + centralization_degree_tmax_impl(nodes = 3, mode = "in", loops = FALSE) + Output + [1] 4 + +# centralization_degree_tmax_impl errors + + Code + centralization_degree_tmax_impl(nodes = -1, loops = TRUE) + Condition + Error in `centralization_degree_tmax_impl()`: + ! Number of vertices must not be negative. Invalid value + Source: : + +# centralization_betweenness_impl basic + + Code + centralization_betweenness_impl(graph = g) + Output + $res + [1] 0 1 0 + + $centralization + [1] 1 + + $theoretical_max + [1] 2 + + +--- + + Code + centralization_betweenness_impl(graph = g, directed = FALSE, normalized = FALSE) + Output + $res + [1] 0 1 0 + + $centralization + [1] 2 + + $theoretical_max + [1] 2 + + +# centralization_betweenness_impl errors + + Code + centralization_betweenness_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# centralization_betweenness_tmax_impl basic + + Code + centralization_betweenness_tmax_impl(nodes = 3, directed = TRUE) + Output + [1] 4 + +--- + + Code + centralization_betweenness_tmax_impl(nodes = 3, directed = FALSE) + Output + [1] 2 + +# centralization_betweenness_tmax_impl errors + + Code + centralization_betweenness_tmax_impl(nodes = -1, directed = TRUE) + Condition + Error in `centralization_betweenness_tmax_impl()`: + ! Number of vertices must not be negative. Invalid value + Source: : + +# centralization_closeness_impl basic + + Code + centralization_closeness_impl(graph = g) + Output + $res + [1] 0.6666667 1.0000000 0.6666667 + + $centralization + [1] 1 + + $theoretical_max + [1] 0.6666667 + + +--- + + Code + centralization_closeness_impl(graph = g, mode = "in", normalized = FALSE) + Output + $res + [1] 0.6666667 1.0000000 0.6666667 + + $centralization + [1] 0.6666667 + + $theoretical_max + [1] 0.6666667 + + +# centralization_closeness_impl errors + + Code + centralization_closeness_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# centralization_closeness_tmax_impl basic + + Code + centralization_closeness_tmax_impl(nodes = 3) + Output + [1] 1.333333 + +--- + + Code + centralization_closeness_tmax_impl(nodes = 3, mode = "in") + Output + [1] 1.333333 + +# centralization_closeness_tmax_impl errors + + Code + centralization_closeness_tmax_impl(nodes = -1) + Condition + Error in `centralization_closeness_tmax_impl()`: + ! Number of vertices must not be negative. Invalid value + Source: : + +# centralization_eigenvector_centrality_impl basic + + Code + centralization_eigenvector_centrality_impl(graph = g) + Output + $vector + [1] 0.7071068 1.0000000 0.7071068 + + $value + [1] 1.414214 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 3 + + $options$which + [1] "LA" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 0 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 1 + + $options$numop + [1] 3 + + $options$numopb + [1] 0 + + $options$numreo + [1] 3 + + + $centralization + [1] 0.5857864 + + $theoretical_max + [1] 1 + + +--- + + Code + centralization_eigenvector_centrality_impl(graph = g, directed = TRUE, + normalized = FALSE) + Output + $vector + [1] 0.7071068 1.0000000 0.7071068 + + $value + [1] 1.414214 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 3 + + $options$which + [1] "LA" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 0 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 1 + + $options$numop + [1] 3 + + $options$numopb + [1] 0 + + $options$numreo + [1] 3 + + + $centralization + [1] 0.5857864 + + $theoretical_max + [1] 1 + + +# centralization_eigenvector_centrality_impl errors + + Code + centralization_eigenvector_centrality_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# centralization_eigenvector_centrality_tmax_impl basic + + Code + centralization_eigenvector_centrality_tmax_impl(nodes = 3) + Output + [1] 1 + +--- + + Code + centralization_eigenvector_centrality_tmax_impl(nodes = 3, directed = TRUE) + Output + [1] 2 + +# centralization_eigenvector_centrality_tmax_impl errors + + Code + centralization_eigenvector_centrality_tmax_impl(nodes = -1) + Condition + Error in `centralization_eigenvector_centrality_tmax_impl()`: + ! Number of vertices must not be negative. Invalid value + Source: : + +# constraint_impl errors + + Code + constraint_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# betweenness_impl basic + + Code + betweenness_impl(graph = g, vids = V(g), directed = FALSE) + Output + [1] 6 0 0 0 0 + +# harmonic_centrality_impl basic + + Code + harmonic_centrality_impl(graph = g, vids = V(g), mode = c("out", "in", "all", + "total")) + Output + [1] 4.0 2.5 2.5 2.5 2.5 + +# pagerank_impl basic + + Code + pagerank_impl(graph = g, vids = V(g), directed = TRUE, damping = 0.85) + Output + $vector + [1] 0.2 0.2 0.2 0.2 0.2 + + $value + [1] 1 + + $options + NULL + + +# hub_score_impl basic + + Code + out + Output + $value + [1] 4 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 5 + + $options$which + [1] "LA" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 0 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 1 + + $options$numop + [1] 4 + + $options$numopb + [1] 0 + + $options$numreo + [1] 4 + + + +# authority_score_impl basic + + Code + out + Output + $value + [1] 4 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 5 + + $options$which + [1] "LA" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 0 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 1 + + $options$numop + [1] 4 + + $options$numopb + [1] 0 + + $options$numreo + [1] 4 + + + diff --git a/tests/testthat/_snaps/aaa-cliques.md b/tests/testthat/_snaps/aaa-cliques.md new file mode 100644 index 00000000000..811d496c592 --- /dev/null +++ b/tests/testthat/_snaps/aaa-cliques.md @@ -0,0 +1,401 @@ +# is_clique_impl basic + + Code + is_clique_impl(graph = g, candidate = 1:2) + Output + [1] TRUE + +--- + + Code + is_clique_impl(graph = g, candidate = 1:2, directed = TRUE) + Output + [1] TRUE + +# is_clique_impl errors + + Code + is_clique_impl(graph = NULL, candidate = 1:2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# cliques_impl basic + + Code + cliques_impl(graph = g) + Output + [[1]] + + 1/3 vertex: + [1] 2 + + [[2]] + + 1/3 vertex: + [1] 3 + + [[3]] + + 2/3 vertices: + [1] 2 3 + + [[4]] + + 1/3 vertex: + [1] 1 + + [[5]] + + 2/3 vertices: + [1] 1 2 + + +--- + + Code + cliques_impl(graph = g, min = 2, max = 2) + Output + [[1]] + + 2/3 vertices: + [1] 2 3 + + [[2]] + + 2/3 vertices: + [1] 1 2 + + +# cliques_impl errors + + Code + cliques_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# clique_size_hist_impl basic + + Code + clique_size_hist_impl(graph = g) + Output + [1] 3 2 + +--- + + Code + clique_size_hist_impl(graph = g, min_size = 2, max_size = 2) + Output + [1] 0 2 + +# clique_size_hist_impl errors + + Code + clique_size_hist_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# largest_cliques_impl basic + + Code + largest_cliques_impl(graph = g) + Output + [[1]] + + 2/3 vertices: + [1] 1 2 + + [[2]] + + 2/3 vertices: + [1] 2 3 + + +# largest_cliques_impl errors + + Code + largest_cliques_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# maximal_cliques_hist_impl basic + + Code + maximal_cliques_hist_impl(graph = g) + Output + [1] 0 2 + +--- + + Code + maximal_cliques_hist_impl(graph = g, min_size = 2, max_size = 2) + Output + [1] 0 2 + +# maximal_cliques_hist_impl errors + + Code + maximal_cliques_hist_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# clique_number_impl basic + + Code + clique_number_impl(graph = g) + Output + [1] 2 + +# clique_number_impl errors + + Code + clique_number_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# weighted_cliques_impl basic + + Code + weighted_cliques_impl(graph = g) + Output + [[1]] + + 1/3 vertex: + [1] 2 + + [[2]] + + 1/3 vertex: + [1] 3 + + [[3]] + + 2/3 vertices: + [1] 2 3 + + [[4]] + + 1/3 vertex: + [1] 1 + + [[5]] + + 2/3 vertices: + [1] 1 2 + + +--- + + Code + weighted_cliques_impl(graph = g, vertex_weights = c(1, 2, 3), min_weight = 1, + max_weight = 3, maximal = TRUE) + Output + [[1]] + + 2/3 vertices: + [1] 1 2 + + +# weighted_cliques_impl errors + + Code + weighted_cliques_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# largest_weighted_cliques_impl basic + + Code + largest_weighted_cliques_impl(graph = g) + Output + [[1]] + + 2/3 vertices: + [1] 1 2 + + [[2]] + + 2/3 vertices: + [1] 2 3 + + +--- + + Code + largest_weighted_cliques_impl(graph = g, vertex_weights = c(1, 2, 3)) + Output + [[1]] + + 2/3 vertices: + [1] 2 3 + + +# largest_weighted_cliques_impl errors + + Code + largest_weighted_cliques_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# weighted_clique_number_impl basic + + Code + weighted_clique_number_impl(graph = g) + Output + [1] 2 + +--- + + Code + weighted_clique_number_impl(graph = g, vertex_weights = c(1, 2, 3)) + Output + [1] 5 + +# weighted_clique_number_impl errors + + Code + weighted_clique_number_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_independent_vertex_set_impl basic + + Code + is_independent_vertex_set_impl(graph = g, candidate = 1:2) + Output + [1] FALSE + +# is_independent_vertex_set_impl errors + + Code + is_independent_vertex_set_impl(graph = NULL, candidate = 1:2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_complete_impl basic + + Code + is_complete_impl(graph = g) + Output + [1] FALSE + +# is_complete_impl errors + + Code + is_complete_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# maximal_cliques_impl basic + + Code + maximal_cliques_impl(graph = g, min_size = 1, max_size = 0) + Output + [[1]] + + 4/4 vertices: + [1] 1 2 4 3 + + +# independent_vertex_sets_impl basic + + Code + independent_vertex_sets_impl(graph = g, min_size = 1, max_size = 0) + Output + [[1]] + + 1/5 vertex: + [1] 1 + + [[2]] + + 1/5 vertex: + [1] 2 + + [[3]] + + 1/5 vertex: + [1] 3 + + [[4]] + + 1/5 vertex: + [1] 4 + + [[5]] + + 1/5 vertex: + [1] 5 + + [[6]] + + 2/5 vertices: + [1] 1 3 + + [[7]] + + 2/5 vertices: + [1] 1 4 + + [[8]] + + 2/5 vertices: + [1] 2 4 + + [[9]] + + 2/5 vertices: + [1] 2 5 + + [[10]] + + 2/5 vertices: + [1] 3 5 + + +# cliques_callback_closure_impl basic + + Code + cat("Result:\n") + Output + Result: + Code + print(result) + Output + NULL + Code + cat("\nNumber of cliques found:", length(clique_data), "\n") + Output + + Number of cliques found: 5 + Code + cat("First clique:\n") + Output + First clique: + Code + print(clique_data[[1]]) + Output + [1] 2 3 4 + +# cliques_callback_closure_impl errors + + Code + cliques_callback_closure_impl(graph = g, min_size = 3, max_size = 4, callback = "not a function") + Condition + Error in `cliques_callback_closure_impl()`: + ! `callback` must be a function + +# maximal_cliques_callback_closure_impl basic + + Code + cat("Result:\n") + Output + Result: + Code + print(result) + Output + NULL + Code + cat("\nNumber of maximal cliques found:", length(clique_data), "\n") + Output + + Number of maximal cliques found: 3 + Code + if (length(clique_data) > 0) { + cat("First maximal clique:\n") + print(clique_data[[1]]) + } + Output + First maximal clique: + [1] 2 1 4 + +# maximal_cliques_callback_closure_impl errors + + Code + maximal_cliques_callback_closure_impl(graph = g, min_size = 3, max_size = 0, + callback = "not a function") + Condition + Error in `maximal_cliques_callback_closure_impl()`: + ! `callback` must be a function + diff --git a/tests/testthat/_snaps/aaa-coloring.md b/tests/testthat/_snaps/aaa-coloring.md new file mode 100644 index 00000000000..27a1ecd0a0a --- /dev/null +++ b/tests/testthat/_snaps/aaa-coloring.md @@ -0,0 +1,89 @@ +# is_perfect_impl basic + + Code + is_perfect_impl(graph = g) + Output + [1] TRUE + +# is_perfect_impl errors + + Code + is_perfect_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# vertex_coloring_greedy_impl basic + + Code + vertex_coloring_greedy_impl(graph = g) + Output + [1] 2 1 2 + +--- + + Code + vertex_coloring_greedy_impl(graph = g, heuristic = "dsatur") + Output + [1] 2 1 2 + +# vertex_coloring_greedy_impl errors + + Code + vertex_coloring_greedy_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_vertex_coloring_impl basic + + Code + is_vertex_coloring_impl(graph = g, types = c(1, 2, 3)) + Output + [1] TRUE + +# is_vertex_coloring_impl errors + + Code + is_vertex_coloring_impl(graph = NULL, types = c(1, 2, 3)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_bipartite_coloring_impl basic + + Code + is_bipartite_coloring_impl(graph = g, types = c(TRUE, FALSE, TRUE)) + Output + [1] TRUE + +# is_bipartite_coloring_impl errors + + Code + is_bipartite_coloring_impl(graph = NULL, types = c(TRUE, FALSE, TRUE)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_edge_coloring_impl basic + + Code + is_edge_coloring_impl(graph = g, types = c(1, 2)) + Output + [1] TRUE + +--- + + Code + is_edge_coloring_impl(graph = g) + Output + [1] TRUE + +# is_edge_coloring_impl errors + + Code + is_edge_coloring_impl(graph = NULL, types = c(1, 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + diff --git a/tests/testthat/_snaps/aaa-community.md b/tests/testthat/_snaps/aaa-community.md new file mode 100644 index 00000000000..25ea4872fd2 --- /dev/null +++ b/tests/testthat/_snaps/aaa-community.md @@ -0,0 +1,439 @@ +# compare_communities_impl basic + + Code + compare_communities_impl(comm1 = c(1, 2, 1), comm2 = c(2, 1, 2)) + Output + [1] 0 + +--- + + Code + compare_communities_impl(comm1 = c(1, 2, 1), comm2 = c(2, 1, 2), method = "nmi") + Output + [1] 1 + +--- + + Code + compare_communities_impl(comm1 = comm1, comm2 = comm2, method = "vi") + Output + [1] 0.5493061 + +# compare_communities_impl errors + + Code + compare_communities_impl(comm1 = "a", comm2 = c(2, 1, 2)) + Condition + Warning in `compare_communities_impl()`: + NAs introduced by coercion + Error in `compare_communities_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + +# modularity_impl basic + + Code + modularity_impl(graph = g, membership = c(1, 2, 1)) + Output + [1] -0.5 + +--- + + Code + modularity_impl(graph = g, membership = c(1, 2, 1), weights = c(1, 2), + resolution = 0.5, directed = FALSE) + Output + [1] -0.25 + +# modularity_impl errors + + Code + modularity_impl(graph = NULL, membership = c(1, 2, 1)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# modularity_matrix_impl basic + + Code + modularity_matrix_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] -0.25 0.5 -0.25 + [2,] 0.50 -1.0 0.50 + [3,] -0.25 0.5 -0.25 + +--- + + Code + 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 + [2,] 0.75000000 -0.75 1.5000000 + [3,] -0.16666667 1.50 -0.3333333 + +# modularity_matrix_impl errors + + Code + modularity_matrix_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# community_fluid_communities_impl basic + + Code + community_fluid_communities_impl(graph = g, no_of_communities = 2) + Output + [1] 1 0 0 + +# community_fluid_communities_impl errors + + Code + community_fluid_communities_impl(graph = NULL, no_of_communities = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# community_label_propagation_impl basic + + Code + community_label_propagation_impl(graph = g) + Output + [1] 0 0 0 + +--- + + Code + 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 + +# community_label_propagation_impl errors + + Code + community_label_propagation_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# community_multilevel_impl basic + + Code + community_multilevel_impl(graph = g) + Output + $membership + [1] 0 0 0 + + $memberships + [,1] [,2] [,3] + [1,] 0 0 0 + + $modularity + [1] 0 + + +--- + + Code + community_multilevel_impl(graph = g, weights = c(1, 2), resolution = 0.5) + Output + $membership + [1] 0 0 0 + + $memberships + [,1] [,2] [,3] + [1,] 0 0 0 + + $modularity + [1] 0.5 + + +# community_multilevel_impl errors + + Code + community_multilevel_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# community_optimal_modularity_impl basic + + Code + community_optimal_modularity_impl(graph = g) + Output + $modularity + [1] 0 + + $membership + [1] 0 0 0 + + +--- + + Code + community_optimal_modularity_impl(graph = g, weights = c(1, 2)) + Output + $modularity + [1] 1.850372e-17 + + $membership + [1] 0 0 0 + + +# community_optimal_modularity_impl errors + + Code + community_optimal_modularity_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# community_leiden_impl basic + + Code + 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 + [1] 0 1 2 + + $nb_clusters + [1] 3 + + $quality + [1] -1.166667 + + +# community_leiden_impl errors + + Code + community_leiden_impl(graph = NULL, resolution = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# split_join_distance_impl basic + + Code + split_join_distance_impl(comm1 = c(1, 2, 1), comm2 = c(2, 1, 2)) + Output + $distance12 + [1] 0 + + $distance21 + [1] 0 + + +# split_join_distance_impl errors + + Code + split_join_distance_impl(comm1 = "a", comm2 = c(2, 1, 2)) + Condition + Warning in `split_join_distance_impl()`: + NAs introduced by coercion + Error in `split_join_distance_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + +# community_infomap_impl basic + + Code + community_infomap_impl(graph = g) + Output + $membership + [1] 0 0 0 + + $codelength + [1] 1.512987 + + +--- + + Code + community_infomap_impl(graph = g, e_weights = c(1, 2), v_weights = c(1, 2, 3), + nb_trials = 2) + Output + $membership + [1] 0 0 0 + + $codelength + [1] 1.462254 + + +# community_infomap_impl errors + + Code + community_infomap_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# community_walktrap_impl basic + + Code + community_walktrap_impl(graph = g, steps = 4) + Output + $merges + [,1] [,2] + [1,] 4 5 + [2,] 1 2 + [3,] 3 6 + [4,] 0 7 + [5,] 8 9 + + $modularity + [1] -0.17346939 -0.07142857 0.03061224 0.19387755 0.35714286 0.00000000 + + $membership + [1] 0 0 0 1 1 1 + + +# community_fastgreedy_impl basic + + Code + community_fastgreedy_impl(graph = g) + Output + $merges + [,1] [,2] + [1,] 2 1 + [2,] 0 6 + [3,] 5 4 + [4,] 3 8 + [5,] 9 7 + + $modularity + [1] -1.734694e-01 -7.142857e-02 9.183673e-02 1.938776e-01 3.571429e-01 + [6] 5.551115e-17 + + $membership + [1] 1 1 1 0 0 0 + + +# community_edge_betweenness_impl basic + + Code + community_edge_betweenness_impl(graph = g, directed = FALSE) + Output + $removed_edges + [1] 6 0 1 2 3 4 5 + + $edge_betweenness + [1] 9 1 2 1 1 2 1 + + $merges + [,1] [,2] + [1,] 5 3 + [2,] 6 4 + [3,] 2 0 + [4,] 8 1 + [5,] 7 9 + + $bridges + [1] 7 6 4 3 1 + + $modularity + [1] -0.17346939 -0.09183673 0.09183673 0.17346939 0.35714286 0.00000000 + + $membership + [1] 0 0 0 1 1 1 + + +# community_leading_eigenvector_callback_closure_impl basic + + Code + cat("Result class:\n") + Output + Result class: + Code + print(class(result)) + Output + [1] "igraph.eigenc" + Code + cat("\nMembership length:\n") + Output + + Membership length: + Code + print(length(result$membership)) + Output + [1] 34 + Code + cat("\nModularity:\n") + Output + + Modularity: + Code + print(result$modularity) + Output + [1] 0.3934089 + Code + cat("\nMerges dimensions:\n") + Output + + Merges dimensions: + Code + print(dim(result$merges)) + Output + [1] 3 2 + +# community_leading_eigenvector_callback_closure_impl with start + + Code + cat("Result with start membership:\n") + Output + Result with start membership: + Code + cat("Membership length:\n") + Output + Membership length: + Code + print(length(result$membership)) + Output + [1] 34 + Code + cat("\nModularity:\n") + Output + + Modularity: + Code + print(result$modularity) + Output + [1] 0.2217291 + +# community_leading_eigenvector_callback_closure_impl errors + + Code + community_leading_eigenvector_callback_closure_impl(graph = g, start = TRUE) + Condition + Error in `community_leading_eigenvector_callback_closure_impl()`: + ! Supplied memberhsip vector length does not match number of vertices. Invalid value + Source: : + +# community_voronoi_impl basic + + Code + community_voronoi_impl(graph = g) + Output + $membership + [1] 3 3 3 3 0 3 2 2 1 1 + + $generators + + 4/10 vertices: + [1] 2 9 7 1 + + $modularity + [1] 0.2222222 + + +# community_voronoi_impl errors + + Code + community_voronoi_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + diff --git a/tests/testthat/_snaps/aaa-cycles.md b/tests/testthat/_snaps/aaa-cycles.md new file mode 100644 index 00000000000..71f9b46d060 --- /dev/null +++ b/tests/testthat/_snaps/aaa-cycles.md @@ -0,0 +1,288 @@ +# feedback_arc_set_impl basic + + Code + feedback_arc_set_impl(graph = g) + Output + + 0/2 edges: + +--- + + Code + feedback_arc_set_impl(graph = g, algo = "exact_ip") + Output + + 0/2 edges: + +# feedback_arc_set_impl errors + + Code + feedback_arc_set_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# feedback_vertex_set_impl basic + + Code + feedback_vertex_set_impl(graph = g) + Output + + 0/3 vertices: + +# feedback_vertex_set_impl errors + + Code + feedback_vertex_set_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_dag_impl basic + + Code + is_dag_impl(graph = g) + Output + [1] FALSE + +# is_dag_impl errors + + Code + is_dag_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_acyclic_impl basic + + Code + is_acyclic_impl(graph = g) + Output + [1] TRUE + +# is_acyclic_impl errors + + Code + is_acyclic_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# find_cycle_impl basic + + Code + find_cycle_impl(graph = g) + Output + $vertices + + 0/3 vertices: + + $edges + + 0/2 edges: + + +--- + + Code + find_cycle_impl(graph = g, mode = "in") + Output + $vertices + + 0/3 vertices: + + $edges + + 0/2 edges: + + +# find_cycle_impl errors + + Code + find_cycle_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# simple_cycles_impl basic + + Code + simple_cycles_impl(graph = g) + Output + $vertices + list() + + $edges + list() + + +--- + + Code + simple_cycles_impl(graph = g, mode = "in", min_cycle_length = 2, + max_cycle_length = 3) + Output + $vertices + list() + + $edges + list() + + +# simple_cycles_impl errors + + Code + simple_cycles_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_eulerian_impl basic + + Code + is_eulerian_impl(graph = g) + Output + $has_path + [1] TRUE + + $has_cycle + [1] FALSE + + +# is_eulerian_impl errors + + Code + is_eulerian_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# eulerian_path_impl basic + + Code + eulerian_path_impl(graph = g) + Output + $epath + + 2/2 edges: + [1] 1--2 2--3 + + $vpath + + 3/3 vertices: + [1] 1 2 3 + + +# eulerian_path_impl errors + + Code + eulerian_path_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# eulerian_cycle_impl basic + + Code + eulerian_cycle_impl(graph = g1) + Condition + Error in `eulerian_cycle_impl()`: + ! The graph does not have an Eulerian cycle. Input problem has no solution + Source: : + +--- + + Code + eulerian_cycle_impl(graph = g2) + Output + $epath + + 4/4 edges: + [1] 1--2 2--3 3--4 1--4 + + $vpath + + 5/4 vertices: + [1] 1 2 3 4 1 + + +# eulerian_cycle_impl errors + + Code + eulerian_cycle_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# fundamental_cycles_impl basic + + Code + fundamental_cycles_impl(graph = g, start = 1) + Output + list() + +--- + + Code + fundamental_cycles_impl(graph = g, start = 1, bfs_cutoff = 2, weights = c(1, 2)) + Output + list() + +# fundamental_cycles_impl errors + + Code + fundamental_cycles_impl(graph = NULL, start = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# minimum_cycle_basis_impl basic + + Code + minimum_cycle_basis_impl(graph = g) + Output + list() + +--- + + Code + minimum_cycle_basis_impl(graph = g, bfs_cutoff = 2, complete = FALSE, + use_cycle_order = FALSE, weights = c(1, 2)) + Output + list() + +# minimum_cycle_basis_impl errors + + Code + minimum_cycle_basis_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# simple_cycles_callback_closure_impl basic + + Code + cat("Result:\n") + Output + Result: + Code + print(result) + Output + NULL + Code + cat("\nNumber of cycles found:", length(cycle_data), "\n") + Output + + Number of cycles found: 1 + Code + cat("First cycle:\n") + Output + First cycle: + Code + print(cycle_data[[1]]) + Output + $vertices + [1] 1 2 3 4 + + $edges + [1] 1 2 3 4 + + +# simple_cycles_callback_closure_impl errors + + Code + simple_cycles_callback_closure_impl(graph = g, mode = "out", min_cycle_length = - + 1, max_cycle_length = -1, callback = "not a function") + Condition + Error in `simple_cycles_callback_closure_impl()`: + ! `callback` must be a function + diff --git a/tests/testthat/_snaps/aaa-embedding.md b/tests/testthat/_snaps/aaa-embedding.md new file mode 100644 index 00000000000..854c8603096 --- /dev/null +++ b/tests/testthat/_snaps/aaa-embedding.md @@ -0,0 +1,282 @@ +# adjacency_spectral_embedding_impl basic + + Code + adjacency_spectral_embedding_impl(graph = g, no = 2) + Output + $X + [,1] [,2] + [1,] 0.6718598 -0.4487712 + [2,] 1.1328501 0.5323058 + [3,] 0.6718598 -0.4487712 + + $Y + [,1] [,2] + [1,] 0.6718598 -0.4487712 + [2,] 1.1328501 0.5323058 + [3,] 0.6718598 -0.4487712 + + $D + [1] 2.1861407 -0.6861407 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 3 + + $options$which + [1] "LM" + + $options$nev + [1] 2 + + $options$tol + [1] 0 + + $options$ncv + [1] 3 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 2 + + $options$numop + [1] 3 + + $options$numopb + [1] 0 + + $options$numreo + [1] 2 + + + +--- + + Code + 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 + [,1] [,2] + [1,] 0.1720265 -0.7864357 + [2,] 0.6311790 -0.3743620 + [3,] 0.7563200 0.4912963 + + $Y + [,1] [,2] + [1,] 0.1720265 -0.7864357 + [2,] 0.6311790 -0.3743620 + [3,] 0.7563200 0.4912963 + + $D + [1] 4.669079 1.476024 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 3 + + $options$which + [1] "LA" + + $options$nev + [1] 2 + + $options$tol + [1] 0 + + $options$ncv + [1] 3 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 10 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 2 + + $options$numop + [1] 3 + + $options$numopb + [1] 0 + + $options$numreo + [1] 2 + + + +# adjacency_spectral_embedding_impl errors + + Code + adjacency_spectral_embedding_impl(graph = NULL, no = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# laplacian_spectral_embedding_impl basic + + Code + laplacian_spectral_embedding_impl(graph = g, no = 2) + Output + $X + [,1] [,2] + [1,] -0.7071068 -0.7071068 + [2,] 1.4142136 0.0000000 + [3,] -0.7071068 0.7071068 + + $Y + [,1] [,2] + [1,] -0.7071068 -0.7071068 + [2,] 1.4142136 0.0000000 + [3,] -0.7071068 0.7071068 + + $D + [1] 3 1 + + $options + $options$bmat + [1] "I" + + $options$n + [1] 3 + + $options$which + [1] "LM" + + $options$nev + [1] 2 + + $options$tol + [1] 0 + + $options$ncv + [1] 3 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 1 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 1 + + $options$nconv + [1] 2 + + $options$numop + [1] 3 + + $options$numopb + [1] 0 + + $options$numreo + [1] 3 + + + +# laplacian_spectral_embedding_impl errors + + Code + laplacian_spectral_embedding_impl(graph = NULL, no = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# dim_select_impl basic + + Code + dim_select_impl(sv = c(1, 2, 3)) + Output + [1] 1 + +# dim_select_impl errors + + Code + dim_select_impl(sv = NULL) + Condition + Error in `dim_select_impl()`: + ! Need at least one singular value for dimensionality selection. Invalid value + Source: : + diff --git a/tests/testthat/_snaps/aaa-flows.md b/tests/testthat/_snaps/aaa-flows.md new file mode 100644 index 00000000000..ce1dd2df02c --- /dev/null +++ b/tests/testthat/_snaps/aaa-flows.md @@ -0,0 +1,362 @@ +# gomory_hu_tree_impl basic + + Code + gomory_hu_tree_impl(graph = g) + Output + $tree + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + + $flows + [1] 1 1 + + +--- + + Code + gomory_hu_tree_impl(graph = g, capacity = c(1, 2)) + Output + $tree + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + + $flows + [1] 1 2 + + +# gomory_hu_tree_impl errors + + Code + gomory_hu_tree_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# maxflow_impl basic + + Code + maxflow_impl(graph = g, source = 1, target = 3) + Output + $value + [1] 1 + + $flow + [1] 1 1 + + $cut + + 1/2 edge: + [1] 2--3 + + $partition1 + + 2/3 vertices: + [1] 1 2 + + $partition2 + + 1/3 vertex: + [1] 3 + + $stats + $stats$nopush + [1] 1 + + $stats$norelabel + [1] 0 + + $stats$nogap + [1] 0 + + $stats$nogapnodes + [1] 0 + + $stats$nobfs + [1] 1 + + + +--- + + Code + maxflow_impl(graph = g, source = 1, target = 3, capacity = c(1, 2)) + Output + $value + [1] 1 + + $flow + [1] 1 1 + + $cut + + 1/2 edge: + [1] 1--2 + + $partition1 + + 1/3 vertex: + [1] 1 + + $partition2 + + 2/3 vertices: + [1] 2 3 + + $stats + $stats$nopush + [1] 1 + + $stats$norelabel + [1] 0 + + $stats$nogap + [1] 0 + + $stats$nogapnodes + [1] 0 + + $stats$nobfs + [1] 1 + + + +# maxflow_impl errors + + Code + maxflow_impl(graph = NULL, source = 1, target = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# residual_graph_impl basic + + Code + residual_graph_impl(graph = g, capacity = c(1, 2), flow = c(1, 2)) + Output + $residual + IGRAPH D--- 3 0 -- + + edges: + + $residual_capacity + numeric(0) + + +# residual_graph_impl errors + + Code + residual_graph_impl(graph = NULL, capacity = c(1, 2), flow = c(1, 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# reverse_residual_graph_impl basic + + Code + reverse_residual_graph_impl(graph = g, capacity = c(1, 2), flow = c(1, 2)) + Output + IGRAPH D--- 3 2 -- + + edges: + [1] 2->1 3->2 + +# reverse_residual_graph_impl errors + + Code + reverse_residual_graph_impl(graph = NULL, capacity = c(1, 2), flow = c(1, 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# st_mincut_impl basic + + Code + st_mincut_impl(graph = g, source = 1, target = 3) + Output + $value + [1] 1 + + $cut + + 1/2 edge: + [1] 2--3 + + $partition1 + + 2/3 vertices: + [1] 1 2 + + $partition2 + + 1/3 vertex: + [1] 3 + + +--- + + Code + st_mincut_impl(graph = g, source = 1, target = 3, capacity = c(1, 2)) + Output + $value + [1] 1 + + $cut + + 1/2 edge: + [1] 1--2 + + $partition1 + + 1/3 vertex: + [1] 1 + + $partition2 + + 2/3 vertices: + [1] 2 3 + + +# st_mincut_impl errors + + Code + st_mincut_impl(graph = NULL, source = 1, target = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# dominator_tree_impl basic + + Code + dominator_tree_impl(graph = g, root = 1) + Output + $dom + [1] 0 1 2 + + $domtree + IGRAPH D--- 3 2 -- + + edges: + [1] 1->2 2->3 + + $leftout + + 0/3 vertices: + + +--- + + Code + dominator_tree_impl(graph = g, root = 1, mode = "in") + Output + $dom + [1] 0 -1 -1 + + $domtree + IGRAPH D--- 3 0 -- + + edges: + + $leftout + + 2/3 vertices: + [1] 2 3 + + +# dominator_tree_impl errors + + Code + dominator_tree_impl(graph = NULL, root = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# all_st_cuts_impl basic + + Code + all_st_cuts_impl(graph = g, source = 1, target = 3) + Output + $cuts + $cuts[[1]] + + 1/2 edge: + [1] 1->2 + + $cuts[[2]] + + 1/2 edge: + [1] 2->3 + + + $partition1s + $partition1s[[1]] + + 1/3 vertex: + [1] 1 + + $partition1s[[2]] + + 2/3 vertices: + [1] 1 2 + + + +# all_st_cuts_impl errors + + Code + all_st_cuts_impl(graph = NULL, source = 1, target = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# all_st_mincuts_impl basic + + Code + all_st_mincuts_impl(graph = g, source = 1, target = 3) + Output + $value + [1] 1 + + $cuts + $cuts[[1]] + + 1/2 edge: + [1] 1->2 + + $cuts[[2]] + + 1/2 edge: + [1] 2->3 + + + $partition1s + $partition1s[[1]] + + 1/3 vertex: + [1] 1 + + $partition1s[[2]] + + 2/3 vertices: + [1] 1 2 + + + +--- + + Code + all_st_mincuts_impl(graph = g, source = 1, target = 3, capacity = c(1, 2)) + Output + $value + [1] 1 + + $cuts + $cuts[[1]] + + 1/2 edge: + [1] 1->2 + + + $partition1s + $partition1s[[1]] + + 1/3 vertex: + [1] 1 + + + +# all_st_mincuts_impl errors + + Code + all_st_mincuts_impl(graph = NULL, source = 1, target = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# edge_connectivity_impl basic + + Code + edge_connectivity_impl(graph = g) + Output + [1] 2 + +# vertex_connectivity_impl basic + + Code + vertex_connectivity_impl(graph = g) + Output + [1] 2 + diff --git a/tests/testthat/_snaps/aaa-foreign.md b/tests/testthat/_snaps/aaa-foreign.md new file mode 100644 index 00000000000..33cb1a6fc11 --- /dev/null +++ b/tests/testthat/_snaps/aaa-foreign.md @@ -0,0 +1,16 @@ +# write_graph_edgelist_impl basic + + Code + content + Output + [1] "0 1" "0 2" "1 2" + +# read_graph_edgelist_impl basic + + Code + read_graph_edgelist_impl(instream = tmp, n = 3, directed = FALSE) + Output + IGRAPH U--- 3 3 -- + + edges: + [1] 1--2 2--3 1--3 + diff --git a/tests/testthat/_snaps/aaa-games.md b/tests/testthat/_snaps/aaa-games.md new file mode 100644 index 00000000000..e26bea824eb --- /dev/null +++ b/tests/testthat/_snaps/aaa-games.md @@ -0,0 +1,699 @@ +# erdos_renyi_game_gnp_impl basic + + Code + erdos_renyi_game_gnp_impl(n = 5, p = 0.5) + Output + IGRAPH U--- 5 7 -- + + edges: + [1] 1--2 1--3 2--3 1--4 2--4 1--5 4--5 + +--- + + Code + erdos_renyi_game_gnp_impl(n = 5, p = 0.5, directed = TRUE, loops = TRUE) + Output + IGRAPH D--- 5 12 -- + + edges: + [1] 2->1 3->1 4->1 2->2 1->3 2->3 4->3 1->4 2->4 5->4 3->5 4->5 + +# erdos_renyi_game_gnp_impl errors + + Code + erdos_renyi_game_gnp_impl(n = -1, p = 0.5) + Condition + Error in `erdos_renyi_game_gnp_impl()`: + ! Invalid number of vertices. Invalid value + Source: : + +# erdos_renyi_game_gnm_impl basic + + Code + erdos_renyi_game_gnm_impl(n = 5, m = 3) + Output + IGRAPH U--- 5 3 -- + + edges: + [1] 3--4 2--5 4--5 + +--- + + Code + erdos_renyi_game_gnm_impl(n = 5, m = 3, directed = TRUE, loops = TRUE) + Output + IGRAPH D--- 5 3 -- + + edges: + [1] 4->3 5->3 3->5 + +# erdos_renyi_game_gnm_impl errors + + Code + erdos_renyi_game_gnm_impl(n = -1, m = 3) + Condition + Error in `erdos_renyi_game_gnm_impl()`: + ! Invalid number of vertices. Invalid value + Source: : + +# growing_random_game_impl basic + + Code + 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) + + edges: + [1] 2->2 1->2 3->3 3->3 3->3 1->2 2->2 5->4 + +--- + + Code + 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) + + edges: + [1] 1--2 1--2 2--3 1--3 1--4 2--4 1--5 4--5 + +--- + + Code + growing_random_game_impl(n = 10, m = 1, directed = TRUE, citation = FALSE) + Output + IGRAPH D--- 10 9 -- Growing random graph + + attr: name (g/c), m (g/n), citation (g/l) + + edges: + [1] 2->2 2->3 4->4 4->4 3->2 1->3 1->8 5->6 5->4 + +# growing_random_game_impl errors + + Code + growing_random_game_impl(n = -1, m = 2) + Condition + Error in `growing_random_game_impl()`: + ! Invalid number of vertices. Invalid value + Source: : + +# preference_game_impl basic + + Code + 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 -- + + edges: + [1] 1--3 3--4 1--4 1--5 + + $node_type_vec + [1] 1 0 0 1 1 + + +# preference_game_impl errors + + Code + preference_game_impl(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)) + Condition + Error in `preference_game_impl()`: + ! The number of vertices must be non-negative. Invalid value + Source: : + +# asymmetric_preference_game_impl basic + + Code + 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 -- + + edges: + [1] 2->4 4->2 5->2 1->3 4->3 4->5 3->1 1->4 1->5 + + $node_type_out_vec + [1] 1 0 1 1 1 + + $node_type_in_vec + [1] 1 0 0 1 1 + + +# asymmetric_preference_game_impl errors + + Code + asymmetric_preference_game_impl(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)) + Condition + Error in `asymmetric_preference_game_impl()`: + ! The number of vertices must not be negative. Invalid value + Source: : + +# rewire_edges_impl basic + + Code + rewire_edges_impl(graph = g, prob = 0.5) + Output + IGRAPH U--- 5 4 -- + + edges: + [1] 2--4 3--4 1--3 2--5 + +# rewire_edges_impl errors + + Code + rewire_edges_impl(graph = NULL, prob = 0.5) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# rewire_directed_edges_impl basic + + Code + rewire_directed_edges_impl(graph = g, prob = 0.5) + Output + IGRAPH D--- 5 4 -- + + edges: + [1] 1->4 2->3 3->2 4->5 + +# rewire_directed_edges_impl errors + + Code + rewire_directed_edges_impl(graph = NULL, prob = 0.5) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# forest_fire_game_impl basic + + Code + 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) + + edges: + [1] 2->1 3->2 4->2 4->1 4->3 5->1 5->2 5->4 5->3 + +--- + + Code + 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) + + edges: + [1] 1--2 1--3 1--4 4--5 + +# forest_fire_game_impl errors + + Code + forest_fire_game_impl(nodes = -1, fw_prob = 0.5) + Condition + Error in `forest_fire_game_impl()`: + ! Insufficient memory for forest fire model. Out of memory + Source: : + +# simple_interconnected_islands_game_impl basic + + Code + 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 + | (g/n), n_inter (g/n) + + edges: + [1] 1--2 1--3 2--3 3--6 5--6 + +# simple_interconnected_islands_game_impl errors + + Code + simple_interconnected_islands_game_impl(islands_n = -1, islands_size = 3, + islands_pin = 0.5, n_inter = 1) + Condition + Error in `simple_interconnected_islands_game_impl()`: + ! Number of islands cannot be negative, got -1. Invalid value + Source: : + +# chung_lu_game_impl basic + + Code + 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) + + edges: + [1] 1--2 1--3 2--2 2--3 3--3 + +--- + + Code + 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) + + edge: + [1] 3->1 + +# chung_lu_game_impl errors + + Code + chung_lu_game_impl(out_weights = -1) + Condition + Error in `chung_lu_game_impl()`: + ! Vertex weights must not be negative in Chung-Lu model, got -1. Invalid value + Source: : + +# static_fitness_game_impl basic + + Code + 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) + + edges: + [1] 1--2 1--3 2--3 + +--- + + Code + 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) + + edges: + [1] 1->2 2->3 1->3 + +# static_fitness_game_impl errors + + Code + static_fitness_game_impl(no_of_edges = -1, fitness_out = c(1, 2, 3)) + Condition + Error in `static_fitness_game_impl()`: + ! Number of edges cannot be negative, got -1. Invalid value + Source: : + +# static_power_law_game_impl basic + + Code + 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), + | multiple (g/l), finite_size_correction (g/l) + + edges: + [1] 1--5 2--4 3--5 4--5 + +--- + + Code + 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), + | multiple (g/l), finite_size_correction (g/l) + + edges: + [1] 1->1 3->5 1->4 5->1 + +# static_power_law_game_impl errors + + Code + static_power_law_game_impl(no_of_nodes = -1, no_of_edges = 4, exponent_out = 2.5) + Condition + Error in `static_power_law_game_impl()`: + ! Number of nodes cannot be negative, got -1. Invalid value + Source: : + +# k_regular_game_impl basic + + Code + 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) + + edges: + [1] 1--3 1--5 2--3 2--4 4--5 + +--- + + Code + 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) + + edges: + [1] 3->4 3->3 2->1 5->5 1->5 4->3 5->2 4->1 1->2 2->4 + +# k_regular_game_impl errors + + Code + k_regular_game_impl(no_of_nodes = -1, k = 2) + Condition + Error in `k_regular_game_impl()`: + ! Number of nodes must be non-negative. Invalid value + Source: : + +# sbm_game_impl basic + + Code + 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) + + edges: + [1] 1--2 1--3 2--3 1--4 1--5 3--5 + +--- + + Code + 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) + + edges: + [1] 1->1 2->1 2->4 1->5 4->1 5->1 5->2 3->3 5->3 3->4 4->4 5->4 3->5 5->5 + +# sbm_game_impl errors + + Code + sbm_game_impl(n = -1, pref_matrix = matrix(0.5, 2, 2), block_sizes = c(2, 3)) + Condition + Error in `sbm_game_impl()`: + ! Sum of the block sizes (5) must equal the number of vertices (-1). Invalid value + Source: : + +# hsbm_game_impl basic + + Code + 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) + + edges: + [1] 1--2 3--4 5--6 1--4 1--5 2--5 1--6 4--5 3--6 + +# hsbm_game_impl errors + + Code + hsbm_game_impl(n = -1, m = 2, rho = 0.5, C = matrix(1, 2, 2), p = 0.5) + Condition + Error in `hsbm_game_impl()`: + ! `n' must be positive for HSBM. Invalid value + Source: : + +# hsbm_list_game_impl basic + + Code + 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) + + edges: + [1] 1-- 2 1-- 3 2-- 3 1-- 4 2-- 4 3-- 4 1-- 5 2-- 5 3-- 5 4-- 5 + [11] 1-- 6 2-- 6 3-- 6 4-- 6 5-- 6 1-- 7 2-- 7 3-- 7 4-- 7 5-- 7 + [21] 6-- 7 1-- 8 2-- 8 3-- 8 4-- 8 5-- 8 6-- 8 7-- 8 1-- 9 2-- 9 + [31] 3-- 9 4-- 9 5-- 9 6-- 9 7-- 9 8-- 9 1--10 2--10 3--10 4--10 + [41] 5--10 6--10 7--10 8--10 9--10 1--11 2--11 3--11 4--11 5--11 + [51] 6--11 7--11 8--11 9--11 10--11 1--12 2--12 3--12 4--12 5--12 + [61] 6--12 7--12 8--12 9--12 10--12 11--12 1--13 2--13 3--13 4--13 + [71] 5--13 6--13 7--13 8--13 9--13 10--13 11--13 12--13 1--14 2--14 + + ... omitted several edges + +# hsbm_list_game_impl errors + + Code + hsbm_list_game_impl(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) + Condition + Error in `hsbm_list_game_impl()`: + ! `n' must be positive for HSBM. Invalid value + Source: : + +# correlated_game_impl basic + + Code + 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) + + edges: + [1] 1--3 3--4 2--5 + +# correlated_game_impl errors + + Code + correlated_game_impl(old_graph = NULL, corr = 0.5) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# correlated_pair_game_impl basic + + Code + correlated_pair_game_impl(n = 5, corr = 0.5, p = 0.5) + Output + $graph1 + IGRAPH U--- 5 7 -- + + edges: + [1] 1--2 1--3 2--3 1--4 2--4 1--5 4--5 + + $graph2 + IGRAPH U--- 5 7 -- + + edges: + [1] 1--2 1--3 2--3 1--4 2--4 1--5 3--5 + + +--- + + Code + correlated_pair_game_impl(n = 5, corr = 0.5, p = 0.5, directed = TRUE) + Output + $graph1 + IGRAPH D--- 5 10 -- + + edges: + [1] 4->1 5->1 2->5 4->2 5->2 3->5 1->4 2->4 4->5 5->4 + + $graph2 + IGRAPH D--- 5 9 -- + + edges: + [1] 1->5 2->1 2->5 4->2 4->3 1->4 2->4 4->5 5->4 + + +# correlated_pair_game_impl errors + + Code + correlated_pair_game_impl(n = -1, corr = 0.5, p = 0.5) + Condition + Error in `correlated_pair_game_impl()`: + ! Invalid number of vertices. Invalid value + Source: : + +# dot_product_game_impl basic + + Code + dot_product_game_impl(vecs = matrix(0.5, 5, 2)) + Condition + Warning in `dot_product_game_impl()`: + Greater than 1 connection probability in dot-product graph. + Source: games/dotproduct.c:90 + Output + IGRAPH U--- 2 1 -- + + edge: + [1] 1--2 + +--- + + Code + dot_product_game_impl(vecs = matrix(0.5, 5, 2), directed = TRUE) + Condition + Warning in `dot_product_game_impl()`: + Greater than 1 connection probability in dot-product graph. + Source: games/dotproduct.c:90 + Output + IGRAPH D--- 2 2 -- + + edges: + [1] 1->2 2->1 + +# dot_product_game_impl errors + + Code + dot_product_game_impl(vecs = NULL) + Condition + Error in `dot_product_game_impl()`: + ! REAL() can only be applied to a 'numeric', not a 'NULL' + +# sample_sphere_surface_impl basic + + Code + 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 + [2,] 0.05165973 0.5261159 0.1145481 0.2979741 0.02649327 + [3,] 0.47443162 0.2229974 0.9830712 0.7128005 0.02500179 + +--- + + Code + 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 + [2,] -1.6787252 1.1329528 -0.7872709 -0.41498660 1.953509 + [3,] -0.9702395 0.7200713 1.7651832 -0.01090904 0.217584 + +# sample_sphere_surface_impl errors + + Code + sample_sphere_surface_impl(dim = -1, n = 5) + Condition + Error in `sample_sphere_surface_impl()`: + ! Sphere must be at least two dimensional to sample from surface. Invalid value + Source: : + +# sample_sphere_volume_impl basic + + Code + 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 + [2,] 0.03948371 0.3914105 0.07855561 0.1939507 0.01943923 + [3,] 0.36260970 0.1659017 0.67417787 0.4639603 0.01834487 + +--- + + Code + 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 + [2,] -0.159619927 0.2402815 -0.1258477 0.1842403 -1.4940836 + [3,] 0.003829883 1.2440192 0.6204597 1.5776103 0.4096058 + +# sample_sphere_volume_impl errors + + Code + sample_sphere_volume_impl(dim = -1, n = 5) + Condition + Error in `sample_sphere_volume_impl()`: + ! Sphere must be at least two dimensional to sample from surface. Invalid value + Source: : + +# sample_dirichlet_impl basic + + Code + 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 + [2,] 0.1093984 0.3461600 0.08924333 0.4251328 0.3561426 + [3,] 0.2608008 0.2369988 0.61481386 0.3316331 0.4921759 + +# sample_dirichlet_impl errors + + Code + sample_dirichlet_impl(n = -1, alpha = c(1, 1, 1)) + Condition + Error in `sample_dirichlet_impl()`: + ! Number of samples should be non-negative, got -1. Invalid value + Source: : + +# tree_game_impl basic + + Code + tree_game_impl(n = 3) + Output + IGRAPH U--- 3 2 -- + + edges: + [1] 2--3 1--2 + +--- + + Code + tree_game_impl(n = 3, directed = TRUE, method = "lerw") + Output + IGRAPH D--- 3 2 -- + + edges: + [1] 3->1 1->2 + +# tree_game_impl errors + + Code + tree_game_impl(n = "a") + Condition + Warning in `tree_game_impl()`: + NAs introduced by coercion + Error in `tree_game_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + +# barabasi_game_impl basic + + Code + barabasi_game_impl(n = 10, power = 1, m = 2, directed = FALSE, algo = "bag") + Output + IGRAPH U--- 10 18 -- + + edges: + [1] 1-- 2 1-- 2 2-- 3 1-- 3 2-- 4 2-- 4 2-- 5 2-- 5 4-- 6 2-- 6 2-- 7 1-- 7 + [13] 3-- 8 2-- 8 8-- 9 5-- 9 6--10 5--10 + +--- + + Code + barabasi_game_impl(n = 10, power = 1, m = 2, directed = FALSE, algo = "psumtree") + Output + IGRAPH U--- 10 17 -- + + edges: + [1] 1-- 2 1-- 3 2-- 3 1-- 4 2-- 4 2-- 5 4-- 5 1-- 6 3-- 6 6-- 7 3-- 7 6-- 8 + [13] 2-- 8 3-- 9 5-- 9 2--10 6--10 + +# grg_game_impl basic + + Code + grg_game_impl(nodes = 10, radius = 0.3, torus = FALSE) + Output + $graph + IGRAPH U--- 10 12 -- + + edges: + [1] 3-- 5 3-- 6 5-- 6 5-- 7 5-- 8 6-- 8 7-- 8 7-- 9 7--10 8-- 9 8--10 9--10 + + $x + [1] 0.08565451 0.15145413 0.45222514 0.45939554 0.55956278 0.61872370 + [7] 0.76201957 0.82545284 0.86690370 0.95857358 + + $y + [1] 0.07820721 0.85018913 0.08700766 0.73223568 0.33212277 0.14562638 + [7] 0.53326474 0.32235478 0.49679861 0.31410636 + + +# watts_strogatz_game_impl basic + + Code + watts_strogatz_game_impl(dim = 1, size = 10, nei = 2, p = 0.1) + Output + IGRAPH U--- 10 20 -- + + edges: + [1] 1-- 2 2-- 6 2-- 3 4-- 5 5-- 6 6-- 7 7-- 8 8-- 9 9--10 1--10 1-- 8 1-- 9 + [13] 2--10 2-- 4 3-- 5 4-- 6 5-- 7 6-- 8 7-- 9 8--10 + +# degree_sequence_game_impl basic + + Code + degree_sequence_game_impl(out_deg = c(2, 2, 2, 2), method = "configuration") + Output + IGRAPH U--- 4 4 -- + + edges: + [1] 2--4 3--3 1--4 1--2 + +--- + + Code + degree_sequence_game_impl(out_deg = c(2, 2, 2, 2), method = "vl") + Output + IGRAPH U--- 4 4 -- + + edges: + [1] 1--2 1--4 2--3 3--4 + diff --git a/tests/testthat/_snaps/aaa-generators.md b/tests/testthat/_snaps/aaa-generators.md new file mode 100644 index 00000000000..41a9cf83420 --- /dev/null +++ b/tests/testthat/_snaps/aaa-generators.md @@ -0,0 +1,808 @@ +# wheel_impl basic + + Code + wheel_impl(n = 5) + Output + IGRAPH D--- 5 8 -- + + edges: + [1] 1->2 1->3 1->4 1->5 2->3 3->4 4->5 5->2 + +--- + + Code + wheel_impl(n = 5, mode = "in", center = 2) + Output + IGRAPH D--- 5 8 -- + + edges: + [1] 1->3 2->3 4->3 5->3 1->2 2->4 4->5 5->1 + +# wheel_impl errors + + Code + wheel_impl(n = -1) + Condition + Error in `wheel_impl()`: + ! Invalid number of vertices. Invalid vertex ID + Source: : + +# hypercube_impl basic + + Code + hypercube_impl(n = 3) + Output + IGRAPH U--- 8 12 -- + + edges: + [1] 1--2 1--3 1--5 2--4 2--6 3--4 3--7 4--8 5--6 5--7 6--8 7--8 + +--- + + Code + hypercube_impl(n = 3, directed = TRUE) + Output + IGRAPH D--- 8 12 -- + + edges: + [1] 1->2 1->3 1->5 2->4 2->6 3->4 3->7 4->8 5->6 5->7 6->8 7->8 + +# hypercube_impl errors + + Code + hypercube_impl(n = 10000) + Condition + Error in `hypercube_impl()`: + ! The requested hypercube graph dimension (10000) is too high. It must be no greater than 57. Invalid value + Source: : + +# square_lattice_impl basic + + Code + square_lattice_impl(dimvector = c(2, 2)) + Output + IGRAPH U--- 4 4 -- + + edges: + [1] 1--2 1--3 2--4 3--4 + +--- + + Code + square_lattice_impl(dimvector = c(2, 2), nei = 2, directed = TRUE, mutual = TRUE, + periodic = c(TRUE, TRUE)) + Output + IGRAPH D--- 4 10 -- + + edges: + [1] 1->2 1->3 2->1 2->4 3->4 3->1 4->3 4->2 1->4 2->3 + +# square_lattice_impl errors + + Code + square_lattice_impl(dimvector = -1) + Condition + Error in `square_lattice_impl()`: + ! Invalid dimension vector. Invalid value + Source: : + +# triangular_lattice_impl basic + + Code + triangular_lattice_impl(dimvector = c(2, 2)) + Output + IGRAPH U--- 4 5 -- + + edges: + [1] 1--2 1--4 1--3 2--4 3--4 + +--- + + Code + triangular_lattice_impl(dimvector = c(2, 2), directed = TRUE, mutual = TRUE) + Output + IGRAPH D--- 4 10 -- + + edges: + [1] 1->2 2->1 1->4 4->1 1->3 3->1 2->4 4->2 3->4 4->3 + +# triangular_lattice_impl errors + + Code + triangular_lattice_impl(dimvector = -1) + Condition + Error in `triangular_lattice_impl()`: + ! Invalid dimension vector. Invalid value + Source: : + +# path_graph_impl basic + + Code + path_graph_impl(n = 5) + Output + IGRAPH U--- 5 4 -- + + edges: + [1] 1--2 2--3 3--4 4--5 + +--- + + Code + path_graph_impl(n = 5, directed = TRUE, mutual = TRUE) + Output + IGRAPH D--- 5 8 -- + + edges: + [1] 1->2 2->1 2->3 3->2 3->4 4->3 4->5 5->4 + +# path_graph_impl errors + + Code + path_graph_impl(n = -1) + Condition + Error in `path_graph_impl()`: + ! The number of vertices must be non-negative, got -1. Invalid value + Source: : + +# cycle_graph_impl basic + + Code + cycle_graph_impl(n = 5) + Output + IGRAPH U--- 5 5 -- + + edges: + [1] 1--2 2--3 3--4 4--5 1--5 + +--- + + Code + cycle_graph_impl(n = 5, directed = TRUE, mutual = TRUE) + Output + IGRAPH D--- 5 10 -- + + edges: + [1] 1->2 2->1 2->3 3->2 3->4 4->3 4->5 5->4 5->1 1->5 + +# cycle_graph_impl errors + + Code + cycle_graph_impl(n = -1) + Condition + Error in `cycle_graph_impl()`: + ! The number of vertices must be non-negative, got -1. Invalid value + Source: : + +# symmetric_tree_impl basic + + Code + symmetric_tree_impl(branches = 3) + Output + IGRAPH D--- 4 3 -- + + edges: + [1] 1->2 1->3 1->4 + +--- + + Code + symmetric_tree_impl(branches = 3, type = "in") + Output + IGRAPH D--- 4 3 -- + + edges: + [1] 2->1 3->1 4->1 + +# symmetric_tree_impl errors + + Code + symmetric_tree_impl(branches = -1) + Condition + Error in `symmetric_tree_impl()`: + ! The number of branches must be positive at each level. Invalid value + Source: : + +# regular_tree_impl basic + + Code + regular_tree_impl(h = 2) + Output + IGRAPH U--- 10 9 -- + + edges: + [1] 1-- 2 1-- 3 1-- 4 2-- 5 2-- 6 3-- 7 3-- 8 4-- 9 4--10 + +--- + + Code + regular_tree_impl(h = 2, k = 4, type = "in") + Output + IGRAPH D--- 17 16 -- + + edges: + [1] 2->1 3->1 4->1 5->1 6->2 7->2 8->2 9->3 10->3 11->3 12->4 13->4 + [13] 14->4 15->5 16->5 17->5 + +# regular_tree_impl errors + + Code + regular_tree_impl(h = -1) + Condition + Error in `regular_tree_impl()`: + ! Height of regular tree must be positive, got -1. Invalid value + Source: : + +# full_citation_impl basic + + Code + full_citation_impl(n = 5) + Output + IGRAPH D--- 5 10 -- + + edges: + [1] 2->1 3->1 3->2 4->1 4->2 4->3 5->1 5->2 5->3 5->4 + +--- + + Code + full_citation_impl(n = 5, directed = FALSE) + Output + IGRAPH U--- 5 10 -- + + edges: + [1] 1--2 1--3 2--3 1--4 2--4 3--4 1--5 2--5 3--5 4--5 + +# full_citation_impl errors + + Code + full_citation_impl(n = -1) + Condition + Error in `full_citation_impl()`: + ! Invalid number of vertices. Invalid value + Source: : + +# atlas_impl basic + + Code + atlas_impl(number = 0) + Output + IGRAPH U--- 0 0 -- + + edges: + +--- + + Code + atlas_impl(number = 5) + Output + IGRAPH U--- 3 1 -- + + edge: + [1] 2--3 + +# atlas_impl errors + + Code + atlas_impl(number = -1) + Condition + Error in `atlas_impl()`: + ! No such graph in atlas. The graph index must be less than 1253. Invalid value + Source: : + +# extended_chordal_ring_impl basic + + Code + extended_chordal_ring_impl(nodes = 5, W = matrix(c(1, 2))) + Output + IGRAPH U--- 5 15 -- + + edges: + [1] 1--2 2--3 3--4 4--5 1--5 1--2 1--3 2--3 2--4 3--4 3--5 4--5 1--4 1--5 2--5 + +--- + + Code + extended_chordal_ring_impl(nodes = 5, W = matrix(c(1, 2)), directed = TRUE) + Output + IGRAPH D--- 5 15 -- + + edges: + [1] 1->2 2->3 3->4 4->5 5->1 1->2 1->3 2->3 2->4 3->4 3->5 4->5 4->1 5->1 5->2 + +# extended_chordal_ring_impl errors + + Code + extended_chordal_ring_impl(nodes = -1, W = matrix(c(1, 2))) + Condition + Error in `extended_chordal_ring_impl()`: + ! An extended chordal ring has at least 3 nodes. Invalid value + Source: : + +# de_bruijn_impl basic + + Code + de_bruijn_impl(m = 2, n = 3) + Output + IGRAPH D--- 8 16 -- + + edges: + [1] 1->1 1->2 2->3 2->4 3->5 3->6 4->7 4->8 5->1 5->2 6->3 6->4 7->5 7->6 8->7 + [16] 8->8 + +# de_bruijn_impl errors + + Code + de_bruijn_impl(m = -1, n = 3) + Condition + Error in `de_bruijn_impl()`: + ! `m' and `n' should be non-negative in a de Bruijn graph. Invalid value + Source: : + +# kautz_impl basic + + Code + kautz_impl(m = 2, n = 3) + Output + IGRAPH D--- 24 48 -- + + edges: + [1] 1-> 9 1->10 2->11 2->12 3->13 3->14 4->15 4->16 5->17 5->18 + [11] 6->19 6->20 7->21 7->22 8->23 8->24 9-> 1 9-> 2 10-> 3 10-> 4 + [21] 11-> 5 11-> 6 12-> 7 12-> 8 13->17 13->18 14->19 14->20 15->21 15->22 + [31] 16->23 16->24 17-> 1 17-> 2 18-> 3 18-> 4 19-> 5 19-> 6 20-> 7 20-> 8 + [41] 21-> 9 21->10 22->11 22->12 23->13 23->14 24->15 24->16 + +# kautz_impl errors + + Code + kautz_impl(m = -1, n = 3) + Condition + Error in `kautz_impl()`: + ! `m' and `n' should be non-negative in a Kautz graph. Invalid value + Source: : + +# lcf_vector_impl basic + + Code + lcf_vector_impl(n = 10, shifts = c(3, -3, 4), repeats = 2) + Output + IGRAPH U--- 10 16 -- LCF graph + + attr: name (g/c) + + edges: + [1] 1-- 2 1-- 4 1--10 2-- 3 2-- 5 2-- 9 3-- 4 3-- 7 4-- 5 4-- 7 5-- 6 6-- 7 + [13] 6--10 7-- 8 8-- 9 9--10 + +# lcf_vector_impl errors + + Code + lcf_vector_impl(n = -1, shifts = c(3, -3, 4), repeats = 2) + Condition + Error in `lcf_vector_impl()`: + ! Number of vertices must not be negative. Invalid value + Source: : + +# mycielski_graph_impl basic + + Code + mycielski_graph_impl(k = 3) + Output + IGRAPH U--- 5 5 -- + + edges: + [1] 1--2 1--4 2--3 3--5 4--5 + +# mycielski_graph_impl errors + + Code + mycielski_graph_impl(k = -1) + Condition + Error in `mycielski_graph_impl()`: + ! The Mycielski graph order must not be negative. Invalid value + Source: : + +# adjlist_impl basic + + Code + adjlist_impl(adjlist = list(c(2, 3), c(1), c(1)), mode = "out") + Output + IGRAPH D--- 3 4 -- + + edges: + [1] 1->2 1->3 2->1 3->1 + +# adjlist_impl errors + + Code + adjlist_impl(adjlist = -1, mode = "out") + Condition + Error in `adjlist_impl()`: + ! Invalid (negative or too large) vertex ID. Invalid vertex ID + Source: : + +# full_multipartite_impl basic + + Code + full_multipartite_impl(n = c(2, 3, 4)) + Output + $graph + IGRAPH U--- 9 26 -- + + edges: + [1] 1--3 1--4 1--5 1--6 1--7 1--8 1--9 2--3 2--4 2--5 2--6 2--7 2--8 2--9 3--6 + [16] 3--7 3--8 3--9 4--6 4--7 4--8 4--9 5--6 5--7 5--8 5--9 + + $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(n = c(2, 3, 4), directed = TRUE, mode = "in") + Output + $graph + IGRAPH D--- 9 26 -- + + edges: + [1] 3->1 4->1 5->1 6->1 7->1 8->1 9->1 3->2 4->2 5->2 6->2 7->2 8->2 9->2 6->3 + [16] 7->3 8->3 9->3 6->4 7->4 8->4 9->4 6->5 7->5 8->5 9->5 + + $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 + + Code + full_multipartite_impl(n = -1) + Condition + Error in `full_multipartite_impl()`: + ! Number of vertices must not be negative in any partition. Invalid value + Source: : + +# realize_degree_sequence_impl basic + + Code + 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 + | (g/n), method (g/n) + + edges: + [1] 2--3 1--3 1--2 + +--- + + Code + 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 + | (g/n), method (g/n) + + edges: + [1] 1->2 1->3 2->1 2->3 3->1 3->2 + +# realize_degree_sequence_impl errors + + Code + realize_degree_sequence_impl(out_deg = -1) + Condition + Error in `realize_degree_sequence_impl()`: + ! The sum of degrees must be even for an undirected graph. Invalid value + Source: : + +# realize_bipartite_degree_sequence_impl basic + + Code + 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 + | (g/n), method (g/n) + + edges: + [1] 2--3 2--4 1--4 1--3 + +--- + + Code + 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 + | (g/n), method (g/n) + + edges: + [1] 1--3 1--4 2--3 2--4 + +# realize_bipartite_degree_sequence_impl errors + + Code + realize_bipartite_degree_sequence_impl(degrees1 = -1, degrees2 = c(2, 2)) + Condition + Error in `realize_bipartite_degree_sequence_impl()`: + ! The given bidegree sequence cannot be realized as a bipartite simple graph. Invalid value + Source: : + +# circulant_impl basic + + Code + circulant_impl(n = 5, shifts = c(1, 2)) + Output + 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(n = 5, shifts = c(1, 2), directed = TRUE) + Output + 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 + +# circulant_impl errors + + Code + circulant_impl(n = -1, shifts = c(1, 2)) + Condition + Error in `circulant_impl()`: + ! Number of nodes = -1 must be non-negative. Invalid value + Source: : + +# generalized_petersen_impl basic + + Code + generalized_petersen_impl(n = 5, k = 2) + Output + IGRAPH U--- 10 15 -- + + edges: + [1] 1-- 2 1-- 6 6-- 8 2-- 3 2-- 7 7-- 9 3-- 4 3-- 8 8--10 4-- 5 4-- 9 6-- 9 + [13] 1-- 5 5--10 7--10 + +# generalized_petersen_impl errors + + Code + generalized_petersen_impl(n = -1, k = 2) + Condition + Error in `generalized_petersen_impl()`: + ! n = -1 must be at least 3. Invalid value + Source: : + +# turan_impl basic + + Code + turan_impl(n = 5, r = 2) + Output + $graph + IGRAPH U--- 5 6 -- + + edges: + [1] 1--4 1--5 2--4 2--5 3--4 3--5 + + $types + [1] 1 1 1 2 2 + + $name + [1] "Turan graph" + + $n + [1] 5 + + $r + [1] 2 + + +# turan_impl errors + + Code + turan_impl(n = -1, r = 2) + Condition + Error in `turan_impl()`: + ! Number of vertices must not be negative, got -1. Invalid value + Source: : + +# from_prufer_impl basic + + Code + from_prufer_impl(prufer = 1:2) + Output + IGRAPH U--- 4 3 -- Tree from Prufer sequence + + attr: name (g/c), prufer (g/n) + + edges: + [1] 1--3 1--2 2--4 + +# from_prufer_impl errors + + Code + from_prufer_impl(prufer = "a") + Condition + Warning in `from_prufer_impl()`: + NAs introduced by coercion + Error in `from_prufer_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + +# tree_from_parent_vector_impl basic + + Code + tree_from_parent_vector_impl(parents = c(-1, 1, 2, 3)) + Output + IGRAPH D--- 4 3 -- + + edges: + [1] 1->2 2->3 3->4 + +--- + + Code + tree_from_parent_vector_impl(parents = c(-1, 1, 2, 3), type = "in") + Output + IGRAPH D--- 4 3 -- + + edges: + [1] 2->1 3->2 4->3 + +# tree_from_parent_vector_impl errors + + Code + tree_from_parent_vector_impl(parents = "a") + Condition + Warning in `tree_from_parent_vector_impl()`: + NAs introduced by coercion + Error in `tree_from_parent_vector_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + +# 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 + famous_impl(name = "NonexistentGraph") + Condition + Error in `famous_impl()`: + ! NonexistentGraph is not a known graph. See the documentation for valid graph names. Invalid value + Source: : + +# star_impl basic + + Code + star_impl(n = 5, mode = "out", center = 0) + Output + IGRAPH D--- 5 4 -- + + edges: + [1] 1->2 1->3 1->4 1->5 + +--- + + Code + star_impl(n = 6, mode = "in", center = 1) + Output + IGRAPH D--- 6 5 -- + + edges: + [1] 1->2 3->2 4->2 5->2 6->2 + +--- + + Code + star_impl(n = 4, mode = "undirected", center = 0) + Output + IGRAPH U--- 4 3 -- + + edges: + [1] 1--2 1--3 1--4 + +# ring_impl basic + + Code + ring_impl(n = 5, directed = FALSE, mutual = FALSE, circular = TRUE) + Output + IGRAPH U--- 5 5 -- + + edges: + [1] 1--2 2--3 3--4 4--5 1--5 + +--- + + Code + ring_impl(n = 4, directed = TRUE, mutual = FALSE, circular = FALSE) + Output + IGRAPH D--- 4 3 -- + + edges: + [1] 1->2 2->3 3->4 + +# full_impl basic + + Code + full_impl(n = 4, directed = FALSE, loops = FALSE) + Output + IGRAPH U--- 4 6 -- + + edges: + [1] 1--2 1--3 1--4 2--3 2--4 3--4 + +--- + + Code + full_impl(n = 3, directed = TRUE, loops = FALSE) + Output + IGRAPH D--- 3 6 -- + + edges: + [1] 1->2 1->3 2->1 2->3 3->1 3->2 + +# kary_tree_impl basic + + Code + kary_tree_impl(n = 7, children = 2, type = c("out", "in", "undirected")) + Output + IGRAPH D--- 7 6 -- + + edges: + [1] 1->2 1->3 2->4 2->5 3->6 3->7 + +--- + + Code + kary_tree_impl(n = 10, children = 3, type = c("in", "out", "undirected")) + Output + IGRAPH D--- 10 9 -- + + edges: + [1] 2->1 3->1 4->1 5->2 6->2 7->2 8->3 9->3 10->3 + +# sparse_adjacency_impl basic + + Code + sparse_adjacency_impl(adjmatrix = M) + Output + IGRAPH D--- 4 4 -- + + edges: + [1] 4->1 1->2 2->3 3->4 + +--- + + Code + sparse_adjacency_impl(adjmatrix = M_sym, mode = "undirected", loops = "once") + Output + IGRAPH U--- 4 4 -- + + edges: + [1] 1--2 2--3 1--4 3--4 + +# sparse_weighted_adjacency_impl basic + + Code + sparse_weighted_adjacency_impl(adjmatrix = M) + Output + $graph + IGRAPH D--- 4 4 -- + + edges: + [1] 4->1 1->2 2->3 3->4 + + $weights + [1] 0.5 2.5 1.0 3.0 + + +--- + + Code + sparse_weighted_adjacency_impl(adjmatrix = M_sym, mode = "undirected", loops = "once") + Output + $graph + IGRAPH U--- 4 4 -- + + edges: + [1] 1--2 2--3 1--4 3--4 + + $weights + [1] 2.5 1.0 0.5 3.0 + + +# weighted_sparsemat_impl basic + + Code + weighted_sparsemat_impl(A = M, directed = TRUE, attr = "weight", loops = FALSE) + Output + IGRAPH D-W- 4 4 -- + + attr: weight (e/n) + + edges: + [1] 4->1 1->2 2->3 3->4 + diff --git a/tests/testthat/_snaps/aaa-graphlets.md b/tests/testthat/_snaps/aaa-graphlets.md new file mode 100644 index 00000000000..9b5ada183fc --- /dev/null +++ b/tests/testthat/_snaps/aaa-graphlets.md @@ -0,0 +1,46 @@ +# graphlets_impl basic + + Code + graphlets_impl(graph = g) + Output + $cliques + $cliques[[1]] + + 2/3 vertices: + [1] 2 3 + + $cliques[[2]] + + 2/3 vertices: + [1] 1 2 + + + $Mu + [1] 0.6665667 0.3332333 + + +--- + + Code + graphlets_impl(graph = g, weights = c(3, 4), niter = 10) + Output + $cliques + $cliques[[1]] + + 2/3 vertices: + [1] 2 3 + + $cliques[[2]] + + 2/3 vertices: + [1] 1 2 + + + $Mu + [1] 1.333233 0.999900 + + +# graphlets_impl errors + + Code + graphlets_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + diff --git a/tests/testthat/_snaps/aaa-hrg.md b/tests/testthat/_snaps/aaa-hrg.md new file mode 100644 index 00000000000..e4b78d658c4 --- /dev/null +++ b/tests/testthat/_snaps/aaa-hrg.md @@ -0,0 +1,207 @@ +# hrg_fit_impl basic + + Code + hrg_fit_impl(graph = g1) + Output + $left + [1] -2 0 + + $right + [1] 1 2 + + $prob + [1] 1 0 + + $edges + [1] 2 0 + + $vertices + [1] 3 2 + + +# hrg_fit_impl errors + + Code + hrg_fit_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# hrg_sample_impl basic + + Code + hrg_sample_impl(hrg = hrg_model) + Output + IGRAPH U--- 10 45 -- + + edges: + [1] 1-- 2 1-- 3 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--10 2-- 3 2-- 4 2-- 5 + [13] 2-- 6 2-- 7 2-- 8 2-- 9 2--10 3-- 4 3-- 5 3-- 6 3-- 7 3-- 8 3-- 9 3--10 + [25] 4-- 5 4-- 6 4-- 7 4-- 8 4-- 9 4--10 5-- 6 5-- 7 5-- 8 5-- 9 5--10 6-- 7 + [37] 6-- 8 6-- 9 6--10 7-- 8 7-- 9 7--10 8-- 9 8--10 9--10 + +# hrg_sample_impl errors + + Code + hrg_sample_impl(hrg = NULL) + Condition + Error in `hrg_sample_impl()`: + ! At :: Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. + Please restart your R session to avoid crashes or other surprising behavior. + +# hrg_sample_many_impl basic + + Code + hrg_sample_many_impl(hrg = hrg_model, num_samples = 2) + Output + [[1]] + IGRAPH U--- 10 45 -- + + edges: + [1] 1-- 2 1-- 3 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--10 2-- 3 2-- 4 2-- 5 + [13] 2-- 6 2-- 7 2-- 8 2-- 9 2--10 3-- 4 3-- 5 3-- 6 3-- 7 3-- 8 3-- 9 3--10 + [25] 4-- 5 4-- 6 4-- 7 4-- 8 4-- 9 4--10 5-- 6 5-- 7 5-- 8 5-- 9 5--10 6-- 7 + [37] 6-- 8 6-- 9 6--10 7-- 8 7-- 9 7--10 8-- 9 8--10 9--10 + + [[2]] + IGRAPH U--- 10 45 -- + + edges: + [1] 1-- 2 1-- 3 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--10 2-- 3 2-- 4 2-- 5 + [13] 2-- 6 2-- 7 2-- 8 2-- 9 2--10 3-- 4 3-- 5 3-- 6 3-- 7 3-- 8 3-- 9 3--10 + [25] 4-- 5 4-- 6 4-- 7 4-- 8 4-- 9 4--10 5-- 6 5-- 7 5-- 8 5-- 9 5--10 6-- 7 + [37] 6-- 8 6-- 9 6--10 7-- 8 7-- 9 7--10 8-- 9 8--10 9--10 + + +# hrg_sample_many_impl errors + + Code + hrg_sample_many_impl(hrg = NULL, num_samples = 2) + Condition + Error in `hrg_sample_many_impl()`: + ! At :: Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. + Please restart your R session to avoid crashes or other surprising behavior. + +# hrg_game_impl basic + + Code + hrg_game_impl(hrg = hrg_model) + Output + IGRAPH U--- 10 45 -- Hierarchical random graph model + + attr: name (g/c) + + edges: + [1] 1-- 2 1-- 3 1-- 4 1-- 5 1-- 6 1-- 7 1-- 8 1-- 9 1--10 2-- 3 2-- 4 2-- 5 + [13] 2-- 6 2-- 7 2-- 8 2-- 9 2--10 3-- 4 3-- 5 3-- 6 3-- 7 3-- 8 3-- 9 3--10 + [25] 4-- 5 4-- 6 4-- 7 4-- 8 4-- 9 4--10 5-- 6 5-- 7 5-- 8 5-- 9 5--10 6-- 7 + [37] 6-- 8 6-- 9 6--10 7-- 8 7-- 9 7--10 8-- 9 8--10 9--10 + +# hrg_game_impl errors + + Code + hrg_game_impl(hrg = NULL) + Condition + Error in `hrg_game_impl()`: + ! At :: Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it. + Please restart your R session to avoid crashes or other surprising behavior. + +# hrg_consensus_impl errors + + Code + hrg_consensus_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# hrg_predict_impl errors + + Code + hrg_predict_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# hrg_create_impl basic + + Code + hrg_create_impl(graph = g, prob = rep(0.5, 2)) + Output + Hierarchical random graph, at level 3: + g1 p=0.5 1 + '- g2 p=0.5 2 3 + +# hrg_create_impl errors + + Code + hrg_create_impl(graph = g, prob = 0.5) + Condition + Error in `hrg_create_impl()`: + ! HRG probability vector size (1) should be equal to the number of internal nodes (2). Invalid value + Source: : + +# hrg_resize_impl basic + + Code + hrg_resize_impl(hrg = hrg_model, newsize = 5) + Output + $left + [1] 0 -9 -6 -2 + + $right + [1] -4 4 7 -8 + + $prob + [1] 1 1 1 1 + + $edges + [1] 9 6 3 14 + + $vertices + [1] 10 7 4 9 + + +# hrg_resize_impl errors + + Code + hrg_resize_impl(hrg = -1, newsize = 2) + Condition + Error in `hrg_resize_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + +# hrg_size_impl basic + + Code + hrg_size_impl(hrg = hrg_model) + Output + [1] 10 + +# hrg_size_impl errors + + Code + hrg_size_impl(hrg = -1) + Condition + Error in `hrg_size_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + +# from_hrg_dendrogram_impl basic + + Code + from_hrg_dendrogram_impl(hrg = hrg_model) + Output + $graph + IGRAPH D--- 19 18 -- + + edges: + [1] 11-> 1 11->14 12->19 12-> 5 13->16 13-> 8 14->12 14->18 15-> 3 15-> 6 + [11] 16->15 16->10 17->13 17-> 4 18-> 7 18-> 9 19-> 2 19->17 + + $prob + [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 1 1 1 1 1 1 1 1 1 + + +# from_hrg_dendrogram_impl errors + + Code + from_hrg_dendrogram_impl(hrg = -1) + Condition + Error in `from_hrg_dendrogram_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + diff --git a/tests/testthat/_snaps/aaa-isomorphism.md b/tests/testthat/_snaps/aaa-isomorphism.md new file mode 100644 index 00000000000..84f7546af4e --- /dev/null +++ b/tests/testthat/_snaps/aaa-isomorphism.md @@ -0,0 +1,724 @@ +# isoclass_impl basic + + Code + isoclass_impl(graph = g) + Output + [1] 2 + +# isoclass_impl errors + + Code + isoclass_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# isomorphic_impl basic + + Code + isomorphic_impl(graph1 = g1, graph2 = g2) + Output + [1] TRUE + +# isomorphic_impl errors + + Code + isomorphic_impl(graph1 = NULL, graph2 = graph2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# isoclass_subgraph_impl basic + + Code + isoclass_subgraph_impl(graph = g, vids = c(1, 2, 3)) + Output + [1] 2 + +# isoclass_subgraph_impl errors + + Code + isoclass_subgraph_impl(graph = NULL, vids = 1:2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# isoclass_create_impl basic + + Code + isoclass_create_impl(size = 3, number = 1) + Output + IGRAPH D--- 3 1 -- + + edge: + [1] 2->1 + +--- + + Code + isoclass_create_impl(size = 3, number = 1, directed = FALSE) + Output + IGRAPH U--- 3 1 -- + + edge: + [1] 1--2 + +# isoclass_create_impl errors + + Code + isoclass_create_impl(size = "a", number = 1) + Condition + Warning in `isoclass_create_impl()`: + NAs introduced by coercion + Error in `isoclass_create_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + +# isomorphic_vf2_impl basic + + Code + isomorphic_vf2_impl(graph1 = g1, graph2 = g2) + Output + $iso + [1] TRUE + + $map12 + [1] 1 2 3 + + $map21 + [1] 1 2 3 + + +--- + + Code + 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 + + $map12 + [1] 1 2 3 + + $map21 + [1] 1 2 3 + + +# isomorphic_vf2_impl errors + + Code + isomorphic_vf2_impl(graph1 = NULL, graph2 = graph2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# count_isomorphisms_vf2_impl basic + + Code + count_isomorphisms_vf2_impl(graph1 = g1, graph2 = g2) + Output + [1] 2 + +--- + + Code + 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 + +# count_isomorphisms_vf2_impl errors + + Code + count_isomorphisms_vf2_impl(graph1 = NULL, graph2 = graph2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_isomorphisms_vf2_impl basic + + Code + get_isomorphisms_vf2_impl(graph1 = g1, graph2 = g2) + Output + [[1]] + [1] 0 1 2 + + [[2]] + [1] 2 1 0 + + +--- + + Code + 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 + + +# get_isomorphisms_vf2_impl errors + + Code + get_isomorphisms_vf2_impl(graph1 = NULL, graph2 = graph2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# subisomorphic_impl basic + + Code + subisomorphic_impl(graph1 = g1, graph2 = g2) + Output + [1] TRUE + +# subisomorphic_impl errors + + Code + subisomorphic_impl(graph1 = NULL, graph2 = graph2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# subisomorphic_vf2_impl basic + + Code + subisomorphic_vf2_impl(graph1 = g1, graph2 = g2) + Output + $iso + [1] TRUE + + $map12 + [1] 1 2 3 + + $map21 + [1] 1 2 3 + + +--- + + Code + 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 + + $map12 + [1] 1 2 3 + + $map21 + [1] 1 2 3 + + +# subisomorphic_vf2_impl errors + + Code + subisomorphic_vf2_impl(graph1 = NULL, graph2 = graph2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# count_subisomorphisms_vf2_impl basic + + Code + count_subisomorphisms_vf2_impl(graph1 = g1, graph2 = g2) + Output + [1] 2 + +--- + + Code + 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 + +# count_subisomorphisms_vf2_impl errors + + Code + count_subisomorphisms_vf2_impl(graph1 = NULL, graph2 = graph2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_subisomorphisms_vf2_impl basic + + Code + get_subisomorphisms_vf2_impl(graph1 = g1, graph2 = g2) + Output + [[1]] + [1] 0 1 2 + + [[2]] + [1] 2 1 0 + + +--- + + Code + 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 + + +# get_subisomorphisms_vf2_impl errors + + Code + get_subisomorphisms_vf2_impl(graph1 = NULL, graph2 = graph2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# canonical_permutation_impl basic + + Code + canonical_permutation_impl(graph = g) + Output + $labeling + [1] 2 3 1 + + $info + $info$nof_nodes + [1] 3 + + $info$nof_leaf_nodes + [1] 3 + + $info$nof_bad_nodes + [1] 0 + + $info$nof_canupdates + [1] 1 + + $info$max_level + [1] 1 + + $info$group_size + [1] "2" + + + +--- + + Code + canonical_permutation_impl(graph = g, colors = c(1, 2, 3), sh = "fl") + Output + $labeling + [1] 1 2 3 + + $info + $info$nof_nodes + [1] 1 + + $info$nof_leaf_nodes + [1] 1 + + $info$nof_bad_nodes + [1] 0 + + $info$nof_canupdates + [1] 0 + + $info$max_level + [1] 0 + + $info$group_size + [1] "1" + + + +# canonical_permutation_impl errors + + Code + canonical_permutation_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# permute_vertices_impl basic + + Code + permute_vertices_impl(graph = g, permutation = 3:1) + Output + IGRAPH U--- 3 2 -- + + edges: + [1] 2--3 1--2 + +# permute_vertices_impl errors + + Code + permute_vertices_impl(graph = NULL, permutation = 3:1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# isomorphic_bliss_impl basic + + Code + isomorphic_bliss_impl(graph1 = g1, graph2 = g2) + Output + $iso + [1] TRUE + + $map12 + [1] 1 2 3 + + $map21 + [1] 1 2 3 + + $info1 + $info1$nof_nodes + [1] 3 + + $info1$nof_leaf_nodes + [1] 3 + + $info1$nof_bad_nodes + [1] 0 + + $info1$nof_canupdates + [1] 1 + + $info1$max_level + [1] 1 + + $info1$group_size + [1] "2" + + + $info2 + $info2$nof_nodes + [1] 3 + + $info2$nof_leaf_nodes + [1] 3 + + $info2$nof_bad_nodes + [1] 0 + + $info2$nof_canupdates + [1] 1 + + $info2$max_level + [1] 1 + + $info2$group_size + [1] "2" + + + +--- + + Code + isomorphic_bliss_impl(graph1 = g1, graph2 = g2, colors1 = c(1, 2, 3), colors2 = c( + 1, 2, 3), sh = "fl") + Output + $iso + [1] TRUE + + $map12 + [1] 1 2 3 + + $map21 + [1] 1 2 3 + + $info1 + $info1$nof_nodes + [1] 1 + + $info1$nof_leaf_nodes + [1] 1 + + $info1$nof_bad_nodes + [1] 0 + + $info1$nof_canupdates + [1] 0 + + $info1$max_level + [1] 0 + + $info1$group_size + [1] "1" + + + $info2 + $info2$nof_nodes + [1] 1 + + $info2$nof_leaf_nodes + [1] 1 + + $info2$nof_bad_nodes + [1] 0 + + $info2$nof_canupdates + [1] 0 + + $info2$max_level + [1] 0 + + $info2$group_size + [1] "1" + + + +# isomorphic_bliss_impl errors + + Code + isomorphic_bliss_impl(graph1 = NULL, graph2 = graph2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# count_automorphisms_impl basic + + Code + count_automorphisms_impl(graph = g) + Output + $nof_nodes + [1] 3 + + $nof_leaf_nodes + [1] 3 + + $nof_bad_nodes + [1] 0 + + $nof_canupdates + [1] 1 + + $max_level + [1] 1 + + $group_size + [1] "2" + + +--- + + Code + count_automorphisms_impl(graph = g, colors = c(1, 2, 3), sh = "fl") + Output + $nof_nodes + [1] 1 + + $nof_leaf_nodes + [1] 1 + + $nof_bad_nodes + [1] 0 + + $nof_canupdates + [1] 0 + + $max_level + [1] 0 + + $group_size + [1] "1" + + +# count_automorphisms_impl errors + + Code + count_automorphisms_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# automorphism_group_impl basic + + Code + automorphism_group_impl(graph = g) + Output + [[1]] + + 3/3 vertices: + [1] 3 2 1 + + +--- + + Code + automorphism_group_impl(graph = g, colors = c(1, 2, 3), sh = "fl", details = TRUE) + Output + $generators + list() + + $info + $info$nof_nodes + [1] 1 + + $info$nof_leaf_nodes + [1] 1 + + $info$nof_bad_nodes + [1] 0 + + $info$nof_canupdates + [1] 0 + + $info$max_level + [1] 0 + + $info$group_size + [1] "1" + + + +# automorphism_group_impl errors + + Code + automorphism_group_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# simplify_and_colorize_impl basic + + Code + simplify_and_colorize_impl(graph = g) + Output + $res + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + + $vertex_color + [1] 0 0 0 + + $edge_color + [1] 1 1 + + +# simplify_and_colorize_impl errors + + Code + simplify_and_colorize_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# graph_count_impl basic + + Code + graph_count_impl(n = 3) + Output + [1] 4 + +--- + + Code + graph_count_impl(n = 3, directed = TRUE) + Output + [1] 16 + +# graph_count_impl errors + + Code + graph_count_impl(n = "a") + Condition + Warning in `graph_count_impl()`: + NAs introduced by coercion + Error in `graph_count_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + +# get_isomorphisms_vf2_callback_closure_impl basic + + Code + cat("Result:\n") + Output + Result: + Code + print(result) + Output + NULL + Code + cat("\nNumber of isomorphisms found:", length(iso_data), "\n") + Output + + Number of isomorphisms found: 2 + Code + cat("First isomorphism:\n") + Output + First isomorphism: + Code + print(iso_data[[1]]) + Output + $map12 + [1] 1 2 3 4 5 + + $map21 + [1] 1 2 3 4 5 + + +# get_isomorphisms_vf2_callback_closure_impl errors + + Code + get_isomorphisms_vf2_callback_closure_impl(graph1 = g1, graph2 = g2, + vertex_color1 = NULL, vertex_color2 = NULL, edge_color1 = NULL, edge_color2 = NULL, + callback = "not a function") + Condition + Error in `get_isomorphisms_vf2_callback_closure_impl()`: + ! `callback` must be a function + +# get_subisomorphisms_vf2_callback_closure_impl basic + + Code + cat("Result:\n") + Output + Result: + Code + print(result) + Output + NULL + Code + cat("\nNumber of subisomorphisms found:", length(subiso_data), "\n") + Output + + Number of subisomorphisms found: 2 + Code + cat("First subisomorphism:\n") + Output + First subisomorphism: + Code + print(subiso_data[[1]]) + Output + $map12 + [1] 1 2 3 0 0 + + $map21 + [1] 1 2 3 + + +# get_subisomorphisms_vf2_callback_closure_impl errors + + Code + get_subisomorphisms_vf2_callback_closure_impl(graph1 = g1, graph2 = g2, + vertex_color1 = NULL, vertex_color2 = NULL, edge_color1 = NULL, edge_color2 = NULL, + callback = "not a function") + Condition + Error in `get_subisomorphisms_vf2_callback_closure_impl()`: + ! `callback` must be a function + +# subisomorphic_lad_impl errors + + Code + subisomorphic_lad_impl(pattern = NULL, target = g, domains = list(), induced = FALSE, + time_limit = 0) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +--- + + Code + subisomorphic_lad_impl(pattern = g, target = g, domains = "not a list", + induced = FALSE, time_limit = 0) + Condition + Error: + ! `domains` must be a list or NULL + diff --git a/tests/testthat/_snaps/aaa-layout.md b/tests/testthat/_snaps/aaa-layout.md new file mode 100644 index 00000000000..0a9e6c8ff30 --- /dev/null +++ b/tests/testthat/_snaps/aaa-layout.md @@ -0,0 +1,464 @@ +# layout_random_impl basic + + Code + layout_random_impl(graph = g) + Output + [,1] [,2] + [1,] 0.91714717 0.7003783 + [2,] -0.84358557 0.6509057 + [3,] -0.08120892 -0.8259847 + +# layout_random_impl errors + + Code + layout_random_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_circle_impl basic + + Code + layout_circle_impl(graph = g) + Output + [,1] [,2] + [1,] 1.0 0.0000000 + [2,] -0.5 0.8660254 + [3,] -0.5 -0.8660254 + +--- + + Code + layout_circle_impl(graph = g, order = 1:3) + Output + [,1] [,2] + [1,] 1.0 0.0000000 + [2,] -0.5 0.8660254 + [3,] -0.5 -0.8660254 + +# layout_circle_impl errors + + Code + layout_circle_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_star_impl basic + + Code + round(layout_star_impl(graph = g), 4) + Output + [,1] [,2] + [1,] 0 0 + [2,] 1 0 + [3,] -1 0 + +--- + + Code + round(layout_star_impl(graph = g, center = 1, order = 3:1), 4) + Output + [,1] [,2] + [1,] 0 0 + [2,] -1 0 + [3,] 1 0 + +# layout_star_impl errors + + Code + layout_star_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_grid_impl basic + + Code + layout_grid_impl(graph = g) + Output + [,1] [,2] + [1,] 0 0 + [2,] 1 0 + [3,] 0 1 + +--- + + Code + layout_grid_impl(graph = g, width = 2) + Output + [,1] [,2] + [1,] 0 0 + [2,] 1 0 + [3,] 0 1 + +# layout_grid_impl errors + + Code + layout_grid_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_grid_3d_impl basic + + Code + layout_grid_3d_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] 0 0 0 + [2,] 1 0 0 + [3,] 0 1 0 + +--- + + Code + layout_grid_3d_impl(graph = g, width = 2, height = 2) + Output + [,1] [,2] [,3] + [1,] 0 0 0 + [2,] 1 0 0 + [3,] 0 1 0 + +# layout_grid_3d_impl errors + + Code + layout_grid_3d_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# roots_for_tree_layout_impl basic + + Code + roots_for_tree_layout_impl(graph = g, mode = "out", heuristic = 1) + Output + + 1/3 vertex: + [1] 2 + +# roots_for_tree_layout_impl errors + + Code + roots_for_tree_layout_impl(graph = NULL, mode = "out", heuristic = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_random_3d_impl basic + + Code + layout_random_3d_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] 0.91714717 0.7003783 0.7338074 + [2,] -0.84358557 0.6509057 0.4644714 + [3,] -0.08120892 -0.8259847 0.5240391 + +# layout_random_3d_impl errors + + Code + layout_random_3d_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_sphere_impl basic + + Code + layout_sphere_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] 0.0000000 0.0000000 -1 + [2,] -0.4861377 0.8738822 0 + [3,] 0.0000000 0.0000000 1 + +--- + + Code + layout_sphere_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] 0.0000000 0.0000000 -1.0 + [2,] -0.2461774 0.8302992 -0.5 + [3,] -0.9468790 -0.3215901 0.0 + [4,] 0.5001161 -0.7070246 0.5 + [5,] 0.0000000 0.0000000 1.0 + +# layout_sphere_impl errors + + Code + layout_sphere_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_sugiyama_impl basic + + Code + layout_sugiyama_impl(graph = g) + Output + $res + [,1] [,2] + [1,] 0.0 1 + [2,] 0.5 0 + [3,] 1.0 1 + + $extd_graph + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + + $extd_to_orig_eids + [1] 1 2 + + +--- + + Code + layout_sugiyama_impl(graph = g, layers = 1:3, hgap = 2, vgap = 2, maxiter = 10, + weights = c(1, 2)) + Output + $res + [,1] [,2] + [1,] 0 0 + [2,] 0 2 + [3,] 0 4 + + $extd_graph + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + + $extd_to_orig_eids + [1] 1 2 + + +# layout_sugiyama_impl errors + + Code + layout_sugiyama_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_mds_impl basic + + Code + layout_mds_impl(graph = g) + Output + [,1] [,2] + [1,] 1 2.807594e-08 + [2,] 0 0.000000e+00 + [3,] -1 2.807594e-08 + +--- + + Code + layout_mds_impl(graph = g, dist = matrix(1:9, nrow = 3), dim = 3) + Output + [,1] [,2] [,3] + [1,] -2.907521 2.32638426 1.444979 + [2,] -3.900013 -1.63291106 2.258035 + [3,] 3.975674 0.09951448 3.271816 + +# layout_mds_impl errors + + Code + layout_mds_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_bipartite_impl basic + + Code + layout_bipartite_impl(graph = g, types = c(TRUE, FALSE, TRUE)) + Output + [,1] [,2] + [1,] 0.0 0 + [2,] 0.5 1 + [3,] 1.0 0 + +--- + + Code + layout_bipartite_impl(graph = g, types = c(TRUE, FALSE, TRUE), hgap = 2, vgap = 2, + maxiter = 10) + Output + [,1] [,2] + [1,] 0 0 + [2,] 1 2 + [3,] 2 0 + +# layout_bipartite_impl errors + + Code + layout_bipartite_impl(graph = NULL, types = c(TRUE, FALSE, TRUE)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_gem_impl basic + + Code + layout_gem_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2)) + Output + [,1] [,2] + [1,] 200.18284 -69.23950 + [2,] 86.00346 64.12806 + [3,] 66.22930 -92.94294 + +--- + + Code + 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] + [1,] 1.0114521 -0.1206363 + [2,] -0.2178589 2.9621162 + [3,] -0.7089555 -3.8896500 + +# layout_gem_impl errors + + Code + layout_gem_impl(graph = NULL, res = matrix(0, nrow = 3, ncol = 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_davidson_harel_impl basic + + Code + layout_davidson_harel_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2)) + Output + [,1] [,2] + [1,] 1.152116 0.9424808 + [2,] 2.474361 2.5195497 + [3,] 3.849187 4.0402661 + +--- + + Code + 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 + [,1] [,2] + [1,] -6.609493 -2.155221 + [2,] -8.660255 -3.797365 + [3,] -6.485087 -5.224752 + +# layout_davidson_harel_impl errors + + Code + layout_davidson_harel_impl(graph = NULL, res = matrix(0, nrow = 3, ncol = 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_umap_impl basic + + Code + layout_umap_impl(graph = g, res = matrix(0, nrow = 3, ncol = 2), use_seed = TRUE) + Output + [,1] [,2] + [1,] 0 0 + [2,] 0 0 + [3,] 0 0 + +--- + + Code + 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] + [1,] 0 0 + [2,] 0 0 + [3,] 0 0 + +# layout_umap_impl errors + + Code + layout_umap_impl(graph = NULL, res = matrix(0, nrow = 3, ncol = 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_umap_3d_impl basic + + Code + layout_umap_3d_impl(graph = g, res = matrix(0, nrow = 3, ncol = 3), use_seed = TRUE) + Output + [,1] [,2] [,3] + [1,] 0 0 0 + [2,] 0 0 0 + [3,] 0 0 0 + +--- + + Code + 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] + [1,] 0 0 0 + [2,] 0 0 0 + [3,] 0 0 0 + +# layout_umap_3d_impl errors + + Code + layout_umap_3d_impl(graph = NULL, res = matrix(0, nrow = 3, ncol = 3)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_umap_compute_weights_impl basic + + Code + layout_umap_compute_weights_impl(graph = g, distances = 1:2, weights = 1:3) + Output + [1] 1 1 + +# layout_umap_compute_weights_impl errors + + Code + layout_umap_compute_weights_impl(graph = NULL, distances = 1:3, weights = 1:3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_align_impl basic + + Code + layout_align_impl(graph = g, layout = matrix(0, nrow = 3, ncol = 2)) + Output + [,1] [,2] + [1,] 0 0 + [2,] 0 0 + [3,] 0 0 + +# layout_align_impl errors + + Code + layout_align_impl(graph = NULL, layout = matrix(0, nrow = 3, ncol = 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# layout_merge_dla_impl basic + + Code + layout_merge_dla_impl(graphs = list(g1, g2), coords = list(coords1, coords2)) + Output + [,1] [,2] + [1,] -2.279507 0.0000000 + [2,] 0.000000 0.0000000 + [3,] 2.279507 0.0000000 + [4,] -6.893133 -0.8307751 + [5,] -4.613626 -0.8307751 + [6,] -2.334119 -0.8307751 + diff --git a/tests/testthat/_snaps/aaa-motifs.md b/tests/testthat/_snaps/aaa-motifs.md new file mode 100644 index 00000000000..bf5beecfc9f --- /dev/null +++ b/tests/testthat/_snaps/aaa-motifs.md @@ -0,0 +1,200 @@ +# motifs_randesu_impl basic + + Code + motifs_randesu_impl(graph = g) + Output + [1] NaN NaN 1 0 + +--- + + Code + 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 + +# motifs_randesu_impl errors + + Code + motifs_randesu_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# motifs_randesu_estimate_impl basic + + Code + motifs_randesu_estimate_impl(graph = g, size = 3, sample_size = 2) + Output + [1] 3 + +--- + + Code + motifs_randesu_estimate_impl(graph = g, size = 4, cut_prob = rep(0.1, 4), + sample_size = 2, sample = 1:2) + Output + [1] 3 + +# motifs_randesu_estimate_impl errors + + Code + motifs_randesu_estimate_impl(graph = NULL, size = 3, sample_size = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# motifs_randesu_no_impl basic + + Code + motifs_randesu_no_impl(graph = g) + Output + [1] 1 + +--- + + Code + motifs_randesu_no_impl(graph = g, size = 4, cut_prob = c(0.1, 0.1, 0.1, 0.1)) + Output + [1] 0 + +# motifs_randesu_no_impl errors + + Code + motifs_randesu_no_impl(graph = g, size = 3, cut_prob = c(0.1)) + Condition + Error in `motifs_randesu_no_impl()`: + ! Cut probability vector size (1) must agree with motif size (3). Invalid value + Source: : + +# dyad_census_impl basic + + Code + dyad_census_impl(graph = g) + Output + $mut + [1] 2 + + $asym + [1] 0 + + $null + [1] 1 + + +# dyad_census_impl errors + + Code + dyad_census_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# triad_census_impl basic + + Code + triad_census_impl(graph = g) + Condition + Warning in `triad_census_impl()`: + Triad census called on an undirected graph. All connections will be treated as mutual. + Source: misc/motifs.c:1157 + Output + [1] 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 + +# triad_census_impl errors + + Code + triad_census_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# count_adjacent_triangles_impl basic + + Code + count_adjacent_triangles_impl(graph = g) + Output + [1] 0 0 0 + +--- + + Code + count_adjacent_triangles_impl(graph = g, vids = 1:2) + Output + [1] 0 0 + +# count_adjacent_triangles_impl errors + + Code + count_adjacent_triangles_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# count_triangles_impl basic + + Code + count_triangles_impl(graph = g) + Output + [1] 0 + +# count_triangles_impl errors + + Code + count_triangles_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# list_triangles_impl basic + + Code + list_triangles_impl(graph = g) + Output + + 0/3 vertices: + +# list_triangles_impl errors + + Code + list_triangles_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# motifs_randesu_callback_closure_impl basic + + Code + cat("Result:\n") + Output + Result: + Code + print(result) + Output + NULL + Code + cat("\nNumber of motifs found:", length(motif_data), "\n") + Output + + Number of motifs found: 1 + Code + cat("First motif:\n") + Output + First motif: + Code + print(motif_data[[1]]) + Output + $vids + [1] 1 3 2 + + $isoclass + [1] 4 + + +# motifs_randesu_callback_closure_impl errors + + Code + motifs_randesu_callback_closure_impl(graph = g, size = 3, cut_prob = NULL, + callback = "not a function") + Condition + Error in `motifs_randesu_callback_closure_impl()`: + ! `callback` must be a function + diff --git a/tests/testthat/_snaps/aaa-nongraph.md b/tests/testthat/_snaps/aaa-nongraph.md new file mode 100644 index 00000000000..4a6cbc11b4a --- /dev/null +++ b/tests/testthat/_snaps/aaa-nongraph.md @@ -0,0 +1,85 @@ +# power_law_fit_impl basic + + Code + power_law_fit_impl(data = c(1, 2, 3)) + Output + $continuous + [1] FALSE + + $alpha + [1] 1.646771 + + $xmin + [1] 1 + + $logLik + [1] -5.272517 + + $KS.stat + [1] 0.2640998 + + +--- + + Code + power_law_fit_impl(data = c(1, 2, 3), xmin = 1, force_continuous = TRUE) + Output + $continuous + [1] TRUE + + $alpha + [1] 2.116221 + + $xmin + [1] 1 + + $logLik + [1] -3.461912 + + $KS.stat + [1] 0.3533555 + + +# power_law_fit_impl errors + + Code + power_law_fit_impl(data = "a") + Condition + Warning in `power_law_fit_impl()`: + NAs introduced by coercion + Error in `power_law_fit_impl()`: + ! xmin must be greater than zero. Invalid value + Source: : + +# solve_lsap_impl basic + + Code + solve_lsap_impl(c = matrix(1:4, ncol = 2), n = 2) + Output + [1] 0 1 + +# solve_lsap_impl errors + + Code + solve_lsap_impl(c = "a", n = 2) + Condition + Warning in `solve_lsap_impl()`: + NAs introduced by coercion + Error in `solve_lsap_impl()`: + ! REAL() can only be applied to a 'numeric', not a 'character' + +# version_impl basic + + Code + version_impl_clean() + Output + [1] "0.10.17" + +# version_impl errors + + Code + version_impl("invalid") + Condition + Error in `version_impl()`: + ! unused argument ("invalid") + diff --git a/tests/testthat/_snaps/aaa-operators.md b/tests/testthat/_snaps/aaa-operators.md new file mode 100644 index 00000000000..71b7962c305 --- /dev/null +++ b/tests/testthat/_snaps/aaa-operators.md @@ -0,0 +1,418 @@ +# graph_power_impl basic + + Code + graph_power_impl(graph = g, order = 2) + Output + IGRAPH U--- 5 7 -- + + edges: + [1] 1--2 2--3 3--4 4--5 1--3 2--4 3--5 + +--- + + Code + graph_power_impl(graph = g, order = 2, directed = TRUE) + Output + IGRAPH U--- 5 7 -- + + edges: + [1] 1--2 2--3 3--4 4--5 1--3 2--4 3--5 + +# graph_power_impl errors + + Code + graph_power_impl(graph = NULL, order = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# linegraph_impl basic + + Code + linegraph_impl(graph = g) + Output + IGRAPH U--- 4 3 -- + + edges: + [1] 1--2 2--3 3--4 + +# linegraph_impl errors + + Code + linegraph_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# induced_subgraph_impl basic + + Code + induced_subgraph_impl(graph = g, vids = 1:2) + Output + IGRAPH U--- 2 1 -- + + edge: + [1] 1--2 + +# induced_subgraph_impl errors + + Code + induced_subgraph_impl(graph = NULL, vids = 1:2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# subgraph_from_edges_impl basic + + Code + subgraph_from_edges_impl(graph = g, eids = 1) + Output + IGRAPH U--- 2 1 -- + + edge: + [1] 1--2 + +# subgraph_from_edges_impl errors + + Code + subgraph_from_edges_impl(graph = NULL, eids = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# reverse_edges_impl basic + + Code + reverse_edges_impl(graph = g) + Output + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + +# reverse_edges_impl errors + + Code + reverse_edges_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# simplify_impl basic + + Code + simplify_impl(graph = g) + Output + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + +--- + + Code + simplify_impl(graph = g, remove_multiple = FALSE, remove_loops = FALSE) + Output + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + +# simplify_impl errors + + Code + simplify_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# contract_vertices_impl basic + + Code + contract_vertices_impl(graph = g, mapping = c(1, 1, 2)) + Output + IGRAPH U--- 2 2 -- + + edges: + [1] 1--1 1--2 + +# contract_vertices_impl errors + + Code + contract_vertices_impl(graph = NULL, mapping = c(1, 1, 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# transitive_closure_dag_impl basic + + Code + transitive_closure_dag_impl(graph = g) + Output + IGRAPH D--- 3 3 -- + + edges: + [1] 1->3 1->2 2->3 + +# transitive_closure_dag_impl errors + + Code + transitive_closure_dag_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# transitive_closure_impl basic + + Code + transitive_closure_impl(graph = g) + Output + IGRAPH U--- 3 3 -- + + edges: + [1] 1--2 1--3 2--3 + +# transitive_closure_impl errors + + Code + transitive_closure_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# join_impl basic + + Code + join_impl(left = g1, right = g2) + Output + IGRAPH U--- 6 13 -- + + edges: + [1] 1--2 2--3 4--5 5--6 1--4 1--5 1--6 2--4 2--5 2--6 3--4 3--5 3--6 + +# join_impl errors + + Code + join_impl(left = NULL, right = right) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# induced_subgraph_map_impl basic + + Code + induced_subgraph_map_impl(graph = g, vids = 1:2, impl = "auto") + Output + $res + IGRAPH U--- 2 1 -- + + edge: + [1] 1--2 + + $map + [1] 2 3 1 + + $invmap + [1] 1 2 + + +--- + + Code + induced_subgraph_map_impl(graph = g, vids = 1:2, impl = "copy_and_delete") + Output + $res + IGRAPH U--- 2 1 -- + + edge: + [1] 1--2 + + $map + [1] 2 3 1 + + $invmap + [1] 1 2 + + +# induced_subgraph_map_impl errors + + Code + induced_subgraph_map_impl(graph = NULL, vids = 1:2, impl = "auto") + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# mycielskian_impl basic + + Code + mycielskian_impl(graph = g) + Output + IGRAPH U--- 7 9 -- + + edges: + [1] 1--2 2--3 1--5 2--4 2--6 3--5 4--7 5--7 6--7 + +--- + + Code + mycielskian_impl(graph = g, k = 2) + Output + IGRAPH U--- 15 34 -- + + edges: + [1] 1-- 2 2-- 3 1-- 5 2-- 4 2-- 6 3-- 5 4-- 7 5-- 7 6-- 7 1-- 9 + [11] 2-- 8 2--10 3-- 9 1--12 5-- 8 2--11 4-- 9 2--13 6-- 9 3--12 + [21] 5--10 4--14 7--11 5--14 7--12 6--14 7--13 8--15 9--15 10--15 + [31] 11--15 12--15 13--15 14--15 + +# mycielskian_impl errors + + Code + mycielskian_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# product_impl basic + + Code + product_impl(g1 = g1, g2 = g2) + Output + IGRAPH U--- 9 12 -- + + edges: + [1] 1--4 2--5 3--6 4--7 5--8 6--9 1--2 4--5 7--8 2--3 5--6 8--9 + +--- + + Code + product_impl(g1 = g1, g2 = g2, type = "tensor") + Output + IGRAPH U--- 9 8 -- + + edges: + [1] 1--5 2--4 2--6 3--5 4--8 5--7 5--9 6--8 + +# product_impl errors + + Code + product_impl(g1 = NULL, g2 = g2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# rooted_product_impl basic + + Code + rooted_product_impl(g1 = g1, g2 = g2, root = 1) + Output + IGRAPH U--- 9 8 -- + + edges: + [1] 1--4 4--7 1--2 4--5 7--8 2--3 5--6 8--9 + +# rooted_product_impl errors + + Code + rooted_product_impl(g1 = NULL, g2 = g2, root = 1) + 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 + union_impl(left = NULL, right = NULL) + 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 + intersection_impl(left = NULL, right = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# connect_neighborhood_impl basic + + Code + connect_neighborhood_impl(graph = g, order = 1, mode = c("all", "out", "in")) + Condition + Warning in `connect_neighborhood_impl()`: + Order smaller than two, graph will be unchanged. + Source: : + Output + IGRAPH U--- 5 5 -- Ring graph + + attr: name (g/c), mutual (g/l), circular (g/l) + + edges: + [1] 1--2 2--3 3--4 4--5 1--5 + +# disjoint_union_many_impl basic + + Code + disjoint_union_many_impl(graphs = list(g1, g2, g3)) + Output + IGRAPH D--- 6 0 -- + + edges: + +# union_many_impl basic + + Code + union_many_impl(graphs = list(g1, g2, g3)) + Output + $res + IGRAPH D--- 3 3 -- + + edges: + [1] 2->3 1->3 1->2 + + $edgemaps + $edgemaps[[1]] + numeric(0) + + $edgemaps[[2]] + [1] 2 0 + + $edgemaps[[3]] + [1] 1 + + + +# intersection_many_impl basic + + Code + intersection_many_impl(graphs = list(g1, g2, g3)) + Output + $res + IGRAPH D--- 3 1 -- + + edge: + [1] 1->2 + + $edgemaps + $edgemaps[[1]] + [1] 0 -1 -1 + + $edgemaps[[2]] + [1] 0 -1 + + $edgemaps[[3]] + [1] 0 + + + diff --git a/tests/testthat/_snaps/aaa-paths.md b/tests/testthat/_snaps/aaa-paths.md new file mode 100644 index 00000000000..b3c6816ff7f --- /dev/null +++ b/tests/testthat/_snaps/aaa-paths.md @@ -0,0 +1,561 @@ +# get_shortest_path_impl basic + + Code + get_shortest_path_impl(graph = g, from = 1, to = 3) + Output + $vertices + + 3/3 vertices: + [1] 1 2 3 + + $edges + + 2/2 edges: + [1] 1--2 2--3 + + +# get_shortest_path_impl errors + + Code + get_shortest_path_impl(graph = NULL, from = 1, to = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_shortest_path_bellman_ford_impl basic + + Code + get_shortest_path_bellman_ford_impl(graph = g, from = 1, to = 3) + Output + $vertices + + 3/3 vertices: + [1] 1 2 3 + + $edges + + 2/2 edges: + [1] 1--2 2--3 + + +# get_shortest_path_bellman_ford_impl errors + + Code + get_shortest_path_bellman_ford_impl(graph = NULL, from = 1, to = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_shortest_path_dijkstra_impl basic + + Code + get_shortest_path_dijkstra_impl(graph = g, from = 1, to = 3) + Output + $vertices + + 3/3 vertices: + [1] 1 2 3 + + $edges + + 2/2 edges: + [1] 1--2 2--3 + + +# get_shortest_path_dijkstra_impl errors + + Code + get_shortest_path_dijkstra_impl(graph = NULL, from = 1, to = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_all_shortest_paths_impl basic + + Code + get_all_shortest_paths_impl(graph = g, from = 1, to = 3) + Output + $vpaths + $vpaths[[1]] + + 3/3 vertices: + [1] 1 2 3 + + + $epaths + $epaths[[1]] + + 2/2 edges: + [1] 1--2 2--3 + + + $nrgeo + [1] 1 1 1 + + +# get_all_shortest_paths_impl errors + + Code + get_all_shortest_paths_impl(graph = NULL, from = 1, to = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_all_shortest_paths_dijkstra_impl basic + + Code + get_all_shortest_paths_dijkstra_impl(graph = g, from = 1, to = 3) + Output + $vpaths + $vpaths[[1]] + + 3/3 vertices: + [1] 1 2 3 + + + $epaths + $epaths[[1]] + + 2/2 edges: + [1] 1--2 2--3 + + + $nrgeo + [1] 1 1 1 + + +# get_all_shortest_paths_dijkstra_impl errors + + Code + get_all_shortest_paths_dijkstra_impl(graph = NULL, from = 1, to = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# voronoi_impl basic + + Code + voronoi_impl(graph = g, generators = 1) + Output + $membership + [1] 0 0 0 + + $distances + [1] 0 1 2 + + +--- + + Code + voronoi_impl(graph = g, generators = 1, mode = "in", tiebreaker = "first") + Output + $membership + [1] 0 0 0 + + $distances + [1] 0 1 2 + + +--- + + Code + voronoi_impl(graph = g, generators = c(1, 5), mode = c("out", "in", "all")) + Output + $membership + [1] 0 0 0 1 1 1 1 1 0 0 + + $distances + [1] 0 1 2 1 0 1 2 3 2 1 + + +# voronoi_impl errors + + Code + voronoi_impl(graph = NULL, generators = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_all_simple_paths_impl basic + + Code + get_all_simple_paths_impl(graph = g, from = 1, to = 3) + Output + + 3/3 vertices: + [1] 1 2 3 + +# get_all_simple_paths_impl errors + + Code + get_all_simple_paths_impl(graph = NULL, from = 1, to = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_k_shortest_paths_impl basic + + Code + get_k_shortest_paths_impl(graph = g, from = 1, to = 3, k = 2) + Output + $vpaths + $vpaths[[1]] + + 3/3 vertices: + [1] 1 2 3 + + + $epaths + $epaths[[1]] + + 2/2 edges: + [1] 1--2 2--3 + + + +# get_k_shortest_paths_impl errors + + Code + get_k_shortest_paths_impl(graph = NULL, from = 1, to = 3, k = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_widest_path_impl basic + + Code + get_widest_path_impl(graph = g, from = 1, to = 3, weights = c(1, 2)) + Output + $vertices + + 3/3 vertices: + [1] 1 2 3 + + $edges + + 2/2 edges: + [1] 1--2 2--3 + + +# get_widest_path_impl errors + + Code + get_widest_path_impl(graph = NULL, from = 1, to = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_widest_paths_impl basic + + Code + get_widest_paths_impl(graph = g, from = 1, to = 3, weights = c(1, 2)) + Output + $vertices + $vertices[[1]] + + 3/3 vertices: + [1] 1 2 3 + + + $edges + $edges[[1]] + + 2/2 edges: + [1] 1--2 2--3 + + + $parents + [1] -1 0 1 + + $inbound_edges + [1] -1 0 1 + + +# get_widest_paths_impl errors + + Code + get_widest_paths_impl(graph = NULL, from = 1, to = 3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# path_length_hist_impl basic + + Code + path_length_hist_impl(graph = g) + Output + $res + [1] 2 1 + + $unconnected + [1] 0 + + +--- + + Code + path_length_hist_impl(graph = g, directed = FALSE) + Output + $res + [1] 2 1 + + $unconnected + [1] 0 + + +# path_length_hist_impl errors + + Code + path_length_hist_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# eccentricity_dijkstra_impl basic + + Code + eccentricity_dijkstra_impl(graph = g) + Output + [1] 2 1 2 + +--- + + Code + eccentricity_dijkstra_impl(graph = g, mode = "in") + Output + [1] 2 1 2 + +# eccentricity_dijkstra_impl errors + + Code + eccentricity_dijkstra_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# graph_center_dijkstra_impl basic + + Code + graph_center_dijkstra_impl(graph = g) + Output + + 1/3 vertex: + [1] 2 + +--- + + Code + graph_center_dijkstra_impl(graph = g, mode = "in") + Output + + 1/3 vertex: + [1] 2 + +# graph_center_dijkstra_impl errors + + Code + graph_center_dijkstra_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# radius_dijkstra_impl basic + + Code + radius_dijkstra_impl(graph = g) + Output + [1] 1 + +--- + + Code + radius_dijkstra_impl(graph = g, mode = "in") + Output + [1] 1 + +# radius_dijkstra_impl errors + + Code + radius_dijkstra_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# pseudo_diameter_impl basic + + Code + pseudo_diameter_impl(graph = g, start_vid = 1) + Output + $diameter + [1] 2 + + $from + [1] 0 + + $to + [1] 2 + + +--- + + Code + pseudo_diameter_impl(graph = g, start_vid = 1, directed = FALSE, unconnected = FALSE) + Output + $diameter + [1] 2 + + $from + [1] 0 + + $to + [1] 2 + + +# pseudo_diameter_impl errors + + Code + pseudo_diameter_impl(graph = NULL, start_vid = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# pseudo_diameter_dijkstra_impl basic + + Code + pseudo_diameter_dijkstra_impl(graph = g, start_vid = 1) + Output + $diameter + [1] 2 + + $from + [1] 0 + + $to + [1] 2 + + +--- + + Code + pseudo_diameter_dijkstra_impl(graph = g, start_vid = 1, directed = FALSE, + unconnected = FALSE) + Output + $diameter + [1] 2 + + $from + [1] 0 + + $to + [1] 2 + + +# pseudo_diameter_dijkstra_impl errors + + Code + pseudo_diameter_dijkstra_impl(graph = NULL, start_vid = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# vertex_path_from_edge_path_impl basic + + Code + vertex_path_from_edge_path_impl(graph = g, start = 1, edge_path = c(1, 2)) + Output + + 3/3 vertices: + [1] 1 2 3 + +--- + + Code + vertex_path_from_edge_path_impl(graph = g, start = 1, edge_path = c(1), mode = "in") + Output + + 2/3 vertices: + [1] 1 2 + +# vertex_path_from_edge_path_impl errors + + Code + vertex_path_from_edge_path_impl(graph = NULL, start = 1, edge_path = c(1, 2)) + 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 + girth_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# distances_impl basic + + Code + distances_impl(graph = g, from = V(g), to = V(g), mode = c("out", "in", "all", + "total")) + Output + [,1] [,2] [,3] [,4] [,5] + [1,] 0 1 2 2 1 + [2,] 1 0 1 2 2 + [3,] 2 1 0 1 2 + [4,] 2 2 1 0 1 + [5,] 1 2 2 1 0 + +# diameter_impl basic + + Code + diameter_impl(graph = g, directed = FALSE, unconnected = TRUE) + Output + $res + [1] 5 + + $from + [1] 0 + + $to + [1] 5 + + $vertex_path + [1] 0 1 2 3 4 5 + + $edge_path + [1] 0 1 2 3 4 + + +# get_shortest_paths_impl basic + + Code + get_shortest_paths_impl(graph = g, from = 1, to = 3, mode = c("out", "in", + "all", "total")) + Output + $vertices + $vertices[[1]] + + 3/5 vertices: + [1] 1 2 3 + + + $edges + $edges[[1]] + + 2/5 edges: + [1] 1--2 2--3 + + + $parents + [1] -1 0 1 -2 0 + + $inbound_edges + [1] -1 0 1 -1 4 + + +# eccentricity_impl basic + + Code + eccentricity_impl(graph = g, vids = V(g), mode = c("out", "in", "all")) + Output + [1] 2 2 2 2 2 + +# radius_impl basic + + Code + radius_impl(graph = g, mode = c("out", "in", "all")) + Output + [1] 2 + +# graph_center_impl basic + + Code + graph_center_impl(graph = g, mode = c("out", "in", "all")) + Output + + 1/5 vertex: + [1] 1 + diff --git a/tests/testthat/_snaps/aaa-processes.md b/tests/testthat/_snaps/aaa-processes.md new file mode 100644 index 00000000000..e29531ae86e --- /dev/null +++ b/tests/testthat/_snaps/aaa-processes.md @@ -0,0 +1,1549 @@ +# sir_impl basic + + Code + sir_impl(graph = g, beta = 0.1, gamma = 0.1) + Output + [[1]] + [[1]]$times + [1] 0.000000 6.326537 8.018361 8.809852 9.405480 17.386752 + + [[1]]$NS + [1] 2 1 0 0 0 0 + + [[1]]$NI + [1] 1 2 3 2 1 0 + + [[1]]$NR + [1] 0 0 0 1 2 3 + + + [[2]] + [[2]]$times + [1] 0.000000 3.674354 13.783038 13.921168 + + [[2]]$NS + [1] 2 1 1 1 + + [[2]]$NI + [1] 1 2 1 0 + + [[2]]$NR + [1] 0 0 1 2 + + + [[3]] + [[3]]$times + [1] 0.000000 3.277542 7.521770 16.781182 18.515742 29.375613 + + [[3]]$NS + [1] 2 1 0 0 0 0 + + [[3]]$NI + [1] 1 2 3 2 1 0 + + [[3]]$NR + [1] 0 0 0 1 2 3 + + + [[4]] + [[4]]$times + [1] 0.0000000 0.3027921 + + [[4]]$NS + [1] 2 2 + + [[4]]$NI + [1] 1 0 + + [[4]]$NR + [1] 0 1 + + + [[5]] + [[5]]$times + [1] 0.000000 3.559451 5.615586 20.582742 + + [[5]]$NS + [1] 2 1 1 1 + + [[5]]$NI + [1] 1 2 1 0 + + [[5]]$NR + [1] 0 0 1 2 + + + [[6]] + [[6]]$times + [1] 0.0000000 0.7300885 0.7328203 1.2536518 1.9258569 5.1406208 + + [[6]]$NS + [1] 2 1 0 0 0 0 + + [[6]]$NI + [1] 1 2 3 2 1 0 + + [[6]]$NR + [1] 0 0 0 1 2 3 + + + [[7]] + [[7]]$times + [1] 0.000000 0.865533 + + [[7]]$NS + [1] 2 2 + + [[7]]$NI + [1] 1 0 + + [[7]]$NR + [1] 0 1 + + + [[8]] + [[8]]$times + [1] 0.00000 10.68605 + + [[8]]$NS + [1] 2 2 + + [[8]]$NI + [1] 1 0 + + [[8]]$NR + [1] 0 1 + + + [[9]] + [[9]]$times + [1] 0.000000 2.185910 7.669126 16.635095 21.440723 23.497554 + + [[9]]$NS + [1] 2 1 0 0 0 0 + + [[9]]$NI + [1] 1 2 3 2 1 0 + + [[9]]$NR + [1] 0 0 0 1 2 3 + + + [[10]] + [[10]]$times + [1] 0.000000 4.105424 4.424244 22.891743 24.099505 32.514828 + + [[10]]$NS + [1] 2 1 1 0 0 0 + + [[10]]$NI + [1] 1 2 1 2 1 0 + + [[10]]$NR + [1] 0 0 1 1 2 3 + + + [[11]] + [[11]]$times + [1] 0.00000 4.93042 21.00935 21.07441 23.37619 41.26694 + + [[11]]$NS + [1] 2 1 0 0 0 0 + + [[11]]$NI + [1] 1 2 3 2 1 0 + + [[11]]$NR + [1] 0 0 0 1 2 3 + + + [[12]] + [[12]]$times + [1] 0.00000 15.47343 26.09187 38.01744 43.76847 50.41068 + + [[12]]$NS + [1] 2 1 0 0 0 0 + + [[12]]$NI + [1] 1 2 3 2 1 0 + + [[12]]$NR + [1] 0 0 0 1 2 3 + + + [[13]] + [[13]]$times + [1] 0.000000 3.540437 + + [[13]]$NS + [1] 2 2 + + [[13]]$NI + [1] 1 0 + + [[13]]$NR + [1] 0 1 + + + [[14]] + [[14]]$times + [1] 0.000000 7.081426 7.638086 11.569527 + + [[14]]$NS + [1] 2 1 1 1 + + [[14]]$NI + [1] 1 2 1 0 + + [[14]]$NR + [1] 0 0 1 2 + + + [[15]] + [[15]]$times + [1] 0.00000 15.60443 15.66654 20.19745 22.11224 42.62196 + + [[15]]$NS + [1] 2 1 0 0 0 0 + + [[15]]$NI + [1] 1 2 3 2 1 0 + + [[15]]$NR + [1] 0 0 0 1 2 3 + + + [[16]] + [[16]]$times + [1] 0.000000 3.239708 17.193626 18.833130 19.040959 35.199892 + + [[16]]$NS + [1] 2 1 1 0 0 0 + + [[16]]$NI + [1] 1 2 1 2 1 0 + + [[16]]$NR + [1] 0 0 1 1 2 3 + + + [[17]] + [[17]]$times + [1] 0.0000000 0.2300489 1.8970602 6.9851496 16.0587095 28.8528567 + + [[17]]$NS + [1] 2 1 0 0 0 0 + + [[17]]$NI + [1] 1 2 3 2 1 0 + + [[17]]$NR + [1] 0 0 0 1 2 3 + + + [[18]] + [[18]]$times + [1] 0.000000 4.674879 5.319832 17.366640 63.357258 86.262883 + + [[18]]$NS + [1] 2 1 1 0 0 0 + + [[18]]$NI + [1] 1 2 1 2 1 0 + + [[18]]$NR + [1] 0 0 1 1 2 3 + + + [[19]] + [[19]]$times + [1] 0.000000 1.972293 + + [[19]]$NS + [1] 2 2 + + [[19]]$NI + [1] 1 0 + + [[19]]$NR + [1] 0 1 + + + [[20]] + [[20]]$times + [1] 0.000000 3.177922 + + [[20]]$NS + [1] 2 2 + + [[20]]$NI + [1] 1 0 + + [[20]]$NR + [1] 0 1 + + + [[21]] + [[21]]$times + [1] 0.000000 1.994279 2.508129 8.208209 28.478526 36.256169 + + [[21]]$NS + [1] 2 1 0 0 0 0 + + [[21]]$NI + [1] 1 2 3 2 1 0 + + [[21]]$NR + [1] 0 0 0 1 2 3 + + + [[22]] + [[22]]$times + [1] 0.000000 5.226609 14.744785 16.304309 + + [[22]]$NS + [1] 2 1 1 1 + + [[22]]$NI + [1] 1 2 1 0 + + [[22]]$NR + [1] 0 0 1 2 + + + [[23]] + [[23]]$times + [1] 0.000000 3.254634 13.673154 21.069828 + + [[23]]$NS + [1] 2 1 1 1 + + [[23]]$NI + [1] 1 2 1 0 + + [[23]]$NR + [1] 0 0 1 2 + + + [[24]] + [[24]]$times + [1] 0.00000 18.01982 18.36106 44.55144 + + [[24]]$NS + [1] 2 1 1 1 + + [[24]]$NI + [1] 1 2 1 0 + + [[24]]$NR + [1] 0 0 1 2 + + + [[25]] + [[25]]$times + [1] 0.00000 18.09036 30.47469 36.51570 + + [[25]]$NS + [1] 2 1 1 1 + + [[25]]$NI + [1] 1 2 1 0 + + [[25]]$NR + [1] 0 0 1 2 + + + [[26]] + [[26]]$times + [1] 0.00000 11.21296 + + [[26]]$NS + [1] 2 2 + + [[26]]$NI + [1] 1 0 + + [[26]]$NR + [1] 0 1 + + + [[27]] + [[27]]$times + [1] 0.000000 1.605373 + + [[27]]$NS + [1] 2 2 + + [[27]]$NI + [1] 1 0 + + [[27]]$NR + [1] 0 1 + + + [[28]] + [[28]]$times + [1] 0.000000 3.448751 12.086502 17.941228 + + [[28]]$NS + [1] 2 1 1 1 + + [[28]]$NI + [1] 1 2 1 0 + + [[28]]$NR + [1] 0 0 1 2 + + + [[29]] + [[29]]$times + [1] 0.000000 8.277924 + + [[29]]$NS + [1] 2 2 + + [[29]]$NI + [1] 1 0 + + [[29]]$NR + [1] 0 1 + + + [[30]] + [[30]]$times + [1] 0.000000 9.146159 + + [[30]]$NS + [1] 2 2 + + [[30]]$NI + [1] 1 0 + + [[30]]$NR + [1] 0 1 + + + [[31]] + [[31]]$times + [1] 0.00000000 0.07833588 + + [[31]]$NS + [1] 2 2 + + [[31]]$NI + [1] 1 0 + + [[31]]$NR + [1] 0 1 + + + [[32]] + [[32]]$times + [1] 0.000000 7.825191 + + [[32]]$NS + [1] 2 2 + + [[32]]$NI + [1] 1 0 + + [[32]]$NR + [1] 0 1 + + + [[33]] + [[33]]$times + [1] 0.0000000 0.4018017 + + [[33]]$NS + [1] 2 2 + + [[33]]$NI + [1] 1 0 + + [[33]]$NR + [1] 0 1 + + + [[34]] + [[34]]$times + [1] 0.000000 1.433794 + + [[34]]$NS + [1] 2 2 + + [[34]]$NI + [1] 1 0 + + [[34]]$NR + [1] 0 1 + + + [[35]] + [[35]]$times + [1] 0.00000000 0.06959151 2.61176819 2.76819228 + + [[35]]$NS + [1] 2 1 1 1 + + [[35]]$NI + [1] 1 2 1 0 + + [[35]]$NR + [1] 0 0 1 2 + + + [[36]] + [[36]]$times + [1] 0.000000 1.539839 17.502742 21.550799 31.779748 59.056912 + + [[36]]$NS + [1] 2 1 0 0 0 0 + + [[36]]$NI + [1] 1 2 3 2 1 0 + + [[36]]$NR + [1] 0 0 0 1 2 3 + + + [[37]] + [[37]]$times + [1] 0.000000 8.878624 + + [[37]]$NS + [1] 2 2 + + [[37]]$NI + [1] 1 0 + + [[37]]$NR + [1] 0 1 + + + [[38]] + [[38]]$times + [1] 0.000000 6.855525 + + [[38]]$NS + [1] 2 2 + + [[38]]$NI + [1] 1 0 + + [[38]]$NR + [1] 0 1 + + + [[39]] + [[39]]$times + [1] 0.000000 2.628739 3.809460 7.051204 + + [[39]]$NS + [1] 2 1 1 1 + + [[39]]$NI + [1] 1 2 1 0 + + [[39]]$NR + [1] 0 0 1 2 + + + [[40]] + [[40]]$times + [1] 0.000000 2.484282 + + [[40]]$NS + [1] 2 2 + + [[40]]$NI + [1] 1 0 + + [[40]]$NR + [1] 0 1 + + + [[41]] + [[41]]$times + [1] 0.0000000 0.8248393 + + [[41]]$NS + [1] 2 2 + + [[41]]$NI + [1] 1 0 + + [[41]]$NR + [1] 0 1 + + + [[42]] + [[42]]$times + [1] 0.000000 2.300359 3.886947 6.810196 7.223496 28.297207 + + [[42]]$NS + [1] 2 1 0 0 0 0 + + [[42]]$NI + [1] 1 2 3 2 1 0 + + [[42]]$NR + [1] 0 0 0 1 2 3 + + + [[43]] + [[43]]$times + [1] 0.00000 5.52241 10.93993 29.15486 + + [[43]]$NS + [1] 2 1 1 1 + + [[43]]$NI + [1] 1 2 1 0 + + [[43]]$NR + [1] 0 0 1 2 + + + [[44]] + [[44]]$times + [1] 0.000000 9.526317 12.154710 21.171748 + + [[44]]$NS + [1] 2 1 1 1 + + [[44]]$NI + [1] 1 2 1 0 + + [[44]]$NR + [1] 0 0 1 2 + + + [[45]] + [[45]]$times + [1] 0.000000 4.448428 + + [[45]]$NS + [1] 2 2 + + [[45]]$NI + [1] 1 0 + + [[45]]$NR + [1] 0 1 + + + [[46]] + [[46]]$times + [1] 0.0000000 0.0560511 + + [[46]]$NS + [1] 2 2 + + [[46]]$NI + [1] 1 0 + + [[46]]$NR + [1] 0 1 + + + [[47]] + [[47]]$times + [1] 0.00000 11.57560 12.20970 12.58732 26.47299 36.19628 + + [[47]]$NS + [1] 2 1 0 0 0 0 + + [[47]]$NI + [1] 1 2 3 2 1 0 + + [[47]]$NR + [1] 0 0 0 1 2 3 + + + [[48]] + [[48]]$times + [1] 0.000000 3.687231 + + [[48]]$NS + [1] 2 2 + + [[48]]$NI + [1] 1 0 + + [[48]]$NR + [1] 0 1 + + + [[49]] + [[49]]$times + [1] 0.0000000 0.3436458 1.0908931 1.4640857 + + [[49]]$NS + [1] 2 1 1 1 + + [[49]]$NI + [1] 1 2 1 0 + + [[49]]$NR + [1] 0 0 1 2 + + + [[50]] + [[50]]$times + [1] 0.000000 1.536136 + + [[50]]$NS + [1] 2 2 + + [[50]]$NI + [1] 1 0 + + [[50]]$NR + [1] 0 1 + + + [[51]] + [[51]]$times + [1] 0.000000 2.021208 + + [[51]]$NS + [1] 2 2 + + [[51]]$NI + [1] 1 0 + + [[51]]$NR + [1] 0 1 + + + [[52]] + [[52]]$times + [1] 0.00000 4.29424 + + [[52]]$NS + [1] 2 2 + + [[52]]$NI + [1] 1 0 + + [[52]]$NR + [1] 0 1 + + + [[53]] + [[53]]$times + [1] 0.000000 1.884908 5.139700 8.417338 12.272436 15.154107 + + [[53]]$NS + [1] 2 1 0 0 0 0 + + [[53]]$NI + [1] 1 2 3 2 1 0 + + [[53]]$NR + [1] 0 0 0 1 2 3 + + + [[54]] + [[54]]$times + [1] 0.0000000 0.1997796 + + [[54]]$NS + [1] 2 2 + + [[54]]$NI + [1] 1 0 + + [[54]]$NR + [1] 0 1 + + + [[55]] + [[55]]$times + [1] 0.0000000 0.1825065 + + [[55]]$NS + [1] 2 2 + + [[55]]$NI + [1] 1 0 + + [[55]]$NR + [1] 0 1 + + + [[56]] + [[56]]$times + [1] 0.000000 1.913698 2.656593 7.598135 + + [[56]]$NS + [1] 2 1 1 1 + + [[56]]$NI + [1] 1 2 1 0 + + [[56]]$NR + [1] 0 0 1 2 + + + [[57]] + [[57]]$times + [1] 0.000000 3.435708 + + [[57]]$NS + [1] 2 2 + + [[57]]$NI + [1] 1 0 + + [[57]]$NR + [1] 0 1 + + + [[58]] + [[58]]$times + [1] 0.000000 0.583133 5.284710 10.065112 18.657681 21.137430 + + [[58]]$NS + [1] 2 1 1 0 0 0 + + [[58]]$NI + [1] 1 2 1 2 1 0 + + [[58]]$NR + [1] 0 0 1 1 2 3 + + + [[59]] + [[59]]$times + [1] 0.000000 8.526031 + + [[59]]$NS + [1] 2 2 + + [[59]]$NI + [1] 1 0 + + [[59]]$NR + [1] 0 1 + + + [[60]] + [[60]]$times + [1] 0.000000 3.470768 + + [[60]]$NS + [1] 2 2 + + [[60]]$NI + [1] 1 0 + + [[60]]$NR + [1] 0 1 + + + [[61]] + [[61]]$times + [1] 0.000000 2.311806 + + [[61]]$NS + [1] 2 2 + + [[61]]$NI + [1] 1 0 + + [[61]]$NR + [1] 0 1 + + + [[62]] + [[62]]$times + [1] 0.000000 5.603495 + + [[62]]$NS + [1] 2 2 + + [[62]]$NI + [1] 1 0 + + [[62]]$NR + [1] 0 1 + + + [[63]] + [[63]]$times + [1] 0.0000000 0.2376974 + + [[63]]$NS + [1] 2 2 + + [[63]]$NI + [1] 1 0 + + [[63]]$NR + [1] 0 1 + + + [[64]] + [[64]]$times + [1] 0.000000 1.164209 4.169140 7.017509 + + [[64]]$NS + [1] 2 1 1 1 + + [[64]]$NI + [1] 1 2 1 0 + + [[64]]$NR + [1] 0 0 1 2 + + + [[65]] + [[65]]$times + [1] 0.000000 6.415227 6.561435 14.007083 + + [[65]]$NS + [1] 2 1 1 1 + + [[65]]$NI + [1] 1 2 1 0 + + [[65]]$NR + [1] 0 0 1 2 + + + [[66]] + [[66]]$times + [1] 0.00000 14.28491 31.69273 39.51170 + + [[66]]$NS + [1] 2 1 1 1 + + [[66]]$NI + [1] 1 2 1 0 + + [[66]]$NR + [1] 0 0 1 2 + + + [[67]] + [[67]]$times + [1] 0.000000 3.592755 4.363836 11.200455 + + [[67]]$NS + [1] 2 1 1 1 + + [[67]]$NI + [1] 1 2 1 0 + + [[67]]$NR + [1] 0 0 1 2 + + + [[68]] + [[68]]$times + [1] 0.000000 8.044133 10.227368 12.702160 16.225120 23.696870 + + [[68]]$NS + [1] 2 1 1 0 0 0 + + [[68]]$NI + [1] 1 2 1 2 1 0 + + [[68]]$NR + [1] 0 0 1 1 2 3 + + + [[69]] + [[69]]$times + [1] 0.000000 3.324148 + + [[69]]$NS + [1] 2 2 + + [[69]]$NI + [1] 1 0 + + [[69]]$NR + [1] 0 1 + + + [[70]] + [[70]]$times + [1] 0.000000 6.316816 + + [[70]]$NS + [1] 2 2 + + [[70]]$NI + [1] 1 0 + + [[70]]$NR + [1] 0 1 + + + [[71]] + [[71]]$times + [1] 0.000000 7.473339 7.757794 15.139281 + + [[71]]$NS + [1] 2 1 1 1 + + [[71]]$NI + [1] 1 2 1 0 + + [[71]]$NR + [1] 0 0 1 2 + + + [[72]] + [[72]]$times + [1] 0.000000 4.073649 6.034897 8.135670 + + [[72]]$NS + [1] 2 1 1 1 + + [[72]]$NI + [1] 1 2 1 0 + + [[72]]$NR + [1] 0 0 1 2 + + + [[73]] + [[73]]$times + [1] 0.00000 1.60059 + + [[73]]$NS + [1] 2 2 + + [[73]]$NI + [1] 1 0 + + [[73]]$NR + [1] 0 1 + + + [[74]] + [[74]]$times + [1] 0.000000 1.497596 + + [[74]]$NS + [1] 2 2 + + [[74]]$NI + [1] 1 0 + + [[74]]$NR + [1] 0 1 + + + [[75]] + [[75]]$times + [1] 0.000000 1.916758 + + [[75]]$NS + [1] 2 2 + + [[75]]$NI + [1] 1 0 + + [[75]]$NR + [1] 0 1 + + + [[76]] + [[76]]$times + [1] 0.0000000 0.8368377 4.1462512 14.4447646 + + [[76]]$NS + [1] 2 1 1 1 + + [[76]]$NI + [1] 1 2 1 0 + + [[76]]$NR + [1] 0 0 1 2 + + + [[77]] + [[77]]$times + [1] 0.000000 8.546053 9.275575 11.920068 14.117820 14.371987 + + [[77]]$NS + [1] 2 1 0 0 0 0 + + [[77]]$NI + [1] 1 2 3 2 1 0 + + [[77]]$NR + [1] 0 0 0 1 2 3 + + + [[78]] + [[78]]$times + [1] 0.000000 2.730273 6.669293 7.301694 14.402306 22.580301 + + [[78]]$NS + [1] 2 1 0 0 0 0 + + [[78]]$NI + [1] 1 2 3 2 1 0 + + [[78]]$NR + [1] 0 0 0 1 2 3 + + + [[79]] + [[79]]$times + [1] 0.00000 13.02458 + + [[79]]$NS + [1] 2 2 + + [[79]]$NI + [1] 1 0 + + [[79]]$NR + [1] 0 1 + + + [[80]] + [[80]]$times + [1] 0.000000 4.655717 10.847343 15.188912 38.570735 51.548959 + + [[80]]$NS + [1] 2 1 0 0 0 0 + + [[80]]$NI + [1] 1 2 3 2 1 0 + + [[80]]$NR + [1] 0 0 0 1 2 3 + + + [[81]] + [[81]]$times + [1] 0.000000 7.919139 12.774389 13.210280 20.037088 27.652380 + + [[81]]$NS + [1] 2 1 0 0 0 0 + + [[81]]$NI + [1] 1 2 3 2 1 0 + + [[81]]$NR + [1] 0 0 0 1 2 3 + + + [[82]] + [[82]]$times + [1] 0.000000 4.565727 4.640174 5.827227 8.181199 13.514984 + + [[82]]$NS + [1] 2 1 0 0 0 0 + + [[82]]$NI + [1] 1 2 3 2 1 0 + + [[82]]$NR + [1] 0 0 0 1 2 3 + + + [[83]] + [[83]]$times + [1] 0.0000000 0.4331829 + + [[83]]$NS + [1] 2 2 + + [[83]]$NI + [1] 1 0 + + [[83]]$NR + [1] 0 1 + + + [[84]] + [[84]]$times + [1] 0.0000000 0.5663187 + + [[84]]$NS + [1] 2 2 + + [[84]]$NI + [1] 1 0 + + [[84]]$NR + [1] 0 1 + + + [[85]] + [[85]]$times + [1] 0.000000 4.717821 7.368033 15.405952 20.251957 28.844191 + + [[85]]$NS + [1] 2 1 0 0 0 0 + + [[85]]$NI + [1] 1 2 3 2 1 0 + + [[85]]$NR + [1] 0 0 0 1 2 3 + + + [[86]] + [[86]]$times + [1] 0.00000 10.41346 13.17259 31.58865 35.49247 39.20284 + + [[86]]$NS + [1] 2 1 1 0 0 0 + + [[86]]$NI + [1] 1 2 1 2 1 0 + + [[86]]$NR + [1] 0 0 1 1 2 3 + + + [[87]] + [[87]]$times + [1] 0.000000 7.800903 + + [[87]]$NS + [1] 2 2 + + [[87]]$NI + [1] 1 0 + + [[87]]$NR + [1] 0 1 + + + [[88]] + [[88]]$times + [1] 0.000000 1.164975 2.214760 3.395779 4.269503 6.277390 + + [[88]]$NS + [1] 2 1 0 0 0 0 + + [[88]]$NI + [1] 1 2 3 2 1 0 + + [[88]]$NR + [1] 0 0 0 1 2 3 + + + [[89]] + [[89]]$times + [1] 0.000000 1.419246 5.241578 10.249121 + + [[89]]$NS + [1] 2 1 1 1 + + [[89]]$NI + [1] 1 2 1 0 + + [[89]]$NR + [1] 0 0 1 2 + + + [[90]] + [[90]]$times + [1] 0.000000 4.015171 + + [[90]]$NS + [1] 2 2 + + [[90]]$NI + [1] 1 0 + + [[90]]$NR + [1] 0 1 + + + [[91]] + [[91]]$times + [1] 0.00000 10.95119 10.95895 13.37237 15.94527 20.47069 + + [[91]]$NS + [1] 2 1 0 0 0 0 + + [[91]]$NI + [1] 1 2 3 2 1 0 + + [[91]]$NR + [1] 0 0 0 1 2 3 + + + [[92]] + [[92]]$times + [1] 0.000000 1.719506 + + [[92]]$NS + [1] 2 2 + + [[92]]$NI + [1] 1 0 + + [[92]]$NR + [1] 0 1 + + + [[93]] + [[93]]$times + [1] 0.00000 20.34997 23.10320 33.53507 37.61908 42.59392 + + [[93]]$NS + [1] 2 1 0 0 0 0 + + [[93]]$NI + [1] 1 2 3 2 1 0 + + [[93]]$NR + [1] 0 0 0 1 2 3 + + + [[94]] + [[94]]$times + [1] 0.000000 2.981562 4.220980 4.501876 5.930935 17.597979 + + [[94]]$NS + [1] 2 1 0 0 0 0 + + [[94]]$NI + [1] 1 2 3 2 1 0 + + [[94]]$NR + [1] 0 0 0 1 2 3 + + + [[95]] + [[95]]$times + [1] 0.0000000 0.8570038 6.2225289 7.4542303 + + [[95]]$NS + [1] 2 1 1 1 + + [[95]]$NI + [1] 1 2 1 0 + + [[95]]$NR + [1] 0 0 1 2 + + + [[96]] + [[96]]$times + [1] 0.00000 10.99346 + + [[96]]$NS + [1] 2 2 + + [[96]]$NI + [1] 1 0 + + [[96]]$NR + [1] 0 1 + + + [[97]] + [[97]]$times + [1] 0.000000 6.324172 10.943694 11.370294 + + [[97]]$NS + [1] 2 1 1 1 + + [[97]]$NI + [1] 1 2 1 0 + + [[97]]$NR + [1] 0 0 1 2 + + + [[98]] + [[98]]$times + [1] 0.00000000 0.07582625 1.04605163 3.19140611 3.57055288 9.94371399 + + [[98]]$NS + [1] 2 1 1 0 0 0 + + [[98]]$NI + [1] 1 2 1 2 1 0 + + [[98]]$NR + [1] 0 0 1 1 2 3 + + + [[99]] + [[99]]$times + [1] 0.000000 1.910419 + + [[99]]$NS + [1] 2 2 + + [[99]]$NI + [1] 1 0 + + [[99]]$NR + [1] 0 1 + + + [[100]] + [[100]]$times + [1] 0.000000 2.446835 + + [[100]]$NS + [1] 2 2 + + [[100]]$NI + [1] 1 0 + + [[100]]$NR + [1] 0 1 + + + attr(,"class") + [1] "sir" + +--- + + Code + sir_impl(graph = g, beta = 0.1, gamma = 0.1, no_sim = 2) + Output + [[1]] + [[1]]$times + [1] 0.0000000 0.5059133 5.9903814 8.4444363 + + [[1]]$NS + [1] 2 1 1 1 + + [[1]]$NI + [1] 1 2 1 0 + + [[1]]$NR + [1] 0 0 1 2 + + + [[2]] + [[2]]$times + [1] 0.000000 4.481524 + + [[2]]$NS + [1] 2 2 + + [[2]]$NI + [1] 1 0 + + [[2]]$NR + [1] 0 1 + + + attr(,"class") + [1] "sir" + +# sir_impl errors + + Code + sir_impl(graph = NULL, beta = 0.1, gamma = 0.1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# deterministic_optimal_imitation_impl basic + + Code + 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(graph = g, vid = 1, optimality = "minimum", + quantities = c(1, 2, 3), strategies = c(1, 2, 3), mode = "in") + Output + [1] 1 2 3 + +# deterministic_optimal_imitation_impl errors + + Code + deterministic_optimal_imitation_impl(graph = NULL, vid = 1, quantities = c(1, 2, + 3), strategies = c(1, 2, 3)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# moran_process_impl basic + + Code + 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 + + $strategies + [1] 1 3 3 + + +# moran_process_impl errors + + Code + moran_process_impl(graph = NULL, quantities = c(1, 2, 3), strategies = c(1, 2, + 3)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# roulette_wheel_imitation_impl basic + + Code + 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(graph = g, vid = 1, is_local = FALSE, quantities = c( + 1, 2, 3), strategies = c(1, 2, 3), mode = "in") + Output + [1] 3 2 3 + +# roulette_wheel_imitation_impl errors + + Code + roulette_wheel_imitation_impl(graph = NULL, vid = 1, is_local = TRUE, + quantities = c(1, 2, 3), strategies = c(1, 2, 3)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# stochastic_imitation_impl basic + + Code + 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(graph = g, vid = 1, algo = 2, quantities = c(1, 2, 3), + strategies = c(1, 2, 3), mode = "in") + Output + [1] 1 2 3 + +# stochastic_imitation_impl errors + + Code + stochastic_imitation_impl(graph = NULL, vid = 1, algo = 1, quantities = c(1, 2, + 3), strategies = c(1, 2, 3)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + diff --git a/tests/testthat/_snaps/aaa-separators.md b/tests/testthat/_snaps/aaa-separators.md new file mode 100644 index 00000000000..6ee3c83255d --- /dev/null +++ b/tests/testthat/_snaps/aaa-separators.md @@ -0,0 +1,88 @@ +# even_tarjan_reduction_impl basic + + Code + even_tarjan_reduction_impl(graph = g) + Output + $graphbar + IGRAPH D--- 6 7 -- + + edges: + [1] 1->4 2->5 3->6 5->1 4->2 6->2 5->3 + + $capacity + [1] 1 1 1 3 3 3 3 + + +# even_tarjan_reduction_impl errors + + Code + even_tarjan_reduction_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_separator_impl basic + + Code + is_separator_impl(graph = g, candidate = 1:2) + Output + [1] FALSE + +# is_separator_impl errors + + Code + is_separator_impl(graph = NULL, candidate = 1:2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_minimal_separator_impl basic + + Code + is_minimal_separator_impl(graph = g, candidate = 1:2) + Output + [1] FALSE + +# is_minimal_separator_impl errors + + Code + is_minimal_separator_impl(graph = NULL, candidate = 1:2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# all_minimal_st_separators_impl basic + + Code + all_minimal_st_separators_impl(graph = g) + Output + [[1]] + + 1/3 vertex: + [1] 2 + + +# all_minimal_st_separators_impl errors + + Code + all_minimal_st_separators_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# minimum_size_separators_impl basic + + Code + minimum_size_separators_impl(graph = g) + Output + [[1]] + + 1/3 vertex: + [1] 2 + + +# minimum_size_separators_impl errors + + Code + minimum_size_separators_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + diff --git a/tests/testthat/_snaps/aaa-spatial.md b/tests/testthat/_snaps/aaa-spatial.md new file mode 100644 index 00000000000..e44e0edf964 --- /dev/null +++ b/tests/testthat/_snaps/aaa-spatial.md @@ -0,0 +1,24 @@ +# convex_hull_2d_impl basic + + Code + convex_hull_2d_impl(data = matrix(1:6, ncol = 2)) + Output + $resverts + [1] 1 3 + + $rescoords + [,1] [,2] + [1,] 1 4 + [2,] 3 6 + + +# convex_hull_2d_impl errors + + Code + convex_hull_2d_impl(data = "a") + Condition + Warning in `convex_hull_2d_impl()`: + NAs introduced by coercion + Error in `convex_hull_2d_impl()`: + ! REAL() can only be applied to a 'numeric', not a 'character' + diff --git a/tests/testthat/_snaps/aaa-structural.md b/tests/testthat/_snaps/aaa-structural.md new file mode 100644 index 00000000000..d168449726d --- /dev/null +++ b/tests/testthat/_snaps/aaa-structural.md @@ -0,0 +1,1922 @@ +# are_adjacent_impl basic + + Code + are_adjacent_impl(graph = g, v1 = 1, v2 = 2) + Output + [1] TRUE + +# are_adjacent_impl errors + + Code + are_adjacent_impl(graph = NULL, v1 = 1, v2 = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# spanner_impl basic + + Code + spanner_impl(graph = g, stretch = 2) + Output + + 2/2 edges: + [1] 1--2 2--3 + +--- + + Code + spanner_impl(graph = g, stretch = 2) + Output + + 5/5 edges: + [1] 1--2 2--3 3--4 4--5 1--5 + +# spanner_impl errors + + Code + spanner_impl(graph = NULL, stretch = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# transitivity_undirected_impl basic + + Code + transitivity_undirected_impl(graph = g) + Output + [1] 0 + +--- + + Code + transitivity_undirected_impl(graph = g, mode = "zero") + Output + [1] 0 + +# transitivity_undirected_impl errors + + Code + transitivity_undirected_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# transitivity_local_undirected_impl basic + + Code + transitivity_local_undirected_impl(graph = g) + Output + [1] NaN 0 NaN + +--- + + Code + transitivity_local_undirected_impl(graph = g, mode = "zero") + Output + [1] 0 0 0 + +# transitivity_local_undirected_impl errors + + Code + transitivity_local_undirected_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# transitivity_avglocal_undirected_impl basic + + Code + transitivity_avglocal_undirected_impl(graph = g) + Output + [1] 0 + +--- + + Code + transitivity_avglocal_undirected_impl(graph = g, mode = "zero") + Output + [1] 0 + +# transitivity_avglocal_undirected_impl errors + + Code + transitivity_avglocal_undirected_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# transitivity_barrat_impl basic + + Code + transitivity_barrat_impl(graph = g) + Condition + Warning in `transitivity_barrat_impl()`: + No weights given for Barrat's transitivity, unweighted version is used. + Source: properties/triangles.c:913 + Output + [1] NaN 0 NaN + +--- + + Code + transitivity_barrat_impl(graph = g, mode = "zero") + Condition + Warning in `transitivity_barrat_impl()`: + No weights given for Barrat's transitivity, unweighted version is used. + Source: properties/triangles.c:913 + Output + [1] 0 0 0 + +# transitivity_barrat_impl errors + + Code + transitivity_barrat_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# ecc_impl basic + + Code + ecc_impl(graph = g) + Output + [1] NaN 0 NaN + +--- + + Code + ecc_impl(graph = g, k = 3, offset = TRUE, normalize = FALSE) + Output + [1] 1 1 1 + +# ecc_impl errors + + Code + ecc_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# reciprocity_impl basic + + Code + reciprocity_impl(graph = g) + Output + [1] 1 + +--- + + Code + reciprocity_impl(graph = g, ignore_loops = FALSE, mode = "ratio") + Output + [1] 1 + +# reciprocity_impl errors + + Code + reciprocity_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# density_impl basic + + Code + density_impl(graph = g) + Output + [1] 0.6666667 + +--- + + Code + density_impl(graph = g, loops = TRUE) + Output + [1] 0.3333333 + +# density_impl errors + + Code + density_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# mean_degree_impl basic + + Code + mean_degree_impl(graph = g) + Output + [1] 1.333333 + +--- + + Code + mean_degree_impl(graph = g, loops = FALSE) + Output + [1] 1.333333 + +# mean_degree_impl errors + + Code + mean_degree_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_loop_impl basic + + Code + is_loop_impl(graph = g) + Output + [1] FALSE FALSE + +# is_loop_impl errors + + Code + is_loop_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_simple_impl basic + + Code + is_simple_impl(graph = g) + Output + [1] TRUE + +# is_simple_impl errors + + Code + is_simple_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_multiple_impl basic + + Code + is_multiple_impl(graph = g) + Output + [1] FALSE FALSE + +# is_multiple_impl errors + + Code + is_multiple_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# has_loop_impl basic + + Code + has_loop_impl(graph = g) + Output + [1] FALSE + +# has_loop_impl errors + + Code + has_loop_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# has_multiple_impl basic + + Code + has_multiple_impl(graph = g) + Output + [1] FALSE + +# has_multiple_impl errors + + Code + has_multiple_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# count_loops_impl basic + + Code + count_loops_impl(graph = g) + Output + [1] 0 + +# count_loops_impl errors + + Code + count_loops_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# count_multiple_impl basic + + Code + count_multiple_impl(graph = g) + Output + [1] 1 1 + +# count_multiple_impl errors + + Code + count_multiple_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_mutual_impl basic + + Code + is_mutual_impl(graph = g) + Output + [1] TRUE TRUE + +--- + + Code + is_mutual_impl(graph = g, loops = FALSE) + Output + [1] TRUE TRUE + +# is_mutual_impl errors + + Code + is_mutual_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# has_mutual_impl basic + + Code + has_mutual_impl(graph = g) + Output + [1] TRUE + +--- + + Code + has_mutual_impl(graph = g, loops = FALSE) + Output + [1] TRUE + +# has_mutual_impl errors + + Code + has_mutual_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# maximum_cardinality_search_impl basic + + Code + maximum_cardinality_search_impl(graph = g) + Output + $alpha + [1] 3 2 1 + + $alpham1 + + 3/3 vertices: + [1] 3 2 1 + + +# maximum_cardinality_search_impl errors + + Code + maximum_cardinality_search_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# avg_nearest_neighbor_degree_impl basic + + Code + avg_nearest_neighbor_degree_impl(graph = g) + Output + $knn + [1] 2 1 2 + + $knnk + [1] 2 1 + + +--- + + Code + avg_nearest_neighbor_degree_impl(graph = g, mode = "in", neighbor_degree_mode = "out") + Output + $knn + [1] 2 1 2 + + $knnk + [1] 2 1 + + +# avg_nearest_neighbor_degree_impl errors + + Code + avg_nearest_neighbor_degree_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# degree_correlation_vector_impl basic + + Code + degree_correlation_vector_impl(graph = g) + Output + [1] NaN 2 1 + +--- + + Code + degree_correlation_vector_impl(graph = g, from_mode = "in", to_mode = "out", + directed_neighbors = FALSE) + Output + [1] NaN 2 1 + +# degree_correlation_vector_impl errors + + Code + degree_correlation_vector_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# rich_club_sequence_impl basic + + Code + rich_club_sequence_impl(graph = g, vertex_order = 1:3) + Output + [1] 0.6666667 1.0000000 NaN + +--- + + Code + rich_club_sequence_impl(graph = g, vertex_order = 1:3, normalized = FALSE, + loops = TRUE, directed = FALSE) + Output + [1] 2 1 0 + +# rich_club_sequence_impl errors + + Code + rich_club_sequence_impl(graph = NULL, vertex_order = 1:3) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# assortativity_nominal_impl basic + + Code + assortativity_nominal_impl(graph = g, types = c(1, 2, 1)) + Output + [1] -1 + +--- + + Code + assortativity_nominal_impl(graph = g, types = c(1, 2, 1), directed = FALSE, + normalized = FALSE) + Output + [1] -0.5 + +# assortativity_nominal_impl errors + + Code + assortativity_nominal_impl(graph = NULL, types = c(1, 2, 1)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# assortativity_impl basic + + Code + assortativity_impl(graph = g, values = c(1, 2, 1)) + Output + [1] -1 + +--- + + Code + assortativity_impl(graph = g, values = c(1, 2, 1), directed = FALSE, + normalized = FALSE) + Output + [1] -0.25 + +# assortativity_impl errors + + Code + assortativity_impl(graph = NULL, values = c(1, 2, 1)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# assortativity_degree_impl basic + + Code + assortativity_degree_impl(graph = g) + Output + [1] -1 + +--- + + Code + assortativity_degree_impl(graph = g, directed = FALSE) + Output + [1] -1 + +# assortativity_degree_impl errors + + Code + assortativity_degree_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# joint_degree_matrix_impl basic + + Code + joint_degree_matrix_impl(graph = g) + Output + [,1] [,2] + [1,] 0 2 + [2,] 2 0 + +--- + + Code + joint_degree_matrix_impl(graph = g, max_out_degree = 2, max_in_degree = 2) + Output + [,1] [,2] + [1,] 0 2 + [2,] 2 0 + +# joint_degree_matrix_impl errors + + Code + joint_degree_matrix_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# joint_degree_distribution_impl basic + + Code + joint_degree_distribution_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] 0 0.0 0.0 + [2,] 0 0.0 0.5 + [3,] 0 0.5 0.0 + +--- + + Code + 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 + [,1] [,2] [,3] + [1,] 0 0 0 + [2,] 0 0 2 + [3,] 0 2 0 + +# joint_degree_distribution_impl errors + + Code + joint_degree_distribution_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# joint_type_distribution_impl basic + + Code + joint_type_distribution_impl(graph = g, from_types = c(1, 2, 1)) + Output + [,1] [,2] + [1,] 0.0 0.5 + [2,] 0.5 0.0 + +--- + + Code + 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 + [2,] 2 0 + +# joint_type_distribution_impl errors + + Code + joint_type_distribution_impl(graph = NULL, from_types = c(1, 2, 1)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# diversity_impl basic + + Code + diversity_impl(graph = g) + Output + [1] 0.0000000 0.9182958 0.0000000 + +# diversity_impl errors + + Code + diversity_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# global_efficiency_impl basic + + Code + global_efficiency_impl(graph = g) + Output + [1] 0.8333333 + +--- + + Code + global_efficiency_impl(graph = g, directed = FALSE) + Output + [1] 0.8333333 + +# global_efficiency_impl errors + + Code + global_efficiency_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# local_efficiency_impl basic + + Code + local_efficiency_impl(graph = g) + Output + [1] 0 0 0 + +--- + + Code + local_efficiency_impl(graph = g, directed = FALSE, mode = "in") + Output + [1] 0 0 0 + +# local_efficiency_impl errors + + Code + local_efficiency_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# average_local_efficiency_impl basic + + Code + average_local_efficiency_impl(graph = g) + Output + [1] 0 + +--- + + Code + average_local_efficiency_impl(graph = g, directed = FALSE, mode = "in") + Output + [1] 0 + +# average_local_efficiency_impl errors + + Code + average_local_efficiency_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# trussness_impl basic + + Code + trussness_impl(graph = g) + Output + [1] 2 2 + +# trussness_impl errors + + Code + trussness_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_graphical_impl basic + + Code + is_graphical_impl(out_deg = c(2, 2, 2)) + Output + [1] TRUE + +--- + + Code + is_graphical_impl(out_deg = c(2, 2, 2), in_deg = c(1, 1, 1), + allowed_edge_types = "all") + Output + [1] FALSE + +# is_graphical_impl errors + + Code + is_graphical_impl(out_deg = "a") + Condition + Warning in `is_graphical_impl()`: + NAs introduced by coercion + Error in `is_graphical_impl()`: + ! The value nan is not representable as an integer. Invalid value + Source: : + +# get_laplacian_impl basic + + Code + get_laplacian_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] 1 -1 0 + [2,] -1 2 -1 + [3,] 0 -1 1 + +--- + + Code + get_laplacian_impl(graph = g, mode = "in", normalization = "symmetric", + weights = c(1, 2)) + Output + [,1] [,2] [,3] + [1,] 1.0000000 -0.5773503 0.0000000 + [2,] -0.5773503 1.0000000 -0.8164966 + [3,] 0.0000000 -0.8164966 1.0000000 + +# get_laplacian_impl errors + + Code + get_laplacian_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_laplacian_sparse_impl basic + + Code + get_laplacian_sparse_impl(graph = g) + Output + $type + [1] "triplet" + + $dim + [1] 3 3 + + $p + [1] 0 1 2 0 1 1 2 + + $i + [1] 0 1 2 1 0 2 1 + + $x + [1] 1 2 1 -1 -1 -1 -1 + + attr(,"class") + [1] "igraph.tmp.sparse" + +--- + + Code + get_laplacian_sparse_impl(graph = g, mode = "in", normalization = "symmetric", + weights = c(1, 2)) + Output + $type + [1] "triplet" + + $dim + [1] 3 3 + + $p + [1] 0 1 2 0 1 1 2 + + $i + [1] 0 1 2 1 0 2 1 + + $x + [1] 1.0000000 1.0000000 1.0000000 -0.5773503 -0.5773503 -0.8164966 -0.8164966 + + attr(,"class") + [1] "igraph.tmp.sparse" + +# get_laplacian_sparse_impl errors + + Code + get_laplacian_sparse_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# connected_components_impl basic + + Code + connected_components_impl(graph = g) + Output + [1] 0 0 0 + +--- + + Code + connected_components_impl(graph = g, mode = "strong", details = TRUE) + Output + $membership + [1] 0 0 0 + + $csize + [1] 3 + + $no + [1] 1 + + +# connected_components_impl errors + + Code + connected_components_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_connected_impl basic + + Code + is_connected_impl(graph = g) + Output + [1] TRUE + +--- + + Code + is_connected_impl(graph = g, mode = "strong") + Output + [1] TRUE + +# is_connected_impl errors + + Code + is_connected_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# articulation_points_impl basic + + Code + articulation_points_impl(graph = g) + Output + + 1/3 vertex: + [1] 2 + +# articulation_points_impl errors + + Code + articulation_points_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# biconnected_components_impl basic + + Code + biconnected_components_impl(graph = g) + Output + $no + [1] 2 + + $tree_edges + $tree_edges[[1]] + + 1/2 edge: + [1] 2--3 + + $tree_edges[[2]] + + 1/2 edge: + [1] 1--2 + + + $component_edges + $component_edges[[1]] + + 1/2 edge: + [1] 2--3 + + $component_edges[[2]] + + 1/2 edge: + [1] 1--2 + + + $components + $components[[1]] + + 2/3 vertices: + [1] 3 2 + + $components[[2]] + + 2/3 vertices: + [1] 2 1 + + + $articulation_points + + 1/3 vertex: + [1] 2 + + +# biconnected_components_impl errors + + Code + biconnected_components_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# bridges_impl basic + + Code + bridges_impl(graph = g) + Output + + 2/2 edges: + [1] 2--3 1--2 + +# bridges_impl errors + + Code + bridges_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_biconnected_impl basic + + Code + is_biconnected_impl(graph = g) + Output + [1] FALSE + +# is_biconnected_impl errors + + Code + is_biconnected_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# count_reachable_impl basic + + Code + count_reachable_impl(graph = g, mode = "out") + Output + [1] 5 5 5 5 5 + +--- + + Code + count_reachable_impl(graph = g, mode = "in") + Output + [1] 5 5 5 5 5 + +# count_reachable_impl errors + + Code + count_reachable_impl(graph = NULL, mode = "out") + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# bond_percolation_impl basic + + Code + bond_percolation_impl(graph = g) + Output + $giant_size + numeric(0) + + $vetex_count + numeric(0) + + +# bond_percolation_impl errors + + Code + bond_percolation_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# site_percolation_impl basic + + Code + site_percolation_impl(graph = g) + Output + $giant_size + [1] 1 2 3 + + $edge_count + [1] 0 1 2 + + +# site_percolation_impl errors + + Code + site_percolation_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# edgelist_percolation_impl basic + + Code + edgelist_percolation_impl(edges = matrix(c(1, 2, 2, 3), ncol = 2)) + Output + $giant_size + [1] 2 3 + + $vertex_count + [1] 2 3 + + +# edgelist_percolation_impl errors + + Code + edgelist_percolation_impl(edges = "a") + Condition + Error in `edges - 1`: + ! non-numeric argument to binary operator + +# similarity_dice_impl basic + + Code + similarity_dice_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] 1 0 1 + [2,] 0 1 0 + [3,] 1 0 1 + +--- + + Code + similarity_dice_impl(graph = g, vids = 1:2, mode = "in", loops = TRUE) + Output + [,1] [,2] + [1,] 1.0 0.8 + [2,] 0.8 1.0 + +# similarity_dice_impl errors + + Code + similarity_dice_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# similarity_dice_es_impl basic + + Code + similarity_dice_es_impl(graph = g) + Output + [1] 0 0 + +--- + + Code + similarity_dice_es_impl(graph = g, es = 1:2, mode = "in", loops = TRUE) + Output + [1] 0.8 0.8 + +# similarity_dice_es_impl errors + + Code + similarity_dice_es_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# similarity_dice_pairs_impl basic + + Code + similarity_dice_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) + Output + [1] 0 0 + +--- + + Code + similarity_dice_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2), + mode = "in", loops = TRUE) + Output + [1] 0.8000000 0.6666667 + +# similarity_dice_pairs_impl errors + + Code + similarity_dice_pairs_impl(graph = NULL, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# similarity_inverse_log_weighted_impl basic + + Code + similarity_inverse_log_weighted_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] 0.000000 0 1.442695 + [2,] 0.000000 0 0.000000 + [3,] 1.442695 0 0.000000 + +--- + + Code + similarity_inverse_log_weighted_impl(graph = g, vids = 1:2, mode = "in") + Output + [,1] [,2] [,3] + [1,] 0 0 1.442695 + [2,] 0 0 0.000000 + +# similarity_inverse_log_weighted_impl errors + + Code + similarity_inverse_log_weighted_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# similarity_jaccard_impl basic + + Code + similarity_jaccard_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] 1 0 1 + [2,] 0 1 0 + [3,] 1 0 1 + +--- + + Code + similarity_jaccard_impl(graph = g, vids = 1:2, mode = "in", loops = TRUE) + Output + [,1] [,2] + [1,] 1.0000000 0.6666667 + [2,] 0.6666667 1.0000000 + +# similarity_jaccard_impl errors + + Code + similarity_jaccard_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# similarity_jaccard_es_impl basic + + Code + similarity_jaccard_es_impl(graph = g) + Output + [1] 0 0 + +--- + + Code + similarity_jaccard_es_impl(graph = g, es = 1:2, mode = "in", loops = TRUE) + Output + [1] 0.6666667 0.6666667 + +# similarity_jaccard_es_impl errors + + Code + similarity_jaccard_es_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# similarity_jaccard_pairs_impl basic + + Code + similarity_jaccard_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) + Output + [1] 0 0 + +--- + + Code + similarity_jaccard_pairs_impl(graph = g, pairs = matrix(c(1, 2, 2, 3), ncol = 2), + mode = "in", loops = TRUE) + Output + [1] 0.6666667 0.5000000 + +# similarity_jaccard_pairs_impl errors + + Code + similarity_jaccard_pairs_impl(graph = NULL, pairs = matrix(c(1, 2, 2, 3), ncol = 2)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_adjacency_sparse_impl basic + + Code + get_adjacency_sparse_impl(graph = g) + Output + $type + [1] "triplet" + + $dim + [1] 3 3 + + $p + [1] 0 1 1 2 + + $i + [1] 1 0 2 1 + + $x + [1] 1 1 1 1 + + attr(,"class") + [1] "igraph.tmp.sparse" + +--- + + Code + get_adjacency_sparse_impl(graph = g, type = "upper", weights = c(1, 2), loops = "none") + Output + $type + [1] "triplet" + + $dim + [1] 3 3 + + $p + [1] 1 2 + + $i + [1] 0 1 + + $x + [1] 1 2 + + attr(,"class") + [1] "igraph.tmp.sparse" + +# get_adjacency_sparse_impl errors + + Code + get_adjacency_sparse_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_stochastic_impl basic + + Code + get_stochastic_impl(graph = g) + Output + [,1] [,2] [,3] + [1,] 0.0 1 0.0 + [2,] 0.5 0 0.5 + [3,] 0.0 1 0.0 + +--- + + Code + get_stochastic_impl(graph = g, column_wise = TRUE, weights = c(1, 2)) + Output + [,1] [,2] [,3] + [1,] 0 0.3333333 0 + [2,] 1 0.0000000 1 + [3,] 0 0.6666667 0 + +# get_stochastic_impl errors + + Code + get_stochastic_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# get_stochastic_sparse_impl basic + + Code + get_stochastic_sparse_impl(graph = g) + Output + $type + [1] "triplet" + + $dim + [1] 3 3 + + $p + [1] 0 1 1 2 + + $i + [1] 1 0 2 1 + + $x + [1] 0.5 1.0 1.0 0.5 + + attr(,"class") + [1] "igraph.tmp.sparse" + +--- + + Code + get_stochastic_sparse_impl(graph = g, column_wise = TRUE, weights = c(1, 2)) + Output + $type + [1] "triplet" + + $dim + [1] 3 3 + + $p + [1] 0 1 1 2 + + $i + [1] 1 0 2 1 + + $x + [1] 1.0000000 0.3333333 0.6666667 1.0000000 + + attr(,"class") + [1] "igraph.tmp.sparse" + +# get_stochastic_sparse_impl errors + + Code + get_stochastic_sparse_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# to_directed_impl basic + + Code + to_directed_impl(graph = g) + Output + IGRAPH D--- 3 4 -- + + edges: + [1] 1->2 2->3 2->1 3->2 + +--- + + Code + to_directed_impl(graph = g, mode = "acyclic") + Output + IGRAPH D--- 3 2 -- + + edges: + [1] 1->2 2->3 + +# to_directed_impl errors + + Code + to_directed_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# to_undirected_impl basic + + Code + to_undirected_impl(graph = g) + Output + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + +--- + + Code + to_undirected_impl(graph = g, mode = "mutual", edge_attr_comb = "sum") + Output + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + +# to_undirected_impl errors + + Code + to_undirected_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# local_scan_0_impl basic + + Code + local_scan_0_impl(graph = g) + Output + [1] 1 2 1 + +--- + + Code + local_scan_0_impl(graph = g, weights = c(1, 2), mode = "in") + Output + [1] 1 3 2 + +# local_scan_0_impl errors + + Code + local_scan_0_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# local_scan_0_them_impl basic + + Code + local_scan_0_them_impl(us = g1, them = g2) + Output + [1] 1 2 1 + +--- + + Code + local_scan_0_them_impl(us = g1, them = g2, weights_them = c(1, 2), mode = "in") + Output + [1] 1 3 2 + +# local_scan_0_them_impl errors + + Code + local_scan_0_them_impl(us = NULL, them = them) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# local_scan_1_ecount_impl basic + + Code + local_scan_1_ecount_impl(graph = g) + Output + [1] 1 2 1 + +--- + + Code + local_scan_1_ecount_impl(graph = g, weights = c(1, 2), mode = "in") + Output + [1] 1 3 2 + +# local_scan_1_ecount_impl errors + + Code + local_scan_1_ecount_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# local_scan_1_ecount_them_impl basic + + Code + local_scan_1_ecount_them_impl(us = g1, them = g2) + Output + [1] 1 2 1 + +--- + + Code + local_scan_1_ecount_them_impl(us = g1, them = g2, weights_them = c(1, 2), mode = "in") + Output + [1] 1 3 2 + +# local_scan_1_ecount_them_impl errors + + Code + local_scan_1_ecount_them_impl(us = NULL, them = them) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# local_scan_k_ecount_impl basic + + Code + local_scan_k_ecount_impl(graph = g, k = 1) + Output + [1] 1 2 1 + +--- + + Code + local_scan_k_ecount_impl(graph = g, k = 1, weights = c(1, 2), mode = "in") + Output + [1] 1 3 2 + +# local_scan_k_ecount_impl errors + + Code + local_scan_k_ecount_impl(graph = NULL, k = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# local_scan_k_ecount_them_impl basic + + Code + local_scan_k_ecount_them_impl(us = g1, them = g2, k = 1) + Output + [1] 1 2 1 + +--- + + Code + local_scan_k_ecount_them_impl(us = g1, them = g2, k = 1, weights_them = c(1, 2), + mode = "in") + Output + [1] 1 3 2 + +# local_scan_k_ecount_them_impl errors + + Code + local_scan_k_ecount_them_impl(us = NULL, them = them, k = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# local_scan_neighborhood_ecount_impl basic + + Code + 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(graph = g, weights = c(1, 2, 3), + neighborhoods = list(1:2, 1:3, 2:4, 1)) + Output + [1] 1 3 5 0 + +# local_scan_neighborhood_ecount_impl errors + + Code + local_scan_neighborhood_ecount_impl(graph = NULL, neighborhoods = list(1:2, 2:3)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# local_scan_subset_ecount_impl basic + + Code + 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(graph = g, weights = c(1, 2, 3), subsets = list(c( + 1, 2), c(2, 3))) + Output + [1] 1 2 + +# local_scan_subset_ecount_impl errors + + Code + local_scan_subset_ecount_impl(graph = g, subsets = list(1:2, letters[2:3])) + Condition + Error in `.x - 1`: + ! non-numeric argument to binary operator + +# is_matching_impl basic + + Code + is_matching_impl(graph = g, matching = 1:2) + Output + [1] FALSE + +--- + + Code + is_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE), matching = 1:2) + Output + [1] FALSE + +# is_matching_impl errors + + Code + is_matching_impl(graph = NULL, matching = 1:2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_maximal_matching_impl basic + + Code + is_maximal_matching_impl(graph = g, matching = 1:2) + Output + [1] FALSE + +--- + + Code + is_maximal_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE), matching = 1: + 2) + Output + [1] FALSE + +# is_maximal_matching_impl errors + + Code + is_maximal_matching_impl(graph = NULL, matching = 1:2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# maximum_bipartite_matching_impl basic + + Code + maximum_bipartite_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE)) + Output + $matching_size + [1] 1 + + $matching_weight + [1] 1 + + $matching + [1] 2 1 0 + + +--- + + Code + maximum_bipartite_matching_impl(graph = g, types = c(TRUE, FALSE, TRUE), + weights = c(1, 2), eps = 1e-05) + Output + $matching_size + [1] 1 + + $matching_weight + [1] 2 + + $matching + [1] 0 3 2 + + +# maximum_bipartite_matching_impl errors + + Code + maximum_bipartite_matching_impl(graph = NULL, types = c(TRUE, FALSE, TRUE)) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# eigen_adjacency_impl basic + + Code + eigen_adjacency_impl(graph = g) + Output + $options + $options$bmat + [1] "I" + + $options$n + [1] 3 + + $options$which + [1] "LM" + + $options$nev + [1] 1 + + $options$tol + [1] 0 + + $options$ncv + [1] 2 + + $options$ldv + [1] 0 + + $options$ishift + [1] 1 + + $options$maxiter + [1] 3000 + + $options$nb + [1] 1 + + $options$mode + [1] 1 + + $options$start + [1] 0 + + $options$sigma + [1] 0 + + $options$sigmai + [1] 0 + + $options$info + [1] 0 + + $options$iter + [1] 29 + + $options$nconv + [1] 1 + + $options$numop + [1] 30 + + $options$numopb + [1] 0 + + $options$numreo + [1] 16 + + + $values + [1] -1.414214 + + $vectors + [,1] + [1,] -0.5000000 + [2,] 0.7071068 + [3,] -0.5000000 + + $cmplxvalues + complex(0) + + $cmplxvectors + <0 x 0 matrix> + + +--- + + Code + eigen_adjacency_impl(graph = g, algorithm = "lapack", which = list(which = "LA"), + options = list(maxiter = 10)) + Condition + Error in `eigen_adjacency_impl()`: + ! 'LAPACK' algorithm not implemented yet. Unimplemented function call + Source: : + +# eigen_adjacency_impl errors + + Code + eigen_adjacency_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# cocitation_impl errors + + Code + cocitation_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# bibcoupling_impl errors + + Code + bibcoupling_impl(graph = NULL) + 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 + coreness_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# subcomponent_impl basic + + Code + subcomponent_impl(graph = g, v = 1, mode = c("all", "out", "in")) + Output + + 3/6 vertices, named: + [1] A B C + +# decompose_impl basic + + Code + decompose_impl(graph = g, mode = c("weak", "strong")) + Output + [[1]] + IGRAPH UN-- 3 2 -- + + attr: name (v/c) + + edges (vertex names): + [1] A--B B--C + + [[2]] + IGRAPH UN-- 2 1 -- + + attr: name (v/c) + + edge (vertex names): + [1] D--E + + +# neighborhood_impl basic + + Code + neighborhood_impl(graph = g, order = 1, vids = V(g), mode = c("all", "out", + "in")) + Output + [[1]] + + 3/5 vertices: + [1] 1 2 5 + + [[2]] + + 3/5 vertices: + [1] 2 1 3 + + [[3]] + + 3/5 vertices: + [1] 3 2 4 + + [[4]] + + 3/5 vertices: + [1] 4 3 5 + + [[5]] + + 3/5 vertices: + [1] 5 1 4 + + +# neighborhood_size_impl basic + + Code + neighborhood_size_impl(graph = g, order = 1, vids = V(g), mode = c("all", "out", + "in")) + Output + [1] 3 3 3 3 3 + +# is_chordal_impl basic + + Code + is_chordal_impl(graph = g, alpha = alpha_vec, alpham1 = alpham1_vec) + Output + $chordal + [1] TRUE + + $fillin + numeric(0) + + $newgraph + IGRAPH U--- 4 6 -- Full graph + + attr: name (g/c), loops (g/l) + + edges: + [1] 1--2 1--3 1--4 2--3 2--4 3--4 + + +--- + + Code + is_chordal_impl(graph = g2, alpha = alpha_vec2, alpham1 = alpham1_vec2) + Output + $chordal + [1] FALSE + + $fillin + [1] 1 3 + + $newgraph + IGRAPH U--- 4 5 -- Ring graph + + attr: name (g/c), mutual (g/l), circular (g/l) + + edges: + [1] 1--2 2--3 3--4 1--4 2--4 + + +# get_adjacency_impl basic + + Code + get_adjacency_impl(graph = g, type = c("both", "upper", "lower")) + Output + [,1] [,2] [,3] + [1,] 0 1 1 + [2,] 1 0 1 + [3,] 1 1 0 + diff --git a/tests/testthat/_snaps/aaa-trees.md b/tests/testthat/_snaps/aaa-trees.md new file mode 100644 index 00000000000..ead092400df --- /dev/null +++ b/tests/testthat/_snaps/aaa-trees.md @@ -0,0 +1,123 @@ +# unfold_tree_impl basic + + Code + unfold_tree_impl(graph = g, roots = 1) + Output + $tree + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + + $vertex_index + [1] 1 2 3 + + +--- + + Code + unfold_tree_impl(graph = g, mode = "in", roots = 1) + Output + $tree + IGRAPH U--- 3 2 -- + + edges: + [1] 1--2 2--3 + + $vertex_index + [1] 1 2 3 + + +# unfold_tree_impl errors + + Code + unfold_tree_impl(graph = NULL, roots = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_tree_impl basic + + Code + is_tree_impl(graph = g) + Output + [1] TRUE + +--- + + Code + is_tree_impl(graph = g, mode = "in", details = TRUE) + Output + $res + [1] TRUE + + $root + + 1/3 vertex: + [1] 1 + + +# is_tree_impl errors + + Code + is_tree_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# is_forest_impl basic + + Code + is_forest_impl(graph = g) + Output + [1] TRUE + +--- + + Code + is_forest_impl(graph = g, mode = "in", details = TRUE) + Output + $res + [1] TRUE + + $roots + + 1/3 vertex: + [1] 1 + + +# is_forest_impl errors + + Code + is_forest_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# to_prufer_impl basic + + Code + to_prufer_impl(graph = g) + Output + [1] 2 + +# to_prufer_impl errors + + Code + to_prufer_impl(graph = NULL) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# random_spanning_tree_impl basic + + Code + random_spanning_tree_impl(graph = g, vid = 1) + Output + + 2/2 edges: + [1] 1--2 2--3 + +# random_spanning_tree_impl errors + + Code + random_spanning_tree_impl(graph = NULL, vid = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + diff --git a/tests/testthat/_snaps/aaa-visitors.md b/tests/testthat/_snaps/aaa-visitors.md new file mode 100644 index 00000000000..b12005b1fd7 --- /dev/null +++ b/tests/testthat/_snaps/aaa-visitors.md @@ -0,0 +1,185 @@ +# random_walk_impl basic + + Code + random_walk_impl(graph = g, start = 1, steps = 2) + Output + $vertices + + 3/3 vertices: + [1] 1 2 3 + + $edges + + 2/2 edges: + [1] 1--2 2--3 + + +--- + + Code + random_walk_impl(graph = g, start = 1, steps = 2, mode = "in", stuck = "error") + Output + $vertices + + 3/3 vertices: + [1] 1 2 1 + + $edges + + 2/2 edges: + [1] 1--2 1--2 + + +# random_walk_impl errors + + Code + random_walk_impl(graph = NULL, start = 1, steps = 2) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# bfs_simple_impl basic + + Code + bfs_simple_impl(graph = g, root = 1) + Output + $order + + 3/3 vertices: + [1] 1 2 3 + + $layers + [1] 0 1 2 3 + + $parents + [1] -1 0 1 + + +--- + + Code + bfs_simple_impl(graph = g, root = 1, mode = "in") + Output + $order + + 3/3 vertices: + [1] 1 2 3 + + $layers + [1] 0 1 2 3 + + $parents + [1] -1 0 1 + + +# bfs_simple_impl errors + + Code + bfs_simple_impl(graph = NULL, root = 1) + Condition + Error in `ensure_igraph()`: + ! Must provide a graph object (provided `NULL`). + +# bfs_closure_impl works + + Code + cat("BFS result:\n") + Output + BFS result: + Code + print(result) + Output + $order + + 10/10 vertices: + [1] 1 2 10 3 9 4 8 5 7 6 + + $rank + [1] 0 1 3 5 7 9 8 6 4 2 + + $parents + [1] -1 0 1 2 3 4 7 8 9 0 + + $pred + [1] -1 0 9 8 7 6 4 3 2 1 + + $succ + [1] 1 9 8 7 6 -1 5 4 3 2 + + $dist + [1] 0 1 2 3 4 5 4 3 2 1 + + Code + cat("\nNumber of BFS visits:", length(bfs_visits), "\n") + Output + + Number of BFS visits: 10 + Code + if (length(bfs_visits) > 0) { + cat("First visit:\n") + print(bfs_visits[[1]]) + } + Output + First visit: + vid pred succ rank dist + 1 0 2 1 0 + +--- + + Code + bfs_closure_impl(graph = g, root = 1, mode = "out", unreachable = TRUE, + restricted = NULL, callback = function(args) { + NA + }) + Condition + Error in `bfs_closure_impl()`: + ! Error in R callback function. Failed + Source: : + +--- + + Code + bfs_closure_impl(graph = g, root = 1, mode = "out", unreachable = TRUE, + restricted = NULL, callback = function(args) { + NA + }) + Condition + Error in `bfs_closure_impl()`: + ! Error in R callback function. Failed + Source: : + +# dfs_closure_impl works + + Code + cat("DFS result:\n") + Output + DFS result: + Code + print(result) + Output + $order + + 10/10 vertices: + [1] 1 2 3 4 5 6 7 8 9 10 + + $order_out + + 10/10 vertices: + [1] 10 9 8 7 6 5 4 3 2 1 + + $father + [1] -1 0 1 2 3 4 5 6 7 8 + + $dist + [1] 0 1 2 3 4 5 6 7 8 9 + + Code + cat("\nNumber of DFS IN visits:", length(dfs_in_visits), "\n") + Output + + Number of DFS IN visits: 10 + Code + cat("Number of DFS OUT visits:", length(dfs_out_visits), "\n") + Output + Number of DFS OUT visits: 10 + Code + if (length(dfs_in_visits) > 0) { + cat("First IN visit:\n") + print(dfs_in_visits[[1]]) + } + Output + First IN visit: + vid dist + 1 0 + diff --git a/tests/testthat/test-aaa-auto.R b/tests/testthat/test-aaa-auto.R deleted file mode 100644 index f55d16dea98..00000000000 --- a/tests/testthat/test-aaa-auto.R +++ /dev/null @@ -1,11402 +0,0 @@ -# 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", { - igraph_local_seed(20250909) - - expect_snapshot(empty_impl()) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(empty_impl( - n = -1 - )) -}) - -# 2. add_edges_impl - -test_that("add_edges_impl basic", { - igraph_local_seed(20250909) - g <- empty_impl( - n = 3 - ) - - expect_snapshot(add_edges_impl( - graph = g, - edges = c(1, 2, 2, 3) - )) - - # Structured tests - result <- add_edges_impl( - graph = g, - edges = c(1, 2, 2, 3) - ) - expect_s3_class(result, "igraph") - expect_equal(vcount(result), 3) - expect_equal(ecount(result), 2) -}) - -test_that("add_edges_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(add_edges_impl( - graph = NULL, - edges = c(1, 2) - )) -}) - -# 3. copy_impl - -test_that("copy_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(copy_impl( - from = NULL - )) -}) - -# 4. delete_vertices_idx_impl - -test_that("delete_vertices_idx_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(delete_vertices_idx_impl( - graph = NULL, - vertices = 1 - )) -}) - -# 5. vcount_impl - -test_that("vcount_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(vcount_impl( - graph = NULL - )) -}) - -# 6. degree_impl - -test_that("degree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(degree_impl( - graph = NULL - )) -}) - -# 7. get_all_eids_between_impl - -test_that("get_all_eids_between_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_all_eids_between_impl( - graph = NULL, - from = 1, - to = 2 - )) -}) - -# 8. wheel_impl - -test_that("wheel_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(wheel_impl( - n = -1 - )) -}) - -# 9. hypercube_impl - -test_that("hypercube_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(hypercube_impl( - n = 10000 - )) -}) - -# 10. square_lattice_impl - -test_that("square_lattice_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(square_lattice_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(square_lattice_impl( - dimvector = -1 - )) -}) - -# 11. triangular_lattice_impl - -test_that("triangular_lattice_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(triangular_lattice_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(triangular_lattice_impl( - dimvector = -1 - )) -}) - -# 12. path_graph_impl - -test_that("path_graph_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(path_graph_impl( - n = -1 - )) -}) - -# 13. cycle_graph_impl - -test_that("cycle_graph_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(cycle_graph_impl( - n = -1 - )) -}) - -# 14. symmetric_tree_impl - -test_that("symmetric_tree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(symmetric_tree_impl( - branches = -1 - )) -}) - -# 15. regular_tree_impl - -test_that("regular_tree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(regular_tree_impl( - h = -1 - )) -}) - -# 16. full_citation_impl - -test_that("full_citation_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(full_citation_impl( - n = -1 - )) -}) - -# 17. atlas_impl - -test_that("atlas_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(atlas_impl( - number = -1 - )) -}) - -# 18. extended_chordal_ring_impl - -test_that("extended_chordal_ring_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(extended_chordal_ring_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(extended_chordal_ring_impl( - nodes = -1, - W = matrix(c(1, 2)) - )) -}) - -# 19. graph_power_impl - -test_that("graph_power_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(graph_power_impl( - graph = NULL, - order = 2 - )) -}) - -# 20. linegraph_impl - -test_that("linegraph_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(linegraph_impl( - graph = NULL - )) -}) - -# 21. de_bruijn_impl -test_that("de_bruijn_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(de_bruijn_impl( - m = -1, - n = 3 - )) -}) - -# 22. kautz_impl -test_that("kautz_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(kautz_impl( - m = -1, - n = 3 - )) -}) - -# 23. lcf_vector_impl -test_that("lcf_vector_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(mycielski_graph_impl( - k = -1 - )) -}) - -# 25. adjlist_impl -test_that("adjlist_impl basic", { - skip_if(Sys.getenv("R_SANITIZER") == "true") - igraph_local_seed(20250909) - 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") - igraph_local_seed(20250909) - expect_snapshot_igraph_error(adjlist_impl( - adjlist = -1, - mode = "out" - )) -}) - -# 26. full_bipartite_impl -test_that("full_bipartite_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(full_bipartite_impl( - n1 = -1, - n2 = 3 - )) -}) - -# 27. full_multipartite_impl -test_that("full_multipartite_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(full_multipartite_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(full_multipartite_impl( - n = -1 - )) -}) - -# 28. realize_degree_sequence_impl -test_that("realize_degree_sequence_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(realize_degree_sequence_impl( - 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", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot(realize_bipartite_degree_sequence_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - realize_bipartite_degree_sequence_impl( - degrees1 = -1, - degrees2 = c(2, 2) - ) - ) -}) - -# 30. circulant_impl -test_that("circulant_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(circulant_impl( - n = -1, - shifts = c(1, 2) - )) -}) - -# 31. generalized_petersen_impl -test_that("generalized_petersen_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(generalized_petersen_impl( - n = -1, - k = 2 - )) -}) - -# 32. turan_impl -test_that("turan_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(turan_impl( - n = -1, - r = 2 - )) -}) - -# 33. erdos_renyi_game_gnp_impl -test_that("erdos_renyi_game_gnp_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(erdos_renyi_game_gnp_impl( - 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", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot(erdos_renyi_game_gnm_impl( - 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", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot(growing_random_game_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(growing_random_game_impl( - n = -1, - m = 2 - )) -}) - -# 36. preference_game_impl -test_that("preference_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(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) - )) - - # 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - preference_game_impl( - 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) - ) - ) -}) - -# 37. asymmetric_preference_game_impl -test_that("asymmetric_preference_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(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) - )) - - # 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - asymmetric_preference_game_impl( - 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) - ) - ) -}) - -# 38. rewire_edges_impl -test_that("rewire_edges_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(rewire_edges_impl( - graph = NULL, - prob = 0.5 - )) -}) - -# 39. rewire_directed_edges_impl -test_that("rewire_directed_edges_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot(forest_fire_game_impl( - 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", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - simple_interconnected_islands_game_impl( - islands_n = -1, - islands_size = 3, - islands_pin = 0.5, - n_inter = 1 - ) - ) -}) - -# 42. chung_lu_game_impl -test_that("chung_lu_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(chung_lu_game_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(chung_lu_game_impl( - out_weights = -1 - )) -}) - -# 43. static_fitness_game_impl -test_that("static_fitness_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(static_fitness_game_impl( - 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", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot(static_power_law_game_impl( - 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", { - igraph_local_seed(20250909) - 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 - -test_that("k_regular_game_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(k_regular_game_impl( - no_of_nodes = -1, - k = 2 - )) -}) - -# 46. sbm_game_impl - -test_that("sbm_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(sbm_game_impl( - 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", { - igraph_local_seed(20250909) - 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 - -test_that("hsbm_game_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - hsbm_game_impl( - n = -1, - m = 2, - rho = 0.5, - C = matrix(1, 2, 2), - p = 0.5 - ) - ) -}) - -# 48. hsbm_list_game_impl - -test_that("hsbm_list_game_impl basic", { - igraph_local_seed(20250909) - C <- matrix( - c( - 1, - 3 / 4, - 0, - 3 / 4, - 0, - 3 / 4, - 0, - 3 / 4, - 3 / 4 - ), - nrow = 3 - ) - expect_snapshot(hsbm_list_game_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - hsbm_list_game_impl( - 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 - ) - ) -}) - -# 49. correlated_game_impl - -test_that("correlated_game_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 5 - ) - - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(correlated_game_impl( - old_graph = NULL, - corr = 0.5 - )) -}) - -# 50. correlated_pair_game_impl - -test_that("correlated_pair_game_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(correlated_pair_game_impl( - n = -1, - corr = 0.5, - p = 0.5 - )) -}) - -# 51. dot_product_game_impl - -test_that("dot_product_game_impl basic", { - igraph_local_seed(20250909) - 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, 0.2, 1) - ) - expect_s3_class(result, "igraph") -}) - -test_that("dot_product_game_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(dot_product_game_impl( - vecs = NULL - )) -}) - -# 52. sample_sphere_surface_impl - -test_that("sample_sphere_surface_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(sample_sphere_surface_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(sample_sphere_surface_impl( - dim = -1, - n = 5 - )) -}) - -# 53. sample_sphere_volume_impl - -test_that("sample_sphere_volume_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(sample_sphere_volume_impl( - dim = -1, - n = 5 - )) -}) - -# 54. sample_dirichlet_impl - -test_that("sample_dirichlet_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(sample_dirichlet_impl( - n = -1, - alpha = c(1, 1, 1) - )) -}) - -# 55. are_adjacent_impl - -test_that("are_adjacent_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(are_adjacent_impl( - graph = NULL, - v1 = 1, - v2 = 2 - )) -}) - -# 56. closeness_impl - -test_that("closeness_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(closeness_impl( - graph = NULL - )) -}) - -# 57. closeness_cutoff_impl - -test_that("closeness_cutoff_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(closeness_cutoff_impl( - graph = g, - cutoff = 2 - )) - expect_snapshot(closeness_cutoff_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(closeness_cutoff_impl( - graph = NULL - )) -}) - -# 58. get_shortest_path_impl - -test_that("get_shortest_path_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_shortest_path_impl( - graph = NULL, - from = 1, - to = 3 - )) -}) - -# 59. get_shortest_path_bellman_ford_impl - -test_that("get_shortest_path_bellman_ford_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_shortest_path_bellman_ford_impl( - graph = NULL, - from = 1, - to = 3 - )) -}) - -# 60. get_shortest_path_dijkstra_impl - -test_that("get_shortest_path_dijkstra_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_shortest_path_dijkstra_impl( - graph = NULL, - from = 1, - to = 3 - )) -}) - -# 61. get_all_shortest_paths_impl - -test_that("get_all_shortest_paths_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_all_shortest_paths_impl( - graph = NULL, - from = 1, - to = 3 - )) -}) - -# 62. get_all_shortest_paths_dijkstra_impl - -test_that("get_all_shortest_paths_dijkstra_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - get_all_shortest_paths_dijkstra_impl( - graph = NULL, - from = 1, - to = 3 - ) - ) -}) - -# 63. voronoi_impl - -test_that("voronoi_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(voronoi_impl( - graph = NULL, - generators = 1 - )) -}) - -# 64. get_all_simple_paths_impl - -test_that("get_all_simple_paths_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_all_simple_paths_impl( - graph = NULL, - from = 1, - to = 3 - )) -}) - -# 65. get_k_shortest_paths_impl - -test_that("get_k_shortest_paths_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_k_shortest_paths_impl( - graph = NULL, - from = 1, - to = 3, - k = 2 - )) -}) - -# 66. get_widest_path_impl - -test_that("get_widest_path_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_widest_path_impl( - graph = NULL, - from = 1, - to = 3 - )) -}) - -# 67. get_widest_paths_impl - -test_that("get_widest_paths_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_widest_paths_impl( - graph = NULL, - from = 1, - to = 3 - )) -}) - -# 70. spanner_impl - -test_that("spanner_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(spanner_impl( - graph = NULL, - stretch = 2 - )) -}) - -# 71. betweenness_cutoff_impl - -test_that("betweenness_cutoff_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(betweenness_cutoff_impl( - graph = NULL, - cutoff = 2 - )) -}) - -# 72. betweenness_subset_impl - -test_that("betweenness_subset_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(betweenness_subset_impl( - graph = NULL - )) -}) - -# 73. edge_betweenness_impl - -test_that("edge_betweenness_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(edge_betweenness_impl( - graph = NULL - )) -}) - -# 74. edge_betweenness_cutoff_impl - -test_that("edge_betweenness_cutoff_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(edge_betweenness_cutoff_impl( - graph = NULL, - cutoff = 2 - )) -}) - -# 75. edge_betweenness_subset_impl - -test_that("edge_betweenness_subset_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(edge_betweenness_subset_impl( - graph = NULL - )) -}) - -# 76. harmonic_centrality_cutoff_impl - -test_that("harmonic_centrality_cutoff_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - harmonic_centrality_cutoff_impl( - graph = NULL, - cutoff = 2 - ) - ) -}) - -# 77. personalized_pagerank_impl - -test_that("personalized_pagerank_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(personalized_pagerank_impl( - graph = NULL - )) -}) - -# 78. personalized_pagerank_vs_impl - -test_that("personalized_pagerank_vs_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(personalized_pagerank_vs_impl( - graph = g, - reset_vids = 1 - )) - expect_snapshot(personalized_pagerank_vs_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - personalized_pagerank_vs_impl( - graph = NULL, - reset_vids = 1 - ) - ) -}) - -# 79. induced_subgraph_impl - -test_that("induced_subgraph_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(induced_subgraph_impl( - graph = NULL, - vids = 1:2 - )) -}) - -# 80. subgraph_from_edges_impl - -test_that("subgraph_from_edges_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(subgraph_from_edges_impl( - graph = NULL, - eids = 1 - )) -}) - -# 81. reverse_edges_impl - -test_that("reverse_edges_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(reverse_edges_impl( - graph = NULL - )) -}) - -# and much more halucination before... -# 91-96: halucination of get_shortest_path_* -# 97-100: halucination of get_widest_path_cutoff_impl,get_widest_paths_cutoff_impl, widest_path_widths_dijkstra_cutoff_impl, widest_path_widths_floyd_warshall_cutoff_impl - -# 101. path_length_hist_impl - -test_that("path_length_hist_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(path_length_hist_impl( - graph = NULL - )) -}) - -# 102. simplify_impl - -test_that("simplify_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(simplify_impl( - graph = g - )) - expect_snapshot(simplify_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(simplify_impl( - graph = NULL - )) -}) - -# 103. transitivity_undirected_impl - -test_that("transitivity_undirected_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(transitivity_undirected_impl( - graph = NULL - )) -}) - -# 104. transitivity_local_undirected_impl - -test_that("transitivity_local_undirected_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(transitivity_local_undirected_impl( - graph = NULL - )) -}) - -# 105. transitivity_avglocal_undirected_impl - -test_that("transitivity_avglocal_undirected_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(transitivity_avglocal_undirected_impl( - graph = NULL - )) -}) - -# 106. transitivity_barrat_impl - -test_that("transitivity_barrat_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(transitivity_barrat_impl( - graph = g - )) - expect_snapshot(transitivity_barrat_impl( - graph = g, - mode = "zero" - )) - - # Structured tests - expect_warning( - result <- transitivity_barrat_impl( - graph = g - ) - ) - expect_true(is.numeric(result) || is.logical(result)) -}) - -test_that("transitivity_barrat_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(transitivity_barrat_impl( - graph = NULL - )) -}) - -# 107. ecc_impl - -test_that("ecc_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(ecc_impl( - graph = NULL - )) -}) - -# 108. reciprocity_impl - -test_that("reciprocity_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(reciprocity_impl( - graph = NULL - )) -}) - -# 109. maxdegree_impl - -test_that("maxdegree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(maxdegree_impl( - graph = NULL - )) -}) - -# 110. density_impl - -test_that("density_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(density_impl( - graph = NULL - )) -}) - -# 111. mean_degree_impl - -test_that("mean_degree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(mean_degree_impl( - graph = NULL - )) -}) - -# 112. feedback_arc_set_impl - -test_that("feedback_arc_set_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(feedback_arc_set_impl( - graph = NULL - )) -}) - -# 113. feedback_vertex_set_impl - -test_that("feedback_vertex_set_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(feedback_vertex_set_impl( - graph = NULL - )) -}) - -# 114. is_loop_impl - -test_that("is_loop_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_loop_impl( - graph = NULL - )) -}) - -# 115. is_dag_impl - -test_that("is_dag_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_dag_impl( - graph = NULL - )) -}) - -# 116. is_acyclic_impl - -test_that("is_acyclic_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_acyclic_impl( - graph = NULL - )) -}) - -# 117. is_simple_impl - -test_that("is_simple_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_simple_impl( - graph = NULL - )) -}) - -# 118. is_multiple_impl - -test_that("is_multiple_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_multiple_impl( - graph = NULL - )) -}) - -# 119. has_loop_impl - -test_that("has_loop_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(has_loop_impl( - graph = NULL - )) -}) - -# 120. has_multiple_impl - -test_that("has_multiple_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(has_multiple_impl( - graph = NULL - )) -}) - -# 121. count_loops_impl - -test_that("count_loops_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(count_loops_impl( - graph = NULL - )) -}) - -# 122. count_multiple_impl - -test_that("count_multiple_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(count_multiple_impl( - graph = NULL - )) -}) - -# 123. is_perfect_impl - -test_that("is_perfect_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_perfect_impl( - graph = NULL - )) -}) - -# 124. eigenvector_centrality_impl - -test_that("eigenvector_centrality_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(eigenvector_centrality_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(eigenvector_centrality_impl( - graph = NULL - )) -}) - -# 125. hub_and_authority_scores_impl - -test_that("hub_and_authority_scores_impl basic", { - igraph_local_seed(20250909) - g <- make_full_graph(5) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(hub_and_authority_scores_impl( - graph = NULL - )) -}) - -# 126. unfold_tree_impl - -test_that("unfold_tree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(unfold_tree_impl( - graph = NULL, - roots = 1 - )) -}) - -# 127. is_mutual_impl - -test_that("is_mutual_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_mutual_impl( - graph = NULL - )) -}) - -# 128. has_mutual_impl - -test_that("has_mutual_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(has_mutual_impl( - graph = NULL - )) -}) - -# 129. maximum_cardinality_search_impl - -test_that("maximum_cardinality_search_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(maximum_cardinality_search_impl( - graph = NULL - )) -}) - -# 130. avg_nearest_neighbor_degree_impl - -test_that("avg_nearest_neighbor_degree_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(avg_nearest_neighbor_degree_impl( - graph = g - )) - expect_snapshot(avg_nearest_neighbor_degree_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(avg_nearest_neighbor_degree_impl( - graph = NULL - )) -}) - -# 131. degree_correlation_vector_impl - -test_that("degree_correlation_vector_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(degree_correlation_vector_impl( - graph = g - )) - expect_snapshot(degree_correlation_vector_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(degree_correlation_vector_impl( - graph = NULL - )) -}) - -# 132. rich_club_sequence_impl - -test_that("rich_club_sequence_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(rich_club_sequence_impl( - graph = g, - vertex_order = 1:3 - )) - expect_snapshot(rich_club_sequence_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - rich_club_sequence_impl( - graph = NULL, - vertex_order = 1:3 - ) - ) -}) - -# 133. strength_impl - -test_that("strength_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(strength_impl( - graph = NULL - )) -}) - -# 134. centralization_impl - -test_that("centralization_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(centralization_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(centralization_impl( - scores = package_version("1.2.3") - )) -}) - -# 135. centralization_degree_impl - -test_that("centralization_degree_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(centralization_degree_impl( - graph = g - )) - expect_snapshot(centralization_degree_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(centralization_degree_impl( - graph = NULL - )) -}) - -# 136. centralization_degree_tmax_impl - -test_that("centralization_degree_tmax_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - centralization_degree_tmax_impl( - nodes = -1, - loops = TRUE - ) - ) -}) - -# 137. centralization_betweenness_impl - -test_that("centralization_betweenness_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(centralization_betweenness_impl( - graph = g - )) - expect_snapshot(centralization_betweenness_impl( - graph = g, - directed = FALSE, - normalized = FALSE - )) - - # Structured tests - result <- centralization_betweenness_impl( - graph = g - ) - expect_type(result, "list") -}) - -test_that("centralization_betweenness_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(centralization_betweenness_impl( - graph = NULL - )) -}) - -# 138. centralization_betweenness_tmax_impl - -test_that("centralization_betweenness_tmax_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(centralization_betweenness_tmax_impl( - nodes = 3, - directed = TRUE - )) - expect_snapshot(centralization_betweenness_tmax_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - centralization_betweenness_tmax_impl( - nodes = -1, - directed = TRUE - ) - ) -}) - -# 139. centralization_closeness_impl - -test_that("centralization_closeness_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(centralization_closeness_impl( - graph = g - )) - expect_snapshot(centralization_closeness_impl( - graph = g, - mode = "in", - normalized = FALSE - )) - - # Structured tests - result <- centralization_closeness_impl( - graph = g - ) - expect_type(result, "list") -}) - -test_that("centralization_closeness_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(centralization_closeness_impl( - graph = NULL - )) -}) - -# 140. centralization_closeness_tmax_impl - -test_that("centralization_closeness_tmax_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(centralization_closeness_tmax_impl( - nodes = -1 - )) -}) - -# 141. centralization_eigenvector_centrality_impl - -test_that("centralization_eigenvector_centrality_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(centralization_eigenvector_centrality_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - centralization_eigenvector_centrality_impl( - graph = NULL - ) - ) -}) - -# 142. centralization_eigenvector_centrality_tmax_impl - -test_that("centralization_eigenvector_centrality_tmax_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - centralization_eigenvector_centrality_tmax_impl( - nodes = -1 - ) - ) -}) - -# 143. assortativity_nominal_impl - -test_that("assortativity_nominal_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(assortativity_nominal_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(assortativity_nominal_impl( - graph = NULL, - types = c(1, 2, 1) - )) -}) - -# 144. assortativity_impl - -test_that("assortativity_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(assortativity_impl( - graph = g, - values = c(1, 2, 1) - )) - expect_snapshot(assortativity_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(assortativity_impl( - graph = NULL, - values = c(1, 2, 1) - )) -}) - -# 145. assortativity_degree_impl - -test_that("assortativity_degree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(assortativity_degree_impl( - graph = NULL - )) -}) - -# 146. joint_degree_matrix_impl - -test_that("joint_degree_matrix_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(joint_degree_matrix_impl( - graph = g - )) - expect_snapshot(joint_degree_matrix_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(joint_degree_matrix_impl( - graph = NULL - )) -}) - -# 147. joint_degree_distribution_impl - -test_that("joint_degree_distribution_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(joint_degree_distribution_impl( - graph = g - )) - expect_snapshot(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 - )) - - # Structured tests - result <- joint_degree_distribution_impl( - graph = g - ) - expect_true(is.numeric(result)) -}) - -test_that("joint_degree_distribution_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(joint_degree_distribution_impl( - graph = NULL - )) -}) - -# 148. joint_type_distribution_impl - -test_that("joint_type_distribution_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(joint_type_distribution_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - joint_type_distribution_impl( - graph = NULL, - from_types = c(1, 2, 1) - ) - ) -}) - -# 149. contract_vertices_impl - -test_that("contract_vertices_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(contract_vertices_impl( - graph = NULL, - mapping = c(1, 1, 2) - )) -}) - -# 150. eccentricity_dijkstra_impl - -test_that("eccentricity_dijkstra_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(eccentricity_dijkstra_impl( - graph = NULL - )) -}) - -# 151. graph_center_dijkstra_impl - -test_that("graph_center_dijkstra_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(graph_center_dijkstra_impl( - graph = NULL - )) -}) - -# 152. radius_dijkstra_impl - -test_that("radius_dijkstra_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(radius_dijkstra_impl( - graph = NULL - )) -}) - -# 153. pseudo_diameter_impl - -test_that("pseudo_diameter_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(pseudo_diameter_impl( - graph = g, - start_vid = 1 - )) - expect_snapshot(pseudo_diameter_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(pseudo_diameter_impl( - graph = NULL, - start_vid = 1 - )) -}) - -# 154. pseudo_diameter_dijkstra_impl - -test_that("pseudo_diameter_dijkstra_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(pseudo_diameter_dijkstra_impl( - graph = g, - start_vid = 1 - )) - expect_snapshot(pseudo_diameter_dijkstra_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - pseudo_diameter_dijkstra_impl( - graph = NULL, - start_vid = 1 - ) - ) -}) - -# 155. diversity_impl - -test_that("diversity_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - E(g)$weight <- c(1, 2) - expect_snapshot(diversity_impl( - graph = g - )) - - # Structured tests - result <- diversity_impl( - graph = g - ) - expect_true(is.numeric(result)) -}) - -test_that("diversity_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(diversity_impl( - graph = NULL - )) -}) - -# 156. random_walk_impl - -test_that("random_walk_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(random_walk_impl( - graph = NULL, - start = 1, - steps = 2 - )) -}) - -# 157. global_efficiency_impl - -test_that("global_efficiency_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(global_efficiency_impl( - graph = NULL - )) -}) - -# 158. local_efficiency_impl - -test_that("local_efficiency_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(local_efficiency_impl( - graph = NULL - )) -}) - -# 159. average_local_efficiency_impl - -test_that("average_local_efficiency_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(average_local_efficiency_impl( - graph = g - )) - expect_snapshot(average_local_efficiency_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(average_local_efficiency_impl( - graph = NULL - )) -}) - -# 160. transitive_closure_dag_impl - -test_that("transitive_closure_dag_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(transitive_closure_dag_impl( - graph = NULL - )) -}) - -# 161. transitive_closure_impl - -test_that("transitive_closure_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(transitive_closure_impl( - graph = NULL - )) -}) - -# 162. trussness_impl - -test_that("trussness_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(trussness_impl( - graph = NULL - )) -}) - -# 163. is_graphical_impl - -test_that("is_graphical_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(is_graphical_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_graphical_impl( - out_deg = "a" - )) -}) - -# 164. bfs_simple_impl - -test_that("bfs_simple_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(bfs_simple_impl( - graph = NULL, - root = 1 - )) -}) - -# 165. bipartite_projection_size_impl - -test_that("bipartite_projection_size_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 4 - ) - - V(g)$type <- c(TRUE, FALSE, TRUE, FALSE) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(bipartite_projection_size_impl( - graph = NULL - )) -}) - -# 166. biadjacency_impl - -test_that("biadjacency_impl basic", { - igraph_local_seed(20250909) - m <- matrix(c(1, 0, 1, 0, 1, 1), nrow = 2) - expect_snapshot(biadjacency_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(biadjacency_impl( - incidence = "a" - )) -}) - -# 167. get_biadjacency_impl - -test_that("get_biadjacency_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - get_biadjacency_impl( - graph = NULL, - types = c(TRUE, FALSE, TRUE) - ) - ) -}) - -# 168. is_bipartite_impl - -test_that("is_bipartite_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_bipartite_impl( - graph = NULL - )) -}) - -# 169. bipartite_game_gnp_impl - -test_that("bipartite_game_gnp_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(bipartite_game_gnp_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(bipartite_game_gnp_impl( - n1 = -1, - n2 = 2, - p = 0.5 - )) -}) - -# 170. bipartite_game_gnm_impl - -test_that("bipartite_game_gnm_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(bipartite_game_gnm_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(bipartite_game_gnm_impl( - n1 = -1, - n2 = 2, - m = 1 - )) -}) - -# 171. get_laplacian_impl - -test_that("get_laplacian_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(get_laplacian_impl( - graph = g - )) - expect_snapshot(get_laplacian_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_laplacian_impl( - graph = NULL - )) -}) - -# 172. get_laplacian_sparse_impl - -test_that("get_laplacian_sparse_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(get_laplacian_sparse_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_laplacian_sparse_impl( - graph = NULL - )) -}) - -# 173. connected_components_impl - -test_that("connected_components_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(connected_components_impl( - graph = NULL - )) -}) - -# 174. is_connected_impl - -test_that("is_connected_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_connected_impl( - graph = NULL - )) -}) - -# 175. articulation_points_impl - -test_that("articulation_points_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(articulation_points_impl( - graph = NULL - )) -}) - -# 176. biconnected_components_impl - -test_that("biconnected_components_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(biconnected_components_impl( - graph = NULL - )) -}) - -# 177. bridges_impl - -test_that("bridges_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(bridges_impl( - graph = NULL - )) -}) - -# 178. is_biconnected_impl - -test_that("is_biconnected_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_biconnected_impl( - graph = NULL - )) -}) - -# 179. count_reachable_impl - -test_that("count_reachable_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(count_reachable_impl( - graph = NULL, - mode = "out" - )) -}) - -# 180. bond_percolation_impl - -test_that("bond_percolation_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(bond_percolation_impl( - graph = NULL - )) -}) - -# 181. site_percolation_impl - -test_that("site_percolation_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(site_percolation_impl( - graph = NULL - )) -}) - -# 182. edgelist_percolation_impl - -test_that("edgelist_percolation_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(edgelist_percolation_impl( - edges = "a" - )) -}) - -# 183. is_clique_impl - -test_that("is_clique_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_clique_impl( - graph = NULL, - candidate = 1:2 - )) -}) - -# 184. cliques_impl - -test_that("cliques_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(cliques_impl( - graph = NULL - )) -}) - -# 185. clique_size_hist_impl - -test_that("clique_size_hist_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(clique_size_hist_impl( - graph = NULL - )) -}) - -# 186. largest_cliques_impl - -test_that("largest_cliques_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(largest_cliques_impl( - graph = NULL - )) -}) - -# 187. maximal_cliques_hist_impl - -test_that("maximal_cliques_hist_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(maximal_cliques_hist_impl( - graph = NULL - )) -}) - -# 188. clique_number_impl - -test_that("clique_number_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(clique_number_impl( - graph = NULL - )) -}) - -# 189. weighted_cliques_impl - -test_that("weighted_cliques_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(weighted_cliques_impl( - graph = g - )) - expect_snapshot(weighted_cliques_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(weighted_cliques_impl( - graph = NULL - )) -}) - -# 190. largest_weighted_cliques_impl - -test_that("largest_weighted_cliques_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(largest_weighted_cliques_impl( - graph = NULL - )) -}) - -# 191. weighted_clique_number_impl - -test_that("weighted_clique_number_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(weighted_clique_number_impl( - graph = NULL - )) -}) - -# 192. is_independent_vertex_set_impl - -test_that("is_independent_vertex_set_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_independent_vertex_set_impl( - graph = NULL, - candidate = 1:2 - )) -}) - -# 193. layout_random_impl - -test_that("layout_random_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(layout_random_impl( - graph = NULL - )) -}) - -# 194. layout_circle_impl - -test_that("layout_circle_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(layout_circle_impl( - graph = NULL - )) -}) - -# 195. layout_star_impl - -test_that("layout_star_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(layout_star_impl( - graph = NULL - )) -}) - -# 196. layout_grid_impl - -test_that("layout_grid_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(layout_grid_impl( - graph = NULL - )) -}) - -# 197. layout_grid_3d_impl - -test_that("layout_grid_3d_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(layout_grid_3d_impl( - graph = NULL - )) -}) - -# 198. roots_for_tree_layout_impl - -test_that("roots_for_tree_layout_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - roots_for_tree_layout_impl( - graph = NULL, - mode = "out", - heuristic = 1 - ) - ) -}) - -# 199. layout_random_3d_impl - -test_that("layout_random_3d_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(layout_random_3d_impl( - graph = NULL - )) -}) - -# 200. layout_sphere_impl - -test_that("layout_sphere_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(layout_sphere_impl( - graph = NULL - )) -}) - -# 201. layout_sugiyama_impl - -test_that("layout_sugiyama_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(layout_sugiyama_impl( - graph = g - )) - expect_snapshot(layout_sugiyama_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(layout_sugiyama_impl( - graph = NULL - )) -}) - -# 202. layout_mds_impl - -test_that("layout_mds_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(layout_mds_impl( - graph = NULL - )) -}) - -# 203. layout_bipartite_impl - -test_that("layout_bipartite_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(layout_bipartite_impl( - graph = g, - types = c(TRUE, FALSE, TRUE) - )) - expect_snapshot(layout_bipartite_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - layout_bipartite_impl( - graph = NULL, - types = c(TRUE, FALSE, TRUE) - ) - ) -}) - -# 204. layout_gem_impl - -test_that("layout_gem_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(layout_gem_impl( - 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, - temp_max = 2, - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - layout_gem_impl( - graph = NULL, - res = matrix(0, nrow = 3, ncol = 2) - ) - ) -}) - -# 205. layout_davidson_harel_impl - -test_that("layout_davidson_harel_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(layout_davidson_harel_impl( - graph = g, - res = matrix(0, nrow = 3, ncol = 2) - )) - expect_snapshot(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 - )) - - # 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - layout_davidson_harel_impl( - graph = NULL, - res = matrix(0, nrow = 3, ncol = 2) - ) - ) -}) - -# 206. layout_umap_impl - -test_that("layout_umap_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(layout_umap_impl( - graph = g, - res = matrix(0, nrow = 3, ncol = 2), - use_seed = TRUE - )) - expect_snapshot(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 - )) - - # 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - layout_umap_impl( - graph = NULL, - res = matrix(0, nrow = 3, ncol = 2) - ) - ) -}) - -# 207. layout_umap_3d_impl - -test_that("layout_umap_3d_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(layout_umap_3d_impl( - graph = g, - res = matrix(0, nrow = 3, ncol = 3), - use_seed = TRUE - )) - expect_snapshot(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 - )) - - # 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - layout_umap_3d_impl( - graph = NULL, - res = matrix(0, nrow = 3, ncol = 3) - ) - ) -}) - -# 208. layout_umap_compute_weights_impl - -test_that("layout_umap_compute_weights_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(layout_umap_compute_weights_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - layout_umap_compute_weights_impl( - graph = NULL, - distances = 1:3, - weights = 1:3 - ) - ) -}) - -# 209. layout_align_impl - -test_that("layout_align_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - layout_align_impl( - graph = NULL, - layout = matrix(0, nrow = 3, ncol = 2) - ) - ) -}) - -# 210. similarity_dice_impl - -test_that("similarity_dice_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(similarity_dice_impl( - graph = g - )) - expect_snapshot(similarity_dice_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(similarity_dice_impl( - graph = NULL - )) -}) - -# 211. similarity_dice_es_impl - -test_that("similarity_dice_es_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(similarity_dice_es_impl( - graph = g - )) - expect_snapshot(similarity_dice_es_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(similarity_dice_es_impl( - graph = NULL - )) -}) - -# 212. similarity_dice_pairs_impl - -test_that("similarity_dice_pairs_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 4 - ) - - expect_snapshot(similarity_dice_pairs_impl( - graph = g, - pairs = matrix(c(1, 2, 2, 3), ncol = 2) - )) - expect_snapshot(similarity_dice_pairs_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - similarity_dice_pairs_impl( - graph = NULL, - pairs = matrix(c(1, 2, 2, 3), ncol = 2) - ) - ) -}) - -# 213. similarity_inverse_log_weighted_impl - -test_that("similarity_inverse_log_weighted_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(similarity_inverse_log_weighted_impl( - graph = g - )) - expect_snapshot(similarity_inverse_log_weighted_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(similarity_inverse_log_weighted_impl( - graph = NULL - )) -}) - -# 214. similarity_jaccard_impl - -test_that("similarity_jaccard_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(similarity_jaccard_impl( - graph = g - )) - expect_snapshot(similarity_jaccard_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(similarity_jaccard_impl( - graph = NULL - )) -}) - -# 215. similarity_jaccard_es_impl - -test_that("similarity_jaccard_es_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(similarity_jaccard_es_impl( - graph = g - )) - expect_snapshot(similarity_jaccard_es_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(similarity_jaccard_es_impl( - graph = NULL - )) -}) - -# 216. similarity_jaccard_pairs_impl - -test_that("similarity_jaccard_pairs_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 4 - ) - - expect_snapshot(similarity_jaccard_pairs_impl( - graph = g, - pairs = matrix(c(1, 2, 2, 3), ncol = 2) - )) - expect_snapshot(similarity_jaccard_pairs_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - similarity_jaccard_pairs_impl( - graph = NULL, - pairs = matrix(c(1, 2, 2, 3), ncol = 2) - ) - ) -}) - -# 217. compare_communities_impl - -test_that("compare_communities_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(compare_communities_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(compare_communities_impl( - comm1 = "a", - comm2 = c(2, 1, 2) - )) -}) - -# 218. modularity_impl - -test_that("modularity_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(modularity_impl( - graph = g, - membership = c(1, 2, 1) - )) - expect_snapshot(modularity_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(modularity_impl( - graph = NULL, - membership = c(1, 2, 1) - )) -}) - -# 219. modularity_matrix_impl - -test_that("modularity_matrix_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(modularity_matrix_impl( - graph = g - )) - expect_snapshot(modularity_matrix_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(modularity_matrix_impl( - graph = NULL - )) -}) - -# 220. community_fluid_communities_impl - -test_that("community_fluid_communities_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - community_fluid_communities_impl( - graph = NULL, - no_of_communities = 2 - ) - ) -}) - -# 221. community_label_propagation_impl - -test_that("community_label_propagation_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(community_label_propagation_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(community_label_propagation_impl( - graph = NULL - )) -}) - -# 222. community_multilevel_impl - -test_that("community_multilevel_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(community_multilevel_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(community_multilevel_impl( - graph = NULL - )) -}) - -# 223. community_optimal_modularity_impl - -test_that("community_optimal_modularity_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(community_optimal_modularity_impl( - graph = NULL - )) -}) - -# 224. community_leiden_impl - -test_that("community_leiden_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(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 - )) - - # 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(community_leiden_impl( - graph = NULL, - resolution = 1 - )) -}) - -# 225. split_join_distance_impl - -test_that("split_join_distance_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(split_join_distance_impl( - comm1 = "a", - comm2 = c(2, 1, 2) - )) -}) - -# 226. community_infomap_impl - -test_that("community_infomap_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(community_infomap_impl( - graph = g - )) - expect_snapshot(community_infomap_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(community_infomap_impl( - graph = NULL - )) -}) - -# 227. graphlets_impl - -test_that("graphlets_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - E(g)$weight <- 1:2 - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(graphlets_impl( - graph = NULL - )) -}) - -# 228. hrg_fit_impl - -test_that("hrg_fit_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(hrg_fit_impl( - graph = NULL - )) -}) - -# 229. hrg_sample_impl - -test_that("hrg_sample_impl basic", { - skip_if(Sys.getenv("R_SANITIZER") == "true") - igraph_local_seed(20250909) - g <- make_full_graph(10) - hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - 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") - igraph_local_seed(20250909) - # FIXME: This test triggers an assertion failure in the C code when passing - # NULL/empty HRG. The C code should validate input and return a proper error - # message instead of an assertion failure. - expect_snapshot_igraph_error(hrg_sample_impl( - hrg = NULL - )) -}) - -# 230. hrg_sample_many_impl - -test_that("hrg_sample_many_impl basic", { - skip_if(Sys.getenv("R_SANITIZER") == "true") - igraph_local_seed(20250909) - g <- make_full_graph(10) - hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - 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") - igraph_local_seed(20250909) - # FIXME: This test triggers an assertion failure in the C code when passing - # NULL/empty HRG. The C code should validate input and return a proper error - # message instead of an assertion failure. - expect_snapshot_igraph_error(hrg_sample_many_impl( - hrg = NULL, - num_samples = 2 - )) -}) - -# 231. hrg_game_impl - -test_that("hrg_game_impl basic", { - skip_if(Sys.getenv("R_SANITIZER") == "true") - igraph_local_seed(20250909) - g <- make_full_graph(10) - hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - 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") - igraph_local_seed(20250909) - # FIXME: This test triggers an assertion failure in the C code when passing - # NULL/empty HRG. The C code should validate input and return a proper error - # message instead of an assertion failure. - expect_snapshot_igraph_error(hrg_game_impl( - hrg = NULL - )) -}) - -# 232. hrg_consensus_impl - -# test_that("hrg_consensus_impl basic", { -# igraph_local_seed(20250909) -# oldval <- igraph_opt("print.id") -# igraph_options(print.id = FALSE) -# g <- path_graph_impl(3) -# expect_snapshot(hrg_consensus_impl(g)) -# expect_snapshot(hrg_consensus_impl(g, hrg=list(left=1, right=2, prob=0.5, edges=1, vertices=1), start=TRUE, num_samples=2)) -# }) - -test_that("hrg_consensus_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(hrg_consensus_impl( - graph = NULL - )) -}) - -# 233. hrg_predict_impl - -# test_that("hrg_predict_impl basic", { -# igraph_local_seed(20250909) -# oldval <- igraph_opt("print.id") -# igraph_options(print.id = FALSE) -# g <- path_graph_impl(3) -# expect_snapshot(hrg_predict_impl(g)) -# expect_snapshot(hrg_predict_impl(g, hrg=list(left=1, right=2, prob=0.5, edges=1, vertices=1), start=TRUE, num_samples=2, num_bins=2)) -# }) - -test_that("hrg_predict_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(hrg_predict_impl( - graph = NULL - )) -}) - -# 234. hrg_create_impl - -test_that("hrg_create_impl basic", { - igraph_local_seed(20250909) - g <- make_tree(5) - 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", { - igraph_local_seed(20250909) - g <- make_full_graph(4, directed = TRUE) - expect_snapshot_igraph_error(hrg_create_impl( - graph = g, - prob = 0.5 - )) -}) - -# 235. hrg_resize_impl - -test_that("hrg_resize_impl basic", { - skip_if(Sys.getenv("R_SANITIZER") == "true") - igraph_local_seed(20250909) - g <- make_full_graph(10) - hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - 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") - igraph_local_seed(20250909) - expect_snapshot_igraph_error(hrg_resize_impl( - hrg = -1, - newsize = 2 - )) -}) - -# 236. hrg_size_impl - -test_that("hrg_size_impl basic", { - skip_if(Sys.getenv("R_SANITIZER") == "true") - igraph_local_seed(20250909) - g <- make_full_graph(10) - hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - 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") - igraph_local_seed(20250909) - expect_snapshot_igraph_error(hrg_size_impl( - hrg = -1 - )) -}) - -# 237. from_hrg_dendrogram_impl - -test_that("from_hrg_dendrogram_impl basic", { - igraph_local_seed(20250909) - g <- make_full_graph(10) - hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(from_hrg_dendrogram_impl( - hrg = -1 - )) -}) - -# 238. get_adjacency_sparse_impl - -test_that("get_adjacency_sparse_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(get_adjacency_sparse_impl( - graph = g - )) - expect_snapshot(get_adjacency_sparse_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_adjacency_sparse_impl( - graph = NULL - )) -}) - -# 239. get_stochastic_impl - -test_that("get_stochastic_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_stochastic_impl( - graph = NULL - )) -}) - -# 240. get_stochastic_sparse_impl - -test_that("get_stochastic_sparse_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(get_stochastic_sparse_impl( - graph = g - )) - expect_snapshot(get_stochastic_sparse_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(get_stochastic_sparse_impl( - graph = NULL - )) -}) - -# 241. to_directed_impl - -test_that("to_directed_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(to_directed_impl( - graph = NULL - )) -}) - -# 242. to_undirected_impl - -test_that("to_undirected_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(to_undirected_impl( - graph = g - )) - expect_snapshot(to_undirected_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(to_undirected_impl( - graph = NULL - )) -}) - -# 243. motifs_randesu_impl - -test_that("motifs_randesu_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(motifs_randesu_impl( - graph = NULL - )) -}) - -# 244. motifs_randesu_estimate_impl - -test_that("motifs_randesu_estimate_impl basic", { - igraph_local_seed(20250909) - 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( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - motifs_randesu_estimate_impl( - graph = NULL, - size = 3, - sample_size = 2 - ) - ) -}) - -# 245. motifs_randesu_no_impl - -test_that("motifs_randesu_no_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(motifs_randesu_no_impl( - graph = g - )) - expect_snapshot(motifs_randesu_no_impl( - 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", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot_igraph_error( - motifs_randesu_no_impl( - graph = g, - size = 3, - cut_prob = c(0.1) - ) - ) -}) - -# 246. dyad_census_impl - -test_that("dyad_census_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(dyad_census_impl( - graph = NULL - )) -}) - -# 247. triad_census_impl - -test_that("triad_census_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(triad_census_impl( - graph = g - )) - - # Structured tests - expect_warning( - result <- triad_census_impl( - graph = g - ) - ) - expect_true(is.numeric(result)) -}) - -test_that("triad_census_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(triad_census_impl( - graph = NULL - )) -}) - -# 248. count_adjacent_triangles_impl - -test_that("count_adjacent_triangles_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(count_adjacent_triangles_impl( - graph = NULL - )) -}) - -# 249. count_triangles_impl - -test_that("count_triangles_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(count_triangles_impl( - graph = NULL - )) -}) - -# 250. local_scan_0_impl - -test_that("local_scan_0_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(local_scan_0_impl( - graph = NULL - )) -}) - -# 251. local_scan_0_them_impl - -test_that("local_scan_0_them_impl basic", { - igraph_local_seed(20250909) - 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( - 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", { - igraph_local_seed(20250909) - them <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error( - local_scan_0_them_impl( - us = NULL, - them = them - ) - ) -}) - -# 252. local_scan_1_ecount_impl - -test_that("local_scan_1_ecount_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(local_scan_1_ecount_impl( - graph = NULL - )) -}) - -# 253. local_scan_1_ecount_them_impl - -test_that("local_scan_1_ecount_them_impl basic", { - igraph_local_seed(20250909) - g1 <- path_graph_impl( - n = 3 - ) - - g2 <- path_graph_impl( - n = 3 - ) - - expect_snapshot(local_scan_1_ecount_them_impl( - 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", { - igraph_local_seed(20250909) - them <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error( - local_scan_1_ecount_them_impl( - us = NULL, - them = them - ) - ) -}) - -# 254. local_scan_k_ecount_impl - -test_that("local_scan_k_ecount_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(local_scan_k_ecount_impl( - graph = g, - k = 1 - )) - expect_snapshot(local_scan_k_ecount_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(local_scan_k_ecount_impl( - graph = NULL, - k = 1 - )) -}) - -# 255. local_scan_k_ecount_them_impl - -test_that("local_scan_k_ecount_them_impl basic", { - igraph_local_seed(20250909) - g1 <- path_graph_impl( - n = 3 - ) - - g2 <- path_graph_impl( - n = 3 - ) - - expect_snapshot(local_scan_k_ecount_them_impl( - 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", { - igraph_local_seed(20250909) - them <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error( - local_scan_k_ecount_them_impl( - us = NULL, - them = them, - k = 1 - ) - ) -}) - -# 256. local_scan_neighborhood_ecount_impl - -test_that("local_scan_neighborhood_ecount_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 4 - ) - - expect_snapshot(local_scan_neighborhood_ecount_impl( - graph = g, - neighborhoods = list(1:2, 2:3, 2:4, 2) - )) - expect_snapshot(local_scan_neighborhood_ecount_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - local_scan_neighborhood_ecount_impl( - graph = NULL, - neighborhoods = list(1:2, 2:3) - ) - ) -}) - -# 257. local_scan_subset_ecount_impl - -test_that("local_scan_subset_ecount_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 4 - ) - - expect_snapshot(local_scan_subset_ecount_impl( - graph = g, - subsets = list(c(1, 2), c(2, 3)) - )) - expect_snapshot(local_scan_subset_ecount_impl( - 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", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 4 - ) - - expect_snapshot_igraph_error( - local_scan_subset_ecount_impl( - graph = g, - subsets = list(1:2, letters[2:3]) - ) - ) -}) - -# 258. list_triangles_impl - -test_that("list_triangles_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(list_triangles_impl( - graph = NULL - )) -}) - -# 259. join_impl - -test_that("join_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - right <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error(join_impl( - left = NULL, - right = right - )) -}) - -# 260. induced_subgraph_map_impl - -test_that("induced_subgraph_map_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - induced_subgraph_map_impl( - graph = NULL, - vids = 1:2, - impl = "auto" - ) - ) -}) - -# 261. mycielskian_impl - -test_that("mycielskian_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(mycielskian_impl( - graph = NULL - )) -}) - -# 262. product_impl - -test_that("product_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - g2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error(product_impl( - g1 = NULL, - g2 = g2 - )) -}) - -# 263. rooted_product_impl - -test_that("rooted_product_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - g2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error( - rooted_product_impl( - g1 = NULL, - g2 = g2, - root = 1 - ) - ) -}) - -# 264. gomory_hu_tree_impl - -test_that("gomory_hu_tree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(gomory_hu_tree_impl( - graph = NULL - )) -}) - -# 265. maxflow_impl - -test_that("maxflow_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(maxflow_impl( - graph = NULL, - source = 1, - target = 3 - )) -}) - -# 266. residual_graph_impl - -test_that("residual_graph_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - residual_graph_impl( - graph = NULL, - capacity = c(1, 2), - flow = c(1, 2) - ) - ) -}) - -# 267. reverse_residual_graph_impl - -test_that("reverse_residual_graph_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(reverse_residual_graph_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - reverse_residual_graph_impl( - graph = NULL, - capacity = c(1, 2), - flow = c(1, 2) - ) - ) -}) - -# 268. st_mincut_impl - -test_that("st_mincut_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(st_mincut_impl( - graph = NULL, - source = 1, - target = 3 - )) -}) - -# 269. dominator_tree_impl - -test_that("dominator_tree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(dominator_tree_impl( - graph = NULL, - root = 1 - )) -}) - -# 270. all_st_cuts_impl - -test_that("all_st_cuts_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(all_st_cuts_impl( - graph = NULL, - source = 1, - target = 3 - )) -}) - -# 271. all_st_mincuts_impl - -test_that("all_st_mincuts_impl basic", { - igraph_local_seed(20250909) - 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( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - all_st_mincuts_impl( - graph = NULL, - source = 1, - target = 3 - ) - ) -}) - -# 272. even_tarjan_reduction_impl - -test_that("even_tarjan_reduction_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(even_tarjan_reduction_impl( - graph = NULL - )) -}) - -# 273. is_separator_impl - -test_that("is_separator_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_separator_impl( - graph = NULL, - candidate = 1:2 - )) -}) - -# 274. is_minimal_separator_impl - -test_that("is_minimal_separator_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_minimal_separator_impl( - graph = NULL, - candidate = 1:2 - )) -}) - -# 275. all_minimal_st_separators_impl - -test_that("all_minimal_st_separators_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(all_minimal_st_separators_impl( - graph = NULL - )) -}) - -# 276. minimum_size_separators_impl - -test_that("minimum_size_separators_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(minimum_size_separators_impl( - graph = NULL - )) -}) - -# 277. isoclass_impl - -test_that("isoclass_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(isoclass_impl( - graph = NULL - )) -}) - -# 278. isomorphic_impl - -test_that("isomorphic_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - graph2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error(isomorphic_impl( - graph1 = NULL, - graph2 = graph2 - )) -}) - -# 279. isoclass_subgraph_impl - -test_that("isoclass_subgraph_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(isoclass_subgraph_impl( - graph = NULL, - vids = 1:2 - )) -}) - -# 280. isoclass_create_impl - -test_that("isoclass_create_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(isoclass_create_impl( - size = "a", - number = 1 - )) -}) - -# 281. isomorphic_vf2_impl - -test_that("isomorphic_vf2_impl basic", { - igraph_local_seed(20250909) - 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( - 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", { - igraph_local_seed(20250909) - graph2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error(isomorphic_vf2_impl( - graph1 = NULL, - graph2 = graph2 - )) -}) - -# 282. get_isomorphisms_vf2_callback_impl -# Skipped: requires callback function, not suitable for snapshot test - -# 283. count_isomorphisms_vf2_impl - -test_that("count_isomorphisms_vf2_impl basic", { - igraph_local_seed(20250909) - 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( - 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", { - igraph_local_seed(20250909) - graph2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error( - count_isomorphisms_vf2_impl( - graph1 = NULL, - graph2 = graph2 - ) - ) -}) - -# 284. get_isomorphisms_vf2_impl - -test_that("get_isomorphisms_vf2_impl basic", { - igraph_local_seed(20250909) - g1 <- path_graph_impl( - n = 3 - ) - - g2 <- path_graph_impl( - n = 3 - ) - - expect_snapshot(get_isomorphisms_vf2_impl( - 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", { - igraph_local_seed(20250909) - graph2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error( - get_isomorphisms_vf2_impl( - graph1 = NULL, - graph2 = graph2 - ) - ) -}) - -# 285. subisomorphic_impl - -test_that("subisomorphic_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - graph2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error(subisomorphic_impl( - graph1 = NULL, - graph2 = graph2 - )) -}) - -# 286. subisomorphic_vf2_impl - -test_that("subisomorphic_vf2_impl basic", { - igraph_local_seed(20250909) - 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( - 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", { - igraph_local_seed(20250909) - graph2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error( - subisomorphic_vf2_impl( - graph1 = NULL, - graph2 = graph2 - ) - ) -}) - -# 287. count_subisomorphisms_vf2_impl - -test_that("count_subisomorphisms_vf2_impl basic", { - igraph_local_seed(20250909) - 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( - 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", { - igraph_local_seed(20250909) - graph2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error( - count_subisomorphisms_vf2_impl( - graph1 = NULL, - graph2 = graph2 - ) - ) -}) - -# 288. get_subisomorphisms_vf2_impl - -test_that("get_subisomorphisms_vf2_impl basic", { - igraph_local_seed(20250909) - 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( - 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", { - igraph_local_seed(20250909) - graph2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error( - get_subisomorphisms_vf2_impl( - graph1 = NULL, - graph2 = graph2 - ) - ) -}) - -# 289. canonical_permutation_impl - -test_that("canonical_permutation_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(canonical_permutation_impl( - graph = NULL - )) -}) - -# 290. permute_vertices_impl - -test_that("permute_vertices_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(permute_vertices_impl( - graph = NULL, - permutation = 3:1 - )) -}) - -# 291. isomorphic_bliss_impl - -test_that("isomorphic_bliss_impl basic", { - igraph_local_seed(20250909) - 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( - 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", { - igraph_local_seed(20250909) - graph2 <- path_graph_impl( - n = 3 - ) - expect_snapshot_igraph_error(isomorphic_bliss_impl( - graph1 = NULL, - graph2 = graph2 - )) -}) - -# 292. count_automorphisms_impl - -test_that("count_automorphisms_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(count_automorphisms_impl( - graph = NULL - )) -}) - -# 293. automorphism_group_impl - -test_that("automorphism_group_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(automorphism_group_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(automorphism_group_impl( - graph = NULL - )) -}) - -# 294. simplify_and_colorize_impl - -test_that("simplify_and_colorize_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(simplify_and_colorize_impl( - graph = NULL - )) -}) - -# 295. graph_count_impl - -test_that("graph_count_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(graph_count_impl( - n = "a" - )) -}) - -# 296. is_matching_impl - -test_that("is_matching_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(is_matching_impl( - graph = g, - matching = 1:2 - )) - expect_snapshot(is_matching_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_matching_impl( - graph = NULL, - matching = 1:2 - )) -}) - -# 297. is_maximal_matching_impl - -test_that("is_maximal_matching_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(is_maximal_matching_impl( - graph = g, - matching = 1:2 - )) - expect_snapshot(is_maximal_matching_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_maximal_matching_impl( - graph = NULL, - matching = 1:2 - )) -}) - -# 298. maximum_bipartite_matching_impl - -test_that("maximum_bipartite_matching_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(maximum_bipartite_matching_impl( - graph = g, - types = c(TRUE, FALSE, TRUE) - )) - expect_snapshot(maximum_bipartite_matching_impl( - graph = g, - types = c(TRUE, FALSE, TRUE), - weights = c(1, 2), - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - maximum_bipartite_matching_impl( - graph = NULL, - types = c(TRUE, FALSE, TRUE) - ) - ) -}) - -# 299. adjacency_spectral_embedding_impl - -test_that("adjacency_spectral_embedding_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(adjacency_spectral_embedding_impl( - graph = g, - no = 2 - )) - expect_snapshot(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) - )) - - # Structured tests - result <- adjacency_spectral_embedding_impl( - graph = g, - no = 2 - ) - expect_type(result, "list") -}) - -test_that("adjacency_spectral_embedding_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(adjacency_spectral_embedding_impl( - graph = NULL, - no = 2 - )) -}) - -# 300. laplacian_spectral_embedding_impl - -test_that("laplacian_spectral_embedding_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(laplacian_spectral_embedding_impl( - graph = NULL, - no = 2 - )) -}) - -# 301. eigen_adjacency_impl - -test_that("eigen_adjacency_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(eigen_adjacency_impl( - graph = g - )) - expect_snapshot_igraph_error( - eigen_adjacency_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(eigen_adjacency_impl( - graph = NULL - )) -}) - -# 302. power_law_fit_impl - -test_that("power_law_fit_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(power_law_fit_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(power_law_fit_impl( - data = "a" - )) -}) - -# 303. sir_impl - -test_that("sir_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(sir_impl( - graph = NULL, - beta = 0.1, - gamma = 0.1 - )) -}) - -# 304. convex_hull_2d_impl - -test_that("convex_hull_2d_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(convex_hull_2d_impl( - data = "a" - )) -}) - -# 305. dim_select_impl - -test_that("dim_select_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(dim_select_impl( - sv = NULL - )) -}) - -# 306. solve_lsap_impl - -test_that("solve_lsap_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(solve_lsap_impl( - c = "a", - n = 2 - )) -}) - -# 307. find_cycle_impl - -test_that("find_cycle_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(find_cycle_impl( - graph = NULL - )) -}) - -# 308. simple_cycles_impl - -test_that("simple_cycles_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(simple_cycles_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(simple_cycles_impl( - graph = NULL - )) -}) - -# 309. is_eulerian_impl - -test_that("is_eulerian_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_eulerian_impl( - graph = NULL - )) -}) - -# 310. eulerian_path_impl - -test_that("eulerian_path_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(eulerian_path_impl( - graph = NULL - )) -}) - -# 311. eulerian_cycle_impl - -test_that("eulerian_cycle_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(eulerian_cycle_impl( - graph = NULL - )) -}) - -# 312. fundamental_cycles_impl - -test_that("fundamental_cycles_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(fundamental_cycles_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(fundamental_cycles_impl( - graph = NULL, - start = 1 - )) -}) - -# 313. minimum_cycle_basis_impl - -test_that("minimum_cycle_basis_impl basic", { - igraph_local_seed(20250909) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(minimum_cycle_basis_impl( - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(minimum_cycle_basis_impl( - graph = NULL - )) -}) - -# 314. is_tree_impl - -test_that("is_tree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_tree_impl( - graph = NULL - )) -}) - -# 315. is_forest_impl - -test_that("is_forest_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_forest_impl( - graph = NULL - )) -}) - -# 316. from_prufer_impl - -test_that("from_prufer_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(from_prufer_impl( - prufer = "a" - )) -}) - -# 317. to_prufer_impl - -test_that("to_prufer_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(to_prufer_impl( - graph = NULL - )) -}) - -# 318. tree_from_parent_vector_impl - -test_that("tree_from_parent_vector_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(tree_from_parent_vector_impl( - parents = "a" - )) -}) - -# 319. is_complete_impl - -test_that("is_complete_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_complete_impl( - graph = NULL - )) -}) - -# 320. random_spanning_tree_impl - -test_that("random_spanning_tree_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(random_spanning_tree_impl( - graph = NULL, - vid = 1 - )) -}) - -# 321. tree_game_impl - -test_that("tree_game_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(tree_game_impl( - n = "a" - )) -}) - -# 322. vertex_coloring_greedy_impl - -test_that("vertex_coloring_greedy_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(vertex_coloring_greedy_impl( - graph = NULL - )) -}) - -# 323. is_vertex_coloring_impl - -test_that("is_vertex_coloring_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error( - is_vertex_coloring_impl( - graph = NULL, - types = c(1, 2, 3) - ) - ) -}) - -# 324. is_bipartite_coloring_impl - -# test_that("is_bipartite_coloring_impl basic", { -# igraph_local_seed(20250909) -# oldval <- igraph_opt("print.id") -# igraph_options(print.id = FALSE) -# g <- path_graph_impl(3) -# expect_snapshot(is_bipartite_coloring_impl(g, types = c(TRUE, FALSE, TRUE))) -#}) - -# 325. is_bipartite_coloring_impl - -test_that("is_bipartite_coloring_impl basic", { - igraph_local_seed(12345) - 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", { - igraph_local_seed(12345) - expect_snapshot_igraph_error( - is_bipartite_coloring_impl( - graph = NULL, - types = c(TRUE, FALSE, TRUE) - ) - ) -}) - -# 326. is_edge_coloring_impl - -test_that("is_edge_coloring_impl basic", { - igraph_local_seed(12345) - g <- path_graph_impl( - n = 3 - ) - - E(g)$color <- c(1, 2) - 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", { - igraph_local_seed(12345) - expect_snapshot_igraph_error(is_edge_coloring_impl( - graph = NULL, - types = c(1, 2) - )) -}) - -# 327. deterministic_optimal_imitation_impl - -test_that("deterministic_optimal_imitation_impl basic", { - igraph_local_seed(12345) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(deterministic_optimal_imitation_impl( - graph = g, - vid = 1, - quantities = c(1, 2, 3), - strategies = c(1, 2, 3) - )) - expect_snapshot(deterministic_optimal_imitation_impl( - 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", { - igraph_local_seed(12345) - expect_snapshot_igraph_error( - deterministic_optimal_imitation_impl( - graph = NULL, - vid = 1, - quantities = c(1, 2, 3), - strategies = c(1, 2, 3) - ) - ) -}) - -# 328. moran_process_impl - -test_that("moran_process_impl basic", { - igraph_local_seed(12345) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(moran_process_impl( - 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", { - igraph_local_seed(12345) - expect_snapshot_igraph_error( - moran_process_impl( - graph = NULL, - quantities = c(1, 2, 3), - strategies = c(1, 2, 3) - ) - ) -}) - -# 329. roulette_wheel_imitation_impl - -test_that("roulette_wheel_imitation_impl basic", { - igraph_local_seed(12345) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(roulette_wheel_imitation_impl( - graph = g, - vid = 1, - is_local = TRUE, - quantities = c(1, 2, 3), - strategies = c(1, 2, 3) - )) - expect_snapshot(roulette_wheel_imitation_impl( - 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", { - igraph_local_seed(12345) - expect_snapshot_igraph_error( - roulette_wheel_imitation_impl( - graph = NULL, - vid = 1, - is_local = TRUE, - quantities = c(1, 2, 3), - strategies = c(1, 2, 3) - ) - ) -}) - -# 330. stochastic_imitation_impl - -test_that("stochastic_imitation_impl basic", { - igraph_local_seed(12345) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(stochastic_imitation_impl( - graph = g, - vid = 1, - algo = 1, - quantities = c(1, 2, 3), - strategies = c(1, 2, 3) - )) - expect_snapshot(stochastic_imitation_impl( - 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", { - igraph_local_seed(12345) - expect_snapshot_igraph_error( - stochastic_imitation_impl( - graph = NULL, - vid = 1, - algo = 1, - quantities = c(1, 2, 3), - strategies = c(1, 2, 3) - ) - ) -}) - -# 331. invalidate_cache_impl - -test_that("invalidate_cache_impl basic", { - igraph_local_seed(12345) - 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", { - igraph_local_seed(12345) - expect_snapshot_igraph_error(invalidate_cache_impl( - graph = NULL - )) -}) - -# 332. vertex_path_from_edge_path_impl - -test_that("vertex_path_from_edge_path_impl basic", { - igraph_local_seed(12345) - g <- path_graph_impl( - n = 3 - ) - - expect_snapshot(vertex_path_from_edge_path_impl( - graph = g, - start = 1, - edge_path = c(1, 2) - )) - expect_snapshot(vertex_path_from_edge_path_impl( - 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", { - igraph_local_seed(12345) - expect_snapshot_igraph_error( - vertex_path_from_edge_path_impl( - graph = NULL, - start = 1, - edge_path = c(1, 2) - ) - ) -}) - -# 333. version_impl - -test_that("version_impl basic", { - igraph_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", { - igraph_local_seed(12345) - # version_impl() has no parameters, so testing with invalid arguments - expect_snapshot_igraph_error(version_impl( - "invalid" - )) -}) - -# 334. ecount_impl - -test_that("ecount_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(ecount_impl( - graph = NULL - )) -}) - -# 335. is_directed_impl - -test_that("is_directed_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(is_directed_impl( - graph = NULL - )) -}) - -# 336. edges_impl - -test_that("edges_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(edges_impl( - graph = NULL, - eids = 1 - )) -}) - -# 337. add_vertices_impl - -test_that("add_vertices_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(add_vertices_impl( - graph = NULL, - nv = 1 - )) -}) - -# 338. delete_edges_impl - -test_that("delete_edges_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(delete_edges_impl( - graph = NULL, - edges = 1 - )) -}) - -# 339. delete_vertices_impl - -test_that("delete_vertices_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(delete_vertices_impl( - graph = NULL, - vertices = 1 - )) -}) - -# 340. incident_impl - -test_that("incident_impl basic", { - igraph_local_seed(20250909) - local_igraph_options(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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(incident_impl( - graph = NULL, - vid = 1 - )) -}) - -test_that("famous_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(famous_impl( - name = "Zachary" - )) -}) - -test_that("famous_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(famous_impl( - name = "NonexistentGraph" - )) -}) - -# 342. constraint_impl - -test_that("constraint_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(constraint_impl( - graph = NULL - )) -}) - -# 343. cocitation_impl - -test_that("cocitation_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(cocitation_impl( - graph = NULL - )) -}) - -# 344. bibcoupling_impl - -test_that("bibcoupling_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(bibcoupling_impl( - graph = NULL - )) -}) - -# 345. girth_impl - -test_that("girth_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - result <- girth_impl( - graph = g - ) - expect_snapshot(result$girth) -}) - -test_that("girth_impl errors", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(girth_impl( - graph = NULL - )) -}) - -# 346. coreness_impl - -test_that("coreness_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(coreness_impl( - graph = NULL - )) -}) - -# 347. union_impl - -test_that("union_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(union_impl( - left = NULL, - right = NULL - )) -}) - -# 348. intersection_impl - -test_that("intersection_impl basic", { - igraph_local_seed(20250909) - 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", { - igraph_local_seed(20250909) - expect_snapshot_igraph_error(intersection_impl( - left = NULL, - right = NULL - )) -}) - - -# Tests for newly autogenerated _impl functions - -# Graph constructors - -test_that("star_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(star_impl(n = 5, mode = "out", center = 0)) - expect_snapshot(star_impl(n = 6, mode = "in", center = 1)) - expect_snapshot(star_impl(n = 4, mode = "undirected", center = 0)) -}) - -test_that("ring_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(ring_impl( - n = 5, - directed = FALSE, - mutual = FALSE, - circular = TRUE - )) - expect_snapshot(ring_impl( - n = 4, - directed = TRUE, - mutual = FALSE, - circular = FALSE - )) -}) - -test_that("full_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(full_impl(n = 4, directed = FALSE, loops = FALSE)) - expect_snapshot(full_impl(n = 3, directed = TRUE, loops = FALSE)) -}) - -test_that("kary_tree_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(kary_tree_impl( - n = 7, - children = 2, - type = c("out", "in", "undirected") - )) - expect_snapshot(kary_tree_impl( - n = 10, - children = 3, - type = c("in", "out", "undirected") - )) -}) - -# Random graph generators - -test_that("barabasi_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(barabasi_game_impl( - n = 10, - power = 1, - m = 2, - directed = FALSE, - algo = "bag" - )) - expect_snapshot(barabasi_game_impl( - n = 10, - power = 1, - m = 2, - directed = FALSE, - algo = "psumtree" - )) -}) - -test_that("growing_random_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(growing_random_game_impl( - n = 10, - m = 1, - directed = TRUE, - citation = FALSE - )) -}) - -test_that("grg_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(grg_game_impl(nodes = 10, radius = 0.3, torus = FALSE)) -}) - -test_that("watts_strogatz_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(watts_strogatz_game_impl( - dim = 1, - size = 10, - nei = 2, - p = 0.1 - )) -}) - -# Distance and path functions - -test_that("distances_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(distances_impl( - graph = g, - from = V(g), - to = V(g), - mode = c("out", "in", "all", "total") - )) -}) - -test_that("diameter_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(10) - expect_snapshot(diameter_impl( - graph = g, - directed = FALSE, - unconnected = TRUE - )) -}) - -test_that("get_shortest_paths_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(get_shortest_paths_impl( - graph = g, - from = 1, - to = 3, - mode = c("out", "in", "all", "total") - )) -}) - -test_that("subcomponent_impl basic", { - igraph_local_seed(20250909) - g <- make_graph(~ A-B-C, D-E-F) - expect_snapshot(subcomponent_impl( - graph = g, - v = 1, - mode = c("all", "out", "in") - )) -}) - -# Centrality measures - -test_that("betweenness_impl basic", { - igraph_local_seed(20250909) - g <- make_star(5, mode = "undirected") - expect_snapshot(betweenness_impl(graph = g, vids = V(g), directed = FALSE)) -}) - -test_that("closeness_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(closeness_impl( - graph = g, - vids = V(g), - mode = c("out", "in", "all", "total") - )) -}) - -test_that("harmonic_centrality_impl basic", { - igraph_local_seed(20250909) - g <- make_star(5, mode = "undirected") - expect_snapshot(harmonic_centrality_impl( - graph = g, - vids = V(g), - mode = c("out", "in", "all", "total") - )) -}) - -test_that("pagerank_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5, directed = TRUE) - expect_snapshot(pagerank_impl( - graph = g, - vids = V(g), - directed = TRUE, - damping = 0.85 - )) -}) - -test_that("hub_score_impl basic", { - igraph_local_seed(20250909) - g <- make_star(5, mode = "undirected") - out <- hub_score_impl(graph = g, scale = TRUE, weights = NULL) - # FIXME: out$vector unstable despite random seed - expect_length(out$vector, 5) - expect_type(out$vector, "double") - out$vector <- NULL - expect_snapshot(out) -}) - -test_that("authority_score_impl basic", { - igraph_local_seed(20250909) - g <- make_star(5, mode = "undirected") - out <- authority_score_impl(graph = g, scale = TRUE, weights = NULL) - # FIXME: out$vector unstable despite random seed - expect_length(out$vector, 5) - expect_type(out$vector, "double") - out$vector <- NULL - expect_snapshot(out) -}) - -# Community detection - -test_that("community_walktrap_impl basic", { - igraph_local_seed(20250909) - g <- make_graph(~ A-B-C-A, D-E-F-D, A-D) - expect_snapshot(community_walktrap_impl(graph = g, steps = 4)) -}) - -test_that("community_fastgreedy_impl basic", { - igraph_local_seed(20250909) - g <- make_graph(~ A-B-C-A, D-E-F-D, A-D) - expect_snapshot(community_fastgreedy_impl(graph = g)) -}) - -test_that("community_edge_betweenness_impl basic", { - igraph_local_seed(20250909) - g <- make_graph(~ A-B-C-A, D-E-F-D, A-D) - expect_snapshot(community_edge_betweenness_impl(graph = g, directed = FALSE)) -}) - -test_that("community_leading_eigenvector_callback_closure_impl basic", { - igraph_local_seed(20250909) - - # Test with a simple graph - g <- make_graph("Zachary") - result <- community_leading_eigenvector_callback_closure_impl( - graph = g - ) - - expect_snapshot({ - cat("Result class:\n") - print(class(result)) - cat("\nMembership length:\n") - print(length(result$membership)) - cat("\nModularity:\n") - print(result$modularity) - cat("\nMerges dimensions:\n") - print(dim(result$merges)) - }) - - # Structured tests - expect_s3_class(result, "igraph.eigenc") - expect_type(result, "list") - expect_true("membership" %in% names(result)) - expect_true("modularity" %in% names(result)) - expect_true("merges" %in% names(result)) - expect_length(result$membership, vcount(g)) - expect_true(is.numeric(result$modularity)) -}) - -test_that("community_leading_eigenvector_callback_closure_impl with start", { - igraph_local_seed(20250909) - - g <- make_graph("Zachary") - # Create initial membership (0-based for the impl function) - initial_membership <- rep(0:1, length.out = vcount(g)) - - result <- community_leading_eigenvector_callback_closure_impl( - graph = g, - membership = initial_membership, - start = TRUE - ) - - expect_snapshot({ - cat("Result with start membership:\n") - cat("Membership length:\n") - print(length(result$membership)) - cat("\nModularity:\n") - print(result$modularity) - }) - - expect_s3_class(result, "igraph.eigenc") - expect_length(result$membership, vcount(g)) -}) - -test_that("community_leading_eigenvector_callback_closure_impl errors", { - igraph_local_seed(20250909) - - g <- make_graph("Zachary") - - # Test with invalid steps - expect_snapshot_igraph_error( - community_leading_eigenvector_callback_closure_impl( - graph = g, - start = TRUE - ) - ) -}) - -# Connectivity - -test_that("edge_connectivity_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(edge_connectivity_impl(graph = g)) -}) - -test_that("vertex_connectivity_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(vertex_connectivity_impl(graph = g)) -}) - -# Layout functions - -test_that("layout_sphere_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(layout_sphere_impl(graph = g)) -}) - -# Bipartite functions - -test_that("create_bipartite_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(create_bipartite_impl( - types = c(FALSE, FALSE, TRUE, TRUE), - edges = c(0, 2, 0, 3, 1, 2, 1, 3), - directed = FALSE - )) -}) - -test_that("bipartite_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(bipartite_game_impl( - type = "gnp", - n1 = 5, - n2 = 5, - p = 0.3, - directed = FALSE - )) - expect_snapshot(bipartite_game_impl( - type = "gnm", - n1 = 5, - n2 = 5, - m = 10, - directed = FALSE - )) -}) - -# Other structural functions - -test_that("decompose_impl basic", { - igraph_local_seed(20250909) - g <- make_graph(~ A-B-C, D-E) - expect_snapshot(decompose_impl(graph = g, mode = c("weak", "strong"))) -}) - -test_that("neighborhood_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(neighborhood_impl( - graph = g, - order = 1, - vids = V(g), - mode = c("all", "out", "in") - )) -}) - -test_that("neighborhood_size_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(neighborhood_size_impl( - graph = g, - order = 1, - vids = V(g), - mode = c("all", "out", "in") - )) -}) - -# Graph properties - -test_that("is_chordal_impl basic", { - igraph_local_seed(20250909) - # Test with a chordal graph (complete graph is chordal) - g <- make_full_graph(4) - # alpha and alpham1 parameters must be provided as vectors matching vertex count - # alpha is a permutation vector, alpham1 is its inverse - alpha_vec <- seq_len(vcount(g)) - alpham1_vec <- seq_len(vcount(g)) - expect_snapshot(is_chordal_impl( - graph = g, - alpha = alpha_vec, - alpham1 = alpham1_vec - )) - - # Test with a non-chordal graph (4-cycle is not chordal) - g2 <- make_ring(4) - alpha_vec2 <- seq_len(vcount(g2)) - alpham1_vec2 <- seq_len(vcount(g2)) - expect_snapshot(is_chordal_impl( - graph = g2, - alpha = alpha_vec2, - alpham1 = alpham1_vec2 - )) -}) - -test_that("get_adjacency_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(3) - expect_snapshot(get_adjacency_impl( - graph = g, - type = c("both", "upper", "lower") - )) -}) - -# IO functions - -test_that("write_graph_edgelist_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(3) - tmp <- tempfile() - write_graph_edgelist_impl(graph = g, outstream = tmp) - content <- readLines(tmp) - unlink(tmp) - expect_snapshot(content) -}) - -test_that("read_graph_edgelist_impl basic", { - igraph_local_seed(20250909) - tmp <- tempfile() - writeLines(c("0 1", "1 2", "2 0"), tmp) - expect_snapshot(read_graph_edgelist_impl( - instream = tmp, - n = 3, - directed = FALSE - )) - unlink(tmp) -}) - -# Utility functions - -test_that("compare_communities_impl basic", { - igraph_local_seed(20250909) - comm1 <- c(1, 1, 2, 2, 3, 3) - comm2 <- c(1, 1, 2, 2, 2, 3) - expect_snapshot(compare_communities_impl( - comm1 = comm1, - comm2 = comm2, - method = "vi" - )) -}) - -# Additional game functions - -test_that("degree_sequence_game_impl basic", { - igraph_local_seed(20250909) - expect_snapshot(degree_sequence_game_impl( - out_deg = c(2, 2, 2, 2), - method = "configuration" - )) - expect_snapshot(degree_sequence_game_impl( - out_deg = c(2, 2, 2, 2), - method = "vl" - )) -}) - -test_that("connect_neighborhood_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot_igraph(connect_neighborhood_impl( - graph = g, - order = 1, - mode = c("all", "out", "in") - )) -}) - -# Additional distance functions - -test_that("eccentricity_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(eccentricity_impl( - graph = g, - vids = V(g), - mode = c("out", "in", "all") - )) -}) - -test_that("radius_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(radius_impl(graph = g, mode = c("out", "in", "all"))) -}) - -test_that("graph_center_impl basic", { - igraph_local_seed(20250909) - g <- make_star(5, mode = "undirected") - expect_snapshot(graph_center_impl(graph = g, mode = c("out", "in", "all"))) -}) - -test_that("voronoi_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(10) - expect_snapshot(voronoi_impl( - graph = g, - generators = c(1, 5), - mode = c("out", "in", "all") - )) -}) - -# Spanner - -test_that("spanner_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(spanner_impl(graph = g, stretch = 2)) -}) - -# Additional centrality - -test_that("edge_betweenness_impl basic", { - igraph_local_seed(20250909) - g <- make_star(5, mode = "undirected") - expect_snapshot(edge_betweenness_impl(graph = g, directed = FALSE)) -}) - -# Maximal cliques - -test_that("maximal_cliques_impl basic", { - igraph_local_seed(20250909) - g <- make_full_graph(4) - expect_snapshot(maximal_cliques_impl(graph = g, min_size = 1, max_size = 0)) -}) - -test_that("independent_vertex_sets_impl basic", { - igraph_local_seed(20250909) - g <- make_ring(5) - expect_snapshot(independent_vertex_sets_impl( - graph = g, - min_size = 1, - max_size = 0 - )) -}) - -# Callback functions - -# bfs_closure_impl - -test_that("bfs_closure_impl works", { - igraph_local_seed(20250125) - - g <- make_ring(10) - - # Collect BFS visit data - bfs_visits <- list() - result <- bfs_closure_impl( - graph = g, - root = 1, - mode = "out", - unreachable = TRUE, - restricted = NULL, - callback = function(args) { - bfs_visits[[length(bfs_visits) + 1]] <<- args - FALSE # Continue - } - ) - - expect_snapshot({ - cat("BFS result:\n") - print(result) - cat("\nNumber of BFS visits:", length(bfs_visits), "\n") - if (length(bfs_visits) > 0) { - cat("First visit:\n") - print(bfs_visits[[1]]) - } - }) - - # Test error handling - expect_snapshot_igraph_error({ - bfs_closure_impl( - graph = g, - root = 1, - mode = "out", - unreachable = TRUE, - restricted = NULL, - callback = function(args) { - NA - } - ) - }) - - expect_snapshot_igraph_error({ - bfs_closure_impl( - graph = g, - root = 1, - mode = "out", - unreachable = TRUE, - restricted = NULL, - callback = function(args) { - NA - } - ) - }) - - calls <- 0 - bfs_closure_impl( - graph = g, - root = 1, - mode = "out", - unreachable = TRUE, - restricted = NULL, - callback = function(args) { - calls <<- calls + 1 - calls > 3 # Stop after 3 calls - } - ) - expect_equal(calls, 4) # Called 4 times: 3 continue (FALSE), 1 stop (TRUE) -}) - -# dfs_closure_impl - -test_that("dfs_closure_impl works", { - igraph_local_seed(20250125) - - g <- make_ring(10) - - # Collect DFS visit data - dfs_in_visits <- list() - dfs_out_visits <- list() - result <- dfs_closure_impl( - graph = g, - root = 1, - mode = "out", - unreachable = TRUE, - in_callback = function(args) { - dfs_in_visits[[length(dfs_in_visits) + 1]] <<- args - FALSE # Continue - }, - out_callback = function(args) { - dfs_out_visits[[length(dfs_out_visits) + 1]] <<- args - FALSE # Continue - } - ) - - expect_snapshot({ - cat("DFS result:\n") - print(result) - cat("\nNumber of DFS IN visits:", length(dfs_in_visits), "\n") - cat("Number of DFS OUT visits:", length(dfs_out_visits), "\n") - if (length(dfs_in_visits) > 0) { - cat("First IN visit:\n") - print(dfs_in_visits[[1]]) - } - }) - - # Structured tests - expect_length(dfs_in_visits, 10) - expect_length(dfs_out_visits, 10) -}) - -# motifs_randesu_callback_closure_impl - -test_that("motifs_randesu_callback_closure_impl basic", { - igraph_local_seed(20250909) - - g <- make_graph(~ A - B - C - A) - - # Collect motif information for snapshot - motif_data <- list() - result <- motifs_randesu_callback_closure_impl( - graph = g, - size = 3, - cut_prob = NULL, - callback = function(vids, isoclass) { - motif_data[[length(motif_data) + 1]] <<- list( - vids = vids, - isoclass = isoclass - ) - FALSE # Continue - } - ) - - expect_snapshot({ - cat("Result:\n") - print(result) - cat("\nNumber of motifs found:", length(motif_data), "\n") - cat("First motif:\n") - print(motif_data[[1]]) - }) - - # Structured tests - expect_null(result) - expect_true(length(motif_data) > 0) - expect_type(motif_data[[1]]$vids, "integer") - expect_length(motif_data[[1]]$vids, 3) - expect_type(motif_data[[1]]$isoclass, "integer") - expect_length(motif_data[[1]]$isoclass, 1) -}) - -test_that("motifs_randesu_callback_closure_impl errors", { - igraph_local_seed(20250909) - - g <- make_graph(~ A - B - C) - - # Should error if callback is not a function - expect_snapshot_igraph_error( - motifs_randesu_callback_closure_impl( - graph = g, - size = 3, - cut_prob = NULL, - callback = "not a function" - ) - ) -}) - -# cliques_callback_closure_impl - -test_that("cliques_callback_closure_impl basic", { - igraph_local_seed(20250909) - - g <- make_full_graph(4) - - # Collect clique information for snapshot - clique_data <- list() - result <- cliques_callback_closure_impl( - graph = g, - min_size = 3, - max_size = 4, - callback = function(clique) { - clique_data[[length(clique_data) + 1]] <<- clique - FALSE # Continue - } - ) - - expect_snapshot({ - cat("Result:\n") - print(result) - cat("\nNumber of cliques found:", length(clique_data), "\n") - cat("First clique:\n") - print(clique_data[[1]]) - }) - - # Structured tests - expect_null(result) - expect_true(length(clique_data) > 0) - expect_type(clique_data[[1]], "integer") - expect_true(length(clique_data[[1]]) >= 3) - expect_true(length(clique_data[[1]]) <= 4) -}) - -test_that("cliques_callback_closure_impl errors", { - igraph_local_seed(20250909) - - g <- make_full_graph(4) - - # Should error if callback is not a function - expect_snapshot_igraph_error( - cliques_callback_closure_impl( - graph = g, - min_size = 3, - max_size = 4, - callback = "not a function" - ) - ) -}) - -# maximal_cliques_callback_closure_impl - -test_that("maximal_cliques_callback_closure_impl basic", { - igraph_local_seed(20250909) - - g <- sample_gnp(10, 0.3) - - # Collect clique information for snapshot - clique_data <- list() - result <- maximal_cliques_callback_closure_impl( - graph = g, - min_size = 3, - max_size = 0, - callback = function(clique) { - clique_data[[length(clique_data) + 1]] <<- clique - if (length(clique_data) >= 3) { - return(TRUE) # Stop after 3 - } - FALSE # Continue - } - ) - - expect_snapshot({ - cat("Result:\n") - print(result) - cat("\nNumber of maximal cliques found:", length(clique_data), "\n") - if (length(clique_data) > 0) { - cat("First maximal clique:\n") - print(clique_data[[1]]) - } - }) - - # Structured tests - expect_null(result) - expect_type(clique_data[[1]], "integer") - expect_true(length(clique_data[[1]]) >= 3) -}) - -test_that("maximal_cliques_callback_closure_impl errors", { - igraph_local_seed(20250909) - - g <- make_full_graph(4) - - # Should error if callback is not a function - expect_snapshot_igraph_error( - maximal_cliques_callback_closure_impl( - graph = g, - min_size = 3, - max_size = 0, - callback = "not a function" - ) - ) -}) - -# simple_cycles_callback_closure_impl - -test_that("simple_cycles_callback_closure_impl basic", { - igraph_local_seed(20250909) - - g <- make_ring(4, directed = TRUE) - - # Collect cycle information for snapshot - cycle_data <- list() - result <- simple_cycles_callback_closure_impl( - graph = g, - mode = "out", - min_cycle_length = -1, - max_cycle_length = -1, - callback = function(vertices, edges) { - cycle_data[[length(cycle_data) + 1]] <<- list( - vertices = vertices, - edges = edges - ) - FALSE # Continue - } - ) - - expect_snapshot({ - cat("Result:\n") - print(result) - cat("\nNumber of cycles found:", length(cycle_data), "\n") - cat("First cycle:\n") - print(cycle_data[[1]]) - }) - - # Structured tests - expect_null(result) - expect_true(length(cycle_data) > 0) - expect_type(cycle_data[[1]]$vertices, "integer") - expect_type(cycle_data[[1]]$edges, "integer") - expect_equal(length(cycle_data[[1]]$vertices), length(cycle_data[[1]]$edges)) -}) - -test_that("simple_cycles_callback_closure_impl errors", { - igraph_local_seed(20250909) - - g <- make_ring(4, directed = TRUE) - - # Should error if callback is not a function - expect_snapshot_igraph_error( - simple_cycles_callback_closure_impl( - graph = g, - mode = "out", - min_cycle_length = -1, - max_cycle_length = -1, - callback = "not a function" - ) - ) -}) - -# get_isomorphisms_vf2_callback_closure_impl - -test_that("get_isomorphisms_vf2_callback_closure_impl basic", { - igraph_local_seed(20250909) - - g1 <- make_ring(5) - g2 <- make_ring(5) - - # Collect isomorphism information for snapshot - iso_data <- list() - result <- get_isomorphisms_vf2_callback_closure_impl( - graph1 = g1, - graph2 = g2, - vertex_color1 = NULL, - vertex_color2 = NULL, - edge_color1 = NULL, - edge_color2 = NULL, - callback = function(map12, map21) { - iso_data[[length(iso_data) + 1]] <<- list( - map12 = map12, - map21 = map21 - ) - if (length(iso_data) >= 2) { - return(TRUE) # Stop after 2 - } - FALSE # Continue - } - ) - - expect_snapshot({ - cat("Result:\n") - print(result) - cat("\nNumber of isomorphisms found:", length(iso_data), "\n") - cat("First isomorphism:\n") - print(iso_data[[1]]) - }) - - # Structured tests - expect_null(result) - expect_true(length(iso_data) > 0) - expect_type(iso_data[[1]]$map12, "integer") - expect_type(iso_data[[1]]$map21, "integer") - expect_length(iso_data[[1]]$map12, vcount(g1)) - expect_length(iso_data[[1]]$map21, vcount(g2)) -}) - -test_that("get_isomorphisms_vf2_callback_closure_impl errors", { - igraph_local_seed(20250909) - - g1 <- make_ring(5) - g2 <- make_ring(5) - - # Should error if callback is not a function - expect_snapshot_igraph_error( - get_isomorphisms_vf2_callback_closure_impl( - graph1 = g1, - graph2 = g2, - vertex_color1 = NULL, - vertex_color2 = NULL, - edge_color1 = NULL, - edge_color2 = NULL, - callback = "not a function" - ) - ) -}) - -# get_subisomorphisms_vf2_callback_closure_impl - -test_that("get_subisomorphisms_vf2_callback_closure_impl basic", { - igraph_local_seed(20250909) - - g1 <- make_full_graph(5) - g2 <- make_ring(3) # triangle - - # Collect subisomorphism information for snapshot - subiso_data <- list() - result <- get_subisomorphisms_vf2_callback_closure_impl( - graph1 = g1, - graph2 = g2, - vertex_color1 = NULL, - vertex_color2 = NULL, - edge_color1 = NULL, - edge_color2 = NULL, - callback = function(map12, map21) { - subiso_data[[length(subiso_data) + 1]] <<- list( - map12 = map12, - map21 = map21 - ) - if (length(subiso_data) >= 2) { - return(TRUE) # Stop after 2 - } - FALSE # Continue - } - ) - - expect_snapshot({ - cat("Result:\n") - print(result) - cat("\nNumber of subisomorphisms found:", length(subiso_data), "\n") - cat("First subisomorphism:\n") - print(subiso_data[[1]]) - }) - - # Structured tests - expect_null(result) - expect_true(length(subiso_data) > 0) - expect_type(subiso_data[[1]]$map12, "integer") - expect_type(subiso_data[[1]]$map21, "integer") - expect_length(subiso_data[[1]]$map12, vcount(g1)) - expect_length(subiso_data[[1]]$map21, vcount(g2)) -}) - -test_that("get_subisomorphisms_vf2_callback_closure_impl errors", { - igraph_local_seed(20250909) - - g1 <- make_ring(3) - g2 <- make_full_graph(5) - - # Should error if callback is not a function - expect_snapshot_igraph_error( - get_subisomorphisms_vf2_callback_closure_impl( - graph1 = g1, - graph2 = g2, - vertex_color1 = NULL, - vertex_color2 = NULL, - edge_color1 = NULL, - edge_color2 = NULL, - callback = "not a function" - ) - ) -}) - -# sparse_adjacency_impl - -test_that("sparse_adjacency_impl basic", { - skip_if_not_installed("Matrix") - igraph_local_seed(20250909) - - # Create a simple sparse matrix - M <- Matrix::sparseMatrix( - i = c(1, 2, 3, 4), - j = c(2, 3, 4, 1), - x = 1, - dims = c(4, 4) - ) - - expect_snapshot(sparse_adjacency_impl(adjmatrix = M)) - - # Create a symmetric matrix for undirected graph - M_sym <- Matrix::sparseMatrix( - i = c(1, 1, 2, 2, 3, 3, 4, 4), - j = c(2, 4, 1, 3, 2, 4, 1, 3), - x = 1, - dims = c(4, 4) - ) - expect_snapshot(sparse_adjacency_impl( - adjmatrix = M_sym, - mode = "undirected", - loops = "once" - )) - - # Structured tests - g1 <- sparse_adjacency_impl(adjmatrix = M) - expect_s3_class(g1, "igraph") - expect_equal(vcount(g1), 4) - expect_equal(ecount(g1), 4) - expect_true(is_directed(g1)) - - g2 <- sparse_adjacency_impl( - adjmatrix = M_sym, - mode = "undirected", - loops = "once" - ) - expect_s3_class(g2, "igraph") - expect_false(is_directed(g2)) -}) - -test_that("sparse_adjacency_impl errors", { - skip_if_not_installed("Matrix") - skip_if_not(getRversion() >= "4.2") - igraph_local_seed(20250909) - - # Regular matrices are converted to sparse matrices automatically - # This should work, not error - g <- sparse_adjacency_impl(adjmatrix = matrix(c(0,1,1,0), 2, 2)) - expect_s3_class(g, "igraph") -}) - -# sparse_weighted_adjacency_impl - -test_that("sparse_weighted_adjacency_impl basic", { - skip_if_not_installed("Matrix") - igraph_local_seed(20250909) - - # Create a weighted sparse matrix - M <- Matrix::sparseMatrix( - i = c(1, 2, 3, 4), - j = c(2, 3, 4, 1), - x = c(2.5, 1.0, 3.0, 0.5), - dims = c(4, 4) - ) - - expect_snapshot(sparse_weighted_adjacency_impl(adjmatrix = M)) - - # Create a symmetric weighted matrix for undirected graph - M_sym <- Matrix::sparseMatrix( - i = c(1, 1, 2, 2, 3, 3, 4, 4), - j = c(2, 4, 1, 3, 2, 4, 1, 3), - x = c(2.5, 0.5, 2.5, 1.0, 1.0, 3.0, 0.5, 3.0), - dims = c(4, 4) - ) - expect_snapshot(sparse_weighted_adjacency_impl( - adjmatrix = M_sym, - mode = "undirected", - loops = "once" - )) - - # Structured tests - result <- sparse_weighted_adjacency_impl(adjmatrix = M) - g1 <- result$graph - weights <- result$weights - - expect_s3_class(g1, "igraph") - expect_equal(vcount(g1), 4) - expect_equal(ecount(g1), 4) - expect_true(is_directed(g1)) - expect_length(weights, 4) -}) - -test_that("sparse_weighted_adjacency_impl errors", { - skip_if_not_installed("Matrix") - skip_if_not(getRversion() >= "4.2") - igraph_local_seed(20250909) - - # Regular matrices are converted to sparse matrices automatically - # This should work, not error - result <- sparse_weighted_adjacency_impl(adjmatrix = matrix(c(0,1,2,0), 2, 2)) - expect_s3_class(result$graph, "igraph") - expect_type(result$weights, "double") -}) - -# weighted_sparsemat_impl - -test_that("weighted_sparsemat_impl basic", { - skip_if_not_installed("Matrix") - igraph_local_seed(20250909) - - # Create a weighted sparse matrix - M <- Matrix::sparseMatrix( - i = c(1, 2, 3, 4), - j = c(2, 3, 4, 1), - x = c(2.5, 1.0, 3.0, 0.5), - dims = c(4, 4) - ) - - expect_snapshot(weighted_sparsemat_impl( - A = M, - directed = TRUE, - attr = "weight", - loops = FALSE - )) - - # Structured tests - g1 <- weighted_sparsemat_impl( - A = M, - directed = TRUE, - attr = "weight", - loops = FALSE - ) - - expect_s3_class(g1, "igraph") - expect_equal(vcount(g1), 4) - expect_true(is_directed(g1)) - expect_true("weight" %in% edge_attr_names(g1)) -}) - -test_that("weighted_sparsemat_impl errors", { - skip_if_not_installed("Matrix") - skip_if_not(getRversion() >= "4.2") - igraph_local_seed(20250909) - - # Regular matrices are converted to sparse matrices automatically - # This should work, not error - g <- weighted_sparsemat_impl( - A = matrix(c(0,1,2,0), 2, 2), - directed = TRUE, - attr = "weight", - loops = FALSE - ) - expect_s3_class(g, "igraph") -}) - -# Tests for newly autogenerated *_many functions - -test_that("disjoint_union_many_impl basic", { - igraph_local_seed(20250909) - g1 <- empty_impl(n = 2) - g2 <- empty_impl(n = 3) - g3 <- empty_impl(n = 1) - - expect_snapshot(disjoint_union_many_impl( - graphs = list(g1, g2, g3) - )) - - # Structured tests - result <- disjoint_union_many_impl( - graphs = list(g1, g2, g3) - ) - expect_s3_class(result, "igraph") - expect_equal(vcount(result), 6) -}) - -test_that("union_many_impl basic", { - igraph_local_seed(20250909) - g1 <- empty_impl(n = 3) - g2 <- add_edges_impl(g1, c(0, 1, 1, 2) + 1) - g3 <- add_edges_impl(g1, c(0, 2) + 1) - - expect_snapshot(union_many_impl( - graphs = list(g1, g2, g3) - )) - - # Structured tests - result <- union_many_impl( - graphs = list(g1, g2, g3) - ) - expect_type(result, "list") - expect_s3_class(result$res, "igraph") -}) - -test_that("intersection_many_impl basic", { - igraph_local_seed(20250909) - g1 <- add_edges_impl(empty_impl(n = 3), c(0, 1, 1, 2, 0, 2) + 1) - g2 <- add_edges_impl(empty_impl(n = 3), c(0, 1, 1, 2) + 1) - g3 <- add_edges_impl(empty_impl(n = 3), c(0, 1) + 1) - - expect_snapshot(intersection_many_impl( - graphs = list(g1, g2, g3) - )) - - # Structured tests - result <- intersection_many_impl( - graphs = list(g1, g2, g3) - ) - expect_type(result, "list") - expect_s3_class(result$res, "igraph") -}) - -test_that("layout_merge_dla_impl basic", { - igraph_local_seed(20250909) - g1 <- path_graph_impl(n = 3) - g2 <- path_graph_impl(n = 3) - coords1 <- matrix(c(0, 0, 1, 0, 2, 0), ncol = 2, byrow = TRUE) - coords2 <- matrix(c(0, 1, 1, 1, 2, 1), ncol = 2, byrow = TRUE) - - expect_snapshot(layout_merge_dla_impl( - graphs = list(g1, g2), - coords = list(coords1, coords2) - )) - - # Structured tests - result <- layout_merge_dla_impl( - graphs = list(g1, g2), - coords = list(coords1, coords2) - ) - expect_true(is.matrix(result)) - expect_equal(nrow(result), 6) - expect_equal(ncol(result), 2) -}) - -# get_eid_impl -test_that("get_eid_impl basic", { - igraph_local_seed(20250909) - g <- add_edges_impl(empty_impl(n = 5), c(0, 1, 1, 2, 2, 3, 3, 4) + 1) - - expect_snapshot(get_eid_impl( - graph = g, - from = 1, - to = 2 - )) - - # Structured tests - result <- get_eid_impl( - graph = g, - from = 1, - to = 2 - ) - expect_s3_class(result, "igraph.es") - expect_length(result, 1) - - # Test that it finds the correct edge - result_int <- as.integer(result) - expect_equal(result_int, 1L) # First edge is 0->1 - - # Test directed vs undirected - result_directed <- get_eid_impl( - graph = g, - from = 2, - to = 1, - directed = TRUE, - error = FALSE - ) - # No edge from 2 to 1 in directed graph, returns empty edge sequence - expect_length(result_directed, 0) -}) - -test_that("get_eid_impl errors", { - igraph_local_seed(20250909) - g <- add_edges_impl(empty_impl(n = 3), c(0, 1, 1, 2) + 1) - - expect_snapshot_igraph_error(get_eid_impl( - graph = NULL, - from = 1, - to = 2 - )) - - # Test error when from or to is not exactly one vertex - expect_snapshot_igraph_error(get_eid_impl( - graph = g, - from = c(1, 2), - to = 2 - )) - - expect_snapshot_igraph_error(get_eid_impl( - graph = g, - from = 1, - to = integer(0) - )) -}) - -# community_voronoi_impl -test_that("community_voronoi_impl basic", { - igraph_local_seed(20250909) - g <- add_edges_impl( - empty_impl(n = 10), - c(0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9) + 1 - ) - - expect_snapshot(community_voronoi_impl( - graph = g - )) - - # Structured tests - result <- community_voronoi_impl( - graph = g - ) - expect_type(result, "list") - expect_named(result, c("membership", "generators", "modularity")) - expect_length(result$membership, 10) - expect_true(is.numeric(result$modularity)) - expect_true(length(result$generators) >= 1) -}) - -test_that("community_voronoi_impl errors", { - igraph_local_seed(20250909) - - expect_snapshot_igraph_error(community_voronoi_impl( - graph = NULL - )) -}) - -# subisomorphic_lad_impl -test_that("subisomorphic_lad_impl basic", { - igraph_local_seed(20250909) - - # FIXME: Add functionality tests once we understand the expected behavior - # The function requires complex setup with pattern/target graphs and domains - # For now, just verify the function exists and has correct signature - expect_true(is.function(subisomorphic_lad_impl)) - expect_named( - formals(subisomorphic_lad_impl), - c("pattern", "target", "domains", "induced", "time_limit") - ) -}) - -test_that("subisomorphic_lad_impl errors", { - igraph_local_seed(20250909) - g <- add_edges_impl(empty_impl(n = 3), c(0, 1, 1, 2) + 1) - - expect_snapshot_igraph_error(subisomorphic_lad_impl( - pattern = NULL, - target = g, - domains = list(), - induced = FALSE, - time_limit = 0 - )) - - # Test that domains must be a list - expect_snapshot_igraph_error(subisomorphic_lad_impl( - pattern = g, - target = g, - domains = "not a list", - induced = FALSE, - time_limit = 0 - )) -}) - -# eigen_matrix_impl -test_that("eigen_matrix_impl basic", { - igraph_local_seed(20250909) - - # FIXME: Add functionality tests once we understand the expected behavior - # The function requires complex matrix setup and understanding of eigenvalue computation - # For now, just verify the function exists and has correct signature - expect_true(is.function(eigen_matrix_impl)) - expect_named( - formals(eigen_matrix_impl), - c("A", "sA", "fun", "n", "algorithm", "which", "options") - ) -}) - -test_that("eigen_matrix_impl errors", { - igraph_local_seed(20250909) - - # Test with invalid matrix dimensions - expect_error(eigen_matrix_impl( - A = matrix(0, 0, 0), - sA = Matrix::Matrix(matrix(0, 0, 0), sparse = TRUE), - fun = NULL, - n = 0, - algorithm = "auto", - which = list(pos = "LM", howmany = 1) - )) -}) - -# eigen_matrix_symmetric_impl -test_that("eigen_matrix_symmetric_impl basic", { - igraph_local_seed(20250909) - - # FIXME: Add functionality tests once we understand the expected behavior - # The function requires complex matrix setup and understanding of eigenvalue computation - # For now, just verify the function exists and has correct signature - expect_true(is.function(eigen_matrix_symmetric_impl)) - expect_named( - formals(eigen_matrix_symmetric_impl), - c("A", "sA", "fun", "n", "algorithm", "which", "options") - ) -}) - -test_that("eigen_matrix_symmetric_impl errors", { - igraph_local_seed(20250909) - - # Test with invalid matrix dimensions - expect_error(eigen_matrix_symmetric_impl( - A = matrix(0, 0, 0), - sA = Matrix::Matrix(matrix(0, 0, 0), sparse = TRUE), - fun = NULL, - n = 0, - algorithm = "auto", - which = list(pos = "LM", howmany = 1) - )) -}) diff --git a/tests/testthat/test-aaa-basic-igraph.R b/tests/testthat/test-aaa-basic-igraph.R new file mode 100644 index 00000000000..0d171e553b0 --- /dev/null +++ b/tests/testthat/test-aaa-basic-igraph.R @@ -0,0 +1,472 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 1. empty_impl +test_that("empty_impl basic", { + igraph_local_seed(20250909) + + expect_snapshot(empty_impl()) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(empty_impl( + n = -1 + )) +}) + +# 2. add_edges_impl + +test_that("add_edges_impl basic", { + igraph_local_seed(20250909) + g <- empty_impl( + n = 3 + ) + + expect_snapshot(add_edges_impl( + graph = g, + edges = c(1, 2, 2, 3) + )) + + # Structured tests + result <- add_edges_impl( + graph = g, + edges = c(1, 2, 2, 3) + ) + expect_s3_class(result, "igraph") + expect_equal(vcount(result), 3) + expect_equal(ecount(result), 2) +}) + +test_that("add_edges_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(add_edges_impl( + graph = NULL, + edges = c(1, 2) + )) +}) + +# 3. copy_impl + +test_that("copy_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(copy_impl( + from = NULL + )) +}) + +# 4. delete_vertices_idx_impl + +test_that("delete_vertices_idx_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(delete_vertices_idx_impl( + graph = NULL, + vertices = 1 + )) +}) + +# 5. vcount_impl + +test_that("vcount_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(vcount_impl( + graph = NULL + )) +}) + +# 6. degree_impl + +test_that("degree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(degree_impl( + graph = NULL + )) +}) + +# 7. get_all_eids_between_impl + +test_that("get_all_eids_between_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_all_eids_between_impl( + graph = NULL, + from = 1, + to = 2 + )) +}) + +# 331. invalidate_cache_impl + +test_that("invalidate_cache_impl basic", { + igraph_local_seed(12345) + 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", { + igraph_local_seed(12345) + expect_snapshot_igraph_error(invalidate_cache_impl( + graph = NULL + )) +}) + +# 334. ecount_impl + +test_that("ecount_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(ecount_impl( + graph = NULL + )) +}) + +# 335. is_directed_impl + +test_that("is_directed_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_directed_impl( + graph = NULL + )) +}) + +# 336. edges_impl + +test_that("edges_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(edges_impl( + graph = NULL, + eids = 1 + )) +}) + +# 337. add_vertices_impl + +test_that("add_vertices_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(add_vertices_impl( + graph = NULL, + nv = 1 + )) +}) + +# 338. delete_edges_impl + +test_that("delete_edges_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(delete_edges_impl( + graph = NULL, + edges = 1 + )) +}) + +# 339. delete_vertices_impl + +test_that("delete_vertices_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(delete_vertices_impl( + graph = NULL, + vertices = 1 + )) +}) + +# 340. incident_impl + +test_that("incident_impl basic", { + igraph_local_seed(20250909) + local_igraph_options(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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(incident_impl( + graph = NULL, + vid = 1 + )) +}) + +# get_eid_impl +test_that("get_eid_impl basic", { + igraph_local_seed(20250909) + g <- add_edges_impl(empty_impl(n = 5), c(0, 1, 1, 2, 2, 3, 3, 4) + 1) + + expect_snapshot(get_eid_impl( + graph = g, + from = 1, + to = 2 + )) + + # Structured tests + result <- get_eid_impl( + graph = g, + from = 1, + to = 2 + ) + expect_s3_class(result, "igraph.es") + expect_length(result, 1) + + # Test that it finds the correct edge + result_int <- as.integer(result) + expect_equal(result_int, 1L) # First edge is 0->1 + + # Test directed vs undirected + result_directed <- get_eid_impl( + graph = g, + from = 2, + to = 1, + directed = TRUE, + error = FALSE + ) + # No edge from 2 to 1 in directed graph, returns empty edge sequence + expect_length(result_directed, 0) +}) + +test_that("get_eid_impl errors", { + igraph_local_seed(20250909) + g <- add_edges_impl(empty_impl(n = 3), c(0, 1, 1, 2) + 1) + + expect_snapshot_igraph_error(get_eid_impl( + graph = NULL, + from = 1, + to = 2 + )) + + # Test error when from or to is not exactly one vertex + expect_snapshot_igraph_error(get_eid_impl( + graph = g, + from = c(1, 2), + to = 2 + )) + + expect_snapshot_igraph_error(get_eid_impl( + graph = g, + from = 1, + to = integer(0) + )) +}) diff --git a/tests/testthat/test-aaa-bipartite.R b/tests/testthat/test-aaa-bipartite.R new file mode 100644 index 00000000000..852a758b85d --- /dev/null +++ b/tests/testthat/test-aaa-bipartite.R @@ -0,0 +1,244 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 26. full_bipartite_impl +test_that("full_bipartite_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(full_bipartite_impl( + n1 = -1, + n2 = 3 + )) +}) + +# 165. bipartite_projection_size_impl + +test_that("bipartite_projection_size_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 4 + ) + + V(g)$type <- c(TRUE, FALSE, TRUE, FALSE) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(bipartite_projection_size_impl( + graph = NULL + )) +}) + +# 166. biadjacency_impl + +test_that("biadjacency_impl basic", { + igraph_local_seed(20250909) + m <- matrix(c(1, 0, 1, 0, 1, 1), nrow = 2) + expect_snapshot(biadjacency_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(biadjacency_impl( + incidence = "a" + )) +}) + +# 167. get_biadjacency_impl + +test_that("get_biadjacency_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + get_biadjacency_impl( + graph = NULL, + types = c(TRUE, FALSE, TRUE) + ) + ) +}) + +# 168. is_bipartite_impl + +test_that("is_bipartite_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_bipartite_impl( + graph = NULL + )) +}) + +# 169. bipartite_game_gnp_impl + +test_that("bipartite_game_gnp_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(bipartite_game_gnp_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(bipartite_game_gnp_impl( + n1 = -1, + n2 = 2, + p = 0.5 + )) +}) + +# 170. bipartite_game_gnm_impl + +test_that("bipartite_game_gnm_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(bipartite_game_gnm_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(bipartite_game_gnm_impl( + n1 = -1, + n2 = 2, + m = 1 + )) +}) + +# Bipartite functions + +test_that("create_bipartite_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(create_bipartite_impl( + types = c(FALSE, FALSE, TRUE, TRUE), + edges = c(0, 2, 0, 3, 1, 2, 1, 3), + directed = FALSE + )) +}) + +test_that("bipartite_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(bipartite_game_impl( + type = "gnp", + n1 = 5, + n2 = 5, + p = 0.3, + directed = FALSE + )) + expect_snapshot(bipartite_game_impl( + type = "gnm", + n1 = 5, + n2 = 5, + m = 10, + directed = FALSE + )) +}) diff --git a/tests/testthat/test-aaa-centrality.R b/tests/testthat/test-aaa-centrality.R new file mode 100644 index 00000000000..5038f7bcfb1 --- /dev/null +++ b/tests/testthat/test-aaa-centrality.R @@ -0,0 +1,780 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 56. closeness_impl + +test_that("closeness_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(closeness_impl( + graph = NULL + )) +}) + +# 57. closeness_cutoff_impl + +test_that("closeness_cutoff_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(closeness_cutoff_impl( + graph = g, + cutoff = 2 + )) + expect_snapshot(closeness_cutoff_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(closeness_cutoff_impl( + graph = NULL + )) +}) + +# 71. betweenness_cutoff_impl + +test_that("betweenness_cutoff_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(betweenness_cutoff_impl( + graph = NULL, + cutoff = 2 + )) +}) + +# 72. betweenness_subset_impl + +test_that("betweenness_subset_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(betweenness_subset_impl( + graph = NULL + )) +}) + +# 73. edge_betweenness_impl + +test_that("edge_betweenness_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(edge_betweenness_impl( + graph = NULL + )) +}) + +# 74. edge_betweenness_cutoff_impl + +test_that("edge_betweenness_cutoff_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(edge_betweenness_cutoff_impl( + graph = NULL, + cutoff = 2 + )) +}) + +# 75. edge_betweenness_subset_impl + +test_that("edge_betweenness_subset_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(edge_betweenness_subset_impl( + graph = NULL + )) +}) + +# 76. harmonic_centrality_cutoff_impl + +test_that("harmonic_centrality_cutoff_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + harmonic_centrality_cutoff_impl( + graph = NULL, + cutoff = 2 + ) + ) +}) + +# 77. personalized_pagerank_impl + +test_that("personalized_pagerank_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(personalized_pagerank_impl( + graph = NULL + )) +}) + +# 78. personalized_pagerank_vs_impl + +test_that("personalized_pagerank_vs_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(personalized_pagerank_vs_impl( + graph = g, + reset_vids = 1 + )) + expect_snapshot(personalized_pagerank_vs_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + personalized_pagerank_vs_impl( + graph = NULL, + reset_vids = 1 + ) + ) +}) + +# 109. maxdegree_impl + +test_that("maxdegree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(maxdegree_impl( + graph = NULL + )) +}) + +# 124. eigenvector_centrality_impl + +test_that("eigenvector_centrality_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(eigenvector_centrality_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(eigenvector_centrality_impl( + graph = NULL + )) +}) + +# 125. hub_and_authority_scores_impl + +test_that("hub_and_authority_scores_impl basic", { + igraph_local_seed(20250909) + g <- make_full_graph(5) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(hub_and_authority_scores_impl( + graph = NULL + )) +}) + +# 133. strength_impl + +test_that("strength_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(strength_impl( + graph = NULL + )) +}) + +# 134. centralization_impl + +test_that("centralization_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(centralization_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(centralization_impl( + scores = package_version("1.2.3") + )) +}) + +# 135. centralization_degree_impl + +test_that("centralization_degree_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(centralization_degree_impl( + graph = g + )) + expect_snapshot(centralization_degree_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(centralization_degree_impl( + graph = NULL + )) +}) + +# 136. centralization_degree_tmax_impl + +test_that("centralization_degree_tmax_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + centralization_degree_tmax_impl( + nodes = -1, + loops = TRUE + ) + ) +}) + +# 137. centralization_betweenness_impl + +test_that("centralization_betweenness_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(centralization_betweenness_impl( + graph = g + )) + expect_snapshot(centralization_betweenness_impl( + graph = g, + directed = FALSE, + normalized = FALSE + )) + + # Structured tests + result <- centralization_betweenness_impl( + graph = g + ) + expect_type(result, "list") +}) + +test_that("centralization_betweenness_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(centralization_betweenness_impl( + graph = NULL + )) +}) + +# 138. centralization_betweenness_tmax_impl + +test_that("centralization_betweenness_tmax_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(centralization_betweenness_tmax_impl( + nodes = 3, + directed = TRUE + )) + expect_snapshot(centralization_betweenness_tmax_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + centralization_betweenness_tmax_impl( + nodes = -1, + directed = TRUE + ) + ) +}) + +# 139. centralization_closeness_impl + +test_that("centralization_closeness_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(centralization_closeness_impl( + graph = g + )) + expect_snapshot(centralization_closeness_impl( + graph = g, + mode = "in", + normalized = FALSE + )) + + # Structured tests + result <- centralization_closeness_impl( + graph = g + ) + expect_type(result, "list") +}) + +test_that("centralization_closeness_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(centralization_closeness_impl( + graph = NULL + )) +}) + +# 140. centralization_closeness_tmax_impl + +test_that("centralization_closeness_tmax_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(centralization_closeness_tmax_impl( + nodes = -1 + )) +}) + +# 141. centralization_eigenvector_centrality_impl + +test_that("centralization_eigenvector_centrality_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(centralization_eigenvector_centrality_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + centralization_eigenvector_centrality_impl( + graph = NULL + ) + ) +}) + +# 142. centralization_eigenvector_centrality_tmax_impl + +test_that("centralization_eigenvector_centrality_tmax_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + centralization_eigenvector_centrality_tmax_impl( + nodes = -1 + ) + ) +}) + +# 342. constraint_impl + +test_that("constraint_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(constraint_impl( + graph = NULL + )) +}) + +# Centrality measures + +test_that("betweenness_impl basic", { + igraph_local_seed(20250909) + g <- make_star(5, mode = "undirected") + expect_snapshot(betweenness_impl(graph = g, vids = V(g), directed = FALSE)) +}) + +test_that("closeness_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(closeness_impl( + graph = g, + vids = V(g), + mode = c("out", "in", "all", "total") + )) +}) + +test_that("harmonic_centrality_impl basic", { + igraph_local_seed(20250909) + g <- make_star(5, mode = "undirected") + expect_snapshot(harmonic_centrality_impl( + graph = g, + vids = V(g), + mode = c("out", "in", "all", "total") + )) +}) + +test_that("pagerank_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5, directed = TRUE) + expect_snapshot(pagerank_impl( + graph = g, + vids = V(g), + directed = TRUE, + damping = 0.85 + )) +}) + +test_that("hub_score_impl basic", { + igraph_local_seed(20250909) + g <- make_star(5, mode = "undirected") + out <- hub_score_impl(graph = g, scale = TRUE, weights = NULL) + # FIXME: out$vector unstable despite random seed + expect_length(out$vector, 5) + expect_type(out$vector, "double") + out$vector <- NULL + expect_snapshot(out) +}) + +test_that("authority_score_impl basic", { + igraph_local_seed(20250909) + g <- make_star(5, mode = "undirected") + out <- authority_score_impl(graph = g, scale = TRUE, weights = NULL) + # FIXME: out$vector unstable despite random seed + expect_length(out$vector, 5) + expect_type(out$vector, "double") + out$vector <- NULL + expect_snapshot(out) +}) + +# Additional centrality + +test_that("edge_betweenness_impl basic", { + igraph_local_seed(20250909) + g <- make_star(5, mode = "undirected") + expect_snapshot(edge_betweenness_impl(graph = g, directed = FALSE)) +}) diff --git a/tests/testthat/test-aaa-cliques.R b/tests/testthat/test-aaa-cliques.R new file mode 100644 index 00000000000..a048e9b185b --- /dev/null +++ b/tests/testthat/test-aaa-cliques.R @@ -0,0 +1,452 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 183. is_clique_impl + +test_that("is_clique_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_clique_impl( + graph = NULL, + candidate = 1:2 + )) +}) + +# 184. cliques_impl + +test_that("cliques_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(cliques_impl( + graph = NULL + )) +}) + +# 185. clique_size_hist_impl + +test_that("clique_size_hist_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(clique_size_hist_impl( + graph = NULL + )) +}) + +# 186. largest_cliques_impl + +test_that("largest_cliques_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(largest_cliques_impl( + graph = NULL + )) +}) + +# 187. maximal_cliques_hist_impl + +test_that("maximal_cliques_hist_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(maximal_cliques_hist_impl( + graph = NULL + )) +}) + +# 188. clique_number_impl + +test_that("clique_number_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(clique_number_impl( + graph = NULL + )) +}) + +# 189. weighted_cliques_impl + +test_that("weighted_cliques_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(weighted_cliques_impl( + graph = g + )) + expect_snapshot(weighted_cliques_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(weighted_cliques_impl( + graph = NULL + )) +}) + +# 190. largest_weighted_cliques_impl + +test_that("largest_weighted_cliques_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(largest_weighted_cliques_impl( + graph = NULL + )) +}) + +# 191. weighted_clique_number_impl + +test_that("weighted_clique_number_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(weighted_clique_number_impl( + graph = NULL + )) +}) + +# 192. is_independent_vertex_set_impl + +test_that("is_independent_vertex_set_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_independent_vertex_set_impl( + graph = NULL, + candidate = 1:2 + )) +}) + +# 319. is_complete_impl + +test_that("is_complete_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_complete_impl( + graph = NULL + )) +}) + +# Maximal cliques + +test_that("maximal_cliques_impl basic", { + igraph_local_seed(20250909) + g <- make_full_graph(4) + expect_snapshot(maximal_cliques_impl(graph = g, min_size = 1, max_size = 0)) +}) + +test_that("independent_vertex_sets_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(independent_vertex_sets_impl( + graph = g, + min_size = 1, + max_size = 0 + )) +}) + +# cliques_callback_closure_impl + +test_that("cliques_callback_closure_impl basic", { + igraph_local_seed(20250909) + + g <- make_full_graph(4) + + # Collect clique information for snapshot + clique_data <- list() + result <- cliques_callback_closure_impl( + graph = g, + min_size = 3, + max_size = 4, + callback = function(clique) { + clique_data[[length(clique_data) + 1]] <<- clique + FALSE # Continue + } + ) + + expect_snapshot({ + cat("Result:\n") + print(result) + cat("\nNumber of cliques found:", length(clique_data), "\n") + cat("First clique:\n") + print(clique_data[[1]]) + }) + + # Structured tests + expect_null(result) + expect_true(length(clique_data) > 0) + expect_type(clique_data[[1]], "integer") + expect_true(length(clique_data[[1]]) >= 3) + expect_true(length(clique_data[[1]]) <= 4) +}) + +test_that("cliques_callback_closure_impl errors", { + igraph_local_seed(20250909) + + g <- make_full_graph(4) + + # Should error if callback is not a function + expect_snapshot_igraph_error( + cliques_callback_closure_impl( + graph = g, + min_size = 3, + max_size = 4, + callback = "not a function" + ) + ) +}) + +# maximal_cliques_callback_closure_impl + +test_that("maximal_cliques_callback_closure_impl basic", { + igraph_local_seed(20250909) + + g <- sample_gnp(10, 0.3) + + # Collect clique information for snapshot + clique_data <- list() + result <- maximal_cliques_callback_closure_impl( + graph = g, + min_size = 3, + max_size = 0, + callback = function(clique) { + clique_data[[length(clique_data) + 1]] <<- clique + if (length(clique_data) >= 3) { + return(TRUE) # Stop after 3 + } + FALSE # Continue + } + ) + + expect_snapshot({ + cat("Result:\n") + print(result) + cat("\nNumber of maximal cliques found:", length(clique_data), "\n") + if (length(clique_data) > 0) { + cat("First maximal clique:\n") + print(clique_data[[1]]) + } + }) + + # Structured tests + expect_null(result) + expect_type(clique_data[[1]], "integer") + expect_true(length(clique_data[[1]]) >= 3) +}) + +test_that("maximal_cliques_callback_closure_impl errors", { + igraph_local_seed(20250909) + + g <- make_full_graph(4) + + # Should error if callback is not a function + expect_snapshot_igraph_error( + maximal_cliques_callback_closure_impl( + graph = g, + min_size = 3, + max_size = 0, + callback = "not a function" + ) + ) +}) diff --git a/tests/testthat/test-aaa-coloring.R b/tests/testthat/test-aaa-coloring.R new file mode 100644 index 00000000000..433be339480 --- /dev/null +++ b/tests/testthat/test-aaa-coloring.R @@ -0,0 +1,163 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 123. is_perfect_impl + +test_that("is_perfect_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_perfect_impl( + graph = NULL + )) +}) + +# 322. vertex_coloring_greedy_impl + +test_that("vertex_coloring_greedy_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(vertex_coloring_greedy_impl( + graph = NULL + )) +}) + +# 323. is_vertex_coloring_impl + +test_that("is_vertex_coloring_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + is_vertex_coloring_impl( + graph = NULL, + types = c(1, 2, 3) + ) + ) +}) + +# 324. is_bipartite_coloring_impl + +# test_that("is_bipartite_coloring_impl basic", { +# igraph_local_seed(20250909) +# oldval <- igraph_opt("print.id") +# igraph_options(print.id = FALSE) +# g <- path_graph_impl(3) +# expect_snapshot(is_bipartite_coloring_impl(g, types = c(TRUE, FALSE, TRUE))) +#}) + +# 325. is_bipartite_coloring_impl + +test_that("is_bipartite_coloring_impl basic", { + igraph_local_seed(12345) + 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", { + igraph_local_seed(12345) + expect_snapshot_igraph_error( + is_bipartite_coloring_impl( + graph = NULL, + types = c(TRUE, FALSE, TRUE) + ) + ) +}) + +# 326. is_edge_coloring_impl + +test_that("is_edge_coloring_impl basic", { + igraph_local_seed(12345) + g <- path_graph_impl( + n = 3 + ) + + E(g)$color <- c(1, 2) + 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", { + igraph_local_seed(12345) + expect_snapshot_igraph_error(is_edge_coloring_impl( + graph = NULL, + types = c(1, 2) + )) +}) diff --git a/tests/testthat/test-aaa-community.R b/tests/testthat/test-aaa-community.R new file mode 100644 index 00000000000..36d0b79b0bb --- /dev/null +++ b/tests/testthat/test-aaa-community.R @@ -0,0 +1,456 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 217. compare_communities_impl + +test_that("compare_communities_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(compare_communities_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(compare_communities_impl( + comm1 = "a", + comm2 = c(2, 1, 2) + )) +}) + +# 218. modularity_impl + +test_that("modularity_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(modularity_impl( + graph = g, + membership = c(1, 2, 1) + )) + expect_snapshot(modularity_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(modularity_impl( + graph = NULL, + membership = c(1, 2, 1) + )) +}) + +# 219. modularity_matrix_impl + +test_that("modularity_matrix_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(modularity_matrix_impl( + graph = g + )) + expect_snapshot(modularity_matrix_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(modularity_matrix_impl( + graph = NULL + )) +}) + +# 220. community_fluid_communities_impl + +test_that("community_fluid_communities_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + community_fluid_communities_impl( + graph = NULL, + no_of_communities = 2 + ) + ) +}) + +# 221. community_label_propagation_impl + +test_that("community_label_propagation_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(community_label_propagation_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(community_label_propagation_impl( + graph = NULL + )) +}) + +# 222. community_multilevel_impl + +test_that("community_multilevel_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(community_multilevel_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(community_multilevel_impl( + graph = NULL + )) +}) + +# 223. community_optimal_modularity_impl + +test_that("community_optimal_modularity_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(community_optimal_modularity_impl( + graph = NULL + )) +}) + +# 224. community_leiden_impl + +test_that("community_leiden_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(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 + )) + + # 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(community_leiden_impl( + graph = NULL, + resolution = 1 + )) +}) + +# 225. split_join_distance_impl + +test_that("split_join_distance_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(split_join_distance_impl( + comm1 = "a", + comm2 = c(2, 1, 2) + )) +}) + +# 226. community_infomap_impl + +test_that("community_infomap_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(community_infomap_impl( + graph = g + )) + expect_snapshot(community_infomap_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(community_infomap_impl( + graph = NULL + )) +}) + +# Community detection + +test_that("community_walktrap_impl basic", { + igraph_local_seed(20250909) + g <- make_graph(~ A-B-C-A, D-E-F-D, A-D) + expect_snapshot(community_walktrap_impl(graph = g, steps = 4)) +}) + +test_that("community_fastgreedy_impl basic", { + igraph_local_seed(20250909) + g <- make_graph(~ A-B-C-A, D-E-F-D, A-D) + expect_snapshot(community_fastgreedy_impl(graph = g)) +}) + +test_that("community_edge_betweenness_impl basic", { + igraph_local_seed(20250909) + g <- make_graph(~ A-B-C-A, D-E-F-D, A-D) + expect_snapshot(community_edge_betweenness_impl(graph = g, directed = FALSE)) +}) + +test_that("community_leading_eigenvector_callback_closure_impl basic", { + igraph_local_seed(20250909) + + # Test with a simple graph + g <- make_graph("Zachary") + result <- community_leading_eigenvector_callback_closure_impl( + graph = g + ) + + expect_snapshot({ + cat("Result class:\n") + print(class(result)) + cat("\nMembership length:\n") + print(length(result$membership)) + cat("\nModularity:\n") + print(result$modularity) + cat("\nMerges dimensions:\n") + print(dim(result$merges)) + }) + + # Structured tests + expect_s3_class(result, "igraph.eigenc") + expect_type(result, "list") + expect_true("membership" %in% names(result)) + expect_true("modularity" %in% names(result)) + expect_true("merges" %in% names(result)) + expect_length(result$membership, vcount(g)) + expect_true(is.numeric(result$modularity)) +}) + +test_that("community_leading_eigenvector_callback_closure_impl with start", { + igraph_local_seed(20250909) + + g <- make_graph("Zachary") + # Create initial membership (0-based for the impl function) + initial_membership <- rep(0:1, length.out = vcount(g)) + + result <- community_leading_eigenvector_callback_closure_impl( + graph = g, + membership = initial_membership, + start = TRUE + ) + + expect_snapshot({ + cat("Result with start membership:\n") + cat("Membership length:\n") + print(length(result$membership)) + cat("\nModularity:\n") + print(result$modularity) + }) + + expect_s3_class(result, "igraph.eigenc") + expect_length(result$membership, vcount(g)) +}) + +test_that("community_leading_eigenvector_callback_closure_impl errors", { + igraph_local_seed(20250909) + + g <- make_graph("Zachary") + + # Test with invalid steps + expect_snapshot_igraph_error( + community_leading_eigenvector_callback_closure_impl( + graph = g, + start = TRUE + ) + ) +}) + +# Utility functions + +test_that("compare_communities_impl basic", { + igraph_local_seed(20250909) + comm1 <- c(1, 1, 2, 2, 3, 3) + comm2 <- c(1, 1, 2, 2, 2, 3) + expect_snapshot(compare_communities_impl( + comm1 = comm1, + comm2 = comm2, + method = "vi" + )) +}) + +# community_voronoi_impl +test_that("community_voronoi_impl basic", { + igraph_local_seed(20250909) + g <- add_edges_impl( + empty_impl(n = 10), + c(0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9) + 1 + ) + + expect_snapshot(community_voronoi_impl( + graph = g + )) + + # Structured tests + result <- community_voronoi_impl( + graph = g + ) + expect_type(result, "list") + expect_named(result, c("membership", "generators", "modularity")) + expect_length(result$membership, 10) + expect_true(is.numeric(result$modularity)) + expect_true(length(result$generators) >= 1) +}) + +test_that("community_voronoi_impl errors", { + igraph_local_seed(20250909) + + expect_snapshot_igraph_error(community_voronoi_impl( + graph = NULL + )) +}) diff --git a/tests/testthat/test-aaa-cycles.R b/tests/testthat/test-aaa-cycles.R new file mode 100644 index 00000000000..a9201fe2b95 --- /dev/null +++ b/tests/testthat/test-aaa-cycles.R @@ -0,0 +1,381 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 112. feedback_arc_set_impl + +test_that("feedback_arc_set_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(feedback_arc_set_impl( + graph = NULL + )) +}) + +# 113. feedback_vertex_set_impl + +test_that("feedback_vertex_set_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(feedback_vertex_set_impl( + graph = NULL + )) +}) + +# 115. is_dag_impl + +test_that("is_dag_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_dag_impl( + graph = NULL + )) +}) + +# 116. is_acyclic_impl + +test_that("is_acyclic_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_acyclic_impl( + graph = NULL + )) +}) + +# 307. find_cycle_impl + +test_that("find_cycle_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(find_cycle_impl( + graph = NULL + )) +}) + +# 308. simple_cycles_impl + +test_that("simple_cycles_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(simple_cycles_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(simple_cycles_impl( + graph = NULL + )) +}) + +# 309. is_eulerian_impl + +test_that("is_eulerian_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_eulerian_impl( + graph = NULL + )) +}) + +# 310. eulerian_path_impl + +test_that("eulerian_path_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(eulerian_path_impl( + graph = NULL + )) +}) + +# 311. eulerian_cycle_impl + +test_that("eulerian_cycle_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(eulerian_cycle_impl( + graph = NULL + )) +}) + +# 312. fundamental_cycles_impl + +test_that("fundamental_cycles_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(fundamental_cycles_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(fundamental_cycles_impl( + graph = NULL, + start = 1 + )) +}) + +# 313. minimum_cycle_basis_impl + +test_that("minimum_cycle_basis_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(minimum_cycle_basis_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(minimum_cycle_basis_impl( + graph = NULL + )) +}) + +# simple_cycles_callback_closure_impl + +test_that("simple_cycles_callback_closure_impl basic", { + igraph_local_seed(20250909) + + g <- make_ring(4, directed = TRUE) + + # Collect cycle information for snapshot + cycle_data <- list() + result <- simple_cycles_callback_closure_impl( + graph = g, + mode = "out", + min_cycle_length = -1, + max_cycle_length = -1, + callback = function(vertices, edges) { + cycle_data[[length(cycle_data) + 1]] <<- list( + vertices = vertices, + edges = edges + ) + FALSE # Continue + } + ) + + expect_snapshot({ + cat("Result:\n") + print(result) + cat("\nNumber of cycles found:", length(cycle_data), "\n") + cat("First cycle:\n") + print(cycle_data[[1]]) + }) + + # Structured tests + expect_null(result) + expect_true(length(cycle_data) > 0) + expect_type(cycle_data[[1]]$vertices, "integer") + expect_type(cycle_data[[1]]$edges, "integer") + expect_equal(length(cycle_data[[1]]$vertices), length(cycle_data[[1]]$edges)) +}) + +test_that("simple_cycles_callback_closure_impl errors", { + igraph_local_seed(20250909) + + g <- make_ring(4, directed = TRUE) + + # Should error if callback is not a function + expect_snapshot_igraph_error( + simple_cycles_callback_closure_impl( + graph = g, + mode = "out", + min_cycle_length = -1, + max_cycle_length = -1, + callback = "not a function" + ) + ) +}) diff --git a/tests/testthat/test-aaa-embedding.R b/tests/testthat/test-aaa-embedding.R new file mode 100644 index 00000000000..8e98127cf68 --- /dev/null +++ b/tests/testthat/test-aaa-embedding.R @@ -0,0 +1,91 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 299. adjacency_spectral_embedding_impl + +test_that("adjacency_spectral_embedding_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(adjacency_spectral_embedding_impl( + graph = g, + no = 2 + )) + expect_snapshot(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) + )) + + # Structured tests + result <- adjacency_spectral_embedding_impl( + graph = g, + no = 2 + ) + expect_type(result, "list") +}) + +test_that("adjacency_spectral_embedding_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(adjacency_spectral_embedding_impl( + graph = NULL, + no = 2 + )) +}) + +# 300. laplacian_spectral_embedding_impl + +test_that("laplacian_spectral_embedding_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(laplacian_spectral_embedding_impl( + graph = NULL, + no = 2 + )) +}) + +# 305. dim_select_impl + +test_that("dim_select_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(dim_select_impl( + sv = NULL + )) +}) diff --git a/tests/testthat/test-aaa-flows.R b/tests/testthat/test-aaa-flows.R new file mode 100644 index 00000000000..a0113091b01 --- /dev/null +++ b/tests/testthat/test-aaa-flows.R @@ -0,0 +1,299 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 264. gomory_hu_tree_impl + +test_that("gomory_hu_tree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(gomory_hu_tree_impl( + graph = NULL + )) +}) + +# 265. maxflow_impl + +test_that("maxflow_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(maxflow_impl( + graph = NULL, + source = 1, + target = 3 + )) +}) + +# 266. residual_graph_impl + +test_that("residual_graph_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + residual_graph_impl( + graph = NULL, + capacity = c(1, 2), + flow = c(1, 2) + ) + ) +}) + +# 267. reverse_residual_graph_impl + +test_that("reverse_residual_graph_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(reverse_residual_graph_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + reverse_residual_graph_impl( + graph = NULL, + capacity = c(1, 2), + flow = c(1, 2) + ) + ) +}) + +# 268. st_mincut_impl + +test_that("st_mincut_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(st_mincut_impl( + graph = NULL, + source = 1, + target = 3 + )) +}) + +# 269. dominator_tree_impl + +test_that("dominator_tree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(dominator_tree_impl( + graph = NULL, + root = 1 + )) +}) + +# 270. all_st_cuts_impl + +test_that("all_st_cuts_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(all_st_cuts_impl( + graph = NULL, + source = 1, + target = 3 + )) +}) + +# 271. all_st_mincuts_impl + +test_that("all_st_mincuts_impl basic", { + igraph_local_seed(20250909) + 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( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + all_st_mincuts_impl( + graph = NULL, + source = 1, + target = 3 + ) + ) +}) + +# Connectivity + +test_that("edge_connectivity_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(edge_connectivity_impl(graph = g)) +}) + +test_that("vertex_connectivity_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(vertex_connectivity_impl(graph = g)) +}) diff --git a/tests/testthat/test-aaa-foreign.R b/tests/testthat/test-aaa-foreign.R new file mode 100644 index 00000000000..86eeeb78a77 --- /dev/null +++ b/tests/testthat/test-aaa-foreign.R @@ -0,0 +1,26 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# IO functions + +test_that("write_graph_edgelist_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(3) + tmp <- tempfile() + write_graph_edgelist_impl(graph = g, outstream = tmp) + content <- readLines(tmp) + unlink(tmp) + expect_snapshot(content) +}) + +test_that("read_graph_edgelist_impl basic", { + igraph_local_seed(20250909) + tmp <- tempfile() + writeLines(c("0 1", "1 2", "2 0"), tmp) + expect_snapshot(read_graph_edgelist_impl( + instream = tmp, + n = 3, + directed = FALSE + )) + unlink(tmp) +}) diff --git a/tests/testthat/test-aaa-games.R b/tests/testthat/test-aaa-games.R new file mode 100644 index 00000000000..7147eb98486 --- /dev/null +++ b/tests/testthat/test-aaa-games.R @@ -0,0 +1,790 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 33. erdos_renyi_game_gnp_impl +test_that("erdos_renyi_game_gnp_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(erdos_renyi_game_gnp_impl( + 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", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot(erdos_renyi_game_gnm_impl( + 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", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot(growing_random_game_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(growing_random_game_impl( + n = -1, + m = 2 + )) +}) + +# 36. preference_game_impl +test_that("preference_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(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) + )) + + # 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + preference_game_impl( + 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) + ) + ) +}) + +# 37. asymmetric_preference_game_impl +test_that("asymmetric_preference_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(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) + )) + + # 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + asymmetric_preference_game_impl( + 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) + ) + ) +}) + +# 38. rewire_edges_impl +test_that("rewire_edges_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(rewire_edges_impl( + graph = NULL, + prob = 0.5 + )) +}) + +# 39. rewire_directed_edges_impl +test_that("rewire_directed_edges_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot(forest_fire_game_impl( + 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", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + simple_interconnected_islands_game_impl( + islands_n = -1, + islands_size = 3, + islands_pin = 0.5, + n_inter = 1 + ) + ) +}) + +# 42. chung_lu_game_impl +test_that("chung_lu_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(chung_lu_game_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(chung_lu_game_impl( + out_weights = -1 + )) +}) + +# 43. static_fitness_game_impl +test_that("static_fitness_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(static_fitness_game_impl( + 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", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot(static_power_law_game_impl( + 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", { + igraph_local_seed(20250909) + 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 + +test_that("k_regular_game_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(k_regular_game_impl( + no_of_nodes = -1, + k = 2 + )) +}) + +# 46. sbm_game_impl + +test_that("sbm_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(sbm_game_impl( + 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", { + igraph_local_seed(20250909) + 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 + +test_that("hsbm_game_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + hsbm_game_impl( + n = -1, + m = 2, + rho = 0.5, + C = matrix(1, 2, 2), + p = 0.5 + ) + ) +}) + +# 48. hsbm_list_game_impl + +test_that("hsbm_list_game_impl basic", { + igraph_local_seed(20250909) + C <- matrix( + c( + 1, + 3 / 4, + 0, + 3 / 4, + 0, + 3 / 4, + 0, + 3 / 4, + 3 / 4 + ), + nrow = 3 + ) + expect_snapshot(hsbm_list_game_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + hsbm_list_game_impl( + 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 + ) + ) +}) + +# 49. correlated_game_impl + +test_that("correlated_game_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 5 + ) + + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(correlated_game_impl( + old_graph = NULL, + corr = 0.5 + )) +}) + +# 50. correlated_pair_game_impl + +test_that("correlated_pair_game_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(correlated_pair_game_impl( + n = -1, + corr = 0.5, + p = 0.5 + )) +}) + +# 51. dot_product_game_impl + +test_that("dot_product_game_impl basic", { + igraph_local_seed(20250909) + 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, 0.2, 1) + ) + expect_s3_class(result, "igraph") +}) + +test_that("dot_product_game_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(dot_product_game_impl( + vecs = NULL + )) +}) + +# 52. sample_sphere_surface_impl + +test_that("sample_sphere_surface_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(sample_sphere_surface_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(sample_sphere_surface_impl( + dim = -1, + n = 5 + )) +}) + +# 53. sample_sphere_volume_impl + +test_that("sample_sphere_volume_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(sample_sphere_volume_impl( + dim = -1, + n = 5 + )) +}) + +# 54. sample_dirichlet_impl + +test_that("sample_dirichlet_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(sample_dirichlet_impl( + n = -1, + alpha = c(1, 1, 1) + )) +}) + +# 321. tree_game_impl + +test_that("tree_game_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(tree_game_impl( + n = "a" + )) +}) + +# Random graph generators + +test_that("barabasi_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(barabasi_game_impl( + n = 10, + power = 1, + m = 2, + directed = FALSE, + algo = "bag" + )) + expect_snapshot(barabasi_game_impl( + n = 10, + power = 1, + m = 2, + directed = FALSE, + algo = "psumtree" + )) +}) + +test_that("growing_random_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(growing_random_game_impl( + n = 10, + m = 1, + directed = TRUE, + citation = FALSE + )) +}) + +test_that("grg_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(grg_game_impl(nodes = 10, radius = 0.3, torus = FALSE)) +}) + +test_that("watts_strogatz_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(watts_strogatz_game_impl( + dim = 1, + size = 10, + nei = 2, + p = 0.1 + )) +}) + +# Additional game functions + +test_that("degree_sequence_game_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(degree_sequence_game_impl( + out_deg = c(2, 2, 2, 2), + method = "configuration" + )) + expect_snapshot(degree_sequence_game_impl( + out_deg = c(2, 2, 2, 2), + method = "vl" + )) +}) diff --git a/tests/testthat/test-aaa-generators.R b/tests/testthat/test-aaa-generators.R new file mode 100644 index 00000000000..355135ae848 --- /dev/null +++ b/tests/testthat/test-aaa-generators.R @@ -0,0 +1,852 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 8. wheel_impl + +test_that("wheel_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(wheel_impl( + n = -1 + )) +}) + +# 9. hypercube_impl + +test_that("hypercube_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(hypercube_impl( + n = 10000 + )) +}) + +# 10. square_lattice_impl + +test_that("square_lattice_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(square_lattice_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(square_lattice_impl( + dimvector = -1 + )) +}) + +# 11. triangular_lattice_impl + +test_that("triangular_lattice_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(triangular_lattice_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(triangular_lattice_impl( + dimvector = -1 + )) +}) + +# 12. path_graph_impl + +test_that("path_graph_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(path_graph_impl( + n = -1 + )) +}) + +# 13. cycle_graph_impl + +test_that("cycle_graph_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(cycle_graph_impl( + n = -1 + )) +}) + +# 14. symmetric_tree_impl + +test_that("symmetric_tree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(symmetric_tree_impl( + branches = -1 + )) +}) + +# 15. regular_tree_impl + +test_that("regular_tree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(regular_tree_impl( + h = -1 + )) +}) + +# 16. full_citation_impl + +test_that("full_citation_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(full_citation_impl( + n = -1 + )) +}) + +# 17. atlas_impl + +test_that("atlas_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(atlas_impl( + number = -1 + )) +}) + +# 18. extended_chordal_ring_impl + +test_that("extended_chordal_ring_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(extended_chordal_ring_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(extended_chordal_ring_impl( + nodes = -1, + W = matrix(c(1, 2)) + )) +}) + +# 21. de_bruijn_impl +test_that("de_bruijn_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(de_bruijn_impl( + m = -1, + n = 3 + )) +}) + +# 22. kautz_impl +test_that("kautz_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(kautz_impl( + m = -1, + n = 3 + )) +}) + +# 23. lcf_vector_impl +test_that("lcf_vector_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(mycielski_graph_impl( + k = -1 + )) +}) + +# 25. adjlist_impl +test_that("adjlist_impl basic", { + skip_if(Sys.getenv("R_SANITIZER") == "true") + igraph_local_seed(20250909) + 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") + igraph_local_seed(20250909) + expect_snapshot_igraph_error(adjlist_impl( + adjlist = -1, + mode = "out" + )) +}) + +# 27. full_multipartite_impl +test_that("full_multipartite_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(full_multipartite_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(full_multipartite_impl( + n = -1 + )) +}) + +# 28. realize_degree_sequence_impl +test_that("realize_degree_sequence_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(realize_degree_sequence_impl( + 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", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot(realize_bipartite_degree_sequence_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + realize_bipartite_degree_sequence_impl( + degrees1 = -1, + degrees2 = c(2, 2) + ) + ) +}) + +# 30. circulant_impl +test_that("circulant_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(circulant_impl( + n = -1, + shifts = c(1, 2) + )) +}) + +# 31. generalized_petersen_impl +test_that("generalized_petersen_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(generalized_petersen_impl( + n = -1, + k = 2 + )) +}) + +# 32. turan_impl +test_that("turan_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(turan_impl( + n = -1, + r = 2 + )) +}) + +# 316. from_prufer_impl + +test_that("from_prufer_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(from_prufer_impl( + prufer = "a" + )) +}) + +# 318. tree_from_parent_vector_impl + +test_that("tree_from_parent_vector_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(tree_from_parent_vector_impl( + parents = "a" + )) +}) + +test_that("famous_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(famous_impl( + name = "Zachary" + )) +}) + +test_that("famous_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(famous_impl( + name = "NonexistentGraph" + )) +}) + +# Tests for newly autogenerated _impl functions + +# Graph constructors + +test_that("star_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(star_impl(n = 5, mode = "out", center = 0)) + expect_snapshot(star_impl(n = 6, mode = "in", center = 1)) + expect_snapshot(star_impl(n = 4, mode = "undirected", center = 0)) +}) + +test_that("ring_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(ring_impl( + n = 5, + directed = FALSE, + mutual = FALSE, + circular = TRUE + )) + expect_snapshot(ring_impl( + n = 4, + directed = TRUE, + mutual = FALSE, + circular = FALSE + )) +}) + +test_that("full_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(full_impl(n = 4, directed = FALSE, loops = FALSE)) + expect_snapshot(full_impl(n = 3, directed = TRUE, loops = FALSE)) +}) + +test_that("kary_tree_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(kary_tree_impl( + n = 7, + children = 2, + type = c("out", "in", "undirected") + )) + expect_snapshot(kary_tree_impl( + n = 10, + children = 3, + type = c("in", "out", "undirected") + )) +}) + +# sparse_adjacency_impl + +test_that("sparse_adjacency_impl basic", { + skip_if_not_installed("Matrix") + igraph_local_seed(20250909) + + # Create a simple sparse matrix + M <- Matrix::sparseMatrix( + i = c(1, 2, 3, 4), + j = c(2, 3, 4, 1), + x = 1, + dims = c(4, 4) + ) + + expect_snapshot(sparse_adjacency_impl(adjmatrix = M)) + + # Create a symmetric matrix for undirected graph + M_sym <- Matrix::sparseMatrix( + i = c(1, 1, 2, 2, 3, 3, 4, 4), + j = c(2, 4, 1, 3, 2, 4, 1, 3), + x = 1, + dims = c(4, 4) + ) + expect_snapshot(sparse_adjacency_impl( + adjmatrix = M_sym, + mode = "undirected", + loops = "once" + )) + + # Structured tests + g1 <- sparse_adjacency_impl(adjmatrix = M) + expect_s3_class(g1, "igraph") + expect_equal(vcount(g1), 4) + expect_equal(ecount(g1), 4) + expect_true(is_directed(g1)) + + g2 <- sparse_adjacency_impl( + adjmatrix = M_sym, + mode = "undirected", + loops = "once" + ) + expect_s3_class(g2, "igraph") + expect_false(is_directed(g2)) +}) + +test_that("sparse_adjacency_impl errors", { + skip_if_not_installed("Matrix") + skip_if_not(getRversion() >= "4.2") + igraph_local_seed(20250909) + + # Regular matrices are converted to sparse matrices automatically + # This should work, not error + g <- sparse_adjacency_impl(adjmatrix = matrix(c(0,1,1,0), 2, 2)) + expect_s3_class(g, "igraph") +}) + +# sparse_weighted_adjacency_impl + +test_that("sparse_weighted_adjacency_impl basic", { + skip_if_not_installed("Matrix") + igraph_local_seed(20250909) + + # Create a weighted sparse matrix + M <- Matrix::sparseMatrix( + i = c(1, 2, 3, 4), + j = c(2, 3, 4, 1), + x = c(2.5, 1.0, 3.0, 0.5), + dims = c(4, 4) + ) + + expect_snapshot(sparse_weighted_adjacency_impl(adjmatrix = M)) + + # Create a symmetric weighted matrix for undirected graph + M_sym <- Matrix::sparseMatrix( + i = c(1, 1, 2, 2, 3, 3, 4, 4), + j = c(2, 4, 1, 3, 2, 4, 1, 3), + x = c(2.5, 0.5, 2.5, 1.0, 1.0, 3.0, 0.5, 3.0), + dims = c(4, 4) + ) + expect_snapshot(sparse_weighted_adjacency_impl( + adjmatrix = M_sym, + mode = "undirected", + loops = "once" + )) + + # Structured tests + result <- sparse_weighted_adjacency_impl(adjmatrix = M) + g1 <- result$graph + weights <- result$weights + + expect_s3_class(g1, "igraph") + expect_equal(vcount(g1), 4) + expect_equal(ecount(g1), 4) + expect_true(is_directed(g1)) + expect_length(weights, 4) +}) + +test_that("sparse_weighted_adjacency_impl errors", { + skip_if_not_installed("Matrix") + skip_if_not(getRversion() >= "4.2") + igraph_local_seed(20250909) + + # Regular matrices are converted to sparse matrices automatically + # This should work, not error + result <- sparse_weighted_adjacency_impl(adjmatrix = matrix(c(0,1,2,0), 2, 2)) + expect_s3_class(result$graph, "igraph") + expect_type(result$weights, "double") +}) + +# weighted_sparsemat_impl + +test_that("weighted_sparsemat_impl basic", { + skip_if_not_installed("Matrix") + igraph_local_seed(20250909) + + # Create a weighted sparse matrix + M <- Matrix::sparseMatrix( + i = c(1, 2, 3, 4), + j = c(2, 3, 4, 1), + x = c(2.5, 1.0, 3.0, 0.5), + dims = c(4, 4) + ) + + expect_snapshot(weighted_sparsemat_impl( + A = M, + directed = TRUE, + attr = "weight", + loops = FALSE + )) + + # Structured tests + g1 <- weighted_sparsemat_impl( + A = M, + directed = TRUE, + attr = "weight", + loops = FALSE + ) + + expect_s3_class(g1, "igraph") + expect_equal(vcount(g1), 4) + expect_true(is_directed(g1)) + expect_true("weight" %in% edge_attr_names(g1)) +}) + +test_that("weighted_sparsemat_impl errors", { + skip_if_not_installed("Matrix") + skip_if_not(getRversion() >= "4.2") + igraph_local_seed(20250909) + + # Regular matrices are converted to sparse matrices automatically + # This should work, not error + g <- weighted_sparsemat_impl( + A = matrix(c(0,1,2,0), 2, 2), + directed = TRUE, + attr = "weight", + loops = FALSE + ) + expect_s3_class(g, "igraph") +}) diff --git a/tests/testthat/test-aaa-graphlets.R b/tests/testthat/test-aaa-graphlets.R new file mode 100644 index 00000000000..e74fa33a00b --- /dev/null +++ b/tests/testthat/test-aaa-graphlets.R @@ -0,0 +1,34 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 227. graphlets_impl + +test_that("graphlets_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + E(g)$weight <- 1:2 + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(graphlets_impl( + graph = NULL + )) +}) diff --git a/tests/testthat/test-aaa-hrg.R b/tests/testthat/test-aaa-hrg.R new file mode 100644 index 00000000000..ce5a2f8faed --- /dev/null +++ b/tests/testthat/test-aaa-hrg.R @@ -0,0 +1,260 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 228. hrg_fit_impl + +test_that("hrg_fit_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(hrg_fit_impl( + graph = NULL + )) +}) + +# 229. hrg_sample_impl + +test_that("hrg_sample_impl basic", { + skip_if(Sys.getenv("R_SANITIZER") == "true") + igraph_local_seed(20250909) + g <- make_full_graph(10) + hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) + 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") + igraph_local_seed(20250909) + # FIXME: This test triggers an assertion failure in the C code when passing + # NULL/empty HRG. The C code should validate input and return a proper error + # message instead of an assertion failure. + expect_snapshot_igraph_error(hrg_sample_impl( + hrg = NULL + )) +}) + +# 230. hrg_sample_many_impl + +test_that("hrg_sample_many_impl basic", { + skip_if(Sys.getenv("R_SANITIZER") == "true") + igraph_local_seed(20250909) + g <- make_full_graph(10) + hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) + 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") + igraph_local_seed(20250909) + # FIXME: This test triggers an assertion failure in the C code when passing + # NULL/empty HRG. The C code should validate input and return a proper error + # message instead of an assertion failure. + expect_snapshot_igraph_error(hrg_sample_many_impl( + hrg = NULL, + num_samples = 2 + )) +}) + +# 231. hrg_game_impl + +test_that("hrg_game_impl basic", { + skip_if(Sys.getenv("R_SANITIZER") == "true") + igraph_local_seed(20250909) + g <- make_full_graph(10) + hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) + 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") + igraph_local_seed(20250909) + # FIXME: This test triggers an assertion failure in the C code when passing + # NULL/empty HRG. The C code should validate input and return a proper error + # message instead of an assertion failure. + expect_snapshot_igraph_error(hrg_game_impl( + hrg = NULL + )) +}) + +# 232. hrg_consensus_impl + +# test_that("hrg_consensus_impl basic", { +# igraph_local_seed(20250909) +# oldval <- igraph_opt("print.id") +# igraph_options(print.id = FALSE) +# g <- path_graph_impl(3) +# expect_snapshot(hrg_consensus_impl(g)) +# expect_snapshot(hrg_consensus_impl(g, hrg=list(left=1, right=2, prob=0.5, edges=1, vertices=1), start=TRUE, num_samples=2)) +# }) + +test_that("hrg_consensus_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(hrg_consensus_impl( + graph = NULL + )) +}) + +# 233. hrg_predict_impl + +# test_that("hrg_predict_impl basic", { +# igraph_local_seed(20250909) +# oldval <- igraph_opt("print.id") +# igraph_options(print.id = FALSE) +# g <- path_graph_impl(3) +# expect_snapshot(hrg_predict_impl(g)) +# expect_snapshot(hrg_predict_impl(g, hrg=list(left=1, right=2, prob=0.5, edges=1, vertices=1), start=TRUE, num_samples=2, num_bins=2)) +# }) + +test_that("hrg_predict_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(hrg_predict_impl( + graph = NULL + )) +}) + +# 234. hrg_create_impl + +test_that("hrg_create_impl basic", { + igraph_local_seed(20250909) + g <- make_tree(5) + 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", { + igraph_local_seed(20250909) + g <- make_full_graph(4, directed = TRUE) + expect_snapshot_igraph_error(hrg_create_impl( + graph = g, + prob = 0.5 + )) +}) + +# 235. hrg_resize_impl + +test_that("hrg_resize_impl basic", { + skip_if(Sys.getenv("R_SANITIZER") == "true") + igraph_local_seed(20250909) + g <- make_full_graph(10) + hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) + 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") + igraph_local_seed(20250909) + expect_snapshot_igraph_error(hrg_resize_impl( + hrg = -1, + newsize = 2 + )) +}) + +# 236. hrg_size_impl + +test_that("hrg_size_impl basic", { + skip_if(Sys.getenv("R_SANITIZER") == "true") + igraph_local_seed(20250909) + g <- make_full_graph(10) + hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) + 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") + igraph_local_seed(20250909) + expect_snapshot_igraph_error(hrg_size_impl( + hrg = -1 + )) +}) + +# 237. from_hrg_dendrogram_impl + +test_that("from_hrg_dendrogram_impl basic", { + igraph_local_seed(20250909) + g <- make_full_graph(10) + hrg_model <- fit_hrg(g, hrg = NULL, start = FALSE, steps = 0) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(from_hrg_dendrogram_impl( + hrg = -1 + )) +}) diff --git a/tests/testthat/test-aaa-isomorphism.R b/tests/testthat/test-aaa-isomorphism.R new file mode 100644 index 00000000000..39d9157cb90 --- /dev/null +++ b/tests/testthat/test-aaa-isomorphism.R @@ -0,0 +1,822 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 277. isoclass_impl + +test_that("isoclass_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(isoclass_impl( + graph = NULL + )) +}) + +# 278. isomorphic_impl + +test_that("isomorphic_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + graph2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error(isomorphic_impl( + graph1 = NULL, + graph2 = graph2 + )) +}) + +# 279. isoclass_subgraph_impl + +test_that("isoclass_subgraph_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(isoclass_subgraph_impl( + graph = NULL, + vids = 1:2 + )) +}) + +# 280. isoclass_create_impl + +test_that("isoclass_create_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(isoclass_create_impl( + size = "a", + number = 1 + )) +}) + +# 281. isomorphic_vf2_impl + +test_that("isomorphic_vf2_impl basic", { + igraph_local_seed(20250909) + 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( + 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", { + igraph_local_seed(20250909) + graph2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error(isomorphic_vf2_impl( + graph1 = NULL, + graph2 = graph2 + )) +}) + +# 282. get_isomorphisms_vf2_callback_impl +# Skipped: requires callback function, not suitable for snapshot test + +# 283. count_isomorphisms_vf2_impl + +test_that("count_isomorphisms_vf2_impl basic", { + igraph_local_seed(20250909) + 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( + 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", { + igraph_local_seed(20250909) + graph2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error( + count_isomorphisms_vf2_impl( + graph1 = NULL, + graph2 = graph2 + ) + ) +}) + +# 284. get_isomorphisms_vf2_impl + +test_that("get_isomorphisms_vf2_impl basic", { + igraph_local_seed(20250909) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_isomorphisms_vf2_impl( + 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", { + igraph_local_seed(20250909) + graph2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error( + get_isomorphisms_vf2_impl( + graph1 = NULL, + graph2 = graph2 + ) + ) +}) + +# 285. subisomorphic_impl + +test_that("subisomorphic_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + graph2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error(subisomorphic_impl( + graph1 = NULL, + graph2 = graph2 + )) +}) + +# 286. subisomorphic_vf2_impl + +test_that("subisomorphic_vf2_impl basic", { + igraph_local_seed(20250909) + 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( + 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", { + igraph_local_seed(20250909) + graph2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error( + subisomorphic_vf2_impl( + graph1 = NULL, + graph2 = graph2 + ) + ) +}) + +# 287. count_subisomorphisms_vf2_impl + +test_that("count_subisomorphisms_vf2_impl basic", { + igraph_local_seed(20250909) + 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( + 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", { + igraph_local_seed(20250909) + graph2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error( + count_subisomorphisms_vf2_impl( + graph1 = NULL, + graph2 = graph2 + ) + ) +}) + +# 288. get_subisomorphisms_vf2_impl + +test_that("get_subisomorphisms_vf2_impl basic", { + igraph_local_seed(20250909) + 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( + 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", { + igraph_local_seed(20250909) + graph2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error( + get_subisomorphisms_vf2_impl( + graph1 = NULL, + graph2 = graph2 + ) + ) +}) + +# 289. canonical_permutation_impl + +test_that("canonical_permutation_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(canonical_permutation_impl( + graph = NULL + )) +}) + +# 290. permute_vertices_impl + +test_that("permute_vertices_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(permute_vertices_impl( + graph = NULL, + permutation = 3:1 + )) +}) + +# 291. isomorphic_bliss_impl + +test_that("isomorphic_bliss_impl basic", { + igraph_local_seed(20250909) + 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( + 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", { + igraph_local_seed(20250909) + graph2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error(isomorphic_bliss_impl( + graph1 = NULL, + graph2 = graph2 + )) +}) + +# 292. count_automorphisms_impl + +test_that("count_automorphisms_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(count_automorphisms_impl( + graph = NULL + )) +}) + +# 293. automorphism_group_impl + +test_that("automorphism_group_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(automorphism_group_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(automorphism_group_impl( + graph = NULL + )) +}) + +# 294. simplify_and_colorize_impl + +test_that("simplify_and_colorize_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(simplify_and_colorize_impl( + graph = NULL + )) +}) + +# 295. graph_count_impl + +test_that("graph_count_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(graph_count_impl( + n = "a" + )) +}) + +# get_isomorphisms_vf2_callback_closure_impl + +test_that("get_isomorphisms_vf2_callback_closure_impl basic", { + igraph_local_seed(20250909) + + g1 <- make_ring(5) + g2 <- make_ring(5) + + # Collect isomorphism information for snapshot + iso_data <- list() + result <- get_isomorphisms_vf2_callback_closure_impl( + graph1 = g1, + graph2 = g2, + vertex_color1 = NULL, + vertex_color2 = NULL, + edge_color1 = NULL, + edge_color2 = NULL, + callback = function(map12, map21) { + iso_data[[length(iso_data) + 1]] <<- list( + map12 = map12, + map21 = map21 + ) + if (length(iso_data) >= 2) { + return(TRUE) # Stop after 2 + } + FALSE # Continue + } + ) + + expect_snapshot({ + cat("Result:\n") + print(result) + cat("\nNumber of isomorphisms found:", length(iso_data), "\n") + cat("First isomorphism:\n") + print(iso_data[[1]]) + }) + + # Structured tests + expect_null(result) + expect_true(length(iso_data) > 0) + expect_type(iso_data[[1]]$map12, "integer") + expect_type(iso_data[[1]]$map21, "integer") + expect_length(iso_data[[1]]$map12, vcount(g1)) + expect_length(iso_data[[1]]$map21, vcount(g2)) +}) + +test_that("get_isomorphisms_vf2_callback_closure_impl errors", { + igraph_local_seed(20250909) + + g1 <- make_ring(5) + g2 <- make_ring(5) + + # Should error if callback is not a function + expect_snapshot_igraph_error( + get_isomorphisms_vf2_callback_closure_impl( + graph1 = g1, + graph2 = g2, + vertex_color1 = NULL, + vertex_color2 = NULL, + edge_color1 = NULL, + edge_color2 = NULL, + callback = "not a function" + ) + ) +}) + +# get_subisomorphisms_vf2_callback_closure_impl + +test_that("get_subisomorphisms_vf2_callback_closure_impl basic", { + igraph_local_seed(20250909) + + g1 <- make_full_graph(5) + g2 <- make_ring(3) # triangle + + # Collect subisomorphism information for snapshot + subiso_data <- list() + result <- get_subisomorphisms_vf2_callback_closure_impl( + graph1 = g1, + graph2 = g2, + vertex_color1 = NULL, + vertex_color2 = NULL, + edge_color1 = NULL, + edge_color2 = NULL, + callback = function(map12, map21) { + subiso_data[[length(subiso_data) + 1]] <<- list( + map12 = map12, + map21 = map21 + ) + if (length(subiso_data) >= 2) { + return(TRUE) # Stop after 2 + } + FALSE # Continue + } + ) + + expect_snapshot({ + cat("Result:\n") + print(result) + cat("\nNumber of subisomorphisms found:", length(subiso_data), "\n") + cat("First subisomorphism:\n") + print(subiso_data[[1]]) + }) + + # Structured tests + expect_null(result) + expect_true(length(subiso_data) > 0) + expect_type(subiso_data[[1]]$map12, "integer") + expect_type(subiso_data[[1]]$map21, "integer") + expect_length(subiso_data[[1]]$map12, vcount(g1)) + expect_length(subiso_data[[1]]$map21, vcount(g2)) +}) + +test_that("get_subisomorphisms_vf2_callback_closure_impl errors", { + igraph_local_seed(20250909) + + g1 <- make_ring(3) + g2 <- make_full_graph(5) + + # Should error if callback is not a function + expect_snapshot_igraph_error( + get_subisomorphisms_vf2_callback_closure_impl( + graph1 = g1, + graph2 = g2, + vertex_color1 = NULL, + vertex_color2 = NULL, + edge_color1 = NULL, + edge_color2 = NULL, + callback = "not a function" + ) + ) +}) + +# subisomorphic_lad_impl +test_that("subisomorphic_lad_impl basic", { + igraph_local_seed(20250909) + + # FIXME: Add functionality tests once we understand the expected behavior + # The function requires complex setup with pattern/target graphs and domains + # For now, just verify the function exists and has correct signature + expect_true(is.function(subisomorphic_lad_impl)) + expect_named( + formals(subisomorphic_lad_impl), + c("pattern", "target", "domains", "induced", "time_limit") + ) +}) + +test_that("subisomorphic_lad_impl errors", { + igraph_local_seed(20250909) + g <- add_edges_impl(empty_impl(n = 3), c(0, 1, 1, 2) + 1) + + expect_snapshot_igraph_error(subisomorphic_lad_impl( + pattern = NULL, + target = g, + domains = list(), + induced = FALSE, + time_limit = 0 + )) + + # Test that domains must be a list + expect_snapshot_igraph_error(subisomorphic_lad_impl( + pattern = g, + target = g, + domains = "not a list", + induced = FALSE, + time_limit = 0 + )) +}) diff --git a/tests/testthat/test-aaa-layout.R b/tests/testthat/test-aaa-layout.R new file mode 100644 index 00000000000..0f6a67478fb --- /dev/null +++ b/tests/testthat/test-aaa-layout.R @@ -0,0 +1,611 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 193. layout_random_impl + +test_that("layout_random_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(layout_random_impl( + graph = NULL + )) +}) + +# 194. layout_circle_impl + +test_that("layout_circle_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(layout_circle_impl( + graph = NULL + )) +}) + +# 195. layout_star_impl + +test_that("layout_star_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(layout_star_impl( + graph = NULL + )) +}) + +# 196. layout_grid_impl + +test_that("layout_grid_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(layout_grid_impl( + graph = NULL + )) +}) + +# 197. layout_grid_3d_impl + +test_that("layout_grid_3d_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(layout_grid_3d_impl( + graph = NULL + )) +}) + +# 198. roots_for_tree_layout_impl + +test_that("roots_for_tree_layout_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + roots_for_tree_layout_impl( + graph = NULL, + mode = "out", + heuristic = 1 + ) + ) +}) + +# 199. layout_random_3d_impl + +test_that("layout_random_3d_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(layout_random_3d_impl( + graph = NULL + )) +}) + +# 200. layout_sphere_impl + +test_that("layout_sphere_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(layout_sphere_impl( + graph = NULL + )) +}) + +# 201. layout_sugiyama_impl + +test_that("layout_sugiyama_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_sugiyama_impl( + graph = g + )) + expect_snapshot(layout_sugiyama_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(layout_sugiyama_impl( + graph = NULL + )) +}) + +# 202. layout_mds_impl + +test_that("layout_mds_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(layout_mds_impl( + graph = NULL + )) +}) + +# 203. layout_bipartite_impl + +test_that("layout_bipartite_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_bipartite_impl( + graph = g, + types = c(TRUE, FALSE, TRUE) + )) + expect_snapshot(layout_bipartite_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + layout_bipartite_impl( + graph = NULL, + types = c(TRUE, FALSE, TRUE) + ) + ) +}) + +# 204. layout_gem_impl + +test_that("layout_gem_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_gem_impl( + 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, + temp_max = 2, + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + layout_gem_impl( + graph = NULL, + res = matrix(0, nrow = 3, ncol = 2) + ) + ) +}) + +# 205. layout_davidson_harel_impl + +test_that("layout_davidson_harel_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_davidson_harel_impl( + graph = g, + res = matrix(0, nrow = 3, ncol = 2) + )) + expect_snapshot(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 + )) + + # 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + layout_davidson_harel_impl( + graph = NULL, + res = matrix(0, nrow = 3, ncol = 2) + ) + ) +}) + +# 206. layout_umap_impl + +test_that("layout_umap_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_umap_impl( + graph = g, + res = matrix(0, nrow = 3, ncol = 2), + use_seed = TRUE + )) + expect_snapshot(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 + )) + + # 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + layout_umap_impl( + graph = NULL, + res = matrix(0, nrow = 3, ncol = 2) + ) + ) +}) + +# 207. layout_umap_3d_impl + +test_that("layout_umap_3d_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_umap_3d_impl( + graph = g, + res = matrix(0, nrow = 3, ncol = 3), + use_seed = TRUE + )) + expect_snapshot(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 + )) + + # 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + layout_umap_3d_impl( + graph = NULL, + res = matrix(0, nrow = 3, ncol = 3) + ) + ) +}) + +# 208. layout_umap_compute_weights_impl + +test_that("layout_umap_compute_weights_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(layout_umap_compute_weights_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + layout_umap_compute_weights_impl( + graph = NULL, + distances = 1:3, + weights = 1:3 + ) + ) +}) + +# 209. layout_align_impl + +test_that("layout_align_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + layout_align_impl( + graph = NULL, + layout = matrix(0, nrow = 3, ncol = 2) + ) + ) +}) + +# Layout functions + +test_that("layout_sphere_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(layout_sphere_impl(graph = g)) +}) + +test_that("layout_merge_dla_impl basic", { + igraph_local_seed(20250909) + g1 <- path_graph_impl(n = 3) + g2 <- path_graph_impl(n = 3) + coords1 <- matrix(c(0, 0, 1, 0, 2, 0), ncol = 2, byrow = TRUE) + coords2 <- matrix(c(0, 1, 1, 1, 2, 1), ncol = 2, byrow = TRUE) + + expect_snapshot(layout_merge_dla_impl( + graphs = list(g1, g2), + coords = list(coords1, coords2) + )) + + # Structured tests + result <- layout_merge_dla_impl( + graphs = list(g1, g2), + coords = list(coords1, coords2) + ) + expect_true(is.matrix(result)) + expect_equal(nrow(result), 6) + expect_equal(ncol(result), 2) +}) diff --git a/tests/testthat/test-aaa-motifs.R b/tests/testthat/test-aaa-motifs.R new file mode 100644 index 00000000000..e00b19b442e --- /dev/null +++ b/tests/testthat/test-aaa-motifs.R @@ -0,0 +1,304 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 243. motifs_randesu_impl + +test_that("motifs_randesu_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(motifs_randesu_impl( + graph = NULL + )) +}) + +# 244. motifs_randesu_estimate_impl + +test_that("motifs_randesu_estimate_impl basic", { + igraph_local_seed(20250909) + 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( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + motifs_randesu_estimate_impl( + graph = NULL, + size = 3, + sample_size = 2 + ) + ) +}) + +# 245. motifs_randesu_no_impl + +test_that("motifs_randesu_no_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(motifs_randesu_no_impl( + graph = g + )) + expect_snapshot(motifs_randesu_no_impl( + 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", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot_igraph_error( + motifs_randesu_no_impl( + graph = g, + size = 3, + cut_prob = c(0.1) + ) + ) +}) + +# 246. dyad_census_impl + +test_that("dyad_census_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(dyad_census_impl( + graph = NULL + )) +}) + +# 247. triad_census_impl + +test_that("triad_census_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(triad_census_impl( + graph = g + )) + + # Structured tests + expect_warning( + result <- triad_census_impl( + graph = g + ) + ) + expect_true(is.numeric(result)) +}) + +test_that("triad_census_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(triad_census_impl( + graph = NULL + )) +}) + +# 248. count_adjacent_triangles_impl + +test_that("count_adjacent_triangles_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(count_adjacent_triangles_impl( + graph = NULL + )) +}) + +# 249. count_triangles_impl + +test_that("count_triangles_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(count_triangles_impl( + graph = NULL + )) +}) + +# 258. list_triangles_impl + +test_that("list_triangles_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(list_triangles_impl( + graph = NULL + )) +}) + +# motifs_randesu_callback_closure_impl + +test_that("motifs_randesu_callback_closure_impl basic", { + igraph_local_seed(20250909) + + g <- make_graph(~ A - B - C - A) + + # Collect motif information for snapshot + motif_data <- list() + result <- motifs_randesu_callback_closure_impl( + graph = g, + size = 3, + cut_prob = NULL, + callback = function(vids, isoclass) { + motif_data[[length(motif_data) + 1]] <<- list( + vids = vids, + isoclass = isoclass + ) + FALSE # Continue + } + ) + + expect_snapshot({ + cat("Result:\n") + print(result) + cat("\nNumber of motifs found:", length(motif_data), "\n") + cat("First motif:\n") + print(motif_data[[1]]) + }) + + # Structured tests + expect_null(result) + expect_true(length(motif_data) > 0) + expect_type(motif_data[[1]]$vids, "integer") + expect_length(motif_data[[1]]$vids, 3) + expect_type(motif_data[[1]]$isoclass, "integer") + expect_length(motif_data[[1]]$isoclass, 1) +}) + +test_that("motifs_randesu_callback_closure_impl errors", { + igraph_local_seed(20250909) + + g <- make_graph(~ A - B - C) + + # Should error if callback is not a function + expect_snapshot_igraph_error( + motifs_randesu_callback_closure_impl( + graph = g, + size = 3, + cut_prob = NULL, + callback = "not a function" + ) + ) +}) diff --git a/tests/testthat/test-aaa-nongraph.R b/tests/testthat/test-aaa-nongraph.R new file mode 100644 index 00000000000..8a875ea7e33 --- /dev/null +++ b/tests/testthat/test-aaa-nongraph.R @@ -0,0 +1,134 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 302. power_law_fit_impl + +test_that("power_law_fit_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(power_law_fit_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(power_law_fit_impl( + data = "a" + )) +}) + +# 306. solve_lsap_impl + +test_that("solve_lsap_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(solve_lsap_impl( + c = "a", + n = 2 + )) +}) + +# 333. version_impl + +test_that("version_impl basic", { + igraph_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", { + igraph_local_seed(12345) + # version_impl() has no parameters, so testing with invalid arguments + expect_snapshot_igraph_error(version_impl( + "invalid" + )) +}) + +# eigen_matrix_impl +test_that("eigen_matrix_impl basic", { + igraph_local_seed(20250909) + + # FIXME: Add functionality tests once we understand the expected behavior + # The function requires complex matrix setup and understanding of eigenvalue computation + # For now, just verify the function exists and has correct signature + expect_true(is.function(eigen_matrix_impl)) + expect_named( + formals(eigen_matrix_impl), + c("A", "sA", "fun", "n", "algorithm", "which", "options") + ) +}) + +test_that("eigen_matrix_impl errors", { + igraph_local_seed(20250909) + + # Test with invalid matrix dimensions + expect_error(eigen_matrix_impl( + A = matrix(0, 0, 0), + sA = Matrix::Matrix(matrix(0, 0, 0), sparse = TRUE), + fun = NULL, + n = 0, + algorithm = "auto", + which = list(pos = "LM", howmany = 1) + )) +}) + +# eigen_matrix_symmetric_impl +test_that("eigen_matrix_symmetric_impl basic", { + igraph_local_seed(20250909) + + # FIXME: Add functionality tests once we understand the expected behavior + # The function requires complex matrix setup and understanding of eigenvalue computation + # For now, just verify the function exists and has correct signature + expect_true(is.function(eigen_matrix_symmetric_impl)) + expect_named( + formals(eigen_matrix_symmetric_impl), + c("A", "sA", "fun", "n", "algorithm", "which", "options") + ) +}) + +test_that("eigen_matrix_symmetric_impl errors", { + igraph_local_seed(20250909) + + # Test with invalid matrix dimensions + expect_error(eigen_matrix_symmetric_impl( + A = matrix(0, 0, 0), + sA = Matrix::Matrix(matrix(0, 0, 0), sparse = TRUE), + fun = NULL, + n = 0, + algorithm = "auto", + which = list(pos = "LM", howmany = 1) + )) +}) diff --git a/tests/testthat/test-aaa-operators.R b/tests/testthat/test-aaa-operators.R new file mode 100644 index 00000000000..0dc91c1c298 --- /dev/null +++ b/tests/testthat/test-aaa-operators.R @@ -0,0 +1,552 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 19. graph_power_impl + +test_that("graph_power_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(graph_power_impl( + graph = NULL, + order = 2 + )) +}) + +# 20. linegraph_impl + +test_that("linegraph_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(linegraph_impl( + graph = NULL + )) +}) + +# 79. induced_subgraph_impl + +test_that("induced_subgraph_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(induced_subgraph_impl( + graph = NULL, + vids = 1:2 + )) +}) + +# 80. subgraph_from_edges_impl + +test_that("subgraph_from_edges_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(subgraph_from_edges_impl( + graph = NULL, + eids = 1 + )) +}) + +# 81. reverse_edges_impl + +test_that("reverse_edges_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(reverse_edges_impl( + graph = NULL + )) +}) + +# 102. simplify_impl + +test_that("simplify_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(simplify_impl( + graph = g + )) + expect_snapshot(simplify_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(simplify_impl( + graph = NULL + )) +}) + +# 149. contract_vertices_impl + +test_that("contract_vertices_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(contract_vertices_impl( + graph = NULL, + mapping = c(1, 1, 2) + )) +}) + +# 160. transitive_closure_dag_impl + +test_that("transitive_closure_dag_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(transitive_closure_dag_impl( + graph = NULL + )) +}) + +# 161. transitive_closure_impl + +test_that("transitive_closure_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(transitive_closure_impl( + graph = NULL + )) +}) + +# 259. join_impl + +test_that("join_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + right <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error(join_impl( + left = NULL, + right = right + )) +}) + +# 260. induced_subgraph_map_impl + +test_that("induced_subgraph_map_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + induced_subgraph_map_impl( + graph = NULL, + vids = 1:2, + impl = "auto" + ) + ) +}) + +# 261. mycielskian_impl + +test_that("mycielskian_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(mycielskian_impl( + graph = NULL + )) +}) + +# 262. product_impl + +test_that("product_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + g2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error(product_impl( + g1 = NULL, + g2 = g2 + )) +}) + +# 263. rooted_product_impl + +test_that("rooted_product_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + g2 <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error( + rooted_product_impl( + g1 = NULL, + g2 = g2, + root = 1 + ) + ) +}) + +# 347. union_impl + +test_that("union_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(union_impl( + left = NULL, + right = NULL + )) +}) + +# 348. intersection_impl + +test_that("intersection_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(intersection_impl( + left = NULL, + right = NULL + )) +}) + +test_that("connect_neighborhood_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot_igraph(connect_neighborhood_impl( + graph = g, + order = 1, + mode = c("all", "out", "in") + )) +}) + +# Tests for newly autogenerated *_many functions + +test_that("disjoint_union_many_impl basic", { + igraph_local_seed(20250909) + g1 <- empty_impl(n = 2) + g2 <- empty_impl(n = 3) + g3 <- empty_impl(n = 1) + + expect_snapshot(disjoint_union_many_impl( + graphs = list(g1, g2, g3) + )) + + # Structured tests + result <- disjoint_union_many_impl( + graphs = list(g1, g2, g3) + ) + expect_s3_class(result, "igraph") + expect_equal(vcount(result), 6) +}) + +test_that("union_many_impl basic", { + igraph_local_seed(20250909) + g1 <- empty_impl(n = 3) + g2 <- add_edges_impl(g1, c(0, 1, 1, 2) + 1) + g3 <- add_edges_impl(g1, c(0, 2) + 1) + + expect_snapshot(union_many_impl( + graphs = list(g1, g2, g3) + )) + + # Structured tests + result <- union_many_impl( + graphs = list(g1, g2, g3) + ) + expect_type(result, "list") + expect_s3_class(result$res, "igraph") +}) + +test_that("intersection_many_impl basic", { + igraph_local_seed(20250909) + g1 <- add_edges_impl(empty_impl(n = 3), c(0, 1, 1, 2, 0, 2) + 1) + g2 <- add_edges_impl(empty_impl(n = 3), c(0, 1, 1, 2) + 1) + g3 <- add_edges_impl(empty_impl(n = 3), c(0, 1) + 1) + + expect_snapshot(intersection_many_impl( + graphs = list(g1, g2, g3) + )) + + # Structured tests + result <- intersection_many_impl( + graphs = list(g1, g2, g3) + ) + expect_type(result, "list") + expect_s3_class(result$res, "igraph") +}) diff --git a/tests/testthat/test-aaa-paths.R b/tests/testthat/test-aaa-paths.R new file mode 100644 index 00000000000..dff63b9adca --- /dev/null +++ b/tests/testthat/test-aaa-paths.R @@ -0,0 +1,656 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 58. get_shortest_path_impl + +test_that("get_shortest_path_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_shortest_path_impl( + graph = NULL, + from = 1, + to = 3 + )) +}) + +# 59. get_shortest_path_bellman_ford_impl + +test_that("get_shortest_path_bellman_ford_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_shortest_path_bellman_ford_impl( + graph = NULL, + from = 1, + to = 3 + )) +}) + +# 60. get_shortest_path_dijkstra_impl + +test_that("get_shortest_path_dijkstra_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_shortest_path_dijkstra_impl( + graph = NULL, + from = 1, + to = 3 + )) +}) + +# 61. get_all_shortest_paths_impl + +test_that("get_all_shortest_paths_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_all_shortest_paths_impl( + graph = NULL, + from = 1, + to = 3 + )) +}) + +# 62. get_all_shortest_paths_dijkstra_impl + +test_that("get_all_shortest_paths_dijkstra_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + get_all_shortest_paths_dijkstra_impl( + graph = NULL, + from = 1, + to = 3 + ) + ) +}) + +# 63. voronoi_impl + +test_that("voronoi_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(voronoi_impl( + graph = NULL, + generators = 1 + )) +}) + +# 64. get_all_simple_paths_impl + +test_that("get_all_simple_paths_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_all_simple_paths_impl( + graph = NULL, + from = 1, + to = 3 + )) +}) + +# 65. get_k_shortest_paths_impl + +test_that("get_k_shortest_paths_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_k_shortest_paths_impl( + graph = NULL, + from = 1, + to = 3, + k = 2 + )) +}) + +# 66. get_widest_path_impl + +test_that("get_widest_path_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_widest_path_impl( + graph = NULL, + from = 1, + to = 3 + )) +}) + +# 67. get_widest_paths_impl + +test_that("get_widest_paths_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_widest_paths_impl( + graph = NULL, + from = 1, + to = 3 + )) +}) + +# and much more halucination before... +# 91-96: halucination of get_shortest_path_* +# 97-100: halucination of get_widest_path_cutoff_impl,get_widest_paths_cutoff_impl, widest_path_widths_dijkstra_cutoff_impl, widest_path_widths_floyd_warshall_cutoff_impl + +# 101. path_length_hist_impl + +test_that("path_length_hist_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(path_length_hist_impl( + graph = NULL + )) +}) + +# 150. eccentricity_dijkstra_impl + +test_that("eccentricity_dijkstra_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(eccentricity_dijkstra_impl( + graph = NULL + )) +}) + +# 151. graph_center_dijkstra_impl + +test_that("graph_center_dijkstra_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(graph_center_dijkstra_impl( + graph = NULL + )) +}) + +# 152. radius_dijkstra_impl + +test_that("radius_dijkstra_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(radius_dijkstra_impl( + graph = NULL + )) +}) + +# 153. pseudo_diameter_impl + +test_that("pseudo_diameter_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(pseudo_diameter_impl( + graph = g, + start_vid = 1 + )) + expect_snapshot(pseudo_diameter_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(pseudo_diameter_impl( + graph = NULL, + start_vid = 1 + )) +}) + +# 154. pseudo_diameter_dijkstra_impl + +test_that("pseudo_diameter_dijkstra_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(pseudo_diameter_dijkstra_impl( + graph = g, + start_vid = 1 + )) + expect_snapshot(pseudo_diameter_dijkstra_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + pseudo_diameter_dijkstra_impl( + graph = NULL, + start_vid = 1 + ) + ) +}) + +# 332. vertex_path_from_edge_path_impl + +test_that("vertex_path_from_edge_path_impl basic", { + igraph_local_seed(12345) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(vertex_path_from_edge_path_impl( + graph = g, + start = 1, + edge_path = c(1, 2) + )) + expect_snapshot(vertex_path_from_edge_path_impl( + 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", { + igraph_local_seed(12345) + expect_snapshot_igraph_error( + vertex_path_from_edge_path_impl( + graph = NULL, + start = 1, + edge_path = c(1, 2) + ) + ) +}) + +# 345. girth_impl + +test_that("girth_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + result <- girth_impl( + graph = g + ) + expect_snapshot(result$girth) +}) + +test_that("girth_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(girth_impl( + graph = NULL + )) +}) + +# Distance and path functions + +test_that("distances_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(distances_impl( + graph = g, + from = V(g), + to = V(g), + mode = c("out", "in", "all", "total") + )) +}) + +test_that("diameter_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(10) + expect_snapshot(diameter_impl( + graph = g, + directed = FALSE, + unconnected = TRUE + )) +}) + +test_that("get_shortest_paths_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(get_shortest_paths_impl( + graph = g, + from = 1, + to = 3, + mode = c("out", "in", "all", "total") + )) +}) + +# Additional distance functions + +test_that("eccentricity_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(eccentricity_impl( + graph = g, + vids = V(g), + mode = c("out", "in", "all") + )) +}) + +test_that("radius_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(radius_impl(graph = g, mode = c("out", "in", "all"))) +}) + +test_that("graph_center_impl basic", { + igraph_local_seed(20250909) + g <- make_star(5, mode = "undirected") + expect_snapshot(graph_center_impl(graph = g, mode = c("out", "in", "all"))) +}) + +test_that("voronoi_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(10) + expect_snapshot(voronoi_impl( + graph = g, + generators = c(1, 5), + mode = c("out", "in", "all") + )) +}) diff --git a/tests/testthat/test-aaa-processes.R b/tests/testthat/test-aaa-processes.R new file mode 100644 index 00000000000..8b930b7a055 --- /dev/null +++ b/tests/testthat/test-aaa-processes.R @@ -0,0 +1,219 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 303. sir_impl + +test_that("sir_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(sir_impl( + graph = NULL, + beta = 0.1, + gamma = 0.1 + )) +}) + +# 327. deterministic_optimal_imitation_impl + +test_that("deterministic_optimal_imitation_impl basic", { + igraph_local_seed(12345) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(deterministic_optimal_imitation_impl( + graph = g, + vid = 1, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + )) + expect_snapshot(deterministic_optimal_imitation_impl( + 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", { + igraph_local_seed(12345) + expect_snapshot_igraph_error( + deterministic_optimal_imitation_impl( + graph = NULL, + vid = 1, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + ) + ) +}) + +# 328. moran_process_impl + +test_that("moran_process_impl basic", { + igraph_local_seed(12345) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(moran_process_impl( + 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", { + igraph_local_seed(12345) + expect_snapshot_igraph_error( + moran_process_impl( + graph = NULL, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + ) + ) +}) + +# 329. roulette_wheel_imitation_impl + +test_that("roulette_wheel_imitation_impl basic", { + igraph_local_seed(12345) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(roulette_wheel_imitation_impl( + graph = g, + vid = 1, + is_local = TRUE, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + )) + expect_snapshot(roulette_wheel_imitation_impl( + 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", { + igraph_local_seed(12345) + expect_snapshot_igraph_error( + roulette_wheel_imitation_impl( + graph = NULL, + vid = 1, + is_local = TRUE, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + ) + ) +}) + +# 330. stochastic_imitation_impl + +test_that("stochastic_imitation_impl basic", { + igraph_local_seed(12345) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(stochastic_imitation_impl( + graph = g, + vid = 1, + algo = 1, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + )) + expect_snapshot(stochastic_imitation_impl( + 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", { + igraph_local_seed(12345) + expect_snapshot_igraph_error( + stochastic_imitation_impl( + graph = NULL, + vid = 1, + algo = 1, + quantities = c(1, 2, 3), + strategies = c(1, 2, 3) + ) + ) +}) diff --git a/tests/testthat/test-aaa-separators.R b/tests/testthat/test-aaa-separators.R new file mode 100644 index 00000000000..20e79eb615c --- /dev/null +++ b/tests/testthat/test-aaa-separators.R @@ -0,0 +1,138 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 272. even_tarjan_reduction_impl + +test_that("even_tarjan_reduction_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(even_tarjan_reduction_impl( + graph = NULL + )) +}) + +# 273. is_separator_impl + +test_that("is_separator_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_separator_impl( + graph = NULL, + candidate = 1:2 + )) +}) + +# 274. is_minimal_separator_impl + +test_that("is_minimal_separator_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_minimal_separator_impl( + graph = NULL, + candidate = 1:2 + )) +}) + +# 275. all_minimal_st_separators_impl + +test_that("all_minimal_st_separators_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(all_minimal_st_separators_impl( + graph = NULL + )) +}) + +# 276. minimum_size_separators_impl + +test_that("minimum_size_separators_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(minimum_size_separators_impl( + graph = NULL + )) +}) diff --git a/tests/testthat/test-aaa-spatial.R b/tests/testthat/test-aaa-spatial.R new file mode 100644 index 00000000000..39b502c1cd0 --- /dev/null +++ b/tests/testthat/test-aaa-spatial.R @@ -0,0 +1,24 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 304. convex_hull_2d_impl + +test_that("convex_hull_2d_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(convex_hull_2d_impl( + data = "a" + )) +}) diff --git a/tests/testthat/test-aaa-structural.R b/tests/testthat/test-aaa-structural.R new file mode 100644 index 00000000000..a52eb46763f --- /dev/null +++ b/tests/testthat/test-aaa-structural.R @@ -0,0 +1,2362 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 55. are_adjacent_impl + +test_that("are_adjacent_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(are_adjacent_impl( + graph = NULL, + v1 = 1, + v2 = 2 + )) +}) + +# 70. spanner_impl + +test_that("spanner_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(spanner_impl( + graph = NULL, + stretch = 2 + )) +}) + +# 103. transitivity_undirected_impl + +test_that("transitivity_undirected_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(transitivity_undirected_impl( + graph = NULL + )) +}) + +# 104. transitivity_local_undirected_impl + +test_that("transitivity_local_undirected_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(transitivity_local_undirected_impl( + graph = NULL + )) +}) + +# 105. transitivity_avglocal_undirected_impl + +test_that("transitivity_avglocal_undirected_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(transitivity_avglocal_undirected_impl( + graph = NULL + )) +}) + +# 106. transitivity_barrat_impl + +test_that("transitivity_barrat_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(transitivity_barrat_impl( + graph = g + )) + expect_snapshot(transitivity_barrat_impl( + graph = g, + mode = "zero" + )) + + # Structured tests + expect_warning( + result <- transitivity_barrat_impl( + graph = g + ) + ) + expect_true(is.numeric(result) || is.logical(result)) +}) + +test_that("transitivity_barrat_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(transitivity_barrat_impl( + graph = NULL + )) +}) + +# 107. ecc_impl + +test_that("ecc_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(ecc_impl( + graph = NULL + )) +}) + +# 108. reciprocity_impl + +test_that("reciprocity_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(reciprocity_impl( + graph = NULL + )) +}) + +# 110. density_impl + +test_that("density_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(density_impl( + graph = NULL + )) +}) + +# 111. mean_degree_impl + +test_that("mean_degree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(mean_degree_impl( + graph = NULL + )) +}) + +# 114. is_loop_impl + +test_that("is_loop_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_loop_impl( + graph = NULL + )) +}) + +# 117. is_simple_impl + +test_that("is_simple_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_simple_impl( + graph = NULL + )) +}) + +# 118. is_multiple_impl + +test_that("is_multiple_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_multiple_impl( + graph = NULL + )) +}) + +# 119. has_loop_impl + +test_that("has_loop_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(has_loop_impl( + graph = NULL + )) +}) + +# 120. has_multiple_impl + +test_that("has_multiple_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(has_multiple_impl( + graph = NULL + )) +}) + +# 121. count_loops_impl + +test_that("count_loops_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(count_loops_impl( + graph = NULL + )) +}) + +# 122. count_multiple_impl + +test_that("count_multiple_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(count_multiple_impl( + graph = NULL + )) +}) + +# 127. is_mutual_impl + +test_that("is_mutual_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_mutual_impl( + graph = NULL + )) +}) + +# 128. has_mutual_impl + +test_that("has_mutual_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(has_mutual_impl( + graph = NULL + )) +}) + +# 129. maximum_cardinality_search_impl + +test_that("maximum_cardinality_search_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(maximum_cardinality_search_impl( + graph = NULL + )) +}) + +# 130. avg_nearest_neighbor_degree_impl + +test_that("avg_nearest_neighbor_degree_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(avg_nearest_neighbor_degree_impl( + graph = g + )) + expect_snapshot(avg_nearest_neighbor_degree_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(avg_nearest_neighbor_degree_impl( + graph = NULL + )) +}) + +# 131. degree_correlation_vector_impl + +test_that("degree_correlation_vector_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(degree_correlation_vector_impl( + graph = g + )) + expect_snapshot(degree_correlation_vector_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(degree_correlation_vector_impl( + graph = NULL + )) +}) + +# 132. rich_club_sequence_impl + +test_that("rich_club_sequence_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(rich_club_sequence_impl( + graph = g, + vertex_order = 1:3 + )) + expect_snapshot(rich_club_sequence_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + rich_club_sequence_impl( + graph = NULL, + vertex_order = 1:3 + ) + ) +}) + +# 143. assortativity_nominal_impl + +test_that("assortativity_nominal_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(assortativity_nominal_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(assortativity_nominal_impl( + graph = NULL, + types = c(1, 2, 1) + )) +}) + +# 144. assortativity_impl + +test_that("assortativity_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(assortativity_impl( + graph = g, + values = c(1, 2, 1) + )) + expect_snapshot(assortativity_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(assortativity_impl( + graph = NULL, + values = c(1, 2, 1) + )) +}) + +# 145. assortativity_degree_impl + +test_that("assortativity_degree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(assortativity_degree_impl( + graph = NULL + )) +}) + +# 146. joint_degree_matrix_impl + +test_that("joint_degree_matrix_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(joint_degree_matrix_impl( + graph = g + )) + expect_snapshot(joint_degree_matrix_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(joint_degree_matrix_impl( + graph = NULL + )) +}) + +# 147. joint_degree_distribution_impl + +test_that("joint_degree_distribution_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(joint_degree_distribution_impl( + graph = g + )) + expect_snapshot(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 + )) + + # Structured tests + result <- joint_degree_distribution_impl( + graph = g + ) + expect_true(is.numeric(result)) +}) + +test_that("joint_degree_distribution_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(joint_degree_distribution_impl( + graph = NULL + )) +}) + +# 148. joint_type_distribution_impl + +test_that("joint_type_distribution_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(joint_type_distribution_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + joint_type_distribution_impl( + graph = NULL, + from_types = c(1, 2, 1) + ) + ) +}) + +# 155. diversity_impl + +test_that("diversity_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + E(g)$weight <- c(1, 2) + expect_snapshot(diversity_impl( + graph = g + )) + + # Structured tests + result <- diversity_impl( + graph = g + ) + expect_true(is.numeric(result)) +}) + +test_that("diversity_impl errors", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(diversity_impl( + graph = NULL + )) +}) + +# 157. global_efficiency_impl + +test_that("global_efficiency_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(global_efficiency_impl( + graph = NULL + )) +}) + +# 158. local_efficiency_impl + +test_that("local_efficiency_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(local_efficiency_impl( + graph = NULL + )) +}) + +# 159. average_local_efficiency_impl + +test_that("average_local_efficiency_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(average_local_efficiency_impl( + graph = g + )) + expect_snapshot(average_local_efficiency_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(average_local_efficiency_impl( + graph = NULL + )) +}) + +# 162. trussness_impl + +test_that("trussness_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(trussness_impl( + graph = NULL + )) +}) + +# 163. is_graphical_impl + +test_that("is_graphical_impl basic", { + igraph_local_seed(20250909) + expect_snapshot(is_graphical_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_graphical_impl( + out_deg = "a" + )) +}) + +# 171. get_laplacian_impl + +test_that("get_laplacian_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_laplacian_impl( + graph = g + )) + expect_snapshot(get_laplacian_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_laplacian_impl( + graph = NULL + )) +}) + +# 172. get_laplacian_sparse_impl + +test_that("get_laplacian_sparse_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_laplacian_sparse_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_laplacian_sparse_impl( + graph = NULL + )) +}) + +# 173. connected_components_impl + +test_that("connected_components_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(connected_components_impl( + graph = NULL + )) +}) + +# 174. is_connected_impl + +test_that("is_connected_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_connected_impl( + graph = NULL + )) +}) + +# 175. articulation_points_impl + +test_that("articulation_points_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(articulation_points_impl( + graph = NULL + )) +}) + +# 176. biconnected_components_impl + +test_that("biconnected_components_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(biconnected_components_impl( + graph = NULL + )) +}) + +# 177. bridges_impl + +test_that("bridges_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(bridges_impl( + graph = NULL + )) +}) + +# 178. is_biconnected_impl + +test_that("is_biconnected_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_biconnected_impl( + graph = NULL + )) +}) + +# 179. count_reachable_impl + +test_that("count_reachable_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(count_reachable_impl( + graph = NULL, + mode = "out" + )) +}) + +# 180. bond_percolation_impl + +test_that("bond_percolation_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(bond_percolation_impl( + graph = NULL + )) +}) + +# 181. site_percolation_impl + +test_that("site_percolation_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(site_percolation_impl( + graph = NULL + )) +}) + +# 182. edgelist_percolation_impl + +test_that("edgelist_percolation_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(edgelist_percolation_impl( + edges = "a" + )) +}) + +# 210. similarity_dice_impl + +test_that("similarity_dice_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(similarity_dice_impl( + graph = g + )) + expect_snapshot(similarity_dice_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(similarity_dice_impl( + graph = NULL + )) +}) + +# 211. similarity_dice_es_impl + +test_that("similarity_dice_es_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(similarity_dice_es_impl( + graph = g + )) + expect_snapshot(similarity_dice_es_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(similarity_dice_es_impl( + graph = NULL + )) +}) + +# 212. similarity_dice_pairs_impl + +test_that("similarity_dice_pairs_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 4 + ) + + expect_snapshot(similarity_dice_pairs_impl( + graph = g, + pairs = matrix(c(1, 2, 2, 3), ncol = 2) + )) + expect_snapshot(similarity_dice_pairs_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + similarity_dice_pairs_impl( + graph = NULL, + pairs = matrix(c(1, 2, 2, 3), ncol = 2) + ) + ) +}) + +# 213. similarity_inverse_log_weighted_impl + +test_that("similarity_inverse_log_weighted_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(similarity_inverse_log_weighted_impl( + graph = g + )) + expect_snapshot(similarity_inverse_log_weighted_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(similarity_inverse_log_weighted_impl( + graph = NULL + )) +}) + +# 214. similarity_jaccard_impl + +test_that("similarity_jaccard_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(similarity_jaccard_impl( + graph = g + )) + expect_snapshot(similarity_jaccard_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(similarity_jaccard_impl( + graph = NULL + )) +}) + +# 215. similarity_jaccard_es_impl + +test_that("similarity_jaccard_es_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(similarity_jaccard_es_impl( + graph = g + )) + expect_snapshot(similarity_jaccard_es_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(similarity_jaccard_es_impl( + graph = NULL + )) +}) + +# 216. similarity_jaccard_pairs_impl + +test_that("similarity_jaccard_pairs_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 4 + ) + + expect_snapshot(similarity_jaccard_pairs_impl( + graph = g, + pairs = matrix(c(1, 2, 2, 3), ncol = 2) + )) + expect_snapshot(similarity_jaccard_pairs_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + similarity_jaccard_pairs_impl( + graph = NULL, + pairs = matrix(c(1, 2, 2, 3), ncol = 2) + ) + ) +}) + +# 238. get_adjacency_sparse_impl + +test_that("get_adjacency_sparse_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_adjacency_sparse_impl( + graph = g + )) + expect_snapshot(get_adjacency_sparse_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_adjacency_sparse_impl( + graph = NULL + )) +}) + +# 239. get_stochastic_impl + +test_that("get_stochastic_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_stochastic_impl( + graph = NULL + )) +}) + +# 240. get_stochastic_sparse_impl + +test_that("get_stochastic_sparse_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(get_stochastic_sparse_impl( + graph = g + )) + expect_snapshot(get_stochastic_sparse_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(get_stochastic_sparse_impl( + graph = NULL + )) +}) + +# 241. to_directed_impl + +test_that("to_directed_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(to_directed_impl( + graph = NULL + )) +}) + +# 242. to_undirected_impl + +test_that("to_undirected_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(to_undirected_impl( + graph = g + )) + expect_snapshot(to_undirected_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(to_undirected_impl( + graph = NULL + )) +}) + +# 250. local_scan_0_impl + +test_that("local_scan_0_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(local_scan_0_impl( + graph = NULL + )) +}) + +# 251. local_scan_0_them_impl + +test_that("local_scan_0_them_impl basic", { + igraph_local_seed(20250909) + 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( + 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", { + igraph_local_seed(20250909) + them <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error( + local_scan_0_them_impl( + us = NULL, + them = them + ) + ) +}) + +# 252. local_scan_1_ecount_impl + +test_that("local_scan_1_ecount_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(local_scan_1_ecount_impl( + graph = NULL + )) +}) + +# 253. local_scan_1_ecount_them_impl + +test_that("local_scan_1_ecount_them_impl basic", { + igraph_local_seed(20250909) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(local_scan_1_ecount_them_impl( + 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", { + igraph_local_seed(20250909) + them <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error( + local_scan_1_ecount_them_impl( + us = NULL, + them = them + ) + ) +}) + +# 254. local_scan_k_ecount_impl + +test_that("local_scan_k_ecount_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(local_scan_k_ecount_impl( + graph = g, + k = 1 + )) + expect_snapshot(local_scan_k_ecount_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(local_scan_k_ecount_impl( + graph = NULL, + k = 1 + )) +}) + +# 255. local_scan_k_ecount_them_impl + +test_that("local_scan_k_ecount_them_impl basic", { + igraph_local_seed(20250909) + g1 <- path_graph_impl( + n = 3 + ) + + g2 <- path_graph_impl( + n = 3 + ) + + expect_snapshot(local_scan_k_ecount_them_impl( + 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", { + igraph_local_seed(20250909) + them <- path_graph_impl( + n = 3 + ) + expect_snapshot_igraph_error( + local_scan_k_ecount_them_impl( + us = NULL, + them = them, + k = 1 + ) + ) +}) + +# 256. local_scan_neighborhood_ecount_impl + +test_that("local_scan_neighborhood_ecount_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 4 + ) + + expect_snapshot(local_scan_neighborhood_ecount_impl( + graph = g, + neighborhoods = list(1:2, 2:3, 2:4, 2) + )) + expect_snapshot(local_scan_neighborhood_ecount_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + local_scan_neighborhood_ecount_impl( + graph = NULL, + neighborhoods = list(1:2, 2:3) + ) + ) +}) + +# 257. local_scan_subset_ecount_impl + +test_that("local_scan_subset_ecount_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 4 + ) + + expect_snapshot(local_scan_subset_ecount_impl( + graph = g, + subsets = list(c(1, 2), c(2, 3)) + )) + expect_snapshot(local_scan_subset_ecount_impl( + 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", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 4 + ) + + expect_snapshot_igraph_error( + local_scan_subset_ecount_impl( + graph = g, + subsets = list(1:2, letters[2:3]) + ) + ) +}) + +# 296. is_matching_impl + +test_that("is_matching_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_matching_impl( + graph = g, + matching = 1:2 + )) + expect_snapshot(is_matching_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_matching_impl( + graph = NULL, + matching = 1:2 + )) +}) + +# 297. is_maximal_matching_impl + +test_that("is_maximal_matching_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(is_maximal_matching_impl( + graph = g, + matching = 1:2 + )) + expect_snapshot(is_maximal_matching_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_maximal_matching_impl( + graph = NULL, + matching = 1:2 + )) +}) + +# 298. maximum_bipartite_matching_impl + +test_that("maximum_bipartite_matching_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(maximum_bipartite_matching_impl( + graph = g, + types = c(TRUE, FALSE, TRUE) + )) + expect_snapshot(maximum_bipartite_matching_impl( + graph = g, + types = c(TRUE, FALSE, TRUE), + weights = c(1, 2), + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error( + maximum_bipartite_matching_impl( + graph = NULL, + types = c(TRUE, FALSE, TRUE) + ) + ) +}) + +# 301. eigen_adjacency_impl + +test_that("eigen_adjacency_impl basic", { + igraph_local_seed(20250909) + g <- path_graph_impl( + n = 3 + ) + + expect_snapshot(eigen_adjacency_impl( + graph = g + )) + expect_snapshot_igraph_error( + eigen_adjacency_impl( + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(eigen_adjacency_impl( + graph = NULL + )) +}) + +# 343. cocitation_impl + +test_that("cocitation_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(cocitation_impl( + graph = NULL + )) +}) + +# 344. bibcoupling_impl + +test_that("bibcoupling_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(bibcoupling_impl( + graph = NULL + )) +}) + +# 346. coreness_impl + +test_that("coreness_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(coreness_impl( + graph = NULL + )) +}) + +test_that("subcomponent_impl basic", { + igraph_local_seed(20250909) + g <- make_graph(~ A-B-C, D-E-F) + expect_snapshot(subcomponent_impl( + graph = g, + v = 1, + mode = c("all", "out", "in") + )) +}) + +# Other structural functions + +test_that("decompose_impl basic", { + igraph_local_seed(20250909) + g <- make_graph(~ A-B-C, D-E) + expect_snapshot(decompose_impl(graph = g, mode = c("weak", "strong"))) +}) + +test_that("neighborhood_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(neighborhood_impl( + graph = g, + order = 1, + vids = V(g), + mode = c("all", "out", "in") + )) +}) + +test_that("neighborhood_size_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(neighborhood_size_impl( + graph = g, + order = 1, + vids = V(g), + mode = c("all", "out", "in") + )) +}) + +# Graph properties + +test_that("is_chordal_impl basic", { + igraph_local_seed(20250909) + # Test with a chordal graph (complete graph is chordal) + g <- make_full_graph(4) + # alpha and alpham1 parameters must be provided as vectors matching vertex count + # alpha is a permutation vector, alpham1 is its inverse + alpha_vec <- seq_len(vcount(g)) + alpham1_vec <- seq_len(vcount(g)) + expect_snapshot(is_chordal_impl( + graph = g, + alpha = alpha_vec, + alpham1 = alpham1_vec + )) + + # Test with a non-chordal graph (4-cycle is not chordal) + g2 <- make_ring(4) + alpha_vec2 <- seq_len(vcount(g2)) + alpham1_vec2 <- seq_len(vcount(g2)) + expect_snapshot(is_chordal_impl( + graph = g2, + alpha = alpha_vec2, + alpham1 = alpham1_vec2 + )) +}) + +test_that("get_adjacency_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(3) + expect_snapshot(get_adjacency_impl( + graph = g, + type = c("both", "upper", "lower") + )) +}) + +# Spanner + +test_that("spanner_impl basic", { + igraph_local_seed(20250909) + g <- make_ring(5) + expect_snapshot(spanner_impl(graph = g, stretch = 2)) +}) diff --git a/tests/testthat/test-aaa-trees.R b/tests/testthat/test-aaa-trees.R new file mode 100644 index 00000000000..0933c195d4b --- /dev/null +++ b/tests/testthat/test-aaa-trees.R @@ -0,0 +1,153 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 126. unfold_tree_impl + +test_that("unfold_tree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(unfold_tree_impl( + graph = NULL, + roots = 1 + )) +}) + +# 314. is_tree_impl + +test_that("is_tree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_tree_impl( + graph = NULL + )) +}) + +# 315. is_forest_impl + +test_that("is_forest_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(is_forest_impl( + graph = NULL + )) +}) + +# 317. to_prufer_impl + +test_that("to_prufer_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(to_prufer_impl( + graph = NULL + )) +}) + +# 320. random_spanning_tree_impl + +test_that("random_spanning_tree_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(random_spanning_tree_impl( + graph = NULL, + vid = 1 + )) +}) diff --git a/tests/testthat/test-aaa-visitors.R b/tests/testthat/test-aaa-visitors.R new file mode 100644 index 00000000000..a32f1b725ef --- /dev/null +++ b/tests/testthat/test-aaa-visitors.R @@ -0,0 +1,191 @@ +# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate? +skip_on_cran() + +# 156. random_walk_impl + +test_that("random_walk_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(random_walk_impl( + graph = NULL, + start = 1, + steps = 2 + )) +}) + +# 164. bfs_simple_impl + +test_that("bfs_simple_impl basic", { + igraph_local_seed(20250909) + 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", { + igraph_local_seed(20250909) + expect_snapshot_igraph_error(bfs_simple_impl( + graph = NULL, + root = 1 + )) +}) + +# Callback functions + +# bfs_closure_impl + +test_that("bfs_closure_impl works", { + igraph_local_seed(20250125) + + g <- make_ring(10) + + # Collect BFS visit data + bfs_visits <- list() + result <- bfs_closure_impl( + graph = g, + root = 1, + mode = "out", + unreachable = TRUE, + restricted = NULL, + callback = function(args) { + bfs_visits[[length(bfs_visits) + 1]] <<- args + FALSE # Continue + } + ) + + expect_snapshot({ + cat("BFS result:\n") + print(result) + cat("\nNumber of BFS visits:", length(bfs_visits), "\n") + if (length(bfs_visits) > 0) { + cat("First visit:\n") + print(bfs_visits[[1]]) + } + }) + + # Test error handling + expect_snapshot_igraph_error({ + bfs_closure_impl( + graph = g, + root = 1, + mode = "out", + unreachable = TRUE, + restricted = NULL, + callback = function(args) { + NA + } + ) + }) + + expect_snapshot_igraph_error({ + bfs_closure_impl( + graph = g, + root = 1, + mode = "out", + unreachable = TRUE, + restricted = NULL, + callback = function(args) { + NA + } + ) + }) + + calls <- 0 + bfs_closure_impl( + graph = g, + root = 1, + mode = "out", + unreachable = TRUE, + restricted = NULL, + callback = function(args) { + calls <<- calls + 1 + calls > 3 # Stop after 3 calls + } + ) + expect_equal(calls, 4) # Called 4 times: 3 continue (FALSE), 1 stop (TRUE) +}) + +# dfs_closure_impl + +test_that("dfs_closure_impl works", { + igraph_local_seed(20250125) + + g <- make_ring(10) + + # Collect DFS visit data + dfs_in_visits <- list() + dfs_out_visits <- list() + result <- dfs_closure_impl( + graph = g, + root = 1, + mode = "out", + unreachable = TRUE, + in_callback = function(args) { + dfs_in_visits[[length(dfs_in_visits) + 1]] <<- args + FALSE # Continue + }, + out_callback = function(args) { + dfs_out_visits[[length(dfs_out_visits) + 1]] <<- args + FALSE # Continue + } + ) + + expect_snapshot({ + cat("DFS result:\n") + print(result) + cat("\nNumber of DFS IN visits:", length(dfs_in_visits), "\n") + cat("Number of DFS OUT visits:", length(dfs_out_visits), "\n") + if (length(dfs_in_visits) > 0) { + cat("First IN visit:\n") + print(dfs_in_visits[[1]]) + } + }) + + # Structured tests + expect_length(dfs_in_visits, 10) + expect_length(dfs_out_visits, 10) +}) diff --git a/tests/testthat/test-centrality.R b/tests/testthat/test-centrality.R index 0461860497d..649fdb7a5b9 100644 --- a/tests/testthat/test-centrality.R +++ b/tests/testthat/test-centrality.R @@ -1281,15 +1281,21 @@ test_that("hits_scores() on an edgeless graph gives NaN silently", { }) test_that("hits_scores() on an undirected graph does not warn", { + igraph_local_seed(42) expect_silent(res <- hits_scores(make_ring(3))) expect_equal(res$value, 4) }) test_that("eigen_centrality() on a disconnected graph does not warn", { + igraph_local_seed(42) g <- make_star(3, mode = "undirected") + make_ring(3) expect_silent(res <- eigen_centrality(g)) expect_equal(res$vector, c(0, 0, 0, 1, 1, 1)) + # Both rings share the leading eigenvalue 2. + # Which vector of that eigenspace ARPACK returns follows from the random + # perturbation of its start vector, so the seed keeps the RNG state that + # earlier test files leave behind from zeroing one ring. g <- make_ring(3) + make_ring(4) expect_silent(res <- eigen_centrality(g)) expect_equal(res$vector, rep(1, 7), tolerance = 1e-5) diff --git a/tests/testthat/test-community.R b/tests/testthat/test-community.R index 33830c52057..4e7adc88bd4 100644 --- a/tests/testthat/test-community.R +++ b/tests/testthat/test-community.R @@ -1045,6 +1045,7 @@ test_that("modularity_matrix() covers migrated tail args and positional recovery test_that("cluster_infomap() code length on the karate graph", { # Pins the vendored Infomap implementation. + igraph_local_seed(42) karate <- make_graph("Zachary") res <- cluster_infomap(karate, nb.trials = 1) expect_equal(code_len(res), 4.606059, tolerance = 1e-6) diff --git a/tools/AGENTS.md b/tools/AGENTS.md index 057f40f22a7..d9e86b96f60 100644 --- a/tools/AGENTS.md +++ b/tools/AGENTS.md @@ -225,7 +225,7 @@ cliques_callback <- function(graph, ..., min = NULL, max = NULL, callback = NULL Add tests in two locations: -**A. Tests for `_impl` function in `tests/testthat/test-aaa-auto.R`:** +**A. Tests for `_impl` function in `tests/testthat/test-aaa-.R`, the file mirroring the `R/aaa-.R` that defines it (here `test-aaa-cliques.R`):** ```r test_that("cliques_callback_closure_impl basic", { @@ -315,7 +315,7 @@ test_that("cliques_callback handles errors in callback", { 3. **UNPROTECT**: Match PROTECT calls with UNPROTECT (count carefully!) 4. **Error Handling**: Check for errors from R callbacks via `Rf_inherits(result, "error")` 5. **Return Values**: `TRUE` continues, `FALSE` stops early -6. **Test Location**: `_impl` tests go in `test-aaa-auto.R`, wrapper tests in feature files +6. **Test Location**: `_impl` tests go in `test-aaa-.R`, wrapper tests in feature files ### Testing Pattern diff --git a/tools/split-aaa-tests.R b/tools/split-aaa-tests.R new file mode 100644 index 00000000000..259ba43dc0e --- /dev/null +++ b/tools/split-aaa-tests.R @@ -0,0 +1,196 @@ +#!/usr/bin/env Rscript +# Distribute the tests of the generated `*_impl()` functions +# over tests/testthat/test-aaa-.R, +# so that each test sits in the file mirroring R/aaa-.R, +# the file that defines its impl. +# R/aaa-.R is itself generated from tools/aaa-categories.yaml +# by tools/split-aaa-auto.R, +# so rerun this script after that one when an impl changes category. +# +# Reads every tests/testthat/test-aaa-*.R and tests/testthat/_snaps/aaa-*.md, +# and rewrites them: +# - each top-level `test_that("_impl ...", ...)` block, +# with the comment lines between it and the previous block, +# moves byte-for-byte to the file of _impl's category, +# keeping the order in which the blocks are read; +# - each snapshot section moves to the snapshot file of its test, +# in the order of the tests, the order testthat writes them in; +# - every file starts with `header` below. +# Any other top-level code, or a comment after the last block, is an error, +# because it would have no file to move to. +# Shared helpers belong in tests/testthat/helper-*.R. +# +# Usage: Rscript tools/split-aaa-tests.R [--check] +# With --check, writes nothing, and fails if a rerun would change a file. + +script_path <- (function() { + args <- commandArgs(trailingOnly = FALSE) + m <- grep("^--file=", args, value = TRUE) + if (length(m)) sub("^--file=", "", m[1]) else "tools/split-aaa-tests.R" +})() +REPO <- normalizePath(file.path(dirname(script_path), "..")) +TEST_DIR <- file.path(REPO, "tests", "testthat") +SNAP_DIR <- file.path(TEST_DIR, "_snaps") +check <- "--check" %in% commandArgs(trailingOnly = TRUE) + +header <- c( + "# FIXME: ASAN tests for this file are crashing on CRAN, can we replicate?", + "skip_on_cran()" +) + +# ---- impl -> category, from the generated R/aaa-.R ----------------- + +impl_cat <- character() +for (path in list.files( + file.path(REPO, "R"), + "^aaa-.*\\.R$", + full.names = TRUE +)) { + cat <- sub("^aaa-(.*)\\.R$", "\\1", basename(path)) + exprs <- parse(path, keep.source = FALSE) + for (e in exprs) { + if (is.call(e) && identical(e[[1]], as.name("<-")) && is.name(e[[2]])) { + name <- as.character(e[[2]]) + if (grepl("_impl$", name)) impl_cat[[name]] <- cat + } + } +} + +# ---- read the test blocks ------------------------------------------------ + +test_files <- sort(list.files(TEST_DIR, "^test-aaa-.*\\.R$", full.names = TRUE)) +blocks <- list() +for (path in test_files) { + lines <- readLines(path, warn = FALSE) + exprs <- parse(path, keep.source = TRUE) + refs <- getSrcref(exprs) + prev <- 0L + for (i in seq_along(exprs)) { + e <- exprs[[i]] + # The lines after the previous expression, + # comments and section banners, belong to this one. + first <- prev + 1L + last <- refs[[i]][3L] + prev <- last + while (first < last && !nzchar(trimws(lines[first]))) { + first <- first + 1L + } + text <- lines[first:last] + if (identical(e, quote(skip_on_cran()))) { + if (!identical(text, header)) { + stop(basename(path), ":", first, ": the header differs from `header`") + } + next + } + if (!is.call(e) || !identical(e[[1]], as.name("test_that"))) { + stop(basename(path), ":", first, ": not a test_that() block") + } + desc <- e[[2]] + fn <- sub("[^A-Za-z0-9_.].*$", "", desc) + if (!fn %in% names(impl_cat)) { + stop( + basename(path), + ":", + first, + ": `", + desc, + "` does not start with an impl defined in R/aaa-*.R" + ) + } + blocks[[length(blocks) + 1L]] <- list( + desc = desc, + cat = impl_cat[[fn]], + text = text + ) + } + rest <- which(nzchar(trimws(lines[-seq_len(prev)]))) + prev + if (length(rest)) { + stop( + basename(path), + ":", + rest[1], + ": line after the last test_that() block" + ) + } +} + +# ---- read the snapshot sections ----------------------------------------- + +snap_files <- sort(list.files(SNAP_DIR, "^aaa-.*\\.md$", full.names = TRUE)) +sections <- list() +for (path in snap_files) { + lines <- readLines(path, warn = FALSE) + starts <- grep("^# ", lines) + ends <- c(starts[-1] - 1L, length(lines)) + for (j in seq_along(starts)) { + name <- sub("^# ", "", lines[starts[j]]) + if (!is.null(sections[[name]])) { + stop("snapshot section `", name, "` appears twice in _snaps/aaa-*.md") + } + sections[[name]] <- lines[starts[j]:ends[j]] + } +} + +# ---- compose the new files ---------------------------------------------- + +out <- list() +cats <- sort(unique(vapply(blocks, `[[`, "", "cat"))) +for (cat in cats) { + mine <- Filter(function(b) b$cat == cat, blocks) + body <- unlist(lapply(mine, function(b) c("", b$text))) + out[[file.path(TEST_DIR, paste0("test-aaa-", cat, ".R"))]] <- c(header, body) + + descs <- unique(vapply(mine, `[[`, "", "desc")) + snaps <- unlist( + sections[intersect(descs, names(sections))], + use.names = FALSE + ) + if (length(snaps)) { + out[[file.path(SNAP_DIR, paste0("aaa-", cat, ".md"))]] <- snaps + } +} + +orphans <- setdiff(names(sections), vapply(blocks, `[[`, "", "desc")) +if (length(orphans)) { + stop("snapshot sections without a test: ", paste(orphans, collapse = ", ")) +} + +# ---- write, or compare -------------------------------------------------- + +stale <- setdiff(c(test_files, snap_files), names(out)) +changed <- names(out)[vapply( + names(out), + function(path) { + !file.exists(path) || !identical(readLines(path, warn = FALSE), out[[path]]) + }, + logical(1) +)] +rel <- function(paths) sub(paste0(REPO, "/"), "", paths, fixed = TRUE) + +if (check) { + if (length(stale) || length(changed)) { + message( + "split-aaa-tests.R: these files are out of date, ", + "run `Rscript tools/split-aaa-tests.R` and commit the result:\n ", + paste(rel(c(stale, changed)), collapse = "\n ") + ) + quit(status = 1) + } + message("split-aaa-tests.R: all ", length(blocks), " impl tests are in place") +} else { + invisible(file.remove(stale)) + for (path in changed) { + writeLines(out[[path]], path) + } + message( + "split-aaa-tests.R: wrote ", + length(changed), + " and removed ", + length(stale), + " file(s); ", + length(blocks), + " tests in ", + length(cats), + " files" + ) +}