From de1a55c980c09807b37772ed23096124769145c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sun, 17 Aug 2025 07:14:32 +0200 Subject: [PATCH 1/2] feat: Generate almost all R implementations --- R/aaa-auto.R | 1543 ++++++++++++++++++++++++++++--- src/cpp11.cpp | 10 + tools/stimulus/functions-R.yaml | 521 +---------- tools/stimulus/types-RR.yaml | 6 +- 4 files changed, 1449 insertions(+), 631 deletions(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index 661515345b9..c722bb495b8 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -185,6 +185,41 @@ regular_tree_impl <- function(h, k=3, type=c("undirected", "out", "in")) { res } +full_citation_impl <- function(n, directed=TRUE) { + # Argument checks + n <- as.numeric(n) + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_full_citation, n, directed) + + res +} + +atlas_impl <- function(number=0) { + # Argument checks + number <- as.numeric(number) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_atlas, number) + + res +} + +extended_chordal_ring_impl <- function(nodes, W, directed=FALSE) { + # Argument checks + nodes <- as.numeric(nodes) + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_extended_chordal_ring, nodes, W, directed) + + res +} + graph_power_impl <- function(graph, order, directed=FALSE) { # Argument checks ensure_igraph(graph) @@ -198,6 +233,41 @@ graph_power_impl <- function(graph, order, directed=FALSE) { res } +linegraph_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_linegraph, graph) + + res +} + +de_bruijn_impl <- function(m, n) { + # Argument checks + m <- as.numeric(m) + n <- as.numeric(n) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_de_bruijn, m, n) + + res +} + +kautz_impl <- function(m, n) { + # Argument checks + m <- as.numeric(m) + n <- as.numeric(n) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_kautz, m, n) + + res +} + lcf_vector_impl <- function(n, shifts, repeats=1) { # Argument checks n <- as.numeric(n) @@ -239,6 +309,22 @@ adjlist_impl <- function(adjlist, mode=c("out", "in", "all", "total"), duplicate res } +full_bipartite_impl <- function(n1, n2, directed=FALSE, mode=c("all", "out", "in", "total")) { + # Argument checks + n1 <- as.numeric(n1) + n2 <- as.numeric(n2) + directed <- as.logical(directed) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_full_bipartite, n1, n2, directed, mode) + if (igraph_opt("add.vertex.names") && is_named()) { + names(res$types) <- vertex_attr(, "name", ) + } + res +} + full_multipartite_impl <- function(n, directed=FALSE, mode=c("all", "out", "in", "total")) { # Argument checks n <- as.numeric(n) @@ -384,6 +470,67 @@ growing_random_game_impl <- function(n, m=1, ..., directed=TRUE, citation=FALSE) res } +preference_game_impl <- function(nodes, types, type.dist, fixed.sizes=FALSE, pref.matrix, directed=FALSE, loops=FALSE) { + # Argument checks + nodes <- as.numeric(nodes) + types <- as.numeric(types) + type.dist <- as.numeric(type.dist) + fixed.sizes <- as.logical(fixed.sizes) + pref.matrix[] <- as.numeric(pref.matrix) + directed <- as.logical(directed) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_preference_game, nodes, types, type.dist, fixed.sizes, pref.matrix, directed, loops) + + res +} + +asymmetric_preference_game_impl <- function(nodes, out.types, in.types, type.dist.matrix, pref.matrix, loops=FALSE) { + # Argument checks + nodes <- as.numeric(nodes) + out.types <- as.numeric(out.types) + in.types <- as.numeric(in.types) + type.dist.matrix[] <- as.numeric(type.dist.matrix) + pref.matrix[] <- as.numeric(pref.matrix) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_asymmetric_preference_game, nodes, out.types, in.types, type.dist.matrix, pref.matrix, loops) + + res +} + +rewire_edges_impl <- function(graph, prob, loops=FALSE, multiple=FALSE) { + # Argument checks + ensure_igraph(graph) + prob <- as.numeric(prob) + loops <- as.logical(loops) + multiple <- as.logical(multiple) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_rewire_edges, graph, prob, loops, multiple) + + res +} + +rewire_directed_edges_impl <- function(graph, prob, loops=FALSE, mode=c("out", "in", "all", "total")) { + # Argument checks + ensure_igraph(graph) + prob <- as.numeric(prob) + loops <- as.logical(loops) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_rewire_directed_edges, graph, prob, loops, mode) + + res +} + forest_fire_game_impl <- function(nodes, fw.prob, bw.factor=1, ambs=1, directed=TRUE) { # Argument checks nodes <- as.numeric(nodes) @@ -681,6 +828,55 @@ are_adjacent_impl <- function(graph, v1, v2) { res } +closeness_impl <- function(graph, vids=V(graph), mode=c("out", "in", "all", "total"), weights=NULL, normalized=FALSE) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + normalized <- as.logical(normalized) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_closeness, graph, vids-1, mode, weights, normalized) + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res$res) <- vertex_attr(graph, "name", vids) + } + res +} + +closeness_cutoff_impl <- function(graph, vids=V(graph), mode=c("out", "in", "all", "total"), weights=NULL, normalized=FALSE, cutoff=-1) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + normalized <- as.logical(normalized) + cutoff <- as.numeric(cutoff) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_closeness_cutoff, graph, vids-1, mode, weights, normalized, cutoff) + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res$res) <- vertex_attr(graph, "name", vids) + } + res +} + get_shortest_path_impl <- function(graph, from, to, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) @@ -772,6 +968,58 @@ get_shortest_path_dijkstra_impl <- function(graph, from, to, weights=NULL, mode= res } +get_all_shortest_paths_impl <- function(graph, from, to, mode=c("out", "in", "all", "total")) { + # Argument checks + ensure_igraph(graph) + from <- as_igraph_vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + to <- as_igraph_vs(graph, to) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_all_shortest_paths, graph, from-1, to-1, mode) + if (igraph_opt("return.vs.es")) { + res$vpaths <- lapply(res$vpaths, unsafe_create_vs, graph = , verts = V()) + } + if (igraph_opt("return.vs.es")) { + res$epaths <- lapply(res$epaths, unsafe_create_es, graph = graph, es = E(graph)) + } + res +} + +get_all_shortest_paths_dijkstra_impl <- function(graph, from, to=V(graph), weights=NULL, mode=c("out", "in", "all", "total")) { + # Argument checks + ensure_igraph(graph) + from <- as_igraph_vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + to <- as_igraph_vs(graph, to) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_all_shortest_paths_dijkstra, graph, from-1, to-1, weights, mode) + if (igraph_opt("return.vs.es")) { + res$vpaths <- lapply(res$vpaths, unsafe_create_vs, graph = graph, verts = V(graph)) + } + if (igraph_opt("return.vs.es")) { + res$epaths <- lapply(res$epaths, unsafe_create_es, graph = graph, es = E(graph)) + } + res +} + voronoi_impl <- function(graph, generators, ..., weights=NULL, mode=c("out", "in", "all", "total"), tiebreaker=c("random", "first", "last")) { # Argument checks check_dots_empty() @@ -795,6 +1043,26 @@ voronoi_impl <- function(graph, generators, ..., weights=NULL, mode=c("out", "in res } +get_all_simple_paths_impl <- function(graph, from, to=V(graph), cutoff=-1, mode=c("out", "in", "all", "total")) { + # Argument checks + ensure_igraph(graph) + from <- as_igraph_vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + to <- as_igraph_vs(graph, to) + cutoff <- as.numeric(cutoff) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_all_simple_paths, graph, from-1, to-1, cutoff, mode) + if (igraph_opt("return.vs.es")) { + res <- create_vs(graph, res) + } + res +} + get_k_shortest_paths_impl <- function(graph, from, to, ..., k, weights=NULL, mode=c("out", "in", "all", "total")) { # Argument checks check_dots_empty() @@ -959,13 +1227,11 @@ spanner_impl <- function(graph, stretch, weights=NULL) { res } -betweenness_subset_impl <- function(graph, vids=V(graph), directed=TRUE, sources=V(graph), targets=V(graph), weights=NULL) { +betweenness_cutoff_impl <- function(graph, vids=V(graph), directed=TRUE, weights=NULL, cutoff=-1) { # Argument checks ensure_igraph(graph) vids <- as_igraph_vs(graph, vids) directed <- as.logical(directed) - sources <- as_igraph_vs(graph, sources) - targets <- as_igraph_vs(graph, targets) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -974,20 +1240,21 @@ betweenness_subset_impl <- function(graph, vids=V(graph), directed=TRUE, sources } else { weights <- NULL } + cutoff <- as.numeric(cutoff) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_betweenness_subset, graph, vids-1, directed, sources-1, targets-1, weights) + res <- .Call(R_igraph_betweenness_cutoff, graph, vids-1, directed, weights, cutoff) if (igraph_opt("add.vertex.names") && is_named(graph)) { names(res) <- vertex_attr(graph, "name", vids) } res } -edge_betweenness_subset_impl <- function(graph, eids=E(graph), directed=TRUE, sources=V(graph), targets=V(graph), weights=NULL) { +betweenness_subset_impl <- function(graph, vids=V(graph), directed=TRUE, sources=V(graph), targets=V(graph), weights=NULL) { # Argument checks ensure_igraph(graph) - eids <- as_igraph_es(graph, eids) + vids <- as_igraph_vs(graph, vids) directed <- as.logical(directed) sources <- as_igraph_vs(graph, sources) targets <- as_igraph_vs(graph, targets) @@ -1002,16 +1269,17 @@ edge_betweenness_subset_impl <- function(graph, eids=E(graph), directed=TRUE, so on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_edge_betweenness_subset, graph, eids-1, directed, sources-1, targets-1, weights) - + res <- .Call(R_igraph_betweenness_subset, graph, vids-1, directed, sources-1, targets-1, weights) + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res) <- vertex_attr(graph, "name", vids) + } res } -harmonic_centrality_cutoff_impl <- function(graph, vids=V(graph), mode=c("out", "in", "all", "total"), weights=NULL, normalized=FALSE, cutoff=-1) { +edge_betweenness_impl <- function(graph, directed=TRUE, weights=NULL) { # Argument checks ensure_igraph(graph) - vids <- as_igraph_vs(graph, vids) - mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + directed <- as.logical(directed) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -1020,26 +1288,91 @@ harmonic_centrality_cutoff_impl <- function(graph, vids=V(graph), mode=c("out", } else { weights <- NULL } - normalized <- as.logical(normalized) - cutoff <- as.numeric(cutoff) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_harmonic_centrality_cutoff, graph, vids-1, mode, weights, normalized, cutoff) - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- vertex_attr(graph, "name", vids) - } + res <- .Call(R_igraph_edge_betweenness, graph, directed, weights) + res } -personalized_pagerank_impl <- function(graph, algo=c("prpack", "arpack"), vids=V(graph), directed=TRUE, damping=0.85, personalized=NULL, weights=NULL, options=NULL) { +edge_betweenness_cutoff_impl <- function(graph, directed=TRUE, weights=NULL, cutoff=-1) { # Argument checks ensure_igraph(graph) - algo <- switch(igraph.match.arg(algo), "arpack"=1L, "prpack"=2L) - vids <- as_igraph_vs(graph, vids) directed <- as.logical(directed) - damping <- as.numeric(damping) - if (!is.null(personalized)) personalized <- as.numeric(personalized) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + cutoff <- as.numeric(cutoff) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_edge_betweenness_cutoff, graph, directed, weights, cutoff) + + res +} + +edge_betweenness_subset_impl <- function(graph, eids=E(graph), directed=TRUE, sources=V(graph), targets=V(graph), weights=NULL) { + # Argument checks + ensure_igraph(graph) + eids <- as_igraph_es(graph, eids) + directed <- as.logical(directed) + sources <- as_igraph_vs(graph, sources) + targets <- as_igraph_vs(graph, targets) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_edge_betweenness_subset, graph, eids-1, directed, sources-1, targets-1, weights) + + res +} + +harmonic_centrality_cutoff_impl <- function(graph, vids=V(graph), mode=c("out", "in", "all", "total"), weights=NULL, normalized=FALSE, cutoff=-1) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + normalized <- as.logical(normalized) + cutoff <- as.numeric(cutoff) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_harmonic_centrality_cutoff, graph, vids-1, mode, weights, normalized, cutoff) + if (igraph_opt("add.vertex.names") && is_named(graph)) { + names(res) <- vertex_attr(graph, "name", vids) + } + res +} + +personalized_pagerank_impl <- function(graph, algo=c("prpack", "arpack"), vids=V(graph), directed=TRUE, damping=0.85, personalized=NULL, weights=NULL, options=NULL) { + # Argument checks + ensure_igraph(graph) + algo <- switch(igraph.match.arg(algo), "arpack"=1L, "prpack"=2L) + vids <- as_igraph_vs(graph, vids) + directed <- as.logical(directed) + damping <- as.numeric(damping) + if (!is.null(personalized)) personalized <- as.numeric(personalized) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -1105,6 +1438,19 @@ personalized_pagerank_vs_impl <- function(graph, algo=c("prpack", "arpack"), vid res } +induced_subgraph_impl <- function(graph, vids, impl=c("auto", "copy_and_delete", "create_from_scratch")) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + impl <- switch(igraph.match.arg(impl), "auto"=0L, "copy_and_delete"=1L, "create_from_scratch"=2L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_induced_subgraph, graph, vids-1, impl) + + res +} + subgraph_from_edges_impl <- function(graph, eids, delete.vertices=TRUE) { # Argument checks ensure_igraph(graph) @@ -1179,6 +1525,60 @@ simplify_impl <- function(graph, remove.multiple=TRUE, remove.loops=TRUE, edge.a res } +transitivity_undirected_impl <- function(graph, mode=NAN) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_transitivity_undirected, graph, mode) + + res +} + +transitivity_local_undirected_impl <- function(graph, vids=V(graph), mode=NAN) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_transitivity_local_undirected, graph, vids-1, mode) + + res +} + +transitivity_avglocal_undirected_impl <- function(graph, mode=NAN) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_transitivity_avglocal_undirected, graph, mode) + + res +} + +transitivity_barrat_impl <- function(graph, vids=V(graph), weights=NULL, mode=NAN) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_transitivity_barrat, graph, vids-1, weights, mode) + + res +} + ecc_impl <- function(graph, eids=E(graph), k=3, offset=FALSE, normalize=TRUE) { # Argument checks ensure_igraph(graph) @@ -1453,6 +1853,19 @@ hub_and_authority_scores_impl <- function(graph, scale=TRUE, weights=NULL, optio res } +unfold_tree_impl <- function(graph, mode=c("all", "out", "in", "total"), roots) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + roots <- as.numeric(roots) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_unfold_tree, graph, mode, roots) + + res +} + is_mutual_impl <- function(graph, eids=E(graph), loops=TRUE) { # Argument checks ensure_igraph(graph) @@ -1589,6 +2002,20 @@ centralization_degree_impl <- function(graph, mode=c("all", "out", "in", "total" res } +centralization_degree_tmax_impl <- function(graph=NULL, nodes=0, mode=c("all", "out", "in", "total"), loops) { + # Argument checks + if (!is.null(graph)) ensure_igraph(graph) + nodes <- as.numeric(nodes) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_centralization_degree_tmax, graph, nodes, mode, loops) + + res +} + centralization_betweenness_impl <- function(graph, directed=TRUE, normalized=TRUE) { # Argument checks ensure_igraph(graph) @@ -2211,6 +2638,20 @@ get_laplacian_sparse_impl <- function(graph, mode=c("out", "in", "all", "total") res } +connected_components_impl <- function(graph, mode=c("weak", "strong"), details=FALSE) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "weak"=1L, "strong"=2L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_connected_components, graph, mode) + if (!details) { + res <- res$membership + } + res +} + is_connected_impl <- function(graph, mode=c("weak", "strong")) { # Argument checks ensure_igraph(graph) @@ -2483,196 +2924,589 @@ is_independent_vertex_set_impl <- function(graph, candidate) { res } -roots_for_tree_layout_impl <- function(graph, mode=c("out", "in", "all", "total"), heuristic) { +layout_random_impl <- function(graph) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_roots_for_tree_layout, graph, mode, heuristic) - if (igraph_opt("return.vs.es")) { - res <- create_vs(graph, res) - } + res <- .Call(R_igraph_layout_random, graph) + res } -layout_umap_impl <- function(graph, res, use.seed=FALSE, distances=NULL, min.dist=0.0, epochs=200, distances.are.weights=FALSE) { +layout_circle_impl <- function(graph, order=V(graph)) { # Argument checks ensure_igraph(graph) - res[] <- as.numeric(res) - use.seed <- as.logical(use.seed) - if (!is.null(distances)) distances <- as.numeric(distances) - min.dist <- as.numeric(min.dist) - epochs <- as.numeric(epochs) - distances.are.weights <- as.logical(distances.are.weights) + order <- as_igraph_vs(graph, order) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_layout_umap, graph, res, use.seed, distances, min.dist, epochs, distances.are.weights) + res <- .Call(R_igraph_layout_circle, graph, order-1) res } -layout_umap_3d_impl <- function(graph, res, use.seed=FALSE, distances=NULL, min.dist=0.0, epochs=200, distances.are.weights=FALSE) { +layout_star_impl <- function(graph, center=V(graph)[1], order=NULL) { # Argument checks ensure_igraph(graph) - res[] <- as.numeric(res) - use.seed <- as.logical(use.seed) - if (!is.null(distances)) distances <- as.numeric(distances) - min.dist <- as.numeric(min.dist) - epochs <- as.numeric(epochs) - distances.are.weights <- as.logical(distances.are.weights) + center <- as_igraph_vs(graph, center) + if (length(center) == 0) { + stop("No vertex was specified") + } + if (!is.null(order)) order <- as.numeric(order)-1 on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_layout_umap_3d, graph, res, use.seed, distances, min.dist, epochs, distances.are.weights) + res <- .Call(R_igraph_layout_star, graph, center-1, order) res } -layout_umap_compute_weights_impl <- function(graph, distances, weights) { +layout_grid_impl <- function(graph, width=0) { # Argument checks ensure_igraph(graph) - distances <- as.numeric(distances) - weights <- as.numeric(weights) + width <- as.numeric(width) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_layout_umap_compute_weights, graph, distances, weights) + res <- .Call(R_igraph_layout_grid, graph, width) res } -layout_align_impl <- function(graph, layout) { +layout_grid_3d_impl <- function(graph, width=0, height=0) { # Argument checks ensure_igraph(graph) - layout[] <- as.numeric(layout) + width <- as.numeric(width) + height <- as.numeric(height) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_layout_align, graph, layout) + res <- .Call(R_igraph_layout_grid_3d, graph, width, height) res } -similarity_dice_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { +roots_for_tree_layout_impl <- function(graph, mode=c("out", "in", "all", "total"), heuristic) { # Argument checks ensure_igraph(graph) - vids <- as_igraph_vs(graph, vids) mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) - loops <- as.logical(loops) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_dice, graph, vids-1, mode, loops) - + res <- .Call(R_igraph_roots_for_tree_layout, graph, mode, heuristic) + if (igraph_opt("return.vs.es")) { + res <- create_vs(graph, res) + } res } -similarity_dice_es_impl <- function(graph, es=E(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { +layout_random_3d_impl <- function(graph) { # Argument checks ensure_igraph(graph) - es <- as_igraph_es(graph, es) - mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) - loops <- as.logical(loops) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_dice_es, graph, es-1, mode, loops) + res <- .Call(R_igraph_layout_random_3d, graph) res } -similarity_dice_pairs_impl <- function(graph, pairs, mode=c("all", "out", "in", "total"), loops=FALSE) { +layout_sphere_impl <- function(graph) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) - loops <- as.logical(loops) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_dice_pairs, graph, pairs, mode, loops) + res <- .Call(R_igraph_layout_sphere, graph) res } -similarity_inverse_log_weighted_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total")) { +layout_sugiyama_impl <- function(graph, layers=NULL, hgap=1, vgap=1, maxiter=100, weights=NULL) { # Argument checks ensure_igraph(graph) - vids <- as_igraph_vs(graph, vids) - mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + if (!is.null(layers)) layers <- as.numeric(layers)-1 + hgap <- as.numeric(hgap) + vgap <- as.numeric(vgap) + maxiter <- as.numeric(maxiter) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_inverse_log_weighted, graph, vids-1, mode) + res <- .Call(R_igraph_layout_sugiyama, graph, layers, hgap, vgap, maxiter, weights) res } -similarity_jaccard_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { +layout_mds_impl <- function(graph, dist=NULL, dim=2) { # Argument checks ensure_igraph(graph) - vids <- as_igraph_vs(graph, vids) - mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) - loops <- as.logical(loops) + if (!is.null(dist)) dist[] <- as.numeric(dist) + dim <- as.numeric(dim) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_jaccard, graph, vids-1, mode, loops) + res <- .Call(R_igraph_layout_mds, graph, dist, dim) res } -similarity_jaccard_es_impl <- function(graph, es=E(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { +layout_bipartite_impl <- function(graph, types, hgap=1, vgap=1, maxiter=100) { # Argument checks ensure_igraph(graph) - es <- as_igraph_es(graph, es) - mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) - loops <- as.logical(loops) + types <- handle_vertex_type_arg(types, graph) + hgap <- as.numeric(hgap) + vgap <- as.numeric(vgap) + maxiter <- as.numeric(maxiter) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_jaccard_es, graph, es-1, mode, loops) + res <- .Call(R_igraph_layout_bipartite, graph, types, hgap, vgap, maxiter) res } -similarity_jaccard_pairs_impl <- function(graph, pairs, mode=c("all", "out", "in", "total"), loops=FALSE) { +layout_gem_impl <- function(graph, res=matrix(), use.seed=FALSE, maxiter=40*vcount(graph)^2, temp.max=vcount(graph), temp.min=1/10, temp.init=sqrt(vcount(graph))) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) - loops <- as.logical(loops) + res[] <- as.numeric(res) + use.seed <- as.logical(use.seed) + maxiter <- as.numeric(maxiter) + temp.max <- as.numeric(temp.max) + temp.min <- as.numeric(temp.min) + temp.init <- as.numeric(temp.init) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_jaccard_pairs, graph, pairs, mode, loops) + res <- .Call(R_igraph_layout_gem, graph, res, use.seed, maxiter, temp.max, temp.min, temp.init) res } -graphlets_impl <- function(graph, weights=NULL, niter=1000) { +layout_davidson_harel_impl <- function(graph, res=matrix(), use.seed=FALSE, maxiter=10, fineiter=max(10, log2(vcount(graph))), cool.fact=0.75, weight.node.dist=1.0, weight.border=0.0, weight.edge.lengths=edge_density(graph) / 10, weight.edge.crossings=1.0 - sqrt(edge_density(graph)), weight.node.edge.dist=0.2 * (1-edge_density(graph))) { # Argument checks ensure_igraph(graph) - if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { - weights <- E(graph)$weight - } - if (!is.null(weights) && any(!is.na(weights))) { - weights <- as.numeric(weights) - } else { - weights <- NULL - } - niter <- as.numeric(niter) + res[] <- as.numeric(res) + use.seed <- as.logical(use.seed) + maxiter <- as.numeric(maxiter) + fineiter <- as.numeric(fineiter) + cool.fact <- as.numeric(cool.fact) + weight.node.dist <- as.numeric(weight.node.dist) + weight.border <- as.numeric(weight.border) + weight.edge.lengths <- as.numeric(weight.edge.lengths) + weight.edge.crossings <- as.numeric(weight.edge.crossings) + weight.node.edge.dist <- as.numeric(weight.node.edge.dist) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_graphlets, graph, weights, niter) + res <- .Call(R_igraph_layout_davidson_harel, graph, res, use.seed, maxiter, fineiter, cool.fact, weight.node.dist, weight.border, weight.edge.lengths, weight.edge.crossings, weight.node.edge.dist) + + res +} + +layout_umap_impl <- function(graph, res, use.seed=FALSE, distances=NULL, min.dist=0.0, epochs=200, distances.are.weights=FALSE) { + # Argument checks + ensure_igraph(graph) + res[] <- as.numeric(res) + use.seed <- as.logical(use.seed) + if (!is.null(distances)) distances <- as.numeric(distances) + min.dist <- as.numeric(min.dist) + epochs <- as.numeric(epochs) + distances.are.weights <- as.logical(distances.are.weights) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_layout_umap, graph, res, use.seed, distances, min.dist, epochs, distances.are.weights) + + res +} + +layout_umap_3d_impl <- function(graph, res, use.seed=FALSE, distances=NULL, min.dist=0.0, epochs=200, distances.are.weights=FALSE) { + # Argument checks + ensure_igraph(graph) + res[] <- as.numeric(res) + use.seed <- as.logical(use.seed) + if (!is.null(distances)) distances <- as.numeric(distances) + min.dist <- as.numeric(min.dist) + epochs <- as.numeric(epochs) + distances.are.weights <- as.logical(distances.are.weights) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_layout_umap_3d, graph, res, use.seed, distances, min.dist, epochs, distances.are.weights) + + res +} + +layout_umap_compute_weights_impl <- function(graph, distances, weights) { + # Argument checks + ensure_igraph(graph) + distances <- as.numeric(distances) + weights <- as.numeric(weights) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_layout_umap_compute_weights, graph, distances, weights) + + res +} + +layout_align_impl <- function(graph, layout) { + # Argument checks + ensure_igraph(graph) + layout[] <- as.numeric(layout) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_layout_align, graph, layout) + + res +} + +similarity_dice_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_dice, graph, vids-1, mode, loops) + + res +} + +similarity_dice_es_impl <- function(graph, es=E(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + es <- as_igraph_es(graph, es) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_dice_es, graph, es-1, mode, loops) + + res +} + +similarity_dice_pairs_impl <- function(graph, pairs, mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_dice_pairs, graph, pairs, mode, loops) + + res +} + +similarity_inverse_log_weighted_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total")) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_inverse_log_weighted, graph, vids-1, mode) + + res +} + +similarity_jaccard_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_jaccard, graph, vids-1, mode, loops) + + res +} + +similarity_jaccard_es_impl <- function(graph, es=E(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + es <- as_igraph_es(graph, es) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_jaccard_es, graph, es-1, mode, loops) + + res +} + +similarity_jaccard_pairs_impl <- function(graph, pairs, mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_jaccard_pairs, graph, pairs, mode, loops) + + res +} + +compare_communities_impl <- function(comm1, comm2, method=c("vi", "nmi", "split.join", "rand", "adjusted.rand")) { + # Argument checks + comm1 <- as.numeric(comm1) + comm2 <- as.numeric(comm2) + method <- switch(igraph.match.arg(method), "vi"=0L, "nmi"=1L, "split.join"=2L, "rand"=3L, "adjusted.rand"=4L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_compare_communities, comm1, comm2, method) + + res +} + +modularity_impl <- function(graph, membership, weights=NULL, resolution=1.0, directed=TRUE) { + # Argument checks + ensure_igraph(graph) + membership <- as.numeric(membership) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + resolution <- as.numeric(resolution) + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_modularity, graph, membership, weights, resolution, directed) + + res +} + +modularity_matrix_impl <- function(graph, weights=NULL, resolution=1.0, directed=TRUE) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + resolution <- as.numeric(resolution) + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_modularity_matrix, graph, weights, resolution, directed) + + res +} + +community_fluid_communities_impl <- function(graph, no.of.communities) { + # Argument checks + ensure_igraph(graph) + no.of.communities <- as.numeric(no.of.communities) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_community_fluid_communities, graph, no.of.communities) + + res +} + +community_label_propagation_impl <- function(graph, mode=c("all", "out", "in", "total"), weights=NULL, initial=NULL, fixed=NULL) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + if (!is.null(initial)) initial <- as.numeric(initial)-1 + if (!is.null(fixed)) fixed <- as.logical(fixed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_community_label_propagation, graph, mode, weights, initial, fixed) + + res +} + +community_multilevel_impl <- function(graph, weights=NULL, resolution=1.0) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + resolution <- as.numeric(resolution) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_community_multilevel, graph, weights, resolution) + + res +} + +community_optimal_modularity_impl <- function(graph, weights=NULL) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_community_optimal_modularity, graph, weights) + + res +} + +community_leiden_impl <- function(graph, weights=NULL, vertex.weights=NULL, resolution, beta=0.01, start, n.iterations=2, membership=NULL) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + if (is.null(vertex.weights) && "weight" %in% vertex_attr_names(graph)) { + vertex.weights <- V(graph)$weight + } + if (!is.null(vertex.weights) && any(!is.na(vertex.weights))) { + vertex.weights <- as.numeric(vertex.weights) + } else { + vertex.weights <- NULL + } + resolution <- as.numeric(resolution) + beta <- as.numeric(beta) + start <- as.logical(start) + n.iterations <- as.numeric(n.iterations) + if (!is.null(membership)) membership <- as.numeric(membership) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_community_leiden, graph, weights, vertex.weights, resolution, beta, start, n.iterations, membership) + + res +} + +split_join_distance_impl <- function(comm1, comm2) { + # Argument checks + comm1 <- as.numeric(comm1) + comm2 <- as.numeric(comm2) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_split_join_distance, comm1, comm2) + + res +} + +community_infomap_impl <- function(graph, e.weights=NULL, v.weights=NULL, nb.trials=10) { + # Argument checks + ensure_igraph(graph) + if (is.null(e.weights) && "weight" %in% edge_attr_names(graph)) { + e.weights <- E(graph)$weight + } + if (!is.null(e.weights) && any(!is.na(e.weights))) { + e.weights <- as.numeric(e.weights) + } else { + e.weights <- NULL + } + if (is.null(v.weights) && "weight" %in% vertex_attr_names(graph)) { + v.weights <- V(graph)$weight + } + if (!is.null(v.weights) && any(!is.na(v.weights))) { + v.weights <- as.numeric(v.weights) + } else { + v.weights <- NULL + } + nb.trials <- as.numeric(nb.trials) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_community_infomap, graph, e.weights, v.weights, nb.trials) + + res +} + +graphlets_impl <- function(graph, weights=NULL, niter=1000) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + niter <- as.numeric(niter) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_graphlets, graph, weights, niter) if (igraph_opt("return.vs.es")) { res$cliques <- lapply(res$cliques, unsafe_create_vs, graph = graph, verts = V(graph)) } res } +hrg_fit_impl <- function(graph, hrg=NULL, start=FALSE, steps=0) { + # Argument checks + ensure_igraph(graph) + if (is.null(hrg)) { + hrg <- list(left=c(), right=c(), prob=c(), edges=c(), vertices=c()) + } + hrg <- lapply(hrg[c("left","right","prob","edges","vertices")], as.numeric) + start <- as.logical(start) + steps <- as.numeric(steps) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_hrg_fit, graph, hrg, start, steps) + + res +} + hrg_sample_impl <- function(hrg) { # Argument checks if (is.null(hrg)) { @@ -2737,6 +3571,26 @@ hrg_consensus_impl <- function(graph, hrg=NULL, start=FALSE, num.samples=10000) res } +hrg_predict_impl <- function(graph, hrg=NULL, start=FALSE, num.samples=10000, num.bins=25) { + # Argument checks + ensure_igraph(graph) + if (is.null(hrg)) { + hrg <- list(left=c(), right=c(), prob=c(), edges=c(), vertices=c()) + } + hrg <- lapply(hrg[c("left","right","prob","edges","vertices")], as.numeric) + start <- as.logical(start) + num.samples <- as.numeric(num.samples) + num.bins <- as.numeric(num.bins) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_hrg_predict, graph, hrg, start, num.samples, num.bins) + if (igraph_opt("return.vs.es")) { + res$edges <- create_vs(graph, res$edges) + } + res +} + hrg_create_impl <- function(graph, prob) { # Argument checks ensure_igraph(graph) @@ -2794,6 +3648,46 @@ from_hrg_dendrogram_impl <- function(hrg) { res } +get_adjacency_sparse_impl <- function(graph, type=c("both", "upper", "lower"), weights=NULL, loops=ONCE) { + # Argument checks + ensure_igraph(graph) + type <- switch(igraph.match.arg(type), "upper"=0L, "lower"=1L, "both"=2L) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_adjacency_sparse, graph, type, weights, loops) + + res +} + +get_stochastic_impl <- function(graph, column.wise=FALSE, weights=NULL) { + # Argument checks + ensure_igraph(graph) + column.wise <- as.logical(column.wise) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_stochastic, graph, column.wise, weights) + + res +} + get_stochastic_sparse_impl <- function(graph, column.wise=FALSE, weights=NULL) { # Argument checks ensure_igraph(graph) @@ -2809,64 +3703,262 @@ get_stochastic_sparse_impl <- function(graph, column.wise=FALSE, weights=NULL) { on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_get_stochastic_sparse, graph, column.wise, weights) + res <- .Call(R_igraph_get_stochastic_sparse, graph, column.wise, weights) + + res +} + +to_directed_impl <- function(graph, mode=c("mutual", "arbitrary", "random", "acyclic")) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "arbitrary"=0L, "mutual"=1L, "random"=2L, "acyclic"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_to_directed, graph, mode) + + res +} + +to_undirected_impl <- function(graph, mode=c("collapse", "each", "mutual"), edge.attr.comb=igraph_opt("edge.attr.comb")) { + # Argument checks + ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "collapse"=1L, "each"=0L, "mutual"=2L) + edge.attr.comb <- igraph.i.attribute.combination(edge.attr.comb) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_to_undirected, graph, mode, edge.attr.comb) + + res +} + +motifs_randesu_impl <- function(graph, size=3, cut.prob=NULL) { + # Argument checks + ensure_igraph(graph) + size <- as.numeric(size) + if (!is.null(cut.prob)) cut.prob <- as.numeric(cut.prob) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_motifs_randesu, graph, size, cut.prob) + + res +} + +motifs_randesu_estimate_impl <- function(graph, size=3, cut.prob=NULL, sample.size, sample=NULL) { + # Argument checks + ensure_igraph(graph) + size <- as.numeric(size) + if (!is.null(cut.prob)) cut.prob <- as.numeric(cut.prob) + sample.size <- as.numeric(sample.size) + if (!is.null(sample)) sample <- as.numeric(sample) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_motifs_randesu_estimate, graph, size, cut.prob, sample.size, sample) + + res +} + +motifs_randesu_no_impl <- function(graph, size=3, cut.prob=NULL) { + # Argument checks + ensure_igraph(graph) + size <- as.numeric(size) + if (!is.null(cut.prob)) cut.prob <- as.numeric(cut.prob) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_motifs_randesu_no, graph, size, cut.prob) + + res +} + +dyad_census_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_dyad_census, graph) + + res +} + +triad_census_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_triad_census, graph) + + res +} + +count_adjacent_triangles_impl <- function(graph, vids=V(graph)) { + # Argument checks + ensure_igraph(graph) + vids <- as_igraph_vs(graph, vids) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_count_adjacent_triangles, graph, vids-1) + + res +} + +count_triangles_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_count_triangles, graph) + + res +} + +local_scan_0_impl <- function(graph, weights=NULL, mode=c("out", "in", "all", "total")) { + # Argument checks + ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_local_scan_0, graph, weights, mode) + + res +} + +local_scan_0_them_impl <- function(us, them, weights.them=NULL, mode=c("out", "in", "all", "total")) { + # Argument checks + ensure_igraph(us) + ensure_igraph(them) + if (is.null(weights.them) && "weight" %in% edge_attr_names(them)) { + weights.them <- E(them)$weight + } + if (!is.null(weights.them) && any(!is.na(weights.them))) { + weights.them <- as.numeric(weights.them) + } else { + weights.them <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_local_scan_0_them, us, them, weights.them, mode) res } -to_directed_impl <- function(graph, mode=c("mutual", "arbitrary", "random", "acyclic")) { +local_scan_1_ecount_impl <- function(graph, weights=NULL, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) - mode <- switch(igraph.match.arg(mode), "arbitrary"=0L, "mutual"=1L, "random"=2L, "acyclic"=3L) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_to_directed, graph, mode) + res <- .Call(R_igraph_local_scan_1_ecount, graph, weights, mode) res } -dyad_census_impl <- function(graph) { +local_scan_1_ecount_them_impl <- function(us, them, weights.them=NULL, mode=c("out", "in", "all", "total")) { # Argument checks - ensure_igraph(graph) + ensure_igraph(us) + ensure_igraph(them) + if (is.null(weights.them) && "weight" %in% edge_attr_names(them)) { + weights.them <- E(them)$weight + } + if (!is.null(weights.them) && any(!is.na(weights.them))) { + weights.them <- as.numeric(weights.them) + } else { + weights.them <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_dyad_census, graph) + res <- .Call(R_igraph_local_scan_1_ecount_them, us, them, weights.them, mode) res } -triad_census_impl <- function(graph) { +local_scan_k_ecount_impl <- function(graph, k, weights=NULL, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) + k <- as.numeric(k) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_triad_census, graph) + res <- .Call(R_igraph_local_scan_k_ecount, graph, k, weights, mode) res } -count_adjacent_triangles_impl <- function(graph, vids=V(graph)) { +local_scan_k_ecount_them_impl <- function(us, them, k, weights.them=NULL, mode=c("out", "in", "all", "total")) { # Argument checks - ensure_igraph(graph) - vids <- as_igraph_vs(graph, vids) + ensure_igraph(us) + ensure_igraph(them) + k <- as.numeric(k) + if (is.null(weights.them) && "weight" %in% edge_attr_names(them)) { + weights.them <- E(them)$weight + } + if (!is.null(weights.them) && any(!is.na(weights.them))) { + weights.them <- as.numeric(weights.them) + } else { + weights.them <- NULL + } + mode <- switch(igraph.match.arg(mode), "out"=1L, "in"=2L, "all"=3L, "total"=3L) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_count_adjacent_triangles, graph, vids-1) + res <- .Call(R_igraph_local_scan_k_ecount_them, us, them, k, weights.them, mode) res } -count_triangles_impl <- function(graph) { +local_scan_neighborhood_ecount_impl <- function(graph, weights=NULL, neighborhoods) { # Argument checks ensure_igraph(graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_count_triangles, graph) + res <- .Call(R_igraph_local_scan_neighborhood_ecount, graph, weights, neighborhoods) res } @@ -3047,6 +4139,41 @@ reverse_residual_graph_impl <- function(graph, capacity, flow) { res } +st_mincut_impl <- function(graph, source, target, capacity=NULL) { + # Argument checks + ensure_igraph(graph) + source <- as_igraph_vs(graph, source) + if (length(source) == 0) { + stop("No vertex was specified") + } + target <- as_igraph_vs(graph, target) + if (length(target) == 0) { + stop("No vertex was specified") + } + if (is.null(capacity) && "capacity" %in% edge_attr_names(graph)) { + capacity <- E(graph)$capacity + } + if (!is.null(capacity) && any(!is.na(capacity))) { + capacity <- as.numeric(capacity) + } else { + capacity <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_st_mincut, graph, source-1, target-1, capacity) + if (igraph_opt("return.vs.es")) { + res$cut <- create_es(graph, res$cut) + } + if (igraph_opt("return.vs.es")) { + res$partition1 <- create_vs(graph, res$partition1) + } + if (igraph_opt("return.vs.es")) { + res$partition2 <- create_vs(graph, res$partition2) + } + res +} + dominator_tree_impl <- function(graph, root, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) @@ -3205,6 +4332,18 @@ isomorphic_impl <- function(graph1, graph2) { res } +isoclass_subgraph_impl <- function(graph, vids) { + # Argument checks + ensure_igraph(graph) + vids <- as.numeric(vids) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_isoclass_subgraph, graph, vids) + + res +} + isoclass_create_impl <- function(size, number, directed=TRUE) { # Argument checks size <- as.numeric(size) @@ -3374,6 +4513,58 @@ count_isomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1=NULL, vert res } +get_isomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1=NULL, vertex.color2=NULL, edge.color1=NULL, edge.color2=NULL) { + # Argument checks + ensure_igraph(graph1) + ensure_igraph(graph2) + if (missing(vertex.color1)) { + if ("color" %in% vertex_attr_names(graph1)) { + vertex.color1 <- V(graph1)$color + } else { + vertex.color1 <- NULL + } + } + if (!is.null(vertex.color1)) { + vertex.color1 <- as.numeric(vertex.color1)-1 + } + if (missing(vertex.color2)) { + if ("color" %in% vertex_attr_names(graph2)) { + vertex.color2 <- V(graph2)$color + } else { + vertex.color2 <- NULL + } + } + if (!is.null(vertex.color2)) { + vertex.color2 <- as.numeric(vertex.color2)-1 + } + if (missing(edge.color1)) { + if ("color" %in% edge_attr_names(graph1)) { + edge.color1 <- E(graph1)$color + } else { + edge.color1 <- NULL + } + } + if (!is.null(edge.color1)) { + edge.color1 <- as.numeric(edge.color1)-1 + } + if (missing(edge.color2)) { + if ("color" %in% edge_attr_names(graph2)) { + edge.color2 <- E(graph2)$color + } else { + edge.color2 <- NULL + } + } + if (!is.null(edge.color2)) { + edge.color2 <- as.numeric(edge.color2)-1 + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_isomorphisms_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + + res +} + subisomorphic_impl <- function(graph1, graph2) { # Argument checks ensure_igraph(graph1) @@ -3490,6 +4681,58 @@ count_subisomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1=NULL, v res } +get_subisomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1=NULL, vertex.color2=NULL, edge.color1=NULL, edge.color2=NULL) { + # Argument checks + ensure_igraph(graph1) + ensure_igraph(graph2) + if (missing(vertex.color1)) { + if ("color" %in% vertex_attr_names(graph1)) { + vertex.color1 <- V(graph1)$color + } else { + vertex.color1 <- NULL + } + } + if (!is.null(vertex.color1)) { + vertex.color1 <- as.numeric(vertex.color1)-1 + } + if (missing(vertex.color2)) { + if ("color" %in% vertex_attr_names(graph2)) { + vertex.color2 <- V(graph2)$color + } else { + vertex.color2 <- NULL + } + } + if (!is.null(vertex.color2)) { + vertex.color2 <- as.numeric(vertex.color2)-1 + } + if (missing(edge.color1)) { + if ("color" %in% edge_attr_names(graph1)) { + edge.color1 <- E(graph1)$color + } else { + edge.color1 <- NULL + } + } + if (!is.null(edge.color1)) { + edge.color1 <- as.numeric(edge.color1)-1 + } + if (missing(edge.color2)) { + if ("color" %in% edge_attr_names(graph2)) { + edge.color2 <- E(graph2)$color + } else { + edge.color2 <- NULL + } + } + if (!is.null(edge.color2)) { + edge.color2 <- as.numeric(edge.color2)-1 + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_subisomorphisms_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + + res +} + canonical_permutation_impl <- function(graph, colors=NULL, sh=c("fm", "f", "fs", "fl", "flm", "fsm")) { # Argument checks ensure_igraph(graph) @@ -3606,6 +4849,17 @@ automorphism_group_impl <- function(graph, colors=NULL, sh=c("fm", "f", "fs", "f res } +simplify_and_colorize_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_simplify_and_colorize, graph) + + res +} + graph_count_impl <- function(n, directed=FALSE) { # Argument checks n <- as.numeric(n) @@ -3618,6 +4872,53 @@ graph_count_impl <- function(n, directed=FALSE) { res } +is_matching_impl <- function(graph, types=NULL, matching) { + # Argument checks + ensure_igraph(graph) + if (!is.null(types)) types <- handle_vertex_type_arg(types, graph) + matching <- as.numeric(matching)-1 + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_is_matching, graph, types, matching) + + res +} + +is_maximal_matching_impl <- function(graph, types=NULL, matching) { + # Argument checks + ensure_igraph(graph) + if (!is.null(types)) types <- handle_vertex_type_arg(types, graph) + matching <- as.numeric(matching)-1 + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_is_maximal_matching, graph, types, matching) + + res +} + +maximum_bipartite_matching_impl <- function(graph, types, weights=NULL, eps=.Machine$double.eps) { + # Argument checks + ensure_igraph(graph) + types <- handle_vertex_type_arg(types, graph) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + eps <- as.numeric(eps) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_maximum_bipartite_matching, graph, types, weights, eps) + + res +} + adjacency_spectral_embedding_impl <- function(graph, no, weights=NULL, which=c("lm", "la", "sa"), scaled=TRUE, cvec=strength(graph, weights=weights)/(vcount(graph)-1), options=arpack_defaults()) { # Argument checks ensure_igraph(graph) @@ -3686,6 +4987,19 @@ eigen_adjacency_impl <- function(graph, algorithm=c("arpack", "auto", "lapack", res } +power_law_fit_impl <- function(data, xmin=-1, force.continuous=FALSE) { + # Argument checks + data <- as.numeric(data) + xmin <- as.numeric(xmin) + force.continuous <- as.logical(force.continuous) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_power_law_fit, data, xmin, force.continuous) + + res +} + sir_impl <- function(graph, beta, gamma, no.sim=100) { # Argument checks ensure_igraph(graph) @@ -4069,6 +5383,17 @@ stochastic_imitation_impl <- function(graph, vid, algo, quantities, strategies, res } +invalidate_cache_impl <- function(graph) { + # Argument checks + ensure_igraph(graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_invalidate_cache, graph) + + res +} + vertex_path_from_edge_path_impl <- function(graph, start=NULL, edge.path, mode=c("out", "in", "all", "total")) { # Argument checks ensure_igraph(graph) diff --git a/src/cpp11.cpp b/src/cpp11.cpp index 3660d9c2fab..a87ea44454b 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -83,6 +83,7 @@ extern SEXP R_igraph_citing_cited_type_game(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_clique_number(SEXP); extern SEXP R_igraph_clique_size_hist(SEXP, SEXP, SEXP); extern SEXP R_igraph_cliques(SEXP, SEXP, SEXP); +extern SEXP R_igraph_closeness(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_closeness_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_cocitation(SEXP, SEXP); extern SEXP R_igraph_cohesion(SEXP, SEXP); @@ -145,6 +146,7 @@ extern SEXP R_igraph_dyad_census(SEXP); extern SEXP R_igraph_ecc(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_eccentricity_dijkstra(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_ecount(SEXP); +extern SEXP R_igraph_edge_betweenness(SEXP, SEXP, SEXP); extern SEXP R_igraph_edge_betweenness_cutoff(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_edge_betweenness_subset(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_edge_connectivity(SEXP, SEXP); @@ -180,6 +182,7 @@ extern SEXP R_igraph_full_multipartite(SEXP, SEXP, SEXP); extern SEXP R_igraph_fundamental_cycles(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_generalized_petersen(SEXP, SEXP); extern SEXP R_igraph_get_adjacency(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_adjacency_sparse(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_adjedgelist(SEXP, SEXP, SEXP); extern SEXP R_igraph_get_adjlist(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_all_eids_between(SEXP, SEXP, SEXP, SEXP); @@ -246,6 +249,7 @@ extern SEXP R_igraph_independent_vertex_sets(SEXP, SEXP, SEXP); extern SEXP R_igraph_induced_subgraph(SEXP, SEXP, SEXP); extern SEXP R_igraph_induced_subgraph_map(SEXP, SEXP, SEXP); extern SEXP R_igraph_intersection(SEXP, SEXP); +extern SEXP R_igraph_invalidate_cache(SEXP); extern SEXP R_igraph_is_acyclic(SEXP); extern SEXP R_igraph_is_biconnected(SEXP); extern SEXP R_igraph_is_bipartite(SEXP); @@ -365,6 +369,7 @@ extern SEXP R_igraph_path_length_hist(SEXP, SEXP); extern SEXP R_igraph_permute_vertices(SEXP, SEXP); extern SEXP R_igraph_personalized_pagerank(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_personalized_pagerank_vs(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_power_law_fit(SEXP, SEXP, SEXP); extern SEXP R_igraph_power_law_fit_new(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_preference_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_product(SEXP, SEXP, SEXP); @@ -550,6 +555,7 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_clique_number", (DL_FUNC) &R_igraph_clique_number, 1}, {"R_igraph_clique_size_hist", (DL_FUNC) &R_igraph_clique_size_hist, 3}, {"R_igraph_cliques", (DL_FUNC) &R_igraph_cliques, 3}, + {"R_igraph_closeness", (DL_FUNC) &R_igraph_closeness, 5}, {"R_igraph_closeness_cutoff", (DL_FUNC) &R_igraph_closeness_cutoff, 6}, {"R_igraph_cocitation", (DL_FUNC) &R_igraph_cocitation, 2}, {"R_igraph_cohesion", (DL_FUNC) &R_igraph_cohesion, 2}, @@ -612,6 +618,7 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_ecc", (DL_FUNC) &R_igraph_ecc, 5}, {"R_igraph_eccentricity_dijkstra", (DL_FUNC) &R_igraph_eccentricity_dijkstra, 4}, {"R_igraph_ecount", (DL_FUNC) &R_igraph_ecount, 1}, + {"R_igraph_edge_betweenness", (DL_FUNC) &R_igraph_edge_betweenness, 3}, {"R_igraph_edge_betweenness_cutoff", (DL_FUNC) &R_igraph_edge_betweenness_cutoff, 4}, {"R_igraph_edge_betweenness_subset", (DL_FUNC) &R_igraph_edge_betweenness_subset, 6}, {"R_igraph_edge_connectivity", (DL_FUNC) &R_igraph_edge_connectivity, 2}, @@ -647,6 +654,7 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_fundamental_cycles", (DL_FUNC) &R_igraph_fundamental_cycles, 4}, {"R_igraph_generalized_petersen", (DL_FUNC) &R_igraph_generalized_petersen, 2}, {"R_igraph_get_adjacency", (DL_FUNC) &R_igraph_get_adjacency, 4}, + {"R_igraph_get_adjacency_sparse", (DL_FUNC) &R_igraph_get_adjacency_sparse, 4}, {"R_igraph_get_adjedgelist", (DL_FUNC) &R_igraph_get_adjedgelist, 3}, {"R_igraph_get_adjlist", (DL_FUNC) &R_igraph_get_adjlist, 4}, {"R_igraph_get_all_eids_between", (DL_FUNC) &R_igraph_get_all_eids_between, 4}, @@ -713,6 +721,7 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_induced_subgraph", (DL_FUNC) &R_igraph_induced_subgraph, 3}, {"R_igraph_induced_subgraph_map", (DL_FUNC) &R_igraph_induced_subgraph_map, 3}, {"R_igraph_intersection", (DL_FUNC) &R_igraph_intersection, 2}, + {"R_igraph_invalidate_cache", (DL_FUNC) &R_igraph_invalidate_cache, 1}, {"R_igraph_is_acyclic", (DL_FUNC) &R_igraph_is_acyclic, 1}, {"R_igraph_is_biconnected", (DL_FUNC) &R_igraph_is_biconnected, 1}, {"R_igraph_is_bipartite", (DL_FUNC) &R_igraph_is_bipartite, 1}, @@ -832,6 +841,7 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_permute_vertices", (DL_FUNC) &R_igraph_permute_vertices, 2}, {"R_igraph_personalized_pagerank", (DL_FUNC) &R_igraph_personalized_pagerank, 8}, {"R_igraph_personalized_pagerank_vs", (DL_FUNC) &R_igraph_personalized_pagerank_vs, 8}, + {"R_igraph_power_law_fit", (DL_FUNC) &R_igraph_power_law_fit, 3}, {"R_igraph_power_law_fit_new", (DL_FUNC) &R_igraph_power_law_fit_new, 5}, {"R_igraph_preference_game", (DL_FUNC) &R_igraph_preference_game, 7}, {"R_igraph_product", (DL_FUNC) &R_igraph_product, 3}, diff --git a/tools/stimulus/functions-R.yaml b/tools/stimulus/functions-R.yaml index 3bac0129fbd..030b28f670f 100644 --- a/tools/stimulus/functions-R.yaml +++ b/tools/stimulus/functions-R.yaml @@ -10,29 +10,19 @@ # The basic interface ####################################### -igraph_empty: - # Not needed in R, we use igraph_emtpy() instead igraph_empty_attrs: IGNORE: RR, RC -igraph_add_edges: - igraph_add_vertices: IGNORE: RR, RC, RInit -igraph_copy: - igraph_delete_edges: IGNORE: RR, RC igraph_delete_vertices: IGNORE: RR, RC -igraph_delete_vertices_idx: - -igraph_vcount: - igraph_ecount: IGNORE: RR, RC @@ -79,6 +69,7 @@ igraph_create: # Constructors, deterministic ####################################### +# TODO: temporarily disabled igraph_adjacency: IGNORE: RR @@ -90,57 +81,25 @@ igraph_sparse_adjacency: igraph_sparse_weighted_adjacency: IGNORE: RR, RC +# TODO: temporarily disabled igraph_weighted_adjacency: IGNORE: RR igraph_star: IGNORE: RR, RC -igraph_wheel: - -igraph_square_lattice: - -igraph_triangular_lattice: - igraph_ring: IGNORE: RR, RC igraph_kary_tree: IGNORE: RR, RC -igraph_symmetric_tree: - -igraph_regular_tree: - igraph_full: IGNORE: RR, RC -igraph_full_citation: - IGNORE: RR - R: - GATTR: - name: Full citation graph - -igraph_atlas: - IGNORE: RR - -igraph_extended_chordal_ring: - IGNORE: RR - igraph_connect_neighborhood: IGNORE: RR, RC -igraph_graph_power: - -igraph_linegraph: - IGNORE: RR - -igraph_de_bruijn: - IGNORE: RR - -igraph_kautz: - IGNORE: RR - igraph_famous: IGNORE: RR, RC @@ -149,13 +108,6 @@ igraph_lcf_vector: GATTR: name: LCF graph -igraph_adjlist: - -igraph_full_bipartite: - IGNORE: RR - -igraph_full_multipartite: - igraph_realize_degree_sequence: PARAMS: |- OUT GRAPH graph, VECTOR_INT out_deg, OPTIONAL VECTOR_INT in_deg, @@ -171,12 +123,6 @@ igraph_realize_bipartite_degree_sequence: name: Bipartite graph from degree sequence GATTR-PARAM: degrees1, degrees2, allowed_edge_types, method -igraph_circulant: - -igraph_generalized_petersen: - -igraph_turan: - # TODO: temporarily disabled igraph_weighted_sparsemat: IGNORE: RR, RC @@ -218,20 +164,6 @@ igraph_establishment_game: igraph_grg_game: IGNORE: RR, RC, RInit -igraph_preference_game: - IGNORE: RR - -igraph_asymmetric_preference_game: - IGNORE: RR - -igraph_rewire_edges: - IGNORE: RR - # Handled by rewire() in the R interface and rewire_directed_edges() - -igraph_rewire_directed_edges: - IGNORE: RR - # Handled by rewire() in the R interface - igraph_watts_strogatz_game: IGNORE: RR, RC @@ -300,16 +232,6 @@ igraph_correlated_game: name: Correlated random graph GATTR-PARAM: corr, p -igraph_correlated_pair_game: - -igraph_dot_product_game: - -igraph_sample_sphere_surface: - -igraph_sample_sphere_volume: - -igraph_sample_dirichlet: - ####################################### # Basic query functions ####################################### @@ -328,24 +250,12 @@ igraph_diameter: igraph_diameter_dijkstra: IGNORE: RR, RC, RInit -igraph_closeness: - IGNORE: RR - -igraph_closeness_cutoff: - IGNORE: RR - igraph_distances: IGNORE: RR, RC igraph_distances_cutoff: IGNORE: RR, RC -igraph_get_shortest_path: - -igraph_get_shortest_path_bellman_ford: - -igraph_get_shortest_path_dijkstra: - igraph_get_shortest_path_astar: IGNORE: RR, RC, Rinit @@ -353,7 +263,6 @@ igraph_get_shortest_paths: IGNORE: RR, RC, RInit igraph_get_all_shortest_paths: - IGNORE: RR PARAM_NAMES: vertices: vpaths edges: epaths @@ -371,7 +280,6 @@ igraph_get_shortest_paths_bellman_ford: IGNORE: RR, RC, RInit igraph_get_all_shortest_paths_dijkstra: - IGNORE: RR PARAM_NAMES: vertices: vpaths edges: epaths @@ -388,11 +296,6 @@ igraph_distances_floyd_warshall: igraph_voronoi: FIRST_KW_PARAM: weights -igraph_get_all_simple_paths: - IGNORE: RR - R: - PP: get.all.simple.paths.pp - igraph_get_k_shortest_paths: PARAM_ORDER: graph, from, to, *, k, ... PARAM_NAMES: @@ -439,32 +342,17 @@ igraph_subcomponent: igraph_betweenness: IGNORE: RR, RC -igraph_betweenness_cutoff: - IGNORE: RR - igraph_betweenness_subset: DEPS: |- vids ON graph, weights ON graph, res ON graph vids, sources ON graph, targets ON graph -igraph_edge_betweenness: - IGNORE: RR - -igraph_edge_betweenness_cutoff: - IGNORE: RR - -igraph_edge_betweenness_subset: - igraph_harmonic_centrality: IGNORE: RR, RC, RInit # This is handled by igraph_harmonic_centrality_cutoff -igraph_harmonic_centrality_cutoff: - igraph_pagerank: IGNORE: RR, RC, RInit -igraph_personalized_pagerank: - igraph_personalized_pagerank_vs: DEPS: vids ON graph, weights ON graph, vector ON graph vids, options ON algo, reset_vids ON graph @@ -472,13 +360,6 @@ igraph_personalized_pagerank_vs: igraph_rewire: IGNORE: RR, RC -igraph_induced_subgraph: - IGNORE: RR - -igraph_subgraph_from_edges: - -igraph_reverse_edges: - igraph_average_path_length: IGNORE: RR, RC, RInit # No need for it, igraph_average_path_length_dijkstra takes care of the @@ -489,26 +370,6 @@ igraph_average_path_length_dijkstra: unconn_pairs: unconnected unconn: unconnected -igraph_path_length_hist: - -igraph_simplify: - -igraph_transitivity_undirected: - IGNORE: RR - -igraph_transitivity_local_undirected: - IGNORE: RR - -igraph_transitivity_avglocal_undirected: - IGNORE: RR - -igraph_transitivity_barrat: - IGNORE: RR - -igraph_ecc: - -igraph_reciprocity: - igraph_constraint: IGNORE: RR, RC @@ -517,8 +378,6 @@ igraph_maxdegree: PARAM_NAMES: vids: v -igraph_density: - igraph_neighborhood_size: IGNORE: RR, RC, RInit @@ -531,28 +390,14 @@ igraph_neighborhood_graphs: igraph_topological_sorting: IGNORE: RR, RC -igraph_feedback_arc_set: - -igraph_feedback_vertex_set: - igraph_is_loop: PARAM_NAMES: es: eids -igraph_is_dag: - -igraph_is_acyclic: - -igraph_is_simple: - igraph_is_multiple: PARAM_NAMES: es: eids -igraph_has_loop: - -igraph_has_multiple: - igraph_count_multiple: PARAM_NAMES: es: eids @@ -560,8 +405,6 @@ igraph_count_multiple: igraph_girth: IGNORE: RR, RC, RInit -igraph_is_perfect: - igraph_add_edge: IGNORE: RR, RC, RInit @@ -597,61 +440,13 @@ igraph_hub_and_authority_scores: OUT REAL value, BOOLEAN scale=True, OPTIONAL EDGEWEIGHTS weights, INOUT ARPACKOPT options=ARPACK_DEFAULTS -igraph_unfold_tree: - IGNORE: RR - igraph_is_mutual: PARAM_NAMES: es: eids -igraph_has_mutual: - -igraph_maximum_cardinality_search: - igraph_is_chordal: IGNORE: RR, RC, RInit -igraph_avg_nearest_neighbor_degree: - -igraph_degree_correlation_vector: - -igraph_strength: - -igraph_centralization: - -igraph_centralization_degree: - -igraph_centralization_degree_tmax: - IGNORE: RR - # temporarily coded manually because we need to handle a deprecation - # between igraph 1.3.0 and 1.4.0 - -igraph_centralization_betweenness: - -igraph_centralization_betweenness_tmax: - -igraph_centralization_closeness: - -igraph_centralization_closeness_tmax: - -igraph_centralization_eigenvector_centrality: - -igraph_centralization_eigenvector_centrality_tmax: - -igraph_assortativity_nominal: - -igraph_assortativity: - -igraph_assortativity_degree: - -igraph_joint_degree_matrix: - -igraph_joint_degree_distribution: - -igraph_joint_type_distribution: - -igraph_contract_vertices: - # We use igraph_eccentricity_dijkstra instead igraph_eccentricity: IGNORE: RR, RC @@ -679,24 +474,12 @@ igraph_pseudo_diameter: igraph_pseudo_diameter_dijkstra: DEPS: start_vid ON graph, weights ON graph -igraph_diversity: - igraph_random_walk: PARAM_ORDER: graph, start, steps, ... igraph_random_edge_walk: IGNORE: RR, RC -igraph_global_efficiency: - -igraph_local_efficiency: - -igraph_average_local_efficiency: - -igraph_transitive_closure_dag: - -igraph_trussness: - ####################################### # Degree sequences ####################################### @@ -704,8 +487,6 @@ igraph_trussness: igraph_is_bigraphical: IGNORE: RR, RC, RInit -igraph_is_graphical: - ####################################### # Visitors ####################################### @@ -746,8 +527,6 @@ igraph_create_bipartite: igraph_biadjacency: DEPS: types ON graph V(graph) -igraph_get_biadjacency: - # Use the name 'type' instead of 'types' (provided by the C core) igraph_is_bipartite: PARAMS: GRAPH graph, OUT BOOLEAN res, OPTIONAL OUT BIPARTITE_TYPES type @@ -773,10 +552,6 @@ igraph_bipartite_game: # Spectral properties ####################################### -igraph_get_laplacian: - -igraph_get_laplacian_sparse: - ####################################### # Spectral properties ####################################### @@ -785,20 +560,9 @@ igraph_get_laplacian_sparse: # Components ####################################### -igraph_connected_components: - IGNORE: RR - -igraph_is_connected: - igraph_decompose: IGNORE: RR, RC -igraph_articulation_points: - -igraph_biconnected_components: - -igraph_bridges: - ####################################### # Cliques ####################################### @@ -816,8 +580,6 @@ igraph_clique_size_hist: # is renamed and internal INTERNAL: true -igraph_largest_cliques: - igraph_maximal_cliques: IGNORE: RR, RC, RInit @@ -839,14 +601,6 @@ igraph_maximal_cliques_hist: # is renamed and internal INTERNAL: true -igraph_clique_number: - -igraph_weighted_cliques: - -igraph_largest_weighted_cliques: - -igraph_weighted_clique_number: - igraph_independent_vertex_sets: IGNORE: RR, RC @@ -862,23 +616,8 @@ igraph_independence_number: ####################################### # Layouts ####################################### - -igraph_layout_random: - IGNORE: RR - -igraph_layout_circle: - IGNORE: RR - -igraph_layout_star: - IGNORE: RR DEPS: center ON graph -igraph_layout_grid: - IGNORE: RR - -igraph_layout_grid_3d: - IGNORE: RR - igraph_layout_fruchterman_reingold: IGNORE: RR, RC, RInit @@ -894,14 +633,6 @@ igraph_layout_reingold_tilford: igraph_layout_reingold_tilford_circular: IGNORE: RR, RC, RInit -igraph_roots_for_tree_layout: - -igraph_layout_random_3d: - IGNORE: RR - -igraph_layout_sphere: - IGNORE: RR - igraph_layout_fruchterman_reingold_3d: IGNORE: RR, RC, RInit @@ -920,27 +651,6 @@ igraph_layout_drl_3d: igraph_layout_merge_dla: IGNORE: RR, RC -igraph_layout_sugiyama: - IGNORE: RR - -igraph_layout_mds: - IGNORE: RR - -igraph_layout_bipartite: - IGNORE: RR - -igraph_layout_gem: - IGNORE: RR - -igraph_layout_davidson_harel: - IGNORE: RR - -igraph_layout_umap: - -igraph_layout_umap_3d: - -igraph_layout_umap_compute_weights: - ####################################### # Cocitation and other similarity measures ####################################### @@ -951,27 +661,10 @@ igraph_cocitation: igraph_bibcoupling: IGNORE: RR, RC -igraph_similarity_dice: - -igraph_similarity_dice_es: - -igraph_similarity_dice_pairs: - -igraph_similarity_inverse_log_weighted: - -igraph_similarity_jaccard: - -igraph_similarity_jaccard_es: - -igraph_similarity_jaccard_pairs: - ####################################### # Community structure ####################################### -igraph_compare_communities: - IGNORE: RR - igraph_community_spinglass: IGNORE: RR, RC, RInit @@ -996,12 +689,6 @@ igraph_community_to_membership: igraph_le_community_to_membership: IGNORE: RR, RC, RInit -igraph_modularity: - IGNORE: RR - -igraph_modularity_matrix: - IGNORE: RR - igraph_reindex_membership: IGNORE: RR, RC, RInit @@ -1010,27 +697,6 @@ igraph_community_leading_eigenvector: R: CLASS: igraph.eigenc -igraph_community_fluid_communities: - IGNORE: RR - -igraph_community_label_propagation: - IGNORE: RR - -igraph_community_multilevel: - IGNORE: RR - -igraph_community_optimal_modularity: - IGNORE: RR - -igraph_community_leiden: - IGNORE: RR - -igraph_split_join_distance: - IGNORE: RR - -igraph_community_infomap: - IGNORE: RR - igraph_community_voronoi: IGNORE: RR, RC, RInit @@ -1050,36 +716,18 @@ igraph_graphlets_project: ####################################### # Hierarchical random graphs ####################################### - -igraph_hrg_fit: - IGNORE: RR R: CLASS: igraphHRG -igraph_hrg_sample: - -igraph_hrg_sample_many: - igraph_hrg_game: R: GATTR: name: Hierarchical random graph model -igraph_hrg_consensus: - -igraph_hrg_predict: - IGNORE: RR - igraph_hrg_create: R: CLASS: igraphHRG -igraph_hrg_resize: - -igraph_hrg_size: - -igraph_from_hrg_dendrogram: - ####################################### # Conversion ####################################### @@ -1087,24 +735,13 @@ igraph_from_hrg_dendrogram: igraph_get_adjacency: IGNORE: RR, RC -# TODO: temporarily disabled -igraph_get_adjacency_sparse: - IGNORE: RR igraph_get_edgelist: IGNORE: RR, RC -igraph_get_stochastic: - IGNORE: RR - -igraph_get_stochastic_sparse: - igraph_to_directed: PARAMS: INOUT GRAPH graph, TODIRECTED mode=MUTUAL -igraph_to_undirected: - IGNORE: RR - ####################################### # Read and write foreign formats ####################################### @@ -1172,46 +809,6 @@ igraph_write_graph_dot: # Motifs ####################################### -igraph_motifs_randesu: - IGNORE: RR - -igraph_motifs_randesu_estimate: - IGNORE: RR - -igraph_motifs_randesu_no: - IGNORE: RR - -igraph_dyad_census: - -igraph_triad_census: - -igraph_count_adjacent_triangles: - -igraph_local_scan_0: - IGNORE: RR - -igraph_local_scan_0_them: - IGNORE: RR - -igraph_local_scan_1_ecount: - IGNORE: RR - -igraph_local_scan_1_ecount_them: - IGNORE: RR - -igraph_local_scan_k_ecount: - IGNORE: RR - -igraph_local_scan_k_ecount_them: - IGNORE: RR - -igraph_local_scan_neighborhood_ecount: - IGNORE: RR - -igraph_local_scan_subset_ecount: - -igraph_list_triangles: - ####################################### # Graph operators ####################################### @@ -1243,16 +840,10 @@ igraph_complementer: igraph_compose: IGNORE: RR, RC, RInit -igraph_induced_subgraph_map: - ####################################### # Maximum flows, minimum cuts ####################################### -igraph_gomory_hu_tree: - -igraph_maxflow: - igraph_maxflow_value: IGNORE: RR, RC, RInit @@ -1262,13 +853,6 @@ igraph_mincut: igraph_mincut_value: IGNORE: RR, RC -igraph_residual_graph: - -igraph_reverse_residual_graph: - -igraph_st_mincut: - IGNORE: RR - igraph_st_mincut_value: IGNORE: RR, RC @@ -1300,22 +884,6 @@ igraph_cohesion: # Listing s-t cuts, separators ####################################### -igraph_dominator_tree: - -igraph_all_st_cuts: - -igraph_all_st_mincuts: - -igraph_even_tarjan_reduction: - -igraph_is_separator: - -igraph_is_minimal_separator: - -igraph_all_minimal_st_separators: - -igraph_minimum_size_separators: - igraph_cohesive_blocks: IGNORE: RR, RC R: @@ -1332,73 +900,24 @@ igraph_coreness: # Graph isomorphism ####################################### -igraph_isoclass: - -igraph_isomorphic: - -igraph_isoclass_subgraph: - IGNORE: RR - -igraph_isoclass_create: - -igraph_isomorphic_vf2: - -igraph_count_isomorphisms_vf2: - -igraph_get_isomorphisms_vf2: - IGNORE: RR - -igraph_subisomorphic: - -igraph_subisomorphic_vf2: - # TODO: temporarily disabled # get_subisomorphisms_vf2_callback_impl gives LTO warnings # wrong number of arguments to R_igraph_get_subisomorphisms_vf2_callback() igraph_get_subisomorphisms_vf2_callback: IGNORE: RR, RC -igraph_count_subisomorphisms_vf2: - -igraph_get_subisomorphisms_vf2: - IGNORE: RR - -igraph_canonical_permutation: - -igraph_permute_vertices: - -igraph_isomorphic_bliss: - -igraph_count_automorphisms: - -igraph_automorphism_group: - igraph_subisomorphic_lad: IGNORE: RR, RC, RInit - -igraph_simplify_and_colorize: - IGNORE: RR # R function is hand-rolled # Despite their names, vertex_color and edge_color are not really colors # but _multiplicities_, so we simply use VECTOR_INT there PARAMS: |- GRAPH graph, OUT GRAPH res, OUT VECTOR_INT vertex_color, OUT VECTOR_INT edge_color -igraph_graph_count: - ####################################### # Matching ####################################### -igraph_is_matching: - IGNORE: RR - -igraph_is_maximal_matching: - IGNORE: RR - -igraph_maximum_bipartite_matching: - IGNORE: RR - ####################################### # Embedding ####################################### @@ -1413,15 +932,10 @@ igraph_laplacian_spectral_embedding: # Eigensolvers ####################################### -igraph_eigen_adjacency: - ####################################### # Fitting power laws ####################################### -igraph_power_law_fit: - IGNORE: RR - ####################################### # Dynamics, on networks ####################################### @@ -1440,10 +954,6 @@ igraph_running_mean: igraph_random_sample: IGNORE: RR, RC -igraph_convex_hull: - -igraph_dim_select: - # Not needed in R igraph_almost_equals: IGNORE: RR, RC @@ -1460,16 +970,10 @@ igraph_eigen_matrix: igraph_eigen_matrix_symmetric: IGNORE: RR, RC -igraph_solve_lsap: - ####################################### # Finding cycles ####################################### -igraph_find_cycle: - -igraph_simple_cycles: - igraph_simple_cycles_callback: IGNORE: RR, RC @@ -1494,10 +998,6 @@ igraph_eulerian_cycle: # Cycle bases ####################################### -igraph_fundamental_cycles: - -igraph_minimum_cycle_basis: - ####################################### # Trees ####################################### @@ -1506,18 +1006,12 @@ igraph_is_tree: PARAMS: GRAPH graph, PRIMARY OUT BOOLEAN res, OPTIONAL OUT VERTEX_ROOT root, NEIMODE mode=OUT DEPS: root ON graph -igraph_is_forest: - igraph_from_prufer: R: GATTR: name: Tree from Prufer sequence GATTR-PARAM: prufer -igraph_to_prufer: - -igraph_tree_from_parent_vector: - igraph_minimum_spanning_tree: IGNORE: RR, RC, RInit @@ -1530,27 +1024,17 @@ igraph_minimum_spanning_tree_prim: igraph_random_spanning_tree: PARAMS: GRAPH graph, OUT EDGE_INDICES res, OPTIONAL VERTEX vid=0 -igraph_tree_game: - ####################################### # Coloring ####################################### -igraph_vertex_coloring_greedy: - ####################################### # Microscopic update ####################################### -igraph_deterministic_optimal_imitation: - igraph_moran_process: DEPS: weights ON graph, quantities ON graph V(graph), strategies ON graph -igraph_roulette_wheel_imitation: - -igraph_stochastic_imitation: - ####################################### # Other, (yet) undocumented functions ####################################### @@ -1583,7 +1067,6 @@ igraph_expand_path_to_pairs: IGNORE: RR igraph_invalidate_cache: - IGNORE: RR PARAMS: INOUT GRAPH graph igraph_vertex_path_from_edge_path: diff --git a/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index 35d208da901..56097611004 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -10,9 +10,9 @@ INTEGER: REAL: DEFAULT: - ECROSSW: 1.0 - sqrt(density(graph)) - ELENW: density(graph) / 10 - NEDISTW: 0.2 * (1-density(graph)) + ECROSSW: 1.0 - sqrt(edge_density(graph)) + ELENW: edge_density(graph) / 10 + NEDISTW: 0.2 * (1-edge_density(graph)) INCONV: IN: '%I% <- as.numeric(%I%)' From 19dd5d240ff13f800df7e81408000faba872f8a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sun, 17 Aug 2025 10:17:57 +0200 Subject: [PATCH 2/2] Fixes --- R/aaa-auto.R | 15 ++++++++++----- tools/stimulus/types-RR.yaml | 10 ++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index c722bb495b8..75175473164 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -1525,9 +1525,10 @@ simplify_impl <- function(graph, remove.multiple=TRUE, remove.loops=TRUE, edge.a res } -transitivity_undirected_impl <- function(graph, mode=NAN) { +transitivity_undirected_impl <- function(graph, mode=c("nan", "zero")) { # Argument checks ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "nan"=0L, "zero"=1L) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -1536,10 +1537,11 @@ transitivity_undirected_impl <- function(graph, mode=NAN) { res } -transitivity_local_undirected_impl <- function(graph, vids=V(graph), mode=NAN) { +transitivity_local_undirected_impl <- function(graph, vids=V(graph), mode=c("nan", "zero")) { # Argument checks ensure_igraph(graph) vids <- as_igraph_vs(graph, vids) + mode <- switch(igraph.match.arg(mode), "nan"=0L, "zero"=1L) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -1548,9 +1550,10 @@ transitivity_local_undirected_impl <- function(graph, vids=V(graph), mode=NAN) { res } -transitivity_avglocal_undirected_impl <- function(graph, mode=NAN) { +transitivity_avglocal_undirected_impl <- function(graph, mode=c("nan", "zero")) { # Argument checks ensure_igraph(graph) + mode <- switch(igraph.match.arg(mode), "nan"=0L, "zero"=1L) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -1559,7 +1562,7 @@ transitivity_avglocal_undirected_impl <- function(graph, mode=NAN) { res } -transitivity_barrat_impl <- function(graph, vids=V(graph), weights=NULL, mode=NAN) { +transitivity_barrat_impl <- function(graph, vids=V(graph), weights=NULL, mode=c("nan", "zero")) { # Argument checks ensure_igraph(graph) vids <- as_igraph_vs(graph, vids) @@ -1571,6 +1574,7 @@ transitivity_barrat_impl <- function(graph, vids=V(graph), weights=NULL, mode=NA } else { weights <- NULL } + mode <- switch(igraph.match.arg(mode), "nan"=0L, "zero"=1L) on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -3648,7 +3652,7 @@ from_hrg_dendrogram_impl <- function(hrg) { res } -get_adjacency_sparse_impl <- function(graph, type=c("both", "upper", "lower"), weights=NULL, loops=ONCE) { +get_adjacency_sparse_impl <- function(graph, type=c("both", "upper", "lower"), weights=NULL, loops=c("once", "none", "twice")) { # Argument checks ensure_igraph(graph) type <- switch(igraph.match.arg(type), "upper"=0L, "lower"=1L, "both"=2L) @@ -3660,6 +3664,7 @@ get_adjacency_sparse_impl <- function(graph, type=c("both", "upper", "lower"), w } else { weights <- NULL } + loops <- switch(igraph.match.arg(loops), "none"=0L, "twice"=1L, "once"=2L) on.exit( .Call(R_igraph_finalizer) ) # Function call diff --git a/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index 56097611004..89717615302 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -90,6 +90,11 @@ TOUNDIRECTED: MUTUAL: c("mutual", "collapse", "each") INCONV: '%I% <- switch(igraph.match.arg(%I%), "collapse"=1L, "each"=0L, "mutual"=2L)' +TRANSITIVITY_MODE: + DEFAULT: + NAN: c("nan", "zero") + INCONV: '%I% <- switch(igraph.match.arg(%I%), "nan"=0L, "zero"=1L)' + INT: INCONV: '%I% <- as.integer(%I%)' @@ -396,6 +401,11 @@ LAPLACIAN_NORMALIZATION: UNNORMALIZED: c("unnormalized", "symmetric", "left", "right") INCONV: '%I% <- switch(igraph.match.arg(%I%), "unnormalized"=0L, "symmetric"=1L, "left"=2L, "right"=3L)' +LOOPS: + DEFAULT: + ONCE: c("once", "none", "twice") + INCONV: '%I% <- switch(igraph.match.arg(%I%), "none"=0L, "twice"=1L, "once"=2L)' + SIRLIST: {} PAGERANKALGO: