diff --git a/.Rbuildignore b/.Rbuildignore index 7e1f0171ce2..956d4a9d918 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,5 +1,3 @@ -src/vendor/cigraph - ^tags$ ^.github$ ^cigraph$ diff --git a/.gitignore b/.gitignore index c61a22919d3..18c76d69c85 100644 --- a/.gitignore +++ b/.gitignore @@ -12,5 +12,6 @@ igraph.Rcheck/ .vscode/ .Rproj.user /configure~ -/build/ +/src/build/ +/src/install/ inst/doc diff --git a/DESCRIPTION b/DESCRIPTION index 627587deee8..23071612ee8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -35,7 +35,8 @@ LinkingTo: cpp11 (>= 0.2.0) License: GPL (>= 2) URL: https://r.igraph.org/, https://igraph.org/, https://igraph.discourse.group/ -SystemRequirements: +SystemRequirements: + CMake (>= 3.18), gmp (optional), libxml2 (optional), glpk (>= 4.57, optional) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index 9636328d32f..ad82a3e019c 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -1,5 +1,27 @@ # styler: off +copy_impl <- function(from) { + # Argument checks + if (!is_igraph(from)) { stop("Not a graph object") } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_copy, from) + + res +} + +delete_vertices_idx_impl <- function(graph, vertices) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_delete_vertices_idx, graph, vertices) + + res +} + vcount_impl <- function(graph) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } @@ -12,10 +34,119 @@ vcount_impl <- function(graph) { res } +empty_attrs_impl <- function(n, directed, attr) { + # Argument checks + n <- as.integer(n) + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_empty_attrs, n, directed, attr) + + res +} + +sparse_adjacency_impl <- function(adjmatrix, mode=DIRECTED, loops=ONCE) { + # Argument checks + require(Matrix); adjmatrix <- as(as(as(adjmatrix, "dMatrix"), "generalMatrix"), "CsparseMatrix") + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_sparse_adjacency, adjmatrix, mode, loops) + + res +} + +sparse_weighted_adjacency_impl <- function(adjmatrix, mode=DIRECTED, loops=ONCE) { + # Argument checks + require(Matrix); adjmatrix <- as(as(as(adjmatrix, "dMatrix"), "generalMatrix"), "CsparseMatrix") + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_sparse_weighted_adjacency, adjmatrix, mode, loops) + + res +} + +wheel_impl <- function(n, mode=OUT, center=0) { + # Argument checks + n <- as.integer(n) + center <- as.integer(center) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_wheel, n, mode, center) + + res +} + +square_lattice_impl <- function(dimvector, nei=1, directed=FALSE, mutual=FALSE, periodic) { + # Argument checks + dimvector <- as.integer(dimvector) + nei <- as.integer(nei) + directed <- as.logical(directed) + mutual <- as.logical(mutual) + periodic <- as.logical(periodic) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_square_lattice, dimvector, nei, directed, mutual, periodic) + + res +} + +triangular_lattice_impl <- function(dimvector, directed=FALSE, mutual=FALSE) { + # Argument checks + dimvector <- as.integer(dimvector) + directed <- as.logical(directed) + mutual <- as.logical(mutual) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_triangular_lattice, dimvector, directed, mutual) + + res +} + +kary_tree_impl <- function(n, children=2, type=OUT) { + # Argument checks + n <- as.integer(n) + children <- as.integer(children) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_kary_tree, n, children, type) + + res +} + +symmetric_tree_impl <- function(branches, type=OUT) { + # Argument checks + branches <- as.integer(branches) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_symmetric_tree, branches, type) + + res +} + +regular_tree_impl <- function(h, k=3, type=UNDIRECTED) { + # Argument checks + h <- as.integer(h) + k <- as.integer(k) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_regular_tree, h, k, type) + + res +} + lcf_vector_impl <- function(n, shifts, repeats=1) { # Argument checks n <- as.integer(n) - shifts <- as.numeric(shifts) + shifts <- as.integer(shifts) repeats <- as.integer(repeats) on.exit( .Call(R_igraph_finalizer) ) @@ -42,9 +173,22 @@ adjlist_impl <- function(adjlist, mode=c("out", "in", "all", "total"), duplicate res } +full_multipartite_impl <- function(n, directed=FALSE, mode=c("all", "out", "in", "total")) { + # Argument checks + n <- as.integer(n) + directed <- as.logical(directed) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_full_multipartite, n, directed, mode) + res$types <- res$types+1 + res +} + realize_degree_sequence_impl <- function(out.deg, in.deg=NULL, allowed.edge.types=c("simple", "loops", "multi", "all"), method=c("smallest", "largest", "index")) { # Argument checks - out.deg <- as.numeric(out.deg) + out.deg <- as.integer(out.deg) if (!is.null(in.deg)) in.deg <- as.numeric(in.deg) allowed.edge.types <- switch(igraph.match.arg(allowed.edge.types), "simple"=0L, "loop"=1L, "loops"=1L, "multi"=6L, "multiple"=6L, "all"=7L) @@ -65,6 +209,70 @@ realize_degree_sequence_impl <- function(out.deg, in.deg=NULL, allowed.edge.type res } +circulant_impl <- function(n, shifts, directed=FALSE) { + # Argument checks + n <- as.integer(n) + shifts <- as.integer(shifts) + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_circulant, n, shifts, directed) + + res +} + +generalized_petersen_impl <- function(n, k) { + # Argument checks + n <- as.integer(n) + k <- as.integer(k) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_generalized_petersen, n, k) + + res +} + +turan_impl <- function(n, r) { + # Argument checks + n <- as.integer(n) + r <- as.integer(r) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_turan, n, r) + res$types <- res$types+1 + res +} + +weighted_sparsemat_impl <- function(A, directed, attr, loops=FALSE) { + # Argument checks + require(Matrix); A <- as(as(as(A, "dMatrix"), "generalMatrix"), "CsparseMatrix") + directed <- as.logical(directed) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_weighted_sparsemat, A, directed, attr, loops) + + res +} + +erdos_renyi_game_impl <- function(type, n, p.or.m, directed=FALSE, loops=FALSE) { + # Argument checks + n <- as.integer(n) + p.or.m <- as.numeric(p.or.m) + directed <- as.logical(directed) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_erdos_renyi_game, type, n, p.or.m, directed, loops) + + res +} + forest_fire_game_impl <- function(nodes, fw.prob, bw.factor=1, ambs=1, directed=TRUE) { # Argument checks nodes <- as.integer(nodes) @@ -109,11 +317,11 @@ simple_interconnected_islands_game_impl <- function(islands.n, islands.size, isl res } -static_fitness_game_impl <- function(no.of.edges, fitness.out, fitness.in=NULL, loops=FALSE, multiple=FALSE) { +static_fitness_game_impl <- function(no.of.edges, fitness.out, fitness.in, loops=FALSE, multiple=FALSE) { # Argument checks no.of.edges <- as.integer(no.of.edges) fitness.out <- as.numeric(fitness.out) - if (!is.null(fitness.in)) fitness.in <- as.numeric(fitness.in) + fitness.in <- as.numeric(fitness.in) loops <- as.logical(loops) multiple <- as.logical(multiple) @@ -244,7 +452,7 @@ correlated_game_impl <- function(old.graph, corr, p=edge_density(old.graph), per if (!is_igraph(old.graph)) { stop("Not a graph object") } corr <- as.numeric(corr) p <- as.numeric(p) - if (!is.null(permutation)) permutation <- as.numeric(permutation)-1 + permutation <- as.integer(permutation)-1L on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -265,7 +473,7 @@ correlated_pair_game_impl <- function(n, corr, p, directed=FALSE, permutation=NU corr <- as.numeric(corr) p <- as.numeric(p) directed <- as.logical(directed) - if (!is.null(permutation)) permutation <- as.numeric(permutation)-1 + permutation <- as.integer(permutation)-1L on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -326,81 +534,67 @@ sample_dirichlet_impl <- function(n, alpha) { res } -harmonic_centrality_cutoff_impl <- function(graph, vids=V(graph), mode=c("out", "in", "all", "total"), weights=NULL, normalized=FALSE, cutoff=-1) { +distances_impl <- function(graph, from=ALL, to=ALL, mode=c("out", "in", "all", "total")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - vids <- as.igraph.vs(graph, vids) mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) - 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 <- .Call(R_igraph_distances, graph, from, to, mode) + res } -personalized_pagerank_impl <- function(graph, algo=c("prpack", "arpack"), vids=V(graph), directed=TRUE, damping=0.85, personalized=NULL, weights=NULL, options=NULL) { +distances_cutoff_impl <- function(graph, from=ALL, to=ALL, mode=c("out", "in", "all", "total"), cutoff=-1) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - 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 - } - if (is.null(options)) { - if (algo == 0L) { - options <- list(niter=1000, eps=0.001) - } else if (algo == 1L) { - options <- arpack_defaults - } else { - options <- NULL - } - } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + cutoff <- as.numeric(cutoff) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_personalized_pagerank, graph, algo, vids-1, directed, damping, personalized, weights, options) - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res$vector) <- vertex_attr(graph, "name", vids) - } + res <- .Call(R_igraph_distances_cutoff, graph, from, to, mode, cutoff) + res } -reverse_edges_impl <- function(graph, eids=E(graph)) { +get_shortest_path_impl <- function(graph, from, to, mode=c("out", "in", "all", "total")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - eids <- as.igraph.es(graph, eids) + from <- as.igraph.vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + to <- as.igraph.vs(graph, to) + if (length(to) == 0) { + stop("No vertex was specified") + } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_reverse_edges, graph, eids-1) - + res <- .Call(R_igraph_get_shortest_path, graph, from-1, to-1, mode) + if (igraph_opt("return.vs.es")) { + res$vertices <- create_vs(graph, res$vertices) + } + if (igraph_opt("return.vs.es")) { + res$edges <- create_vs(graph, res$edges) + } res } -average_path_length_dijkstra_impl <- function(graph, weights=NULL, directed=TRUE, unconnected=TRUE, details=FALSE) { +get_shortest_path_bellman_ford_impl <- function(graph, from, to, weights=NULL, mode=c("out", "in", "all", "total")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } + from <- as.igraph.vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + to <- as.igraph.vs(graph, to) + if (length(to) == 0) { + stop("No vertex was specified") + } if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -409,45 +603,74 @@ average_path_length_dijkstra_impl <- function(graph, weights=NULL, directed=TRUE } else { weights <- NULL } - directed <- as.logical(directed) - unconnected <- as.logical(unconnected) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_average_path_length_dijkstra, graph, weights, directed, unconnected) - if (!details) { - res <- res$res + res <- .Call(R_igraph_get_shortest_path_bellman_ford, graph, from-1, to-1, weights, mode) + if (igraph_opt("return.vs.es")) { + res$vertices <- create_vs(graph, res$vertices) + } + if (igraph_opt("return.vs.es")) { + res$edges <- create_vs(graph, res$edges) } res } -path_length_hist_impl <- function(graph, directed=TRUE) { +get_shortest_path_dijkstra_impl <- function(graph, from, to, weights=NULL, mode=c("out", "in", "all", "total")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - directed <- as.logical(directed) + from <- as.igraph.vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + to <- as.igraph.vs(graph, to) + if (length(to) == 0) { + stop("No vertex was specified") + } + 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"=1, "in"=2, "all"=3, "total"=3) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_path_length_hist, graph, directed) - + res <- .Call(R_igraph_get_shortest_path_dijkstra, graph, from-1, to-1, weights, mode) + if (igraph_opt("return.vs.es")) { + res$vertices <- create_vs(graph, res$vertices) + } + if (igraph_opt("return.vs.es")) { + res$edges <- create_vs(graph, res$edges) + } res } -simplify_impl <- function(graph, remove.multiple=TRUE, remove.loops=TRUE, edge.attr.comb=igraph_opt("edge.attr.comb")) { +distances_dijkstra_impl <- function(graph, from=ALL, to=ALL, weights, mode=c("out", "in", "all", "total")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - remove.multiple <- as.logical(remove.multiple) - remove.loops <- as.logical(remove.loops) - edge.attr.comb <- igraph.i.attribute.combination(edge.attr.comb) + 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"=1, "in"=2, "all"=3, "total"=3) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_simplify, graph, remove.multiple, remove.loops, edge.attr.comb) + res <- .Call(R_igraph_distances_dijkstra, graph, from, to, weights, mode) res } -feedback_arc_set_impl <- function(graph, weights=NULL, algo=c("approx_eades", "exact_ip")) { +distances_dijkstra_cutoff_impl <- function(graph, from=ALL, to=ALL, weights, mode=c("out", "in", "all", "total"), cutoff=-1) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { @@ -458,25 +681,486 @@ feedback_arc_set_impl <- function(graph, weights=NULL, algo=c("approx_eades", "e } else { weights <- NULL } - algo <- switch(igraph.match.arg(algo), "exact_ip"=0L, "approx_eades"=1L) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + cutoff <- as.numeric(cutoff) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_distances_dijkstra_cutoff, graph, from, to, weights, mode, cutoff) + + res +} + +distances_bellman_ford_impl <- function(graph, from=ALL, to=ALL, weights, mode=c("out", "in", "all", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_distances_bellman_ford, graph, from, to, weights, mode) + + res +} + +distances_johnson_impl <- function(graph, from=ALL, to=ALL, weights) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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_distances_johnson, graph, from, to, weights) + + res +} + +distances_floyd_warshall_impl <- function(graph, from=ALL, to=ALL, weights=NULL, mode=c("out", "in", "all", "total"), method) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_distances_floyd_warshall, graph, from, to, weights, mode, method) + + res +} + +voronoi_impl <- function(graph, generators, weights=NULL, mode=c("out", "in", "all", "total"), tiebreaker=RANDOM) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + generators <- as.igraph.vs(graph, generators) + 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"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_voronoi, graph, generators-1, weights, mode, tiebreaker) + + res +} + +get_k_shortest_paths_impl <- function(graph, weights, k, from, to, mode=c("out", "in", "all", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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 + } + k <- as.integer(k) + from <- as.igraph.vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + to <- as.igraph.vs(graph, to) + if (length(to) == 0) { + stop("No vertex was specified") + } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_k_shortest_paths, graph, weights, k, from-1, to-1, mode) + + res +} + +get_widest_path_impl <- function(graph, from, to, weights=NULL, mode=c("out", "in", "all", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + from <- as.igraph.vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + to <- as.igraph.vs(graph, to) + if (length(to) == 0) { + stop("No vertex was specified") + } + 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"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_widest_path, graph, from-1, to-1, weights, mode) + if (igraph_opt("return.vs.es")) { + res$vertices <- create_vs(graph, res$vertices) + } + if (igraph_opt("return.vs.es")) { + res$edges <- create_vs(graph, res$edges) + } + res +} + +get_widest_paths_impl <- function(graph, from, to=ALL, weights=NULL, mode=c("out", "in", "all", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + from <- as.igraph.vs(graph, from) + if (length(from) == 0) { + stop("No vertex was specified") + } + 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"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_widest_paths, graph, from-1, to, weights, mode) + + res +} + +widest_path_widths_dijkstra_impl <- function(graph, from=ALL, to=ALL, weights, mode=c("out", "in", "all", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_widest_path_widths_dijkstra, graph, from, to, weights, mode) + + res +} + +widest_path_widths_floyd_warshall_impl <- function(graph, from=ALL, to=ALL, weights, mode=c("out", "in", "all", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_widest_path_widths_floyd_warshall, graph, from, to, weights, mode) + + res +} + +spanner_impl <- function(graph, stretch, weights) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + stretch <- as.numeric(stretch) + 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_spanner, graph, stretch, weights) + if (igraph_opt("return.vs.es")) { + res <- create_vs(, res) + } + res +} + +betweenness_subset_impl <- function(graph, vids=ALL, directed=TRUE, sources=ALL, targets=ALL, weights=NULL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + directed <- as.logical(directed) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_betweenness_subset, graph, vids, directed, sources, targets, weights) + + res +} + +edge_betweenness_subset_impl <- function(graph, eids=ALL, directed=TRUE, sources=ALL, targets=ALL, weights=NULL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + directed <- as.logical(directed) + if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { + weights <- E(graph)$weight + } + if (!is.null(weights) && any(!is.na(weights))) { + weights <- as.numeric(weights) + } else { + weights <- NULL + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_edge_betweenness_subset, graph, eids, directed, sources, targets, weights) + + res +} + +harmonic_centrality_cutoff_impl <- function(graph, vids=ALL, mode=c("out", "in", "all", "total"), weights=NULL, normalized=FALSE, cutoff=-1) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + 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, mode, weights, normalized, cutoff) + + res +} + +personalized_pagerank_impl <- function(graph, algo=c("prpack", "arpack"), vids=ALL, directed=TRUE, damping=0.85, personalized, weights, options=NULL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + algo <- switch(igraph.match.arg(algo), "arpack"=1L, "prpack"=2L) + directed <- as.logical(directed) + damping <- as.numeric(damping) + 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 + } + if (is.null(options)) { + if (algo == 0L) { + options <- list(niter=1000, eps=0.001) + } else if (algo == 1L) { + options <- arpack_defaults + } else { + options <- NULL + } + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_personalized_pagerank, graph, algo, vids, directed, damping, personalized, weights, options) + + res +} + +personalized_pagerank_vs_impl <- function(graph, algo=c("prpack", "arpack"), vids=ALL, directed=TRUE, damping=0.85, reset.vids, weights=NULL, options=NULL, details=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + algo <- switch(igraph.match.arg(algo), "arpack"=1L, "prpack"=2L) + directed <- as.logical(directed) + damping <- as.numeric(damping) + 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(options)) { + if (algo == 0L) { + options <- list(niter=1000, eps=0.001) + } else if (algo == 1L) { + options <- arpack_defaults + } else { + options <- NULL + } + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_personalized_pagerank_vs, graph, algo, vids, directed, damping, reset.vids, weights, options) + if (!details) { + res <- res$vector + } + res +} + +subgraph_from_edges_impl <- function(graph, eids, delete.vertices=TRUE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + delete.vertices <- as.logical(delete.vertices) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_subgraph_from_edges, graph, eids, delete.vertices) + + res +} + +reverse_edges_impl <- function(graph, eids=ALL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_reverse_edges, graph, eids) + + res +} + +average_path_length_dijkstra_impl <- function(graph, weights=NULL, directed=TRUE, unconnected=TRUE, details=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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 + } + directed <- as.logical(directed) + unconnected <- as.logical(unconnected) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_average_path_length_dijkstra, graph, weights, directed, unconnected) + if (!details) { + res <- res$res + } + res +} + +path_length_hist_impl <- function(graph, directed=TRUE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_path_length_hist, graph, directed) + + res +} + +simplify_impl <- function(graph, remove.multiple=TRUE, remove.loops=TRUE, edge.attr.comb=igraph_opt("edge.attr.comb")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + remove.multiple <- as.logical(remove.multiple) + remove.loops <- as.logical(remove.loops) + edge.attr.comb <- igraph.i.attribute.combination(edge.attr.comb) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_simplify, graph, remove.multiple, remove.loops, edge.attr.comb) + + res +} + +ecc_impl <- function(graph, eids=ALL, k=3, offset=FALSE, normalize=TRUE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + k <- as.integer(k) + offset <- as.logical(offset) + normalize <- as.logical(normalize) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_ecc, graph, eids, k, offset, normalize) + + res +} + +feedback_arc_set_impl <- function(graph, weights=NULL, algo=c("approx_eades", "exact_ip")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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 + } + algo <- switch(igraph.match.arg(algo), "exact_ip"=0L, "approx_eades"=1L) on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_feedback_arc_set, graph, weights, algo) if (igraph_opt("return.vs.es")) { - res <- create_es(graph, res) + res <- create_vs(graph, res) } res } -is_loop_impl <- function(graph, eids=E(graph)) { +is_loop_impl <- function(graph, eids=ALL) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - eids <- as.igraph.es(graph, eids) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_loop, graph, eids-1) + res <- .Call(R_igraph_is_loop, graph, eids) res } @@ -492,6 +1176,17 @@ is_dag_impl <- function(graph) { res } +is_acyclic_impl <- function(graph) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_is_acyclic, graph) + + res +} + is_simple_impl <- function(graph) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } @@ -503,14 +1198,13 @@ is_simple_impl <- function(graph) { res } -is_multiple_impl <- function(graph, eids=E(graph)) { +is_multiple_impl <- function(graph, eids=ALL) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - eids <- as.igraph.es(graph, eids) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_multiple, graph, eids-1) + res <- .Call(R_igraph_is_multiple, graph, eids) res } @@ -537,14 +1231,24 @@ has_multiple_impl <- function(graph) { res } -count_multiple_impl <- function(graph, eids=E(graph)) { +count_multiple_impl <- function(graph, eids=ALL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_count_multiple, graph, eids) + + res +} + +is_perfect_impl <- function(graph) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - eids <- as.igraph.es(graph, eids) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_count_multiple, graph, eids-1) + res <- .Call(R_igraph_is_perfect, graph) res } @@ -567,9 +1271,7 @@ eigenvector_centrality_impl <- function(graph, directed=FALSE, scale=TRUE, weigh on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_eigenvector_centrality, graph, directed, scale, weights, options) - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res$vector) <- vertex_attr(graph, "name", V(graph)) - } + res } @@ -590,9 +1292,7 @@ hub_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack_defau on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_hub_score, graph, scale, weights, options) - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res$vector) <- vertex_attr(graph, "name", V(graph)) - } + res } @@ -613,20 +1313,30 @@ authority_score_impl <- function(graph, scale=TRUE, weights=NULL, options=arpack on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_authority_score, graph, scale, weights, options) - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res$vector) <- vertex_attr(graph, "name", V(graph)) - } + res } -is_mutual_impl <- function(graph, eids=E(graph)) { +is_mutual_impl <- function(graph, eids=ALL, loops=TRUE) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - eids <- as.igraph.es(graph, eids) + loops <- as.logical(loops) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_mutual, graph, eids-1) + res <- .Call(R_igraph_is_mutual, graph, eids, loops) + + res +} + +has_mutual_impl <- function(graph, loops=TRUE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_has_mutual, graph, loops) res } @@ -638,16 +1348,16 @@ maximum_cardinality_search_impl <- function(graph) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_maximum_cardinality_search, graph) + res$alpha <- res$alpha+1 if (igraph_opt("return.vs.es")) { res$alpham1 <- create_vs(graph, res$alpham1) } res } -avg_nearest_neighbor_degree_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), neighbor.degree.mode=c("all", "out", "in", "total"), weights=NULL) { +avg_nearest_neighbor_degree_impl <- function(graph, vids=ALL, mode=c("all", "out", "in", "total"), neighbor.degree.mode=c("all", "out", "in", "total"), weights=NULL) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - vids <- as.igraph.vs(graph, vids) mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) neighbor.degree.mode <- switch(igraph.match.arg(neighbor.degree.mode), "out"=1, "in"=2, "all"=3, "total"=3) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { @@ -661,17 +1371,14 @@ avg_nearest_neighbor_degree_impl <- function(graph, vids=V(graph), mode=c("all", on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_avg_nearest_neighbor_degree, graph, vids-1, mode, neighbor.degree.mode, weights) - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res$knn) <- vertex_attr(graph, "name", vids) - } + res <- .Call(R_igraph_avg_nearest_neighbor_degree, graph, vids, mode, neighbor.degree.mode, weights) + res } -strength_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=TRUE, weights=NULL) { +strength_impl <- function(graph, vids=ALL, mode=c("all", "out", "in", "total"), loops=TRUE, weights=NULL) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - vids <- as.igraph.vs(graph, vids) mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) loops <- as.logical(loops) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { @@ -685,10 +1392,8 @@ strength_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "tota on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_strength, graph, vids-1, mode, loops, weights) - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- vertex_attr(graph, "name", vids) - } + res <- .Call(R_igraph_strength, graph, vids, mode, loops, weights) + res } @@ -733,9 +1438,9 @@ centralization_betweenness_impl <- function(graph, directed=TRUE, normalized=TRU res } -centralization_betweenness_tmax_impl <- function(graph=NULL, nodes=0, directed=TRUE) { +centralization_betweenness_tmax_impl <- function(graph, nodes=0, directed=TRUE) { # Argument checks - if (!is.null(graph) && !is_igraph(graph)) { stop("Not a graph object") } + if (!is_igraph(graph)) { stop("Not a graph object") } nodes <- as.integer(nodes) directed <- as.logical(directed) @@ -759,9 +1464,9 @@ centralization_closeness_impl <- function(graph, mode=c("out", "in", "all", "tot res } -centralization_closeness_tmax_impl <- function(graph=NULL, nodes=0, mode=c("out", "in", "all", "total")) { +centralization_closeness_tmax_impl <- function(graph, nodes=0, mode=c("out", "in", "all", "total")) { # Argument checks - if (!is.null(graph) && !is_igraph(graph)) { stop("Not a graph object") } + if (!is_igraph(graph)) { stop("Not a graph object") } nodes <- as.integer(nodes) mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) @@ -787,9 +1492,9 @@ centralization_eigenvector_centrality_impl <- function(graph, directed=FALSE, sc res } -centralization_eigenvector_centrality_tmax_impl <- function(graph=NULL, nodes=0, directed=FALSE, scale=TRUE) { +centralization_eigenvector_centrality_tmax_impl <- function(graph, nodes=0, directed=FALSE, scale=TRUE) { # Argument checks - if (!is.null(graph) && !is_igraph(graph)) { stop("Not a graph object") } + if (!is_igraph(graph)) { stop("Not a graph object") } nodes <- as.integer(nodes) directed <- as.logical(directed) scale <- as.logical(scale) @@ -801,29 +1506,31 @@ centralization_eigenvector_centrality_tmax_impl <- function(graph=NULL, nodes=0, res } -assortativity_nominal_impl <- function(graph, types, directed=TRUE) { +assortativity_nominal_impl <- function(graph, types, directed=TRUE, normalized=TRUE) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - types <- as.numeric(types)-1 + types <- as.integer(types)-1L directed <- as.logical(directed) + normalized <- as.logical(normalized) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_assortativity_nominal, graph, types, directed) + res <- .Call(R_igraph_assortativity_nominal, graph, types, directed, normalized) res } -assortativity_impl <- function(graph, types1, types2=NULL, directed=TRUE) { +assortativity_impl <- function(graph, values, values.in, directed=TRUE, normalized=TRUE) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - types1 <- as.numeric(types1) - if (!is.null(types2)) types2 <- as.numeric(types2) + values <- as.numeric(values) + values.in <- as.numeric(values.in) directed <- as.logical(directed) + normalized <- as.logical(normalized) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_assortativity, graph, types1, types2, directed) + res <- .Call(R_igraph_assortativity, graph, values, values.in, directed, normalized) res } @@ -843,7 +1550,7 @@ assortativity_degree_impl <- function(graph, directed=TRUE) { contract_vertices_impl <- function(graph, mapping, vertex.attr.comb=igraph_opt("vertex.attr.comb")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - mapping <- as.numeric(mapping)-1 + mapping <- as.integer(mapping)-1L vertex.attr.comb <- igraph.i.attribute.combination(vertex.attr.comb) on.exit( .Call(R_igraph_finalizer) ) @@ -853,17 +1560,48 @@ contract_vertices_impl <- function(graph, mapping, vertex.attr.comb=igraph_opt(" res } -eccentricity_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total")) { +eccentricity_impl <- function(graph, vids=ALL, mode=c("all", "out", "in", "total")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - vids <- as.igraph.vs(graph, vids) mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_eccentricity, graph, vids-1, mode) - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- vertex_attr(graph, "name", vids) + res <- .Call(R_igraph_eccentricity, graph, vids, mode) + + res +} + +eccentricity_dijkstra_impl <- function(graph, weights=NULL, vids=ALL, mode=c("all", "out", "in", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_eccentricity_dijkstra, graph, weights, vids, mode) + + res +} + +graph_center_impl <- function(graph, mode=c("all", "out", "in", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_graph_center, graph, mode) + if (igraph_opt("return.vs.es")) { + res <- create_vs(graph, res) } res } @@ -880,7 +1618,26 @@ radius_impl <- function(graph, mode=c("all", "out", "in", "total")) { res } -diversity_impl <- function(graph, weights=NULL, vids=V(graph)) { +diversity_impl <- function(graph, weights=NULL, vids=ALL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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_diversity, graph, weights, vids) + + res +} + +random_walk_impl <- function(graph, start, steps, weights=NULL, mode=c("out", "in", "all", "total"), stuck=c("return", "error")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { @@ -891,20 +1648,6 @@ diversity_impl <- function(graph, weights=NULL, vids=V(graph)) { } else { weights <- NULL } - vids <- as.igraph.vs(graph, vids) - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_diversity, graph, weights, vids-1) - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- vertex_attr(graph, "name", vids) - } - res -} - -random_walk_impl <- function(graph, start, steps, mode=c("out", "in", "all", "total"), stuck=c("return", "error")) { - # Argument checks - if (!is_igraph(graph)) { stop("Not a graph object") } start <- as.igraph.vs(graph, start) if (length(start) == 0) { stop("No vertex was specified") @@ -915,9 +1658,12 @@ random_walk_impl <- function(graph, start, steps, mode=c("out", "in", "all", "to on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_random_walk, graph, start-1, mode, steps, stuck) + res <- .Call(R_igraph_random_walk, graph, weights, start-1, mode, steps, stuck) if (igraph_opt("return.vs.es")) { - res <- create_vs(graph, res) + res$vertices <- create_vs(graph, res$vertices) + } + if (igraph_opt("return.vs.es")) { + res$edges <- create_vs(graph, res$edges) } res } @@ -945,7 +1691,7 @@ random_edge_walk_impl <- function(graph, start, steps, weights=NULL, mode=c("out # Function call res <- .Call(R_igraph_random_edge_walk, graph, weights, start-1, mode, steps, stuck) if (igraph_opt("return.vs.es")) { - res <- create_es(graph, res) + res <- create_vs(graph, res) } res } @@ -970,10 +1716,9 @@ global_efficiency_impl <- function(graph, weights=NULL, directed=TRUE) { res } -local_efficiency_impl <- function(graph, vids=V(graph), weights=NULL, directed=TRUE, mode=c("all", "out", "in", "total")) { +local_efficiency_impl <- function(graph, vids=ALL, weights=NULL, directed=TRUE, mode=c("all", "out", "in", "total")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - vids <- as.igraph.vs(graph, vids) if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { weights <- E(graph)$weight } @@ -987,10 +1732,8 @@ local_efficiency_impl <- function(graph, vids=V(graph), weights=NULL, directed=T on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_local_efficiency, graph, vids-1, weights, directed, mode) - if (igraph_opt("add.vertex.names") && is_named(graph)) { - names(res) <- vertex_attr(graph, "name", vids) - } + res <- .Call(R_igraph_local_efficiency, graph, vids, weights, directed, mode) + res } @@ -1015,10 +1758,32 @@ average_local_efficiency_impl <- function(graph, weights=NULL, directed=TRUE, mo res } -is_graphical_impl <- function(out.deg, in.deg=NULL, allowed.edge.types=c("simple", "loops", "multi", "all")) { +transitive_closure_dag_impl <- function(graph) { # Argument checks - out.deg <- as.numeric(out.deg) - if (!is.null(in.deg)) in.deg <- as.numeric(in.deg) + if (!is_igraph(graph)) { stop("Not a graph object") } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_transitive_closure_dag, graph) + + res +} + +trussness_impl <- function(graph) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_trussness, graph) + + res +} + +is_graphical_impl <- function(out.deg, in.deg, allowed.edge.types=c("simple", "loops", "multi", "all")) { + # Argument checks + out.deg <- as.integer(out.deg) + in.deg <- as.integer(in.deg) allowed.edge.types <- switch(igraph.match.arg(allowed.edge.types), "simple"=0L, "loop"=1L, "loops"=1L, "multi"=6L, "multiple"=6L, "all"=7L) @@ -1041,6 +1806,35 @@ bipartite_projection_size_impl <- function(graph, types=NULL) { res } +biadjacency_impl <- function(incidence, directed=FALSE, mode=c("all", "out", "in", "total"), multiple=FALSE) { + # Argument checks + incidence <- as.matrix(structure(as.double(incidence), dim=dim(incidence))) + directed <- as.logical(directed) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + multiple <- as.logical(multiple) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_biadjacency, incidence, directed, mode, multiple) + if (igraph_opt("add.vertex.names") && is_named()) { + names(res$types) <- vertex_attr(, "name", ) + } + res +} + +get_biadjacency_impl <- function(graph, types=NULL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + types <- handle_vertex_type_arg(types, graph) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_get_biadjacency, graph, types) + res$row.ids <- res$row.ids+1 + res$col.ids <- res$col.ids+1 + res +} + is_bipartite_impl <- function(graph) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } @@ -1048,6 +1842,66 @@ is_bipartite_impl <- function(graph) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_is_bipartite, graph) + if (igraph_opt("add.vertex.names") && is_named()) { + names(res$type) <- vertex_attr(, "name", ) + } + res +} + +bipartite_game_impl <- function(type, n1, n2, p=0.0, m=0, directed=FALSE, mode=c("all", "out", "in", "total")) { + # Argument checks + n1 <- as.integer(n1) + n2 <- as.integer(n2) + p <- as.numeric(p) + m <- as.integer(m) + directed <- as.logical(directed) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_bipartite_game, type, n1, n2, p, m, directed, mode) + if (igraph_opt("add.vertex.names") && is_named()) { + names(res$types) <- vertex_attr(, "name", ) + } + res +} + +get_laplacian_impl <- function(graph, mode=c("out", "in", "all", "total"), normalization=UNNORMALIZED, weights=NULL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + 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_laplacian, graph, mode, normalization, weights) + + res +} + +get_laplacian_sparse_impl <- function(graph, mode=c("out", "in", "all", "total"), normalization=UNNORMALIZED, weights=NULL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + 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_laplacian_sparse, graph, mode, normalization, weights) res } @@ -1084,24 +1938,6 @@ biconnected_components_impl <- function(graph) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_biconnected_components, graph) - if (igraph_opt("return.vs.es")) { - es <- E(graph) - for (i_ in seq_along(res$tree.edges)) { - res$tree.edges[[i_]] <- unsafe_create_es(graph, res$tree.edges[[i_]], es = es) - } - } - if (igraph_opt("return.vs.es")) { - es <- E(graph) - for (i_ in seq_along(res$component.edges)) { - res$component.edges[[i_]] <- unsafe_create_es(graph, res$component.edges[[i_]], es = es) - } - } - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res$components)) { - res$components[[i_]] <- unsafe_create_vs(graph, res$components[[i_]], verts = verts) - } - } if (igraph_opt("return.vs.es")) { res$articulation.points <- create_vs(graph, res$articulation.points) } @@ -1116,7 +1952,7 @@ bridges_impl <- function(graph) { # Function call res <- .Call(R_igraph_bridges, graph) if (igraph_opt("return.vs.es")) { - res <- create_es(graph, res) + res <- create_vs(graph, res) } res } @@ -1130,12 +1966,7 @@ cliques_impl <- function(graph, min=0, max=0) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_cliques, graph, min, max) - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res)) { - res[[i_]] <- unsafe_create_vs(graph, res[[i_]], verts = verts) - } - } + res } @@ -1159,11 +1990,22 @@ largest_cliques_impl <- function(graph) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_largest_cliques, graph) - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res)) { - res[[i_]] <- unsafe_create_vs(graph, res[[i_]], verts = verts) - } + + res +} + +maximal_cliques_subset_impl <- function(graph, subset, outfile=NULL, min.size=0, max.size=0, details=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + subset <- as.igraph.vs(graph, subset) + min.size <- as.integer(min.size) + max.size <- as.integer(max.size) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_maximal_cliques_subset, graph, subset-1, outfile, min.size, max.size) + if (!details) { + res <- res$res } res } @@ -1210,12 +2052,7 @@ weighted_cliques_impl <- function(graph, vertex.weights=NULL, min.weight=0, max. on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_weighted_cliques, graph, vertex.weights, min.weight, max.weight, maximal) - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res)) { - res[[i_]] <- unsafe_create_vs(graph, res[[i_]], verts = verts) - } - } + res } @@ -1234,12 +2071,7 @@ largest_weighted_cliques_impl <- function(graph, vertex.weights=NULL) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_largest_weighted_cliques, graph, vertex.weights) - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res)) { - res[[i_]] <- unsafe_create_vs(graph, res[[i_]], verts = verts) - } - } + res } @@ -1257,48 +2089,209 @@ weighted_clique_number_impl <- function(graph, vertex.weights=NULL) { on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_weighted_clique_number, graph, vertex.weights) + res <- .Call(R_igraph_weighted_clique_number, graph, vertex.weights) + + res +} + +roots_for_tree_layout_impl <- function(graph, mode=c("out", "in", "all", "total"), heuristic) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + 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 +} + +layout_umap_impl <- function(graph, res, use.seed=FALSE, distances=NULL, min.dist=0.0, epochs=200, distances.are.weights=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + res <- as.matrix(structure(as.double(res), dim=dim(res))) + use.seed <- as.logical(use.seed) + distances <- as.numeric(distances) + min.dist <- as.numeric(min.dist) + epochs <- as.integer(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 + if (!is_igraph(graph)) { stop("Not a graph object") } + res <- as.matrix(structure(as.double(res), dim=dim(res))) + use.seed <- as.logical(use.seed) + distances <- as.numeric(distances) + min.dist <- as.numeric(min.dist) + epochs <- as.integer(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 + if (!is_igraph(graph)) { stop("Not a graph object") } + 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 +} + +similarity_dice_impl <- function(graph, vids=ALL, mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_dice, graph, vids, mode, loops) + + res +} + +similarity_dice_es_impl <- function(graph, es=ALL, mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_dice_es, graph, es, mode, loops) + + res +} + +similarity_dice_pairs_impl <- function(graph, pairs, mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + pairs <- as.igraph.vs(graph, pairs) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_dice_pairs, graph, pairs-1, mode, loops) + + res +} + +similarity_inverse_log_weighted_impl <- function(graph, vids=ALL, mode=c("all", "out", "in", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_inverse_log_weighted, graph, vids, mode) + + res +} + +similarity_jaccard_impl <- function(graph, vids=ALL, mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_jaccard, graph, vids, mode, loops) + + res +} + +similarity_jaccard_es_impl <- function(graph, es=ALL, mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_jaccard_es, graph, es, mode, loops) + + res +} + +similarity_jaccard_pairs_impl <- function(graph, pairs, mode=c("all", "out", "in", "total"), loops=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + pairs <- as.igraph.vs(graph, pairs) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + loops <- as.logical(loops) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_similarity_jaccard_pairs, graph, pairs-1, mode, loops) res } -similarity_jaccard_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { +graphlets_impl <- function(graph, weights=NULL, niter=1000) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - vids <- as.igraph.vs(graph, vids) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) - loops <- as.logical(loops) + 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.integer(niter) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_jaccard, graph, vids-1, mode, loops) + res <- .Call(R_igraph_graphlets, graph, weights, niter) res } -similarity_dice_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total"), loops=FALSE) { +hrg_sample_impl <- function(hrg) { # Argument checks - if (!is_igraph(graph)) { stop("Not a graph object") } - vids <- as.igraph.vs(graph, vids) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) - loops <- as.logical(loops) + 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) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_dice, graph, vids-1, mode, loops) + res <- .Call(R_igraph_hrg_sample, hrg) res } -similarity_inverse_log_weighted_impl <- function(graph, vids=V(graph), mode=c("all", "out", "in", "total")) { +hrg_sample_many_impl <- function(hrg, num.samples) { # Argument checks - if (!is_igraph(graph)) { stop("Not a graph object") } - vids <- as.igraph.vs(graph, vids) - mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + 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) + num.samples <- as.integer(num.samples) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_similarity_inverse_log_weighted, graph, vids-1, mode) + res <- .Call(R_igraph_hrg_sample_many, hrg, num.samples) res } @@ -1365,7 +2358,37 @@ hrg_create_impl <- function(graph, prob) { res } -graphlets_impl <- function(graph, weights=NULL, niter=1000) { +hrg_resize_impl <- function(hrg, newsize) { + # Argument checks + 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) + newsize <- as.integer(newsize) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_hrg_resize, hrg, newsize) + + res +} + +hrg_size_impl <- function(hrg) { + # Argument checks + 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) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_hrg_size, hrg) + + + res +} + +get_adjacency_sparse_impl <- function(graph, type=BOTH, weights=NULL, loops=ONCE) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } if (is.null(weights) && "weight" %in% edge_attr_names(graph)) { @@ -1376,17 +2399,31 @@ graphlets_impl <- function(graph, weights=NULL, niter=1000) { } else { weights <- NULL } - niter <- as.integer(niter) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_graphlets, graph, weights, niter) - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res$cliques)) { - res$cliques[[i_]] <- unsafe_create_vs(graph, res$cliques[[i_]], verts = verts) - } + res <- .Call(R_igraph_get_adjacency_sparse, graph, type, weights, loops) + + res +} + +get_stochastic_sparse_impl <- function(graph, column.wise=FALSE, weights=NULL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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_sparse, graph, column.wise, weights) + res } @@ -1402,6 +2439,17 @@ to_directed_impl <- function(graph, mode=c("mutual", "arbitrary", "random", "acy res } +read_graph_dimacs_flow_impl <- function(instream, directed=TRUE) { + # Argument checks + directed <- as.logical(directed) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_read_graph_dimacs_flow, instream, directed) + + res +} + dyad_census_impl <- function(graph) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } @@ -1424,14 +2472,32 @@ triad_census_impl <- function(graph) { res } -adjacent_triangles_impl <- function(graph, vids=V(graph)) { +adjacent_triangles_impl <- function(graph, vids=ALL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_adjacent_triangles, graph, vids) + + res +} + +local_scan_subset_ecount_impl <- function(graph, weights=NULL, subsets) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - 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_adjacent_triangles, graph, vids-1) + res <- .Call(R_igraph_local_scan_subset_ecount, graph, weights, subsets) res } @@ -1449,7 +2515,39 @@ list_triangles_impl <- function(graph) { res } -maxflow_impl <- function(graph, source, target, capacity=NULL) { +induced_subgraph_map_impl <- function(graph, vids, impl) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + impl <- switch(igraph.match.arg(impl), "auto"=0, "copy_and_delete"=1, "create_from_scratch"=2) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_induced_subgraph_map, graph, vids, impl) + res$map <- res$map+1 + res$invmap <- res$invmap+1 + res +} + +gomory_hu_tree_impl <- function(graph, capacity) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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_gomory_hu_tree, graph, capacity) + + res +} + +maxflow_impl <- function(graph, source, target, capacity) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } source <- as.igraph.vs(graph, source) @@ -1472,6 +2570,9 @@ maxflow_impl <- function(graph, source, target, capacity=NULL) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_maxflow, graph, source-1, target-1, capacity) + if (igraph_opt("return.vs.es")) { + res$cut <- create_vs(graph, res$cut) + } if (igraph_opt("return.vs.es")) { res$partition1 <- create_vs(graph, res$partition1) } @@ -1481,6 +2582,46 @@ maxflow_impl <- function(graph, source, target, capacity=NULL) { res } +residual_graph_impl <- function(graph, capacity, flow) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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 + } + flow <- as.numeric(flow) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_residual_graph, graph, capacity, flow) + + res +} + +reverse_residual_graph_impl <- function(graph, capacity, flow) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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 + } + flow <- as.numeric(flow) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_reverse_residual_graph, graph, capacity, flow) + + res +} + dominator_tree_impl <- function(graph, root, mode=c("out", "in", "all", "total")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } @@ -1493,6 +2634,7 @@ dominator_tree_impl <- function(graph, root, mode=c("out", "in", "all", "total") on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_dominator_tree, graph, root-1, mode) + res$dom <- res$dom+1 if (igraph_opt("return.vs.es")) { res$leftout <- create_vs(graph, res$leftout) } @@ -1514,22 +2656,11 @@ all_st_cuts_impl <- function(graph, source, target) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_all_st_cuts, graph, source-1, target-1) - if (igraph_opt("return.vs.es")) { - es <- E(graph) - for (i_ in seq_along(res$cuts)) { - res$cuts[[i_]] <- unsafe_create_es(graph, res$cuts[[i_]], es = es) - } - } - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res$partition1s)) { - res$partition1s[[i_]] <- unsafe_create_vs(graph, res$partition1s[[i_]], verts = verts) - } - } + res } -all_st_mincuts_impl <- function(graph, source, target, capacity=NULL) { +all_st_mincuts_impl <- function(graph, source, target, capacity) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } source <- as.igraph.vs(graph, source) @@ -1540,8 +2671,8 @@ all_st_mincuts_impl <- function(graph, source, target, capacity=NULL) { if (length(target) == 0) { stop("No vertex was specified") } - if (is.null(capacity) && "weight" %in% edge_attr_names(graph)) { - capacity <- E(graph)$weight + 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) @@ -1552,29 +2683,28 @@ all_st_mincuts_impl <- function(graph, source, target, capacity=NULL) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_all_st_mincuts, graph, source-1, target-1, capacity) - if (igraph_opt("return.vs.es")) { - es <- E(graph) - for (i_ in seq_along(res$cuts)) { - res$cuts[[i_]] <- unsafe_create_es(graph, res$cuts[[i_]], es = es) - } - } - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res$partition1s)) { - res$partition1s[[i_]] <- unsafe_create_vs(graph, res$partition1s[[i_]], verts = verts) - } - } + + res +} + +even_tarjan_reduction_impl <- function(graph) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_even_tarjan_reduction, graph) + res } is_separator_impl <- function(graph, candidate) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - candidate <- as.igraph.vs(graph, candidate) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_separator, graph, candidate-1) + res <- .Call(R_igraph_is_separator, graph, candidate) res } @@ -1582,11 +2712,10 @@ is_separator_impl <- function(graph, candidate) { is_minimal_separator_impl <- function(graph, candidate) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - candidate <- as.igraph.vs(graph, candidate) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_is_minimal_separator, graph, candidate-1) + res <- .Call(R_igraph_is_minimal_separator, graph, candidate) res } @@ -1598,12 +2727,7 @@ all_minimal_st_separators_impl <- function(graph) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_all_minimal_st_separators, graph) - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res)) { - res[[i_]] <- unsafe_create_vs(graph, res[[i_]], verts = verts) - } - } + res } @@ -1614,12 +2738,7 @@ minimum_size_separators_impl <- function(graph) { on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_minimum_size_separators, graph) - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res)) { - res[[i_]] <- unsafe_create_vs(graph, res[[i_]], verts = verts) - } - } + res } @@ -1706,12 +2825,77 @@ isomorphic_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, ed on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_isomorphic_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + res <- .Call(R_igraph_isomorphic_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + res$map12 <- res$map12+1 + res$map21 <- res$map21+1 + res +} + +count_isomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) { + # Argument checks + if (!is_igraph(graph1)) { stop("Not a graph object") } + if (!is_igraph(graph2)) { stop("Not a graph object") } + 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.integer(vertex.color1)-1L + } + 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.integer(vertex.color2)-1L + } + 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.integer(edge.color1)-1L + } + 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.integer(edge.color2)-1L + } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_count_isomorphisms_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + + res +} + +subisomorphic_impl <- function(graph1, graph2) { + # Argument checks + if (!is_igraph(graph1)) { stop("Not a graph object") } + if (!is_igraph(graph2)) { stop("Not a graph object") } + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_subisomorphic, graph1, graph2) res } -count_isomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) { +subisomorphic_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) { # Argument checks if (!is_igraph(graph1)) { stop("Not a graph object") } if (!is_igraph(graph2)) { stop("Not a graph object") } @@ -1758,12 +2942,13 @@ count_isomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.co on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_count_isomorphisms_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) - + res <- .Call(R_igraph_subisomorphic_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) + res$map12 <- res$map12+1 + res$map21 <- res$map21+1 res } -subisomorphic_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) { +subisomorphic_function_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2, ishohandler.fn) { # Argument checks if (!is_igraph(graph1)) { stop("Not a graph object") } if (!is_igraph(graph2)) { stop("Not a graph object") } @@ -1810,8 +2995,9 @@ subisomorphic_vf2_impl <- function(graph1, graph2, vertex.color1, vertex.color2, on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_subisomorphic_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2) - + res <- .Call(R_igraph_subisomorphic_function_vf2, graph1, graph2, vertex.color1, vertex.color2, edge.color1, edge.color2, ishohandler.fn) + res$map12 <- res$map12+1 + res$map21 <- res$map21+1 res } @@ -1867,18 +3053,6 @@ count_subisomorphisms_vf2_impl <- function(graph1, graph2, vertex.color1, vertex res } -isomorphic_34_impl <- function(graph1, graph2) { - # Argument checks - if (!is_igraph(graph1)) { stop("Not a graph object") } - if (!is_igraph(graph2)) { stop("Not a graph object") } - - on.exit( .Call(R_igraph_finalizer) ) - # Function call - res <- .Call(R_igraph_isomorphic_34, graph1, graph2) - - res -} - canonical_permutation_impl <- function(graph, colors, sh=c("fm", "f", "fs", "fl", "flm", "fsm")) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } @@ -1897,14 +3071,14 @@ canonical_permutation_impl <- function(graph, colors, sh=c("fm", "f", "fs", "fl" on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_canonical_permutation, graph, colors, sh) - + res$labeling <- res$labeling+1 res } permute_vertices_impl <- function(graph, permutation) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } - permutation <- as.numeric(permutation)-1 + permutation <- as.integer(permutation)-1L on.exit( .Call(R_igraph_finalizer) ) # Function call @@ -1942,7 +3116,8 @@ isomorphic_bliss_impl <- function(graph1, graph2, colors1, colors2, sh=c("fm", " on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_isomorphic_bliss, graph1, graph2, colors1, colors2, sh) - + res$map12 <- res$map12+1 + res$map21 <- res$map21+1 res } @@ -1986,29 +3161,20 @@ automorphism_group_impl <- function(graph, colors, sh=c("fm", "f", "fs", "fl", " on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_automorphism_group, graph, colors, sh) - if (igraph_opt("return.vs.es")) { - verts <- V(graph) - for (i_ in seq_along(res$generators)) { - res$generators[[i_]] <- unsafe_create_vs(graph, res$generators[[i_]], verts = verts) - } - } if (!details) { res <- res$generators } res } -scg_norm_eps_impl <- function(V, groups, mtype=c("symmetric", "laplacian", "stochastic"), p=NULL, norm=c("row", "col")) { +graph_count_impl <- function(n, directed=FALSE) { # Argument checks - V <- as.matrix(structure(as.double(V), dim=dim(V))) - groups <- as.numeric(groups)-1 - mtype <- switch(igraph.match.arg(mtype), "symmetric"=1, "laplacian"=2, "stochastic"=3) - if (!is.null(p)) p <- as.numeric(p) - norm <- switch(igraph.match.arg(norm), "row"=1, "col"=2) + n <- as.integer(n) + directed <- as.logical(directed) on.exit( .Call(R_igraph_finalizer) ) # Function call - res <- .Call(R_igraph_scg_norm_eps, V, groups, mtype, p, norm) + res <- .Call(R_igraph_graph_count, n, directed) res } @@ -2118,6 +3284,80 @@ dim_select_impl <- function(sv) { res } +almost_equals_impl <- function(a, b, eps) { + # Argument checks + + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_almost_equals, a, b, eps) + + + res +} + +cmp_epsilon_impl <- function(a, b, eps) { + # Argument checks + + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_cmp_epsilon, a, b, eps) + + + res +} + +eigen_matrix_impl <- function(A, sA, fun, n, algorithm, which, options=igraph.arpack.default) { + # Argument checks + A <- as.matrix(structure(as.double(A), dim=dim(A))) + require(Matrix); sA <- as(as(as(sA, "dMatrix"), "generalMatrix"), "CsparseMatrix") + n <- as.integer(n) + algorithm <- switch(igraph.match.arg(algorithm), "auto"=0, "lapack"=1, + "arpack"=2, "comp_auto"=3, "comp_lapack"=4, + "comp_arpack"=5) + which.tmp <- eigen_defaults(); + which.tmp[ names(which) ] <- which ; which <- which.tmp + options.tmp <- arpack_defaults; options.tmp[ names(options) ] <- options ; options <- options.tmp + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_eigen_matrix, A, sA, fun, n, algorithm, which, options) + + res +} + +eigen_matrix_symmetric_impl <- function(A, sA, fun, n, algorithm, which, options=igraph.arpack.default) { + # Argument checks + A <- as.matrix(structure(as.double(A), dim=dim(A))) + require(Matrix); sA <- as(as(as(sA, "dMatrix"), "generalMatrix"), "CsparseMatrix") + n <- as.integer(n) + algorithm <- switch(igraph.match.arg(algorithm), "auto"=0, "lapack"=1, + "arpack"=2, "comp_auto"=3, "comp_lapack"=4, + "comp_arpack"=5) + which.tmp <- eigen_defaults(); + which.tmp[ names(which) ] <- which ; which <- which.tmp + options.tmp <- arpack_defaults; options.tmp[ names(options) ] <- options ; options <- options.tmp + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_eigen_matrix_symmetric, A, sA, fun, n, algorithm, which, options) + + res +} + +solve_lsap_impl <- function(c, n) { + # Argument checks + c <- as.matrix(structure(as.double(c), dim=dim(c))) + n <- as.integer(n) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_solve_lsap, c, n) + + res +} + is_eulerian_impl <- function(graph) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } @@ -2137,7 +3377,7 @@ eulerian_path_impl <- function(graph) { # Function call res <- .Call(R_igraph_eulerian_path, graph) if (igraph_opt("return.vs.es")) { - res$epath <- create_es(graph, res$epath) + res$epath <- create_vs(graph, res$epath) } if (igraph_opt("return.vs.es")) { res$vpath <- create_vs(graph, res$vpath) @@ -2153,7 +3393,7 @@ eulerian_cycle_impl <- function(graph) { # Function call res <- .Call(R_igraph_eulerian_cycle, graph) if (igraph_opt("return.vs.es")) { - res$epath <- create_es(graph, res$epath) + res$epath <- create_vs(graph, res$epath) } if (igraph_opt("return.vs.es")) { res$vpath <- create_vs(graph, res$vpath) @@ -2161,6 +3401,52 @@ eulerian_cycle_impl <- function(graph) { res } +fundamental_cycles_impl <- function(graph, start, bfs.cutoff, weights=NULL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + start <- as.igraph.vs(graph, start) + if (length(start) == 0) { + stop("No vertex was specified") + } + bfs.cutoff <- as.integer(bfs.cutoff) + 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_fundamental_cycles, graph, start-1, bfs.cutoff, weights) + + res +} + +minimum_cycle_basis_impl <- function(graph, bfs.cutoff, complete, use.cycle.order, weights=NULL) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + bfs.cutoff <- as.integer(bfs.cutoff) + complete <- as.logical(complete) + use.cycle.order <- as.logical(use.cycle.order) + 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_minimum_cycle_basis, graph, bfs.cutoff, complete, use.cycle.order, weights) + + res +} + is_tree_impl <- function(graph, mode=c("out", "in", "all", "total"), details=FALSE) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } @@ -2178,6 +3464,23 @@ is_tree_impl <- function(graph, mode=c("out", "in", "all", "total"), details=FAL res } +is_forest_impl <- function(graph, mode=c("out", "in", "all", "total"), details=FALSE) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_is_forest, graph, mode) + if (igraph_opt("return.vs.es")) { + res$roots <- create_vs(graph, res$roots) + } + if (!details) { + res <- res$res + } + res +} + from_prufer_impl <- function(prufer) { # Argument checks prufer <- as.integer(prufer)-1L @@ -2205,6 +3508,17 @@ to_prufer_impl <- function(graph) { res } +tree_from_parent_vector_impl <- function(parents, type=OUT) { + # Argument checks + parents <- as.integer(parents)-1L + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_tree_from_parent_vector, parents, type) + + res +} + random_spanning_tree_impl <- function(graph, vid=0) { # Argument checks if (!is_igraph(graph)) { stop("Not a graph object") } @@ -2217,7 +3531,7 @@ random_spanning_tree_impl <- function(graph, vid=0) { # Function call res <- .Call(R_igraph_random_spanning_tree, graph, vid-1) if (igraph_opt("return.vs.es")) { - res <- create_es(graph, res) + res <- create_vs(graph, res) } res } @@ -2250,3 +3564,135 @@ vertex_coloring_greedy_impl <- function(graph, heuristic=c("colored_neighbors")) res } +deterministic_optimal_imitation_impl <- function(graph, vid, optimality=MAXIMUM, quantities, strategies, mode=c("out", "in", "all", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + vid <- as.igraph.vs(graph, vid) + if (length(vid) == 0) { + stop("No vertex was specified") + } + strategies <- as.integer(strategies) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_deterministic_optimal_imitation, graph, vid-1, optimality, quantities, strategies, mode) + + res +} + +stochastic_imitation_impl <- function(graph, vid, algo, quantities, strategies, mode=c("out", "in", "all", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + vid <- as.igraph.vs(graph, vid) + if (length(vid) == 0) { + stop("No vertex was specified") + } + strategies <- as.integer(strategies) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_stochastic_imitation, graph, vid-1, algo, quantities, strategies, mode) + + res +} + +moran_process_impl <- function(graph, weights=NULL, quantities, strategies, mode=c("out", "in", "all", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + 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 + } + strategies <- as.integer(strategies) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_moran_process, graph, weights, quantities, strategies, mode) + + res +} + +roulette_wheel_imitation_impl <- function(graph, vid, is.local, quantities, strategies, mode=c("out", "in", "all", "total")) { + # Argument checks + if (!is_igraph(graph)) { stop("Not a graph object") } + vid <- as.igraph.vs(graph, vid) + if (length(vid) == 0) { + stop("No vertex was specified") + } + is.local <- as.logical(is.local) + strategies <- as.integer(strategies) + mode <- switch(igraph.match.arg(mode), "out"=1, "in"=2, "all"=3, "total"=3) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_roulette_wheel_imitation, graph, vid-1, is.local, quantities, strategies, mode) + + res +} + +has_attribute_table_impl <- function() { + # Argument checks + + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_has_attribute_table, ) + + + res +} + +progress_impl <- function(message, percent) { + # Argument checks + percent <- as.numeric(percent) + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_progress, message, percent) + + + res +} + +status_impl <- function(message) { + # Argument checks + + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_status, message) + + + res +} + +strerror_impl <- function(igraph.errno) { + # Argument checks + + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_strerror, igraph.errno) + + + res +} + +version_impl <- function() { + # Argument checks + + + on.exit( .Call(R_igraph_finalizer) ) + # Function call + res <- .Call(R_igraph_version, ) + + res +} + diff --git a/R/conversion.R b/R/conversion.R index b3d8af59d10..b5dc4b0ace4 100644 --- a/R/conversion.R +++ b/R/conversion.R @@ -724,7 +724,7 @@ get.incidence.dense <- function(graph, types, names, attr) { if (is.null(attr)) { on.exit(.Call(R_igraph_finalizer)) ## Function call - res <- .Call(R_igraph_get_incidence, graph, types) + res <- .Call(R_igraph_get_biadjacency, graph, types) if (names && "name" %in% vertex_attr_names(graph)) { rownames(res$res) <- V(graph)$name[res$row_ids + 1] diff --git a/R/interface.R b/R/interface.R index 77df4ef034d..15134c4d7a2 100644 --- a/R/interface.R +++ b/R/interface.R @@ -389,7 +389,7 @@ ends <- function(graph, es, names = TRUE) { stop("Not a graph object") } - es2 <- as.igraph.es(graph, na.omit(es)) - 1 + es2 <- as.integer(as.igraph.es(graph, na.omit(es)) - 1) res <- matrix(NA_integer_, ncol = length(es), nrow = 2) on.exit(.Call(R_igraph_finalizer)) @@ -476,7 +476,7 @@ get.edge.ids <- function(graph, vp, directed = TRUE, error = FALSE, multi = FALS on.exit(.Call(R_igraph_finalizer)) .Call( R_igraph_get_eids, graph, as.igraph.vs(graph, vp) - 1, - as.logical(directed), as.logical(error), as.logical(multi) + as.logical(directed), as.logical(error) ) + 1 } diff --git a/R/scg.R b/R/scg.R index 76bd4baa821..632d6419cb1 100644 --- a/R/scg.R +++ b/R/scg.R @@ -121,10 +121,10 @@ stochastic_matrix <- function(graph, column.wise = FALSE, on.exit(.Call(R_igraph_finalizer)) if (sparse) { - res <- .Call(R_igraph_get_stochastic_sparsemat, graph, column.wise) + res <- get_stochastic_sparse_impl(graph, column.wise) res <- igraph.i.spMatrix(res) } else { - res <- .Call(R_igraph_get_stochastic, graph, column.wise) + res <- .Call(R_igraph_get_stochastic, graph, column.wise, NULL) } if (igraph_opt("add.vertex.names") && is_named(graph)) { @@ -279,11 +279,7 @@ scg_group <- function(V, nt, on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call( - R_igraph_scg_grouping, V, as.integer(nt[1]), - if (length(nt) == 1) NULL else nt, - mtype, algo, p, maxiter - ) + res <- NULL res } @@ -392,10 +388,7 @@ scg_semi_proj <- function(groups, on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call( - R_igraph_scg_semiprojectors, groups, mtype, p, norm, - sparse - ) + res <- NULL if (sparse) { res$L <- igraph.i.spMatrix(res$L) @@ -750,11 +743,7 @@ myscg <- function(graph, matrix, sparsemat, ev, nt, groups = NULL, if (!is.null(evec)) { storage.mode(evec) <- "double" } - res <- .Call( - R_igraph_scg_adjacency, graph, matrix, sparsemat, ev, - nt, algo, evec, groups, - use.arpack, maxiter, sparse, output, semproj, epairs - ) + res <- NULL } else if (mtype == "laplacian") { norm <- switch(igraph.match.arg(norm), "row" = 1, @@ -768,12 +757,7 @@ myscg <- function(graph, matrix, sparsemat, ev, nt, groups = NULL, "left" = 2, "right" = 3 ) - res <- .Call( - R_igraph_scg_laplacian, graph, matrix, sparsemat, ev, - nt, algo, norm, direction, - evec, groups, use.arpack, maxiter, sparse, output, - semproj, epairs - ) + res <- NULL } else if (mtype == "stochastic") { norm <- switch(igraph.match.arg(norm), "row" = 1, @@ -786,11 +770,7 @@ myscg <- function(graph, matrix, sparsemat, ev, nt, groups = NULL, storage.mode(p) <- "double" } stat.prob <- as.logical(stat.prob) - res <- .Call( - R_igraph_scg_stochastic, graph, matrix, sparsemat, ev, - nt, algo, norm, evec, groups, p, use.arpack, - maxiter, sparse, output, semproj, epairs, stat.prob - ) + res <- NULL } if (!is.null(res$Xt) && @@ -846,4 +826,6 @@ myscg <- function(graph, matrix, sparsemat, ev, nt, groups = NULL, #' sum(km$withinss) #' scg_eps(cbind(v), km$cluster)^2 #' @family scg -scg_eps <- scg_norm_eps_impl +scg_eps <- function(V, groups, mtype, p, norm) { + scg_norm_eps_impl(V, groups, mtype, p, norm) +} diff --git a/R/structural.properties.R b/R/structural.properties.R index f3cc0ba1e08..59f3eabc0d2 100644 --- a/R/structural.properties.R +++ b/R/structural.properties.R @@ -792,7 +792,7 @@ subgraph.edges <- function(graph, eids, delete.vertices = TRUE) { on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_subgraph_edges, graph, eids - 1, delete.vertices) + res <- .Call(R_igraph_subgraph_from_edges, graph, eids - 1, delete.vertices) res } @@ -1939,7 +1939,7 @@ components <- function(graph, mode = c("weak", "strong")) { on.exit(.Call(R_igraph_finalizer)) # Function call - res <- .Call(R_igraph_clusters, graph, mode) + res <- .Call(R_igraph_connected_components, graph, mode) res$membership <- res$membership + 1 if (igraph_opt("add.vertex.names") && is_named(graph)) { names(res$membership) <- V(graph)$name diff --git a/R/topology.R b/R/topology.R index 922c0e7194f..9a80cd2006b 100644 --- a/R/topology.R +++ b/R/topology.R @@ -328,7 +328,7 @@ isomorphic <- function(graph1, graph2, method = c( .Call(R_igraph_isomorphic, graph1, graph2) } else if (method == "direct") { on.exit(.Call(R_igraph_finalizer)) - .Call(R_igraph_isomorphic_34, graph1, graph2) + .Call(R_igraph_isomorphic, graph1, graph2) } else if (method == "vf2") { graph.isomorphic.vf2(graph1, graph2, ...)$iso } else if (method == "bliss") { @@ -337,7 +337,9 @@ isomorphic <- function(graph1, graph2, method = c( } #' @export -graph.isomorphic.34 <- isomorphic_34_impl +graph.isomorphic.34 <- function(graph1, graph2, method) { + isomorphic_34_impl(graph1, graph2, method) +} #' @export graph.isomorphic.bliss <- isomorphic_bliss_impl #' @export diff --git a/configure b/configure index 2e5d6484602..38835e54b2d 100755 --- a/configure +++ b/configure @@ -1,6439 +1,18 @@ #! /bin/sh -# Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71. -# -# -# Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, -# Inc. -# -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -as_nop=: -if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 -then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else $as_nop - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - - -# Reset variables that may have inherited troublesome values from -# the environment. - -# IFS needs to be set, to space, tab, and newline, in precisely that order. -# (If _AS_PATH_WALK were called with IFS unset, it would have the -# side effect of setting IFS to empty, thus disabling word splitting.) -# Quoting is to prevent editors from complaining about space-tab. -as_nl=' -' -export as_nl -IFS=" "" $as_nl" - -PS1='$ ' -PS2='> ' -PS4='+ ' - -# Ensure predictable behavior from utilities with locale-dependent output. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# We cannot yet rely on "unset" to work, but we need these variables -# to be unset--not just set to an empty or harmless value--now, to -# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct -# also avoids known problems related to "unset" and subshell syntax -# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). -for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH -do eval test \${$as_var+y} \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done - -# Ensure that fds 0, 1, and 2 are open. -if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi -if (exec 3>&2) ; then :; else exec 2>/dev/null; fi - -# The user is always right. -if ${PATH_SEPARATOR+false} :; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - test -r "$as_dir$0" && as_myself=$as_dir$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - - -# Use a proper internal environment variable to ensure we don't fall - # into an infinite loop, continuously re-executing ourselves. - if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then - _as_can_reexec=no; export _as_can_reexec; - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 - fi - # We don't want this to propagate to other subprocesses. - { _as_can_reexec=; unset _as_can_reexec;} -if test "x$CONFIG_SHELL" = x; then - as_bourne_compatible="as_nop=: -if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 -then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which - # is contrary to our usage. Disable this feature. - alias -g '\${1+\"\$@\"}'='\"\$@\"' - setopt NO_GLOB_SUBST -else \$as_nop - case \`(set -o) 2>/dev/null\` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi -" - as_required="as_fn_return () { (exit \$1); } -as_fn_success () { as_fn_return 0; } -as_fn_failure () { as_fn_return 1; } -as_fn_ret_success () { return 0; } -as_fn_ret_failure () { return 1; } - -exitcode=0 -as_fn_success || { exitcode=1; echo as_fn_success failed.; } -as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } -as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } -as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } -if ( set x; as_fn_ret_success y && test x = \"\$1\" ) -then : - -else \$as_nop - exitcode=1; echo positional parameters were not saved. -fi -test x\$exitcode = x0 || exit 1 -blah=\$(echo \$(echo blah)) -test x\"\$blah\" = xblah || exit 1 -test -x / || exit 1" - as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO - as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO - eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && - test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" - if (eval "$as_required") 2>/dev/null -then : - as_have_required=yes -else $as_nop - as_have_required=no -fi - if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null -then : - -else $as_nop - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -as_found=false -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - as_found=: - case $as_dir in #( - /*) - for as_base in sh bash ksh sh5; do - # Try only shells that exist, to save several forks. - as_shell=$as_dir$as_base - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null -then : - CONFIG_SHELL=$as_shell as_have_required=yes - if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null -then : - break 2 -fi -fi - done;; - esac - as_found=false -done -IFS=$as_save_IFS -if $as_found -then : - -else $as_nop - if { test -f "$SHELL" || test -f "$SHELL.exe"; } && - as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null -then : - CONFIG_SHELL=$SHELL as_have_required=yes -fi -fi - - - if test "x$CONFIG_SHELL" != x -then : - export CONFIG_SHELL - # We cannot yet assume a decent shell, so we have to provide a -# neutralization value for shells without unset; and this also -# works around shells that cannot unset nonexistent variables. -# Preserve -v and -x to the replacement shell. -BASH_ENV=/dev/null -ENV=/dev/null -(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV -case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; -esac -exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} -# Admittedly, this is quite paranoid, since all the known shells bail -# out after a failed `exec'. -printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2 -exit 255 -fi - - if test x$as_have_required = xno -then : - printf "%s\n" "$0: This script requires a shell more modern than all" - printf "%s\n" "$0: the shells that I found on your system." - if test ${ZSH_VERSION+y} ; then - printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should" - printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later." - else - printf "%s\n" "$0: Please tell bug-autoconf@gnu.org about your system, -$0: including any error possibly output before this -$0: message. Then install a modern shell, or manually run -$0: the script under such a shell if you do have one." - fi - exit 1 -fi -fi -fi -SHELL=${CONFIG_SHELL-/bin/sh} -export SHELL -# Unset more variables known to interfere with behavior of common tools. -CLICOLOR_FORCE= GREP_OPTIONS= -unset CLICOLOR_FORCE GREP_OPTIONS - -## --------------------- ## -## M4sh Shell Functions. ## -## --------------------- ## -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit -# as_fn_nop -# --------- -# Do nothing but, unlike ":", preserve the value of $?. -as_fn_nop () -{ - return $? -} -as_nop=as_fn_nop - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null -then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else $as_nop - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null -then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else $as_nop - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - -# as_fn_nop -# --------- -# Do nothing but, unlike ":", preserve the value of $?. -as_fn_nop () -{ - return $? -} -as_nop=as_fn_nop - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - printf "%s\n" "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - - as_lineno_1=$LINENO as_lineno_1a=$LINENO - as_lineno_2=$LINENO as_lineno_2a=$LINENO - eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && - test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { - # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - - # If we had to re-execute with $CONFIG_SHELL, we're ensured to have - # already done that, so ensure we don't try to do so again and fall - # in an infinite loop. This has already happened in practice. - _as_can_reexec=no; export _as_can_reexec - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -# Determine whether it's possible to make 'echo' print without a newline. -# These variables are no longer used directly by Autoconf, but are AC_SUBSTed -# for compatibility with existing Makefiles. -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -# For backward compatibility with old third-party macros, we provide -# the shell variables $as_echo and $as_echo_n. New code should use -# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. -as_echo='printf %s\n' -as_echo_n='printf %s' - - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -test -n "$DJDIR" || exec 7<&0 &1 - -# Name of the host. -# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, -# so uname gets run too. -ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` - -# -# Initializations. -# -ac_default_prefix=/usr/local -ac_clean_files= -ac_config_libobj_dir=. -LIBOBJS= -cross_compiling=no -subdirs= -MFLAGS= -MAKEFLAGS= - -# Identity of this package. -PACKAGE_NAME='' -PACKAGE_TARNAME='' -PACKAGE_VERSION='' -PACKAGE_STRING='' -PACKAGE_BUGREPORT='' -PACKAGE_URL='' - -ac_unique_file="igraph" -ac_unique_file="src/rinterface.c" -# Factoring default headers for most tests. -ac_includes_default="\ -#include -#ifdef HAVE_STDIO_H -# include -#endif -#ifdef HAVE_STDLIB_H -# include -#endif -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_INTTYPES_H -# include -#endif -#ifdef HAVE_STDINT_H -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#ifdef HAVE_SYS_TYPES_H -# include -#endif -#ifdef HAVE_SYS_STAT_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif" - -ac_header_cxx_list= -ac_subst_vars='LTLIBOBJS -LIBOBJS -GLPK_LIBS -HAVE_GLPK -EGREP -GREP -CXXCPP -GMP_LIBS -INTERNAL_GMP -HAVE_GMP -XML2_CPPFLAGS -XML2_LIBS -HAVE_LIBXML -XML2CONFIG -ac_ct_FC -FCFLAGS -FC -ac_ct_CXX -CXXFLAGS -CXX -OBJEXT -EXEEXT -ac_ct_CC -CPPFLAGS -LDFLAGS -CFLAGS -CC -target_alias -host_alias -build_alias -LIBS -ECHO_T -ECHO_N -ECHO_C -DEFS -mandir -localedir -libdir -psdir -pdfdir -dvidir -htmldir -infodir -docdir -oldincludedir -includedir -runstatedir -localstatedir -sharedstatedir -sysconfdir -datadir -datarootdir -libexecdir -sbindir -bindir -program_transform_name -prefix -exec_prefix -PACKAGE_URL -PACKAGE_BUGREPORT -PACKAGE_STRING -PACKAGE_VERSION -PACKAGE_TARNAME -PACKAGE_NAME -PATH_SEPARATOR -SHELL' -ac_subst_files='' -ac_user_opts=' -enable_option_checking -enable_graphml -enable_glpk -' - ac_precious_vars='build_alias -host_alias -target_alias -CC -CFLAGS -LDFLAGS -LIBS -CPPFLAGS -CXX -CXXFLAGS -CCC -FC -FCFLAGS -CXXCPP' - - -# Initialize some variables set by options. -ac_init_help= -ac_init_version=false -ac_unrecognized_opts= -ac_unrecognized_sep= -# The variables have the same names as the options, with -# dashes changed to underlines. -cache_file=/dev/null -exec_prefix=NONE -no_create= -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -srcdir= -verbose= -x_includes=NONE -x_libraries=NONE - -# Installation directory options. -# These are left unexpanded so users can "make install exec_prefix=/foo" -# and all the variables that are supposed to be based on exec_prefix -# by default will actually change. -# Use braces instead of parens because sh, perl, etc. also accept them. -# (The list follows the same order as the GNU Coding Standards.) -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datarootdir='${prefix}/share' -datadir='${datarootdir}' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' -includedir='${prefix}/include' -oldincludedir='/usr/include' -docdir='${datarootdir}/doc/${PACKAGE}' -infodir='${datarootdir}/info' -htmldir='${docdir}' -dvidir='${docdir}' -pdfdir='${docdir}' -psdir='${docdir}' -libdir='${exec_prefix}/lib' -localedir='${datarootdir}/locale' -mandir='${datarootdir}/man' - -ac_prev= -ac_dashdash= -for ac_option -do - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval $ac_prev=\$ac_option - ac_prev= - continue - fi - - case $ac_option in - *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *=) ac_optarg= ;; - *) ac_optarg=yes ;; - esac - - case $ac_dashdash$ac_option in - --) - ac_dashdash=yes ;; - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir=$ac_optarg ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build_alias ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build_alias=$ac_optarg ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file=$ac_optarg ;; - - --config-cache | -C) - cache_file=config.cache ;; - - -datadir | --datadir | --datadi | --datad) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=*) - datadir=$ac_optarg ;; - - -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ - | --dataroo | --dataro | --datar) - ac_prev=datarootdir ;; - -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ - | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) - datarootdir=$ac_optarg ;; - - -disable-* | --disable-*) - ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: \`$ac_useropt'" - ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=no ;; - - -docdir | --docdir | --docdi | --doc | --do) - ac_prev=docdir ;; - -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) - docdir=$ac_optarg ;; - - -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) - ac_prev=dvidir ;; - -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) - dvidir=$ac_optarg ;; - - -enable-* | --enable-*) - ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid feature name: \`$ac_useropt'" - ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"enable_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval enable_$ac_useropt=\$ac_optarg ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix=$ac_optarg ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he | -h) - ac_init_help=long ;; - -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) - ac_init_help=recursive ;; - -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) - ac_init_help=short ;; - - -host | --host | --hos | --ho) - ac_prev=host_alias ;; - -host=* | --host=* | --hos=* | --ho=*) - host_alias=$ac_optarg ;; - - -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) - ac_prev=htmldir ;; - -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ - | --ht=*) - htmldir=$ac_optarg ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir=$ac_optarg ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir=$ac_optarg ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir=$ac_optarg ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir=$ac_optarg ;; - - -localedir | --localedir | --localedi | --localed | --locale) - ac_prev=localedir ;; - -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) - localedir=$ac_optarg ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst | --locals) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) - localstatedir=$ac_optarg ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir=$ac_optarg ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c | -n) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir=$ac_optarg ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix=$ac_optarg ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix=$ac_optarg ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix=$ac_optarg ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name=$ac_optarg ;; - - -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) - ac_prev=pdfdir ;; - -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) - pdfdir=$ac_optarg ;; - - -psdir | --psdir | --psdi | --psd | --ps) - ac_prev=psdir ;; - -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) - psdir=$ac_optarg ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir=$ac_optarg ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir=$ac_optarg ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site=$ac_optarg ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir=$ac_optarg ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir=$ac_optarg ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target_alias ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target_alias=$ac_optarg ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers | -V) - ac_init_version=: ;; - - -with-* | --with-*) - ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: \`$ac_useropt'" - ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=\$ac_optarg ;; - - -without-* | --without-*) - ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` - # Reject names that are not valid shell variable names. - expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error $? "invalid package name: \`$ac_useropt'" - ac_useropt_orig=$ac_useropt - ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'` - case $ac_user_opts in - *" -"with_$ac_useropt" -"*) ;; - *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" - ac_unrecognized_sep=', ';; - esac - eval with_$ac_useropt=no ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes=$ac_optarg ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries=$ac_optarg ;; - - -*) as_fn_error $? "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information" - ;; - - *=*) - ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` - # Reject names that are not valid shell variable names. - case $ac_envvar in #( - '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; - esac - eval $ac_envvar=\$ac_optarg - export $ac_envvar ;; - - *) - # FIXME: should be removed in autoconf 3.0. - printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2 - expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && - printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2 - : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" - ;; - - esac -done - -if test -n "$ac_prev"; then - ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error $? "missing argument to $ac_option" -fi - -if test -n "$ac_unrecognized_opts"; then - case $enable_option_checking in - no) ;; - fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; - *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; - esac -fi - -# Check all directory arguments for consistency. -for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ - datadir sysconfdir sharedstatedir localstatedir includedir \ - oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir -do - eval ac_val=\$$ac_var - # Remove trailing slashes. - case $ac_val in - */ ) - ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` - eval $ac_var=\$ac_val;; - esac - # Be sure to have absolute directory names. - case $ac_val in - [\\/$]* | ?:[\\/]* ) continue;; - NONE | '' ) case $ac_var in *prefix ) continue;; esac;; - esac - as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" -done - -# There might be people who depend on the old broken behavior: `$host' -# used to hold the argument of --host etc. -# FIXME: To remove some day. -build=$build_alias -host=$host_alias -target=$target_alias - -# FIXME: To remove some day. -if test "x$host_alias" != x; then - if test "x$build_alias" = x; then - cross_compiling=maybe - elif test "x$build_alias" != "x$host_alias"; then - cross_compiling=yes - fi -fi - -ac_tool_prefix= -test -n "$host_alias" && ac_tool_prefix=$host_alias- - -test "$silent" = yes && exec 6>/dev/null - - -ac_pwd=`pwd` && test -n "$ac_pwd" && -ac_ls_di=`ls -di .` && -ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error $? "working directory cannot be determined" -test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error $? "pwd does not report name of working directory" - - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then the parent directory. - ac_confdir=`$as_dirname -- "$as_myself" || -$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_myself" : 'X\(//\)[^/]' \| \ - X"$as_myself" : 'X\(//\)$' \| \ - X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$as_myself" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - srcdir=$ac_confdir - if test ! -r "$srcdir/$ac_unique_file"; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r "$srcdir/$ac_unique_file"; then - test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" -fi -ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" -ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" - pwd)` -# When building in place, set srcdir=. -if test "$ac_abs_confdir" = "$ac_pwd"; then - srcdir=. -fi -# Remove unnecessary trailing slashes from srcdir. -# Double slashes in file names in object file debugging info -# mess up M-x gdb in Emacs. -case $srcdir in -*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; -esac -for ac_var in $ac_precious_vars; do - eval ac_env_${ac_var}_set=\${${ac_var}+set} - eval ac_env_${ac_var}_value=\$${ac_var} - eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} - eval ac_cv_env_${ac_var}_value=\$${ac_var} -done - -# -# Report the --help message. -# -if test "$ac_init_help" = "long"; then - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat <<_ACEOF -\`configure' configures this package to adapt to many kinds of systems. - -Usage: $0 [OPTION]... [VAR=VALUE]... - -To assign environment variables (e.g., CC, CFLAGS...), specify them as -VAR=VALUE. See below for descriptions of some of the useful variables. - -Defaults for the options are specified in brackets. - -Configuration: - -h, --help display this help and exit - --help=short display options specific to this package - --help=recursive display the short help of all the included packages - -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking ...' messages - --cache-file=FILE cache test results in FILE [disabled] - -C, --config-cache alias for \`--cache-file=config.cache' - -n, --no-create do not create output files - --srcdir=DIR find the sources in DIR [configure dir or \`..'] - -Installation directories: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [PREFIX] - -By default, \`make install' will install all the files in -\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify -an installation prefix other than \`$ac_default_prefix' using \`--prefix', -for instance \`--prefix=\$HOME'. - -For better control, use the options below. - -Fine tuning of the installation directories: - --bindir=DIR user executables [EPREFIX/bin] - --sbindir=DIR system admin executables [EPREFIX/sbin] - --libexecdir=DIR program executables [EPREFIX/libexec] - --sysconfdir=DIR read-only single-machine data [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] - --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] - --libdir=DIR object code libraries [EPREFIX/lib] - --includedir=DIR C header files [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc [/usr/include] - --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] - --datadir=DIR read-only architecture-independent data [DATAROOTDIR] - --infodir=DIR info documentation [DATAROOTDIR/info] - --localedir=DIR locale-dependent data [DATAROOTDIR/locale] - --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] - --htmldir=DIR html documentation [DOCDIR] - --dvidir=DIR dvi documentation [DOCDIR] - --pdfdir=DIR pdf documentation [DOCDIR] - --psdir=DIR ps documentation [DOCDIR] -_ACEOF - - cat <<\_ACEOF -_ACEOF -fi - -if test -n "$ac_init_help"; then - - cat <<\_ACEOF - -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --disable-graphml Disable support for GraphML format - --disable-glpk Compile without the GLPK library - -Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags - LDFLAGS linker flags, e.g. -L if you have libraries in a - nonstandard directory - LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if - you have headers in a nonstandard directory - CXX C++ compiler command - CXXFLAGS C++ compiler flags - FC Fortran compiler command - FCFLAGS Fortran compiler flags - CXXCPP C++ preprocessor - -Use these variables to override the choices made by `configure' or to help -it to find libraries and programs with nonstandard names/locations. - -Report bugs to the package provider. -_ACEOF -ac_status=$? -fi - -if test "$ac_init_help" = "recursive"; then - # If there are subdirs, report their specific --help. - for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue - test -d "$ac_dir" || - { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || - continue - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - cd "$ac_dir" || { ac_status=$?; continue; } - # Check for configure.gnu first; this name is used for a wrapper for - # Metaconfig's "Configure" on case-insensitive file systems. - if test -f "$ac_srcdir/configure.gnu"; then - echo && - $SHELL "$ac_srcdir/configure.gnu" --help=recursive - elif test -f "$ac_srcdir/configure"; then - echo && - $SHELL "$ac_srcdir/configure" --help=recursive - else - printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi || ac_status=$? - cd "$ac_pwd" || { ac_status=$?; break; } - done -fi - -test -n "$ac_init_help" && exit $ac_status -if $ac_init_version; then - cat <<\_ACEOF -configure -generated by GNU Autoconf 2.71 - -Copyright (C) 2021 Free Software Foundation, Inc. -This configure script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it. -_ACEOF - exit -fi - -## ------------------------ ## -## Autoconf initialization. ## -## ------------------------ ## - -# ac_fn_c_try_compile LINENO -# -------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext -then : - ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_compile - -# ac_fn_cxx_try_compile LINENO -# ---------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext -then : - ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_compile - -# ac_fn_fc_try_compile LINENO -# --------------------------- -# Try to compile conftest.$ac_ext, and return whether this succeeded. -ac_fn_fc_try_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam - if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_fc_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext -then : - ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_fc_try_compile - -# ac_fn_cxx_try_link LINENO -# ------------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - } -then : - ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_link - -# ac_fn_cxx_check_func LINENO FUNC VAR -# ------------------------------------ -# Tests whether FUNC exists, setting the cache variable VAR accordingly -ac_fn_cxx_check_func () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -printf %s "checking for $2... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Define $2 to an innocuous variant, in case declares $2. - For example, HP-UX 11i declares gettimeofday. */ -#define $2 innocuous_$2 - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $2 (); below. */ - -#include -#undef $2 - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $2 (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$2 || defined __stub___$2 -choke me -#endif - -int -main (void) -{ -return $2 (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO" -then : - eval "$3=yes" -else $as_nop - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -fi -eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_cxx_check_func - -# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES -# --------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_cxx_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -printf %s "checking for $2... " >&6; } -if eval test \${$3+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : - eval "$3=yes" -else $as_nop - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -eval ac_res=\$$3 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_cxx_check_header_compile - -# ac_fn_cxx_check_member LINENO AGGR MEMBER VAR INCLUDES -# ------------------------------------------------------ -# Tries to find if the field MEMBER exists in type AGGR, after including -# INCLUDES, setting cache variable VAR accordingly. -ac_fn_cxx_check_member () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 -printf %s "checking for $2.$3... " >&6; } -if eval test \${$4+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main (void) -{ -static $2 ac_aggr; -if (ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : - eval "$4=yes" -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$5 -int -main (void) -{ -static $2 ac_aggr; -if (sizeof ac_aggr.$3) -return 0; - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : - eval "$4=yes" -else $as_nop - eval "$4=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -eval ac_res=\$$4 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -printf "%s\n" "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_cxx_check_member - -# ac_fn_cxx_try_cpp LINENO -# ------------------------ -# Try to preprocess conftest.$ac_ext, and return whether this succeeded. -ac_fn_cxx_try_cpp () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } > conftest.i && { - test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || - test ! -s conftest.err - } -then : - ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_cxx_try_cpp -ac_configure_args_raw= -for ac_arg -do - case $ac_arg in - *\'*) - ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append ac_configure_args_raw " '$ac_arg'" -done - -case $ac_configure_args_raw in - *$as_nl*) - ac_safe_unquote= ;; - *) - ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab. - ac_unsafe_a="$ac_unsafe_z#~" - ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g" - ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;; -esac - -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by $as_me, which was -generated by GNU Autoconf 2.71. Invocation command line was - - $ $0$ac_configure_args_raw - -_ACEOF -exec 5>>config.log -{ -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` - -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` - -_ASUNAME - -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - printf "%s\n" "PATH: $as_dir" - done -IFS=$as_save_IFS - -} >&5 - -cat >&5 <<_ACEOF - - -## ----------- ## -## Core tests. ## -## ----------- ## - -_ACEOF - - -# Keep a trace of the command line. -# Strip out --no-create and --no-recursion so they do not pile up. -# Strip out --silent because we don't want to record it for future runs. -# Also quote any args containing shell meta-characters. -# Make two passes to allow for proper duplicate-argument suppression. -ac_configure_args= -ac_configure_args0= -ac_configure_args1= -ac_must_keep_next=false -for ac_pass in 1 2 -do - for ac_arg - do - case $ac_arg in - -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - continue ;; - *\'*) - ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - case $ac_pass in - 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; - 2) - as_fn_append ac_configure_args1 " '$ac_arg'" - if test $ac_must_keep_next = true; then - ac_must_keep_next=false # Got value, back to normal. - else - case $ac_arg in - *=* | --config-cache | -C | -disable-* | --disable-* \ - | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ - | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ - | -with-* | --with-* | -without-* | --without-* | --x) - case "$ac_configure_args0 " in - "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; - esac - ;; - -* ) ac_must_keep_next=true ;; - esac - fi - as_fn_append ac_configure_args " '$ac_arg'" - ;; - esac - done -done -{ ac_configure_args0=; unset ac_configure_args0;} -{ ac_configure_args1=; unset ac_configure_args1;} - -# When interrupted or exit'd, cleanup temporary files, and complete -# config.log. We remove comments because anyway the quotes in there -# would cause problems or look ugly. -# WARNING: Use '\'' to represent an apostrophe within the trap. -# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. -trap 'exit_status=$? - # Sanitize IFS. - IFS=" "" $as_nl" - # Save into config.log some information that might help in debugging. - { - echo - - printf "%s\n" "## ---------------- ## -## Cache variables. ## -## ---------------- ##" - echo - # The following way of writing the cache mishandles newlines in values, -( - for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - (set) 2>&1 | - case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - sed -n \ - "s/'\''/'\''\\\\'\'''\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" - ;; #( - *) - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) - echo - - printf "%s\n" "## ----------------- ## -## Output variables. ## -## ----------------- ##" - echo - for ac_var in $ac_subst_vars - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - printf "%s\n" "$ac_var='\''$ac_val'\''" - done | sort - echo - - if test -n "$ac_subst_files"; then - printf "%s\n" "## ------------------- ## -## File substitutions. ## -## ------------------- ##" - echo - for ac_var in $ac_subst_files - do - eval ac_val=\$$ac_var - case $ac_val in - *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; - esac - printf "%s\n" "$ac_var='\''$ac_val'\''" - done | sort - echo - fi - - if test -s confdefs.h; then - printf "%s\n" "## ----------- ## -## confdefs.h. ## -## ----------- ##" - echo - cat confdefs.h - echo - fi - test "$ac_signal" != 0 && - printf "%s\n" "$as_me: caught signal $ac_signal" - printf "%s\n" "$as_me: exit $exit_status" - } >&5 - rm -f core *.core core.conftest.* && - rm -f -r conftest* confdefs* conf$$* $ac_clean_files && - exit $exit_status -' 0 -for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal -done -ac_signal=0 - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -f -r conftest* confdefs.h - -printf "%s\n" "/* confdefs.h */" > confdefs.h - -# Predefined preprocessor variables. - -printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h - -printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h - -printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h - -printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h - -printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h - -printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h - - -# Let the site file select an alternate cache file if it wants to. -# Prefer an explicitly selected file to automatically selected ones. -if test -n "$CONFIG_SITE"; then - ac_site_files="$CONFIG_SITE" -elif test "x$prefix" != xNONE; then - ac_site_files="$prefix/share/config.site $prefix/etc/config.site" -else - ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" -fi - -for ac_site_file in $ac_site_files -do - case $ac_site_file in #( - */*) : - ;; #( - *) : - ac_site_file=./$ac_site_file ;; -esac - if test -f "$ac_site_file" && test -r "$ac_site_file"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 -printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;} - sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" \ - || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "failed to load site script $ac_site_file -See \`config.log' for more details" "$LINENO" 5; } - fi -done - -if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special files - # actually), so we avoid doing that. DJGPP emulates it as a regular file. - if test /dev/null != "$cache_file" && test -f "$cache_file"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 -printf "%s\n" "$as_me: loading cache $cache_file" >&6;} - case $cache_file in - [\\/]* | ?:[\\/]* ) . "$cache_file";; - *) . "./$cache_file";; - esac - fi -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 -printf "%s\n" "$as_me: creating cache $cache_file" >&6;} - >$cache_file -fi - -# Test code for whether the C compiler supports C89 (global declarations) -ac_c_conftest_c89_globals=' -/* Does the compiler advertise C89 conformance? - Do not test the value of __STDC__, because some compilers set it to 0 - while being otherwise adequately conformant. */ -#if !defined __STDC__ -# error "Compiler does not advertise C89 conformance" -#endif - -#include -#include -struct stat; -/* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */ -struct buf { int x; }; -struct buf * (*rcsopen) (struct buf *, struct stat *, int); -static char *e (p, i) - char **p; - int i; -{ - return p[i]; -} -static char *f (char * (*g) (char **, int), char **p, ...) -{ - char *s; - va_list v; - va_start (v,p); - s = g (p, va_arg (v,int)); - va_end (v); - return s; -} - -/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has - function prototypes and stuff, but not \xHH hex character constants. - These do not provoke an error unfortunately, instead are silently treated - as an "x". The following induces an error, until -std is added to get - proper ANSI mode. Curiously \x00 != x always comes out true, for an - array size at least. It is necessary to write \x00 == 0 to get something - that is true only with -std. */ -int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1]; - -/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters - inside strings and character constants. */ -#define FOO(x) '\''x'\'' -int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1]; - -int test (int i, double x); -struct s1 {int (*f) (int a);}; -struct s2 {int (*f) (double a);}; -int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int), - int, int);' - -# Test code for whether the C compiler supports C89 (body of main). -ac_c_conftest_c89_main=' -ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]); -' - -# Test code for whether the C compiler supports C99 (global declarations) -ac_c_conftest_c99_globals=' -// Does the compiler advertise C99 conformance? -#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L -# error "Compiler does not advertise C99 conformance" -#endif - -#include -extern int puts (const char *); -extern int printf (const char *, ...); -extern int dprintf (int, const char *, ...); -extern void *malloc (size_t); - -// Check varargs macros. These examples are taken from C99 6.10.3.5. -// dprintf is used instead of fprintf to avoid needing to declare -// FILE and stderr. -#define debug(...) dprintf (2, __VA_ARGS__) -#define showlist(...) puts (#__VA_ARGS__) -#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) -static void -test_varargs_macros (void) -{ - int x = 1234; - int y = 5678; - debug ("Flag"); - debug ("X = %d\n", x); - showlist (The first, second, and third items.); - report (x>y, "x is %d but y is %d", x, y); -} - -// Check long long types. -#define BIG64 18446744073709551615ull -#define BIG32 4294967295ul -#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) -#if !BIG_OK - #error "your preprocessor is broken" -#endif -#if BIG_OK -#else - #error "your preprocessor is broken" -#endif -static long long int bignum = -9223372036854775807LL; -static unsigned long long int ubignum = BIG64; - -struct incomplete_array -{ - int datasize; - double data[]; -}; - -struct named_init { - int number; - const wchar_t *name; - double average; -}; - -typedef const char *ccp; - -static inline int -test_restrict (ccp restrict text) -{ - // See if C++-style comments work. - // Iterate through items via the restricted pointer. - // Also check for declarations in for loops. - for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i) - continue; - return 0; -} - -// Check varargs and va_copy. -static bool -test_varargs (const char *format, ...) -{ - va_list args; - va_start (args, format); - va_list args_copy; - va_copy (args_copy, args); - - const char *str = ""; - int number = 0; - float fnumber = 0; - - while (*format) - { - switch (*format++) - { - case '\''s'\'': // string - str = va_arg (args_copy, const char *); - break; - case '\''d'\'': // int - number = va_arg (args_copy, int); - break; - case '\''f'\'': // float - fnumber = va_arg (args_copy, double); - break; - default: - break; - } - } - va_end (args_copy); - va_end (args); - - return *str && number && fnumber; -} -' - -# Test code for whether the C compiler supports C99 (body of main). -ac_c_conftest_c99_main=' - // Check bool. - _Bool success = false; - success |= (argc != 0); - - // Check restrict. - if (test_restrict ("String literal") == 0) - success = true; - char *restrict newvar = "Another string"; - - // Check varargs. - success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234); - test_varargs_macros (); - - // Check flexible array members. - struct incomplete_array *ia = - malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); - ia->datasize = 10; - for (int i = 0; i < ia->datasize; ++i) - ia->data[i] = i * 1.234; - - // Check named initializers. - struct named_init ni = { - .number = 34, - .name = L"Test wide string", - .average = 543.34343, - }; - - ni.number = 58; - - int dynamic_array[ni.number]; - dynamic_array[0] = argv[0][0]; - dynamic_array[ni.number - 1] = 543; - - // work around unused variable warnings - ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\'' - || dynamic_array[ni.number - 1] != 543); -' - -# Test code for whether the C compiler supports C11 (global declarations) -ac_c_conftest_c11_globals=' -// Does the compiler advertise C11 conformance? -#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L -# error "Compiler does not advertise C11 conformance" -#endif - -// Check _Alignas. -char _Alignas (double) aligned_as_double; -char _Alignas (0) no_special_alignment; -extern char aligned_as_int; -char _Alignas (0) _Alignas (int) aligned_as_int; - -// Check _Alignof. -enum -{ - int_alignment = _Alignof (int), - int_array_alignment = _Alignof (int[100]), - char_alignment = _Alignof (char) -}; -_Static_assert (0 < -_Alignof (int), "_Alignof is signed"); - -// Check _Noreturn. -int _Noreturn does_not_return (void) { for (;;) continue; } - -// Check _Static_assert. -struct test_static_assert -{ - int x; - _Static_assert (sizeof (int) <= sizeof (long int), - "_Static_assert does not work in struct"); - long int y; -}; - -// Check UTF-8 literals. -#define u8 syntax error! -char const utf8_literal[] = u8"happens to be ASCII" "another string"; - -// Check duplicate typedefs. -typedef long *long_ptr; -typedef long int *long_ptr; -typedef long_ptr long_ptr; - -// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1. -struct anonymous -{ - union { - struct { int i; int j; }; - struct { int k; long int l; } w; - }; - int m; -} v1; -' - -# Test code for whether the C compiler supports C11 (body of main). -ac_c_conftest_c11_main=' - _Static_assert ((offsetof (struct anonymous, i) - == offsetof (struct anonymous, w.k)), - "Anonymous union alignment botch"); - v1.i = 2; - v1.w.k = 5; - ok |= v1.i != 5; -' - -# Test code for whether the C compiler supports C11 (complete). -ac_c_conftest_c11_program="${ac_c_conftest_c89_globals} -${ac_c_conftest_c99_globals} -${ac_c_conftest_c11_globals} - -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_c_conftest_c89_main} - ${ac_c_conftest_c99_main} - ${ac_c_conftest_c11_main} - return ok; -} -" - -# Test code for whether the C compiler supports C99 (complete). -ac_c_conftest_c99_program="${ac_c_conftest_c89_globals} -${ac_c_conftest_c99_globals} - -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_c_conftest_c89_main} - ${ac_c_conftest_c99_main} - return ok; -} -" - -# Test code for whether the C compiler supports C89 (complete). -ac_c_conftest_c89_program="${ac_c_conftest_c89_globals} - -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_c_conftest_c89_main} - return ok; -} -" - -# Test code for whether the C++ compiler supports C++98 (global declarations) -ac_cxx_conftest_cxx98_globals=' -// Does the compiler advertise C++98 conformance? -#if !defined __cplusplus || __cplusplus < 199711L -# error "Compiler does not advertise C++98 conformance" -#endif - -// These inclusions are to reject old compilers that -// lack the unsuffixed header files. -#include -#include - -// and are *not* freestanding headers in C++98. -extern void assert (int); -namespace std { - extern int strcmp (const char *, const char *); -} - -// Namespaces, exceptions, and templates were all added after "C++ 2.0". -using std::exception; -using std::strcmp; - -namespace { - -void test_exception_syntax() -{ - try { - throw "test"; - } catch (const char *s) { - // Extra parentheses suppress a warning when building autoconf itself, - // due to lint rules shared with more typical C programs. - assert (!(strcmp) (s, "test")); - } -} - -template struct test_template -{ - T const val; - explicit test_template(T t) : val(t) {} - template T add(U u) { return static_cast(u) + val; } -}; - -} // anonymous namespace -' - -# Test code for whether the C++ compiler supports C++98 (body of main) -ac_cxx_conftest_cxx98_main=' - assert (argc); - assert (! argv[0]); -{ - test_exception_syntax (); - test_template tt (2.0); - assert (tt.add (4) == 6.0); - assert (true && !false); -} -' - -# Test code for whether the C++ compiler supports C++11 (global declarations) -ac_cxx_conftest_cxx11_globals=' -// Does the compiler advertise C++ 2011 conformance? -#if !defined __cplusplus || __cplusplus < 201103L -# error "Compiler does not advertise C++11 conformance" -#endif - -namespace cxx11test -{ - constexpr int get_val() { return 20; } - - struct testinit - { - int i; - double d; - }; - - class delegate - { - public: - delegate(int n) : n(n) {} - delegate(): delegate(2354) {} - - virtual int getval() { return this->n; }; - protected: - int n; - }; - - class overridden : public delegate - { - public: - overridden(int n): delegate(n) {} - virtual int getval() override final { return this->n * 2; } - }; - - class nocopy - { - public: - nocopy(int i): i(i) {} - nocopy() = default; - nocopy(const nocopy&) = delete; - nocopy & operator=(const nocopy&) = delete; - private: - int i; - }; - - // for testing lambda expressions - template Ret eval(Fn f, Ret v) - { - return f(v); - } - - // for testing variadic templates and trailing return types - template auto sum(V first) -> V - { - return first; - } - template auto sum(V first, Args... rest) -> V - { - return first + sum(rest...); - } -} -' - -# Test code for whether the C++ compiler supports C++11 (body of main) -ac_cxx_conftest_cxx11_main=' -{ - // Test auto and decltype - auto a1 = 6538; - auto a2 = 48573953.4; - auto a3 = "String literal"; - - int total = 0; - for (auto i = a3; *i; ++i) { total += *i; } - - decltype(a2) a4 = 34895.034; -} -{ - // Test constexpr - short sa[cxx11test::get_val()] = { 0 }; -} -{ - // Test initializer lists - cxx11test::testinit il = { 4323, 435234.23544 }; -} -{ - // Test range-based for - int array[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3, - 14, 19, 17, 8, 6, 20, 16, 2, 11, 1}; - for (auto &x : array) { x += 23; } -} -{ - // Test lambda expressions - using cxx11test::eval; - assert (eval ([](int x) { return x*2; }, 21) == 42); - double d = 2.0; - assert (eval ([&](double x) { return d += x; }, 3.0) == 5.0); - assert (d == 5.0); - assert (eval ([=](double x) mutable { return d += x; }, 4.0) == 9.0); - assert (d == 5.0); -} -{ - // Test use of variadic templates - using cxx11test::sum; - auto a = sum(1); - auto b = sum(1, 2); - auto c = sum(1.0, 2.0, 3.0); -} -{ - // Test constructor delegation - cxx11test::delegate d1; - cxx11test::delegate d2(); - cxx11test::delegate d3(45); -} -{ - // Test override and final - cxx11test::overridden o1(55464); -} -{ - // Test nullptr - char *c = nullptr; -} -{ - // Test template brackets - test_template<::test_template> v(test_template(12)); -} -{ - // Unicode literals - char const *utf8 = u8"UTF-8 string \u2500"; - char16_t const *utf16 = u"UTF-8 string \u2500"; - char32_t const *utf32 = U"UTF-32 string \u2500"; -} -' - -# Test code for whether the C compiler supports C++11 (complete). -ac_cxx_conftest_cxx11_program="${ac_cxx_conftest_cxx98_globals} -${ac_cxx_conftest_cxx11_globals} - -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_cxx_conftest_cxx98_main} - ${ac_cxx_conftest_cxx11_main} - return ok; -} -" - -# Test code for whether the C compiler supports C++98 (complete). -ac_cxx_conftest_cxx98_program="${ac_cxx_conftest_cxx98_globals} -int -main (int argc, char **argv) -{ - int ok = 0; - ${ac_cxx_conftest_cxx98_main} - return ok; -} -" - -as_fn_append ac_header_cxx_list " stdio.h stdio_h HAVE_STDIO_H" -as_fn_append ac_header_cxx_list " stdlib.h stdlib_h HAVE_STDLIB_H" -as_fn_append ac_header_cxx_list " string.h string_h HAVE_STRING_H" -as_fn_append ac_header_cxx_list " inttypes.h inttypes_h HAVE_INTTYPES_H" -as_fn_append ac_header_cxx_list " stdint.h stdint_h HAVE_STDINT_H" -as_fn_append ac_header_cxx_list " strings.h strings_h HAVE_STRINGS_H" -as_fn_append ac_header_cxx_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H" -as_fn_append ac_header_cxx_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H" -as_fn_append ac_header_cxx_list " unistd.h unistd_h HAVE_UNISTD_H" -# Check that the precious variables saved in the cache have kept the same -# value. -ac_cache_corrupted=false -for ac_var in $ac_precious_vars; do - eval ac_old_set=\$ac_cv_env_${ac_var}_set - eval ac_new_set=\$ac_env_${ac_var}_set - eval ac_old_val=\$ac_cv_env_${ac_var}_value - eval ac_new_val=\$ac_env_${ac_var}_value - case $ac_old_set,$ac_new_set in - set,) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,set) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} - ac_cache_corrupted=: ;; - ,);; - *) - if test "x$ac_old_val" != "x$ac_new_val"; then - # differences in whitespace do not lead to failure. - ac_old_val_w=`echo x $ac_old_val` - ac_new_val_w=`echo x $ac_new_val` - if test "$ac_old_val_w" != "$ac_new_val_w"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 -printf "%s\n" "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} - ac_cache_corrupted=: - else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 -printf "%s\n" "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} - eval $ac_var=\$ac_old_val - fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 -printf "%s\n" "$as_me: former value: \`$ac_old_val'" >&2;} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 -printf "%s\n" "$as_me: current value: \`$ac_new_val'" >&2;} - fi;; - esac - # Pass precious variables to config.status. - if test "$ac_new_set" = set; then - case $ac_new_val in - *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; - *) ac_arg=$ac_var=$ac_new_val ;; - esac - case " $ac_configure_args " in - *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) as_fn_append ac_configure_args " '$ac_arg'" ;; - esac - fi -done -if $ac_cache_corrupted; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 -printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error $? "run \`${MAKE-make} distclean' and/or \`rm $cache_file' - and start over" "$LINENO" 5 -fi -## -------------------- ## -## Main body of script. ## -## -------------------- ## - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - -ac_config_headers="$ac_config_headers src/config.h" - - -: ${R_HOME=`R RHOME`} -if test -z "${R_HOME}"; then - echo "could not determine R_HOME" - exit 1 -fi -CC=`"${R_HOME}/bin/R" CMD config CC` -CXX=`"${R_HOME}/bin/R" CMD config CXX11` -if test -z "$CXX"; then - as_fn_error $? "No C++11 compiler is available" "$LINENO" 5 -fi -CXX11STD=`"${R_HOME}/bin/R" CMD config CXX11STD` -CXX="${CXX} ${CXX11STD}" -FC=`"${R_HOME}/bin/R" CMD config FC` -CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS` -CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXX11FLAGS` -CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS` -FCFLAGS=`"${R_HOME}/bin/R" CMD config FCFLAGS` -FLIBS=`"${R_HOME}/bin/R" CMD config FLIBS` -LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS` - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - - - - - - - - - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="gcc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - - test -n "$CC" && break - done -fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - - test -n "$ac_ct_CC" && break -done - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -fi - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args. -set dummy ${ac_tool_prefix}clang; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_CC="${ac_tool_prefix}clang" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 -printf "%s\n" "$CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "clang", so it can be a program name with args. -set dummy clang; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CC="clang" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 -printf "%s\n" "$ac_ct_CC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -fi - - -test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "no acceptable C compiler found in \$PATH -See \`config.log' for more details" "$LINENO" 5; } - -# Provide some information about the compiler. -printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion -version; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" -# Try to create an executable without -o first, disregard a.out. -# It will help us diagnose broken compilers, and finding out an intuition -# of exeext. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -printf %s "checking whether the C compiler works... " >&6; } -ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'` - -# The possible output files: -ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" - -ac_rmfiles= -for ac_file in $ac_files -do - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - * ) ac_rmfiles="$ac_rmfiles $ac_file";; - esac -done -rm -f $ac_rmfiles - -if { { ac_try="$ac_link_default" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_link_default") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -then : - # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. -# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' -# in a Makefile. We should not override ac_cv_exeext if it was cached, -# so that the user can short-circuit this test for compilers unknown to -# Autoconf. -for ac_file in $ac_files '' -do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) - ;; - [ab].out ) - # We found the default executable, but exeext='' is most - # certainly right. - break;; - *.* ) - if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no; - then :; else - ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - fi - # We set ac_cv_exeext here because the later test for it is not - # safe: cross compilers may not add the suffix if given an `-o' - # argument, so we may need to know it at that point already. - # Even if this section looks crufty: it has the advantage of - # actually working. - break;; - * ) - break;; - esac -done -test "$ac_cv_exeext" = no && ac_cv_exeext= - -else $as_nop - ac_file='' -fi -if test -z "$ac_file" -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "C compiler cannot create executables -See \`config.log' for more details" "$LINENO" 5; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; } -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -printf %s "checking for C compiler default output file name... " >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -printf "%s\n" "$ac_file" >&6; } -ac_exeext=$ac_cv_exeext - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out -ac_clean_files=$ac_clean_files_save -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 -printf %s "checking for suffix of executables... " >&6; } -if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -then : - # If both `conftest.exe' and `conftest' are `present' (well, observable) -# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will -# work properly (i.e., refer to `conftest.exe'), while it won't with -# `rm'. -for ac_file in conftest.exe conftest conftest.*; do - test -f "$ac_file" || continue - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; - *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` - break;; - * ) break;; - esac -done -else $as_nop - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest conftest$ac_cv_exeext -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 -printf "%s\n" "$ac_cv_exeext" >&6; } - -rm -f conftest.$ac_ext -EXEEXT=$ac_cv_exeext -ac_exeext=$EXEEXT -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; - - ; - return 0; -} -_ACEOF -ac_clean_files="$ac_clean_files conftest.out" -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -printf %s "checking whether we are cross compiling... " >&6; } -if test "$cross_compiling" != yes; then - { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } - if { ac_try='./conftest$ac_cv_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error 77 "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details" "$LINENO" 5; } - fi - fi -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -printf "%s\n" "$cross_compiling" >&6; } - -rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out -ac_clean_files=$ac_clean_files_save -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 -printf %s "checking for suffix of object files... " >&6; } -if test ${ac_cv_objext+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -rm -f conftest.o conftest.obj -if { { ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_compile") 2>&5 - ac_status=$? - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -then : - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot compute suffix of object files: cannot compile -See \`config.log' for more details" "$LINENO" 5; } -fi -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 -printf "%s\n" "$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5 -printf %s "checking whether the compiler supports GNU C... " >&6; } -if test ${ac_cv_c_compiler_gnu+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_compiler_gnu=yes -else $as_nop - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -ac_cv_c_compiler_gnu=$ac_compiler_gnu - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 -printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; } -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -if test $ac_compiler_gnu = yes; then - GCC=yes -else - GCC= -fi -ac_test_CFLAGS=${CFLAGS+y} -ac_save_CFLAGS=$CFLAGS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 -printf %s "checking whether $CC accepts -g... " >&6; } -if test ${ac_cv_prog_cc_g+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_save_c_werror_flag=$ac_c_werror_flag - ac_c_werror_flag=yes - ac_cv_prog_cc_g=no - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_g=yes -else $as_nop - CFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - -else $as_nop - ac_c_werror_flag=$ac_save_c_werror_flag - CFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ac_c_werror_flag=$ac_save_c_werror_flag -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 -printf "%s\n" "$ac_cv_prog_cc_g" >&6; } -if test $ac_test_CFLAGS; then - CFLAGS=$ac_save_CFLAGS -elif test $ac_cv_prog_cc_g = yes; then - if test "$GCC" = yes; then - CFLAGS="-g -O2" - else - CFLAGS="-g" - fi -else - if test "$GCC" = yes; then - CFLAGS="-O2" - else - CFLAGS= - fi -fi -ac_prog_cc_stdc=no -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5 -printf %s "checking for $CC option to enable C11 features... " >&6; } -if test ${ac_cv_prog_cc_c11+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c11=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_c_conftest_c11_program -_ACEOF -for ac_arg in '' -std=gnu11 -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_c11=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cc_c11" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -fi - -if test "x$ac_cv_prog_cc_c11" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c11" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5 -printf "%s\n" "$ac_cv_prog_cc_c11" >&6; } - CC="$CC $ac_cv_prog_cc_c11" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11 - ac_prog_cc_stdc=c11 -fi -fi -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5 -printf %s "checking for $CC option to enable C99 features... " >&6; } -if test ${ac_cv_prog_cc_c99+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c99=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_c_conftest_c99_program -_ACEOF -for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99= -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_c99=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cc_c99" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -fi - -if test "x$ac_cv_prog_cc_c99" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c99" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 -printf "%s\n" "$ac_cv_prog_cc_c99" >&6; } - CC="$CC $ac_cv_prog_cc_c99" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 - ac_prog_cc_stdc=c99 -fi -fi -if test x$ac_prog_cc_stdc = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5 -printf %s "checking for $CC option to enable C89 features... " >&6; } -if test ${ac_cv_prog_cc_c89+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cc_c89=no -ac_save_CC=$CC -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_c_conftest_c89_program -_ACEOF -for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" -do - CC="$ac_save_CC $ac_arg" - if ac_fn_c_try_compile "$LINENO" -then : - ac_cv_prog_cc_c89=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cc_c89" != "xno" && break -done -rm -f conftest.$ac_ext -CC=$ac_save_CC -fi - -if test "x$ac_cv_prog_cc_c89" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cc_c89" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 -printf "%s\n" "$ac_cv_prog_cc_c89" >&6; } - CC="$CC $ac_cv_prog_cc_c89" -fi - ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 - ac_prog_cc_stdc=c89 -fi -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - - - - - - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -if test -z "$CXX"; then - if test -n "$CCC"; then - CXX=$CCC - else - if test -n "$ac_tool_prefix"; then - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$CXX"; then - ac_cv_prog_CXX="$CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -CXX=$ac_cv_prog_CXX -if test -n "$CXX"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 -printf "%s\n" "$CXX" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - - test -n "$CXX" && break - done -fi -if test -z "$CXX"; then - ac_ct_CXX=$CXX - for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++ -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_CXX+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_CXX"; then - ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_CXX="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_CXX=$ac_cv_prog_ac_ct_CXX -if test -n "$ac_ct_CXX"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 -printf "%s\n" "$ac_ct_CXX" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - - test -n "$ac_ct_CXX" && break -done - - if test "x$ac_ct_CXX" = x; then - CXX="g++" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - CXX=$ac_ct_CXX - fi -fi - - fi -fi -# Provide some information about the compiler. -printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C++" >&5 -printf %s "checking whether the compiler supports GNU C++... " >&6; } -if test ${ac_cv_cxx_compiler_gnu+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ -#ifndef __GNUC__ - choke me -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : - ac_compiler_gnu=yes -else $as_nop - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -ac_cv_cxx_compiler_gnu=$ac_compiler_gnu - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 -printf "%s\n" "$ac_cv_cxx_compiler_gnu" >&6; } -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -if test $ac_compiler_gnu = yes; then - GXX=yes -else - GXX= -fi -ac_test_CXXFLAGS=${CXXFLAGS+y} -ac_save_CXXFLAGS=$CXXFLAGS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 -printf %s "checking whether $CXX accepts -g... " >&6; } -if test ${ac_cv_prog_cxx_g+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_save_cxx_werror_flag=$ac_cxx_werror_flag - ac_cxx_werror_flag=yes - ac_cv_prog_cxx_g=no - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : - ac_cv_prog_cxx_g=yes -else $as_nop - CXXFLAGS="" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : - -else $as_nop - ac_cxx_werror_flag=$ac_save_cxx_werror_flag - CXXFLAGS="-g" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO" -then : - ac_cv_prog_cxx_g=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - ac_cxx_werror_flag=$ac_save_cxx_werror_flag -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 -printf "%s\n" "$ac_cv_prog_cxx_g" >&6; } -if test $ac_test_CXXFLAGS; then - CXXFLAGS=$ac_save_CXXFLAGS -elif test $ac_cv_prog_cxx_g = yes; then - if test "$GXX" = yes; then - CXXFLAGS="-g -O2" - else - CXXFLAGS="-g" - fi -else - if test "$GXX" = yes; then - CXXFLAGS="-O2" - else - CXXFLAGS= - fi -fi -ac_prog_cxx_stdcxx=no -if test x$ac_prog_cxx_stdcxx = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5 -printf %s "checking for $CXX option to enable C++11 features... " >&6; } -if test ${ac_cv_prog_cxx_11+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cxx_11=no -ac_save_CXX=$CXX -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_cxx_conftest_cxx11_program -_ACEOF -for ac_arg in '' -std=gnu++11 -std=gnu++0x -std=c++11 -std=c++0x -qlanglvl=extended0x -AA -do - CXX="$ac_save_CXX $ac_arg" - if ac_fn_cxx_try_compile "$LINENO" -then : - ac_cv_prog_cxx_cxx11=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cxx_cxx11" != "xno" && break -done -rm -f conftest.$ac_ext -CXX=$ac_save_CXX -fi - -if test "x$ac_cv_prog_cxx_cxx11" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cxx_cxx11" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx11" >&5 -printf "%s\n" "$ac_cv_prog_cxx_cxx11" >&6; } - CXX="$CXX $ac_cv_prog_cxx_cxx11" -fi - ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11 - ac_prog_cxx_stdcxx=cxx11 -fi -fi -if test x$ac_prog_cxx_stdcxx = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5 -printf %s "checking for $CXX option to enable C++98 features... " >&6; } -if test ${ac_cv_prog_cxx_98+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_cv_prog_cxx_98=no -ac_save_CXX=$CXX -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_cxx_conftest_cxx98_program -_ACEOF -for ac_arg in '' -std=gnu++98 -std=c++98 -qlanglvl=extended -AA -do - CXX="$ac_save_CXX $ac_arg" - if ac_fn_cxx_try_compile "$LINENO" -then : - ac_cv_prog_cxx_cxx98=$ac_arg -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam - test "x$ac_cv_prog_cxx_cxx98" != "xno" && break -done -rm -f conftest.$ac_ext -CXX=$ac_save_CXX -fi - -if test "x$ac_cv_prog_cxx_cxx98" = xno -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 -printf "%s\n" "unsupported" >&6; } -else $as_nop - if test "x$ac_cv_prog_cxx_cxx98" = x -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 -printf "%s\n" "none needed" >&6; } -else $as_nop - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_cxx98" >&5 -printf "%s\n" "$ac_cv_prog_cxx_cxx98" >&6; } - CXX="$CXX $ac_cv_prog_cxx_cxx98" -fi - ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98 - ac_prog_cxx_stdcxx=cxx98 -fi -fi - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -# Fortran compiler, we need to check if it is the GNU compiler -ac_ext=${ac_fc_srcext-f} -ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5' -ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_fc_compiler_gnu -if test -n "$ac_tool_prefix"; then - for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 - do - # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. -set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_FC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$FC"; then - ac_cv_prog_FC="$FC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_FC="$ac_tool_prefix$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -FC=$ac_cv_prog_FC -if test -n "$FC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $FC" >&5 -printf "%s\n" "$FC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - - test -n "$FC" && break - done -fi -if test -z "$FC"; then - ac_ct_FC=$FC - for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn nagfor xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_prog_ac_ct_FC+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -n "$ac_ct_FC"; then - ac_cv_prog_ac_ct_FC="$ac_ct_FC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_FC="$ac_prog" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_FC=$ac_cv_prog_ac_ct_FC -if test -n "$ac_ct_FC"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FC" >&5 -printf "%s\n" "$ac_ct_FC" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - - test -n "$ac_ct_FC" && break -done - - if test "x$ac_ct_FC" = x; then - FC="" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - FC=$ac_ct_FC - fi -fi - - -# Provide some information about the compiler. -printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Fortran compiler version" >&5 -set X $ac_compile -ac_compiler=$2 -for ac_option in --version -v -V -qversion; do - { { ac_try="$ac_compiler $ac_option >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_compiler $ac_option >&5") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - sed '10a\ -... rest of stderr output deleted ... - 10q' conftest.err >conftest.er1 - cat conftest.er1 >&5 - fi - rm -f conftest.er1 conftest.err - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } -done -rm -f a.out - -# If we don't use `.F' as extension, the preprocessor is not run on the -# input file. (Note that this only needs to work for GNU compilers.) -ac_save_ext=$ac_ext -ac_ext=F -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU Fortran" >&5 -printf %s "checking whether the compiler supports GNU Fortran... " >&6; } -if test ${ac_cv_fc_compiler_gnu+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat > conftest.$ac_ext <<_ACEOF - program main -#ifndef __GNUC__ - choke me -#endif - - end -_ACEOF -if ac_fn_fc_try_compile "$LINENO" -then : - ac_compiler_gnu=yes -else $as_nop - ac_compiler_gnu=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext -ac_cv_fc_compiler_gnu=$ac_compiler_gnu - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_compiler_gnu" >&5 -printf "%s\n" "$ac_cv_fc_compiler_gnu" >&6; } -ac_compiler_gnu=$ac_cv_fc_compiler_gnu - -ac_ext=$ac_save_ext -ac_test_FCFLAGS=${FCFLAGS+y} -ac_save_FCFLAGS=$FCFLAGS -FCFLAGS= -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $FC accepts -g" >&5 -printf %s "checking whether $FC accepts -g... " >&6; } -if test ${ac_cv_prog_fc_g+y} -then : - printf %s "(cached) " >&6 -else $as_nop - FCFLAGS=-g -cat > conftest.$ac_ext <<_ACEOF - program main - - end -_ACEOF -if ac_fn_fc_try_compile "$LINENO" -then : - ac_cv_prog_fc_g=yes -else $as_nop - ac_cv_prog_fc_g=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_fc_g" >&5 -printf "%s\n" "$ac_cv_prog_fc_g" >&6; } -if test $ac_test_FCFLAGS; then - FCFLAGS=$ac_save_FCFLAGS -elif test $ac_cv_prog_fc_g = yes; then - if test "x$ac_cv_fc_compiler_gnu" = xyes; then - FCFLAGS="-g -O2" - else - FCFLAGS="-g" - fi -else - if test "x$ac_cv_fc_compiler_gnu" = xyes; then - FCFLAGS="-O2" - else - FCFLAGS= - fi -fi - -if test $ac_compiler_gnu = yes; then - GFC=yes -else - GFC= -fi -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -if test "x$ac_cv_fc_compiler_gnu" = xyes; then - -printf "%s\n" "#define HAVE_GFORTRAN 1" >>confdefs.h - -fi - -LIBS_SAVE=$LIBS -LIBS="$LIBS -lm" - -ac_fn_cxx_check_func "$LINENO" "expm1" "ac_cv_func_expm1" -if test "x$ac_cv_func_expm1" = xyes -then : - printf "%s\n" "#define HAVE_EXPM1 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "fmin" "ac_cv_func_fmin" -if test "x$ac_cv_func_fmin" = xyes -then : - printf "%s\n" "#define HAVE_FMIN 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "finite" "ac_cv_func_finite" -if test "x$ac_cv_func_finite" = xyes -then : - printf "%s\n" "#define HAVE_FINITE 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "log2" "ac_cv_func_log2" -if test "x$ac_cv_func_log2" = xyes -then : - printf "%s\n" "#define HAVE_LOG2 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "log1p" "ac_cv_func_log1p" -if test "x$ac_cv_func_log1p" = xyes -then : - printf "%s\n" "#define HAVE_LOG1P 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "rint" "ac_cv_func_rint" -if test "x$ac_cv_func_rint" = xyes -then : - printf "%s\n" "#define HAVE_RINT 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "rintf" "ac_cv_func_rintf" -if test "x$ac_cv_func_rintf" = xyes -then : - printf "%s\n" "#define HAVE_RINTF 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "round" "ac_cv_func_round" -if test "x$ac_cv_func_round" = xyes -then : - printf "%s\n" "#define HAVE_ROUND 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "stpcpy" "ac_cv_func_stpcpy" -if test "x$ac_cv_func_stpcpy" = xyes -then : - printf "%s\n" "#define HAVE_STPCPY 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "strcasecmp" "ac_cv_func_strcasecmp" -if test "x$ac_cv_func_strcasecmp" = xyes -then : - printf "%s\n" "#define HAVE_STRCASECMP 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "_stricmp" "ac_cv_func__stricmp" -if test "x$ac_cv_func__stricmp" = xyes -then : - printf "%s\n" "#define HAVE__STRICMP 1" >>confdefs.h - -fi -ac_fn_cxx_check_func "$LINENO" "strdup" "ac_cv_func_strdup" -if test "x$ac_cv_func_strdup" = xyes -then : - printf "%s\n" "#define HAVE_STRDUP 1" >>confdefs.h - -fi - - - for ac_func in isfinite -do : - ac_fn_cxx_check_func "$LINENO" "isfinite" "ac_cv_func_isfinite" -if test "x$ac_cv_func_isfinite" = xyes -then : - printf "%s\n" "#define HAVE_ISFINITE 1" >>confdefs.h - printf "%s\n" "#define HAVE_ISFINITE 1" >>confdefs.h - -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ -double f = 0.0; isfinite(f) - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO" -then : - printf "%s\n" "#define HAVE_ISFINITE 1" >>confdefs.h - -else $as_nop - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "isfinite() not available -See \`config.log' for more details" "$LINENO" 5; } - -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - -fi - -done -LIBS=$LIBS_SAVE - -ac_header= ac_cache= -for ac_item in $ac_header_cxx_list -do - if test $ac_cache; then - ac_fn_cxx_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default" - if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then - printf "%s\n" "#define $ac_item 1" >> confdefs.h - fi - ac_header= ac_cache= - elif test $ac_header; then - ac_cache=$ac_item - else - ac_header=$ac_item - fi -done - - - - - - - - -if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes -then : - -printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h - -fi -ac_fn_cxx_check_header_compile "$LINENO" "sys/times.h" "ac_cv_header_sys_times_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_times_h" = xyes -then : - -printf "%s\n" "#define HAVE_TIMES_H 1" >>confdefs.h - -fi - - -ac_fn_cxx_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "$ac_includes_default" -if test "x$ac_cv_header_net_if_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_IF_H 1" >>confdefs.h - -fi -ac_fn_cxx_check_header_compile "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default" -if test "x$ac_cv_header_netinet_in_h" = xyes -then : - printf "%s\n" "#define HAVE_NETINET_IN_H 1" >>confdefs.h - -fi -ac_fn_cxx_check_header_compile "$LINENO" "net/if_dl.h" "ac_cv_header_net_if_dl_h" "$ac_includes_default" -if test "x$ac_cv_header_net_if_dl_h" = xyes -then : - printf "%s\n" "#define HAVE_NET_IF_DL_H 1" >>confdefs.h - -fi -ac_fn_cxx_check_header_compile "$LINENO" "sys/sockio.h" "ac_cv_header_sys_sockio_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_sockio_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_SOCKIO_H 1" >>confdefs.h - -fi -ac_fn_cxx_check_header_compile "$LINENO" "sys/un.h" "ac_cv_header_sys_un_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_un_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_UN_H 1" >>confdefs.h - -fi -ac_fn_cxx_check_header_compile "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_socket_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_SOCKET_H 1" >>confdefs.h - -fi -ac_fn_cxx_check_header_compile "$LINENO" "sys/ioctl.h" "ac_cv_header_sys_ioctl_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_ioctl_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_IOCTL_H 1" >>confdefs.h - -fi -ac_fn_cxx_check_header_compile "$LINENO" "sys/time.h" "ac_cv_header_sys_time_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_time_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_TIME_H 1" >>confdefs.h - -fi -ac_fn_cxx_check_header_compile "$LINENO" "sys/file.h" "ac_cv_header_sys_file_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_file_h" = xyes -then : - printf "%s\n" "#define HAVE_SYS_FILE_H 1" >>confdefs.h - -fi - - -ac_fn_cxx_check_member "$LINENO" "struct sockaddr" "sa_len" "ac_cv_member_struct_sockaddr_sa_len" "#include - #include -" -if test "x$ac_cv_member_struct_sockaddr_sa_len" = xyes -then : - -printf "%s\n" "#define HAVE_SA_LEN 1" >>confdefs.h - -fi - - -graphml_support=yes -# Check whether --enable-graphml was given. -if test ${enable_graphml+y} -then : - enableval=$enable_graphml; graphml_support=$enableval -else $as_nop - graphml_support=yes -fi - - -HAVE_LIBXML=0 -if test $graphml_support = yes; then - # Extract the first word of "xml2-config", so it can be a program name with args. -set dummy xml2-config; ac_word=$2 -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -printf %s "checking for $ac_word... " >&6; } -if test ${ac_cv_path_XML2CONFIG+y} -then : - printf %s "(cached) " >&6 -else $as_nop - case $XML2CONFIG in - [\\/]* | ?:[\\/]*) - ac_cv_path_XML2CONFIG="$XML2CONFIG" # Let the user override the test with a path. - ;; - *) - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then - ac_cv_path_XML2CONFIG="$as_dir$ac_word$ac_exec_ext" - printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - - test -z "$ac_cv_path_XML2CONFIG" && ac_cv_path_XML2CONFIG="none" - ;; -esac -fi -XML2CONFIG=$ac_cv_path_XML2CONFIG -if test -n "$XML2CONFIG"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $XML2CONFIG" >&5 -printf "%s\n" "$XML2CONFIG" >&6; } -else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; } -fi - - - if test "$XML2CONFIG" = "none"; then - graphml_support=no - else - # xml2-config puts only preprocessor flags in --cflags (i.e. -D and -I) so - # we can put them in XML2_CPPFLAGS. This might not be true for other - # libraries, though. - XML2_CPPFLAGS=`$XML2CONFIG --cflags` - XML2_LIBS=`$XML2CONFIG --libs` - OLDLIBS=${LIBS} - LIBS=${XML2_LIBS} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for xmlSAXUserParseFile in -lxml2" >&5 -printf %s "checking for xmlSAXUserParseFile in -lxml2... " >&6; } -if test ${ac_cv_lib_xml2_xmlSAXUserParseFile+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-lxml2 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -namespace conftest { - extern "C" int xmlSAXUserParseFile (); -} -int -main (void) -{ -return conftest::xmlSAXUserParseFile (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO" -then : - ac_cv_lib_xml2_xmlSAXUserParseFile=yes -else $as_nop - ac_cv_lib_xml2_xmlSAXUserParseFile=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_xmlSAXUserParseFile" >&5 -printf "%s\n" "$ac_cv_lib_xml2_xmlSAXUserParseFile" >&6; } -if test "x$ac_cv_lib_xml2_xmlSAXUserParseFile" = xyes -then : - - OLDCPPFLAGS=${CPPFLAGS} - CPPFLAGS=${XML2_CPPFLAGS} - ac_fn_cxx_check_header_compile "$LINENO" "libxml/parser.h" "ac_cv_header_libxml_parser_h" "$ac_includes_default" -if test "x$ac_cv_header_libxml_parser_h" = xyes -then : - - HAVE_LIBXML=1 - -printf "%s\n" "#define HAVE_LIBXML 1" >>confdefs.h - - -else $as_nop - - graphml_support=no - -fi - - CPPFLAGS=${OLDCPPFLAGS} - -else $as_nop - - graphml_support=no - -fi - - LIBS=${OLDLIBS} - fi -fi - - - - - -printf "%s\n" "#define INTERNAL_GMP 1" >>confdefs.h - - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -HAVE_GMP=0 -INTERNAL_GMP=1 -GMP_LIBS="" -gmp_support=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for __gmpz_add in -lgmp" >&5 -printf %s "checking for __gmpz_add in -lgmp... " >&6; } -if test ${ac_cv_lib_gmp___gmpz_add+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-lgmp $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -namespace conftest { - extern "C" int __gmpz_add (); -} -int -main (void) -{ -return conftest::__gmpz_add (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO" -then : - ac_cv_lib_gmp___gmpz_add=yes -else $as_nop - ac_cv_lib_gmp___gmpz_add=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gmp___gmpz_add" >&5 -printf "%s\n" "$ac_cv_lib_gmp___gmpz_add" >&6; } -if test "x$ac_cv_lib_gmp___gmpz_add" = xyes -then : - - ac_fn_cxx_check_header_compile "$LINENO" "gmp.h" "ac_cv_header_gmp_h" "$ac_includes_default" -if test "x$ac_cv_header_gmp_h" = xyes -then : - - HAVE_GMP=1 - INTERNAL_GMP=0 - -printf "%s\n" "#define HAVE_GMP 1" >>confdefs.h - - gmp_support=yes - GMP_LIBS="-lgmp" - -fi - - -fi - - - - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -HAVE_GLPK=0 -GLPK_LIBS="" -glpk_support=no -# Check whether --enable-glpk was given. -if test ${enable_glpk+y} -then : - enableval=$enable_glpk; -fi - -if test "x$enable_glpk" != "xno"; then - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 -printf %s "checking how to run the C++ preprocessor... " >&6; } -if test -z "$CXXCPP"; then - if test ${ac_cv_prog_CXXCPP+y} -then : - printf %s "(cached) " >&6 -else $as_nop - # Double quotes because $CXX needs to be expanded - for CXXCPP in "$CXX -E" cpp /lib/cpp - do - ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - Syntax error -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO" -then : - -else $as_nop - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO" -then : - # Broken: success on invalid input. -continue -else $as_nop - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok -then : - break -fi - - done - ac_cv_prog_CXXCPP=$CXXCPP - -fi - CXXCPP=$ac_cv_prog_CXXCPP -else - ac_cv_prog_CXXCPP=$CXXCPP -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 -printf "%s\n" "$CXXCPP" >&6; } -ac_preproc_ok=false -for ac_cxx_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include - Syntax error -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO" -then : - -else $as_nop - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -_ACEOF -if ac_fn_cxx_try_cpp "$LINENO" -then : - # Broken: success on invalid input. -continue -else $as_nop - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok -then : - -else $as_nop - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -printf %s "checking for grep that handles long lines and -e... " >&6; } -if test ${ac_cv_path_GREP+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in grep ggrep - do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - printf %s 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - printf "%s\n" 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -printf "%s\n" "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -printf %s "checking for egrep... " >&6; } -if test ${ac_cv_path_EGREP+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - for ac_prog in egrep - do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - printf %s 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - printf "%s\n" 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -printf "%s\n" "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for glp_read_mps in -lglpk" >&5 -printf %s "checking for glp_read_mps in -lglpk... " >&6; } -if test ${ac_cv_lib_glpk_glp_read_mps+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-lglpk $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -namespace conftest { - extern "C" int glp_read_mps (); -} -int -main (void) -{ -return conftest::glp_read_mps (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO" -then : - ac_cv_lib_glpk_glp_read_mps=yes -else $as_nop - ac_cv_lib_glpk_glp_read_mps=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_glpk_glp_read_mps" >&5 -printf "%s\n" "$ac_cv_lib_glpk_glp_read_mps" >&6; } -if test "x$ac_cv_lib_glpk_glp_read_mps" = xyes -then : - - ac_fn_cxx_check_header_compile "$LINENO" "glpk.h" "ac_cv_header_glpk_h" "$ac_includes_default" -if test "x$ac_cv_header_glpk_h" = xyes -then : - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #include - #if GLP_MAJOR_VERSION > 4 || (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION >= 57) - yes - #endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "yes" >/dev/null 2>&1 -then : - - HAVE_GLPK=1 - -printf "%s\n" "#define HAVE_GLPK 1" >>confdefs.h - - glpk_support=yes - GLPK_LIBS="-lglpk" - -fi -rm -rf conftest* - - -fi - - -fi - -fi - - - - -printf "%s\n" "#define IGRAPH_THREAD_LOCAL /**/" >>confdefs.h - - -ac_config_files="$ac_config_files src/Makevars.tmp:src/Makevars.in" - - -cat >confcache <<\_ACEOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs, see configure's option --config-cache. -# It is not useful on other systems. If it contains results you don't -# want to keep, you may remove or edit it. -# -# config.status only pays attention to the cache file if you give it -# the --recheck option to rerun configure. -# -# `ac_cv_env_foo' variables (set or unset) will be overridden when -# loading this file, other *unset* `ac_cv_foo' will be assigned the -# following values. - -_ACEOF - -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, we kill variables containing newlines. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -( - for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do - eval ac_val=\$$ac_var - case $ac_val in #( - *${as_nl}*) - case $ac_var in #( - *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 -printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; - esac - case $ac_var in #( - _ | IFS | as_nl) ;; #( - BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) { eval $ac_var=; unset $ac_var;} ;; - esac ;; - esac - done - - (set) 2>&1 | - case $as_nl`(ac_space=' '; set) 2>&1` in #( - *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes: double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \. - sed -n \ - "s/'/'\\\\''/g; - s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" - ;; #( - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" - ;; - esac | - sort -) | - sed ' - /^ac_cv_env_/b end - t clear - :clear - s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/ - t end - s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ - :end' >>confcache -if diff "$cache_file" confcache >/dev/null 2>&1; then :; else - if test -w "$cache_file"; then - if test "x$cache_file" != "x/dev/null"; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 -printf "%s\n" "$as_me: updating cache $cache_file" >&6;} - if test ! -f "$cache_file" || test -h "$cache_file"; then - cat confcache >"$cache_file" - else - case $cache_file in #( - */* | ?:*) - mv -f confcache "$cache_file"$$ && - mv -f "$cache_file"$$ "$cache_file" ;; #( - *) - mv -f confcache "$cache_file" ;; - esac - fi - fi - else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 -printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;} - fi -fi -rm -f confcache - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -DEFS=-DHAVE_CONFIG_H - -ac_libobjs= -ac_ltlibobjs= -U= -for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue - # 1. Remove the extension, and $U if already installed. - ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' - ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"` - # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR - # will be set to the directory where LIBOBJS objects are built. - as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" - as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' -done -LIBOBJS=$ac_libobjs - -LTLIBOBJS=$ac_ltlibobjs - - - -: "${CONFIG_STATUS=./config.status}" -ac_write_fail=0 -ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 -printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;} -as_write_fail=0 -cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 -#! $SHELL -# Generated by $as_me. -# Run this file to recreate the current configuration. -# Compiler output produced by configure, useful for debugging -# configure, is in config.log if it exists. - -debug=false -ac_cs_recheck=false -ac_cs_silent=false - -SHELL=\${CONFIG_SHELL-$SHELL} -export SHELL -_ASEOF -cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 -## -------------------- ## -## M4sh Initialization. ## -## -------------------- ## - -# Be more Bourne compatible -DUALCASE=1; export DUALCASE # for MKS sh -as_nop=: -if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1 -then : - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else $as_nop - case `(set -o) 2>/dev/null` in #( - *posix*) : - set -o posix ;; #( - *) : - ;; -esac -fi - - - -# Reset variables that may have inherited troublesome values from -# the environment. - -# IFS needs to be set, to space, tab, and newline, in precisely that order. -# (If _AS_PATH_WALK were called with IFS unset, it would have the -# side effect of setting IFS to empty, thus disabling word splitting.) -# Quoting is to prevent editors from complaining about space-tab. -as_nl=' -' -export as_nl -IFS=" "" $as_nl" - -PS1='$ ' -PS2='> ' -PS4='+ ' - -# Ensure predictable behavior from utilities with locale-dependent output. -LC_ALL=C -export LC_ALL -LANGUAGE=C -export LANGUAGE - -# We cannot yet rely on "unset" to work, but we need these variables -# to be unset--not just set to an empty or harmless value--now, to -# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct -# also avoids known problems related to "unset" and subshell syntax -# in other old shells (e.g. bash 2.01 and pdksh 5.2.14). -for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH -do eval test \${$as_var+y} \ - && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : -done - -# Ensure that fds 0, 1, and 2 are open. -if (exec 3>&0) 2>/dev/null; then :; else exec 0&1) 2>/dev/null; then :; else exec 1>/dev/null; fi -if (exec 3>&2) ; then :; else exec 2>/dev/null; fi - -# The user is always right. -if ${PATH_SEPARATOR+false} :; then - PATH_SEPARATOR=: - (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { - (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || - PATH_SEPARATOR=';' - } -fi - - -# Find who we are. Look in the path if we contain no directory separator. -as_myself= -case $0 in #(( - *[\\/]* ) as_myself=$0 ;; - *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - case $as_dir in #((( - '') as_dir=./ ;; - */) ;; - *) as_dir=$as_dir/ ;; - esac - test -r "$as_dir$0" && as_myself=$as_dir$0 && break - done -IFS=$as_save_IFS - - ;; -esac -# We did not find ourselves, most probably we were run as `sh COMMAND' -# in which case we are not to be found in the path. -if test "x$as_myself" = x; then - as_myself=$0 -fi -if test ! -f "$as_myself"; then - printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - exit 1 -fi - - - -# as_fn_error STATUS ERROR [LINENO LOG_FD] -# ---------------------------------------- -# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are -# provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with STATUS, using 1 if that was 0. -as_fn_error () -{ - as_status=$1; test $as_status -eq 0 && as_status=1 - if test "$4"; then - as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 - fi - printf "%s\n" "$as_me: error: $2" >&2 - as_fn_exit $as_status -} # as_fn_error - - - -# as_fn_set_status STATUS -# ----------------------- -# Set $? to STATUS, without forking. -as_fn_set_status () -{ - return $1 -} # as_fn_set_status - -# as_fn_exit STATUS -# ----------------- -# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. -as_fn_exit () -{ - set +e - as_fn_set_status $1 - exit $1 -} # as_fn_exit - -# as_fn_unset VAR -# --------------- -# Portably unset VAR. -as_fn_unset () -{ - { eval $1=; unset $1;} -} -as_unset=as_fn_unset - -# as_fn_append VAR VALUE -# ---------------------- -# Append the text in VALUE to the end of the definition contained in VAR. Take -# advantage of any shell optimizations that allow amortized linear growth over -# repeated appends, instead of the typical quadratic growth present in naive -# implementations. -if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null -then : - eval 'as_fn_append () - { - eval $1+=\$2 - }' -else $as_nop - as_fn_append () - { - eval $1=\$$1\$2 - } -fi # as_fn_append - -# as_fn_arith ARG... -# ------------------ -# Perform arithmetic evaluation on the ARGs, and store the result in the -# global $as_val. Take advantage of shells that can avoid forks. The arguments -# must be portable across $(()) and expr. -if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null -then : - eval 'as_fn_arith () - { - as_val=$(( $* )) - }' -else $as_nop - as_fn_arith () - { - as_val=`expr "$@" || test $? -eq 1` - } -fi # as_fn_arith - - -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then - as_basename=basename -else - as_basename=false -fi - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -as_me=`$as_basename -- "$0" || -$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ - X"$0" : 'X\(//\)$' \| \ - X"$0" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X/"$0" | - sed '/^.*\/\([^/][^/]*\)\/*$/{ - s//\1/ - q - } - /^X\/\(\/\/\)$/{ - s//\1/ - q - } - /^X\/\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - - -# Determine whether it's possible to make 'echo' print without a newline. -# These variables are no longer used directly by Autoconf, but are AC_SUBSTed -# for compatibility with existing Makefiles. -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in #((((( --n*) - case `echo 'xy\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - xy) ECHO_C='\c';; - *) echo `echo ksh88 bug on AIX 6.1` > /dev/null - ECHO_T=' ';; - esac;; -*) - ECHO_N='-n';; -esac - -# For backward compatibility with old third-party macros, we provide -# the shell variables $as_echo and $as_echo_n. New code should use -# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively. -as_echo='printf %s\n' -as_echo_n='printf %s' - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -pR'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -pR' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -pR' - fi -else - as_ln_s='cp -pR' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - - -# as_fn_mkdir_p -# ------------- -# Create "$as_dir" as a directory, including parents if necessary. -as_fn_mkdir_p () -{ - - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || eval $as_mkdir_p || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" - - -} # as_fn_mkdir_p -if mkdir -p . 2>/dev/null; then - as_mkdir_p='mkdir -p "$as_dir"' -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - - -# as_fn_executable_p FILE -# ----------------------- -# Test if FILE is an executable regular file. -as_fn_executable_p () -{ - test -f "$1" && test -x "$1" -} # as_fn_executable_p -as_test_x='test -x' -as_executable_p=as_fn_executable_p - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -exec 6>&1 -## ----------------------------------- ## -## Main body of $CONFIG_STATUS script. ## -## ----------------------------------- ## -_ASEOF -test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# Save the log message, to keep $0 and so on meaningful, and to -# report actual input values of CONFIG_FILES etc. instead of their -# values after options handling. -ac_log=" -This file was extended by $as_me, which was -generated by GNU Autoconf 2.71. Invocation command line was - - CONFIG_FILES = $CONFIG_FILES - CONFIG_HEADERS = $CONFIG_HEADERS - CONFIG_LINKS = $CONFIG_LINKS - CONFIG_COMMANDS = $CONFIG_COMMANDS - $ $0 $@ - -on `(hostname || uname -n) 2>/dev/null | sed 1q` -" - -_ACEOF - -case $ac_config_files in *" -"*) set x $ac_config_files; shift; ac_config_files=$*;; -esac - -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac - - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -# Files that config.status was made for. -config_files="$ac_config_files" -config_headers="$ac_config_headers" - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -ac_cs_usage="\ -\`$as_me' instantiates files and other configuration actions -from templates according to the current configuration. Unless the files -and actions are specified as TAGs, all are instantiated by default. - -Usage: $0 [OPTION]... [TAG]... - - -h, --help print this help, then exit - -V, --version print version number and configuration settings, then exit - --config print configuration, then exit - -q, --quiet, --silent - do not print progress messages - -d, --debug don't remove temporary files - --recheck update $as_me by reconfiguring in the same conditions - --file=FILE[:TEMPLATE] - instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE - -Configuration files: -$config_files - -Configuration headers: -$config_headers - -Report bugs to the package provider." - -_ACEOF -ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"` -ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"` -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_cs_config='$ac_cs_config_escaped' -ac_cs_version="\\ -config.status -configured by $0, generated by GNU Autoconf 2.71, - with options \\"\$ac_cs_config\\" - -Copyright (C) 2021 Free Software Foundation, Inc. -This config.status script is free software; the Free Software Foundation -gives unlimited permission to copy, distribute and modify it." - -ac_pwd='$ac_pwd' -srcdir='$srcdir' -test -n "\$AWK" || AWK=awk -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# The default lists apply if the user does not specify any file. -ac_need_defaults=: -while test $# != 0 -do - case $1 in - --*=?*) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` - ac_shift=: - ;; - --*=) - ac_option=`expr "X$1" : 'X\([^=]*\)='` - ac_optarg= - ac_shift=: - ;; - *) - ac_option=$1 - ac_optarg=$2 - ac_shift=shift - ;; - esac - - case $ac_option in - # Handling of the options. - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - ac_cs_recheck=: ;; - --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) - printf "%s\n" "$ac_cs_version"; exit ;; - --config | --confi | --conf | --con | --co | --c ) - printf "%s\n" "$ac_cs_config"; exit ;; - --debug | --debu | --deb | --de | --d | -d ) - debug=: ;; - --file | --fil | --fi | --f ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - '') as_fn_error $? "missing file argument" ;; - esac - as_fn_append CONFIG_FILES " '$ac_optarg'" - ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; - --help | --hel | -h ) - printf "%s\n" "$ac_cs_usage"; exit ;; - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil | --si | --s) - ac_cs_silent=: ;; - - # This is an error. - -*) as_fn_error $? "unrecognized option: \`$1' -Try \`$0 --help' for more information." ;; +set -eux pipefail - *) as_fn_append ac_config_targets " $1" - ac_need_defaults=false ;; +cd src - esac - shift -done - -ac_configure_extra_args= - -if $ac_cs_silent; then - exec 6>/dev/null - ac_configure_extra_args="$ac_configure_extra_args --silent" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -if \$ac_cs_recheck; then - set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion - shift - \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6 - CONFIG_SHELL='$SHELL' - export CONFIG_SHELL - exec "\$@" -fi - -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -exec 5>>config.log -{ - echo - sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX -## Running $as_me. ## -_ASBOX - printf "%s\n" "$ac_log" -} >&5 - -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - -# Handling of arguments. -for ac_config_target in $ac_config_targets -do - case $ac_config_target in - "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; - "src/Makevars.tmp") CONFIG_FILES="$CONFIG_FILES src/Makevars.tmp:src/Makevars.in" ;; - - *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -done - - -# If the user did not use the arguments to specify the items to instantiate, -# then the envvar interface is used. Set only those that are not. -# We use the long form for the default assignment because of an extremely -# bizarre bug on SunOS 4.1.3. -if $ac_need_defaults; then - test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files - test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers -fi - -# Have a temporary directory for convenience. Make it in the build tree -# simply because there is no reason against having it here, and in addition, -# creating and moving files from /tmp can sometimes cause problems. -# Hook for its removal unless debugging. -# Note that there is a small window in which the directory will not be cleaned: -# after its creation but before its name has been assigned to `$tmp'. -$debug || -{ - tmp= ac_tmp= - trap 'exit_status=$? - : "${ac_tmp:=$tmp}" - { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status -' 0 - trap 'as_fn_exit 1' 1 2 13 15 -} -# Create a (secure) tmp directory for tmp files. - -{ - tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -d "$tmp" -} || -{ - tmp=./conf$$-$RANDOM - (umask 077 && mkdir "$tmp") -} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 -ac_tmp=$tmp - -# Set up the scripts for CONFIG_FILES section. -# No need to generate them if there are no CONFIG_FILES. -# This happens for instance with `./config.status config.h'. -if test -n "$CONFIG_FILES"; then - - -ac_cr=`echo X | tr X '\015'` -# On cygwin, bash can eat \r inside `` if the user requested igncr. -# But we know of no other shell where ac_cr would be empty at this -# point, so we can use a bashism as a fallback. -if test "x$ac_cr" = x; then - eval ac_cr=\$\'\\r\' -fi -ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` -if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' -else - ac_cs_awk_cr=$ac_cr -fi - -echo 'BEGIN {' >"$ac_tmp/subs1.awk" && -_ACEOF - - -{ - echo "cat >conf$$subs.awk <<_ACEOF" && - echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && - echo "_ACEOF" -} >conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` -ac_delim='%!_!# ' -for ac_last_try in false false false false false :; do - . ./conf$$subs.sh || - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - - ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` - if test $ac_delim_n = $ac_delim_num; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done -rm -f conf$$subs.sh - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && -_ACEOF -sed -n ' -h -s/^/S["/; s/!.*/"]=/ -p -g -s/^[^!]*!// -:repl -t repl -s/'"$ac_delim"'$// -t delim -:nl -h -s/\(.\{148\}\)..*/\1/ -t more1 -s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ -p -n -b repl -:more1 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t nl -:delim -h -s/\(.\{148\}\)..*/\1/ -t more2 -s/["\\]/\\&/g; s/^/"/; s/$/"/ -p -b -:more2 -s/["\\]/\\&/g; s/^/"/; s/$/"\\/ -p -g -s/.\{148\}// -t delim -' >$CONFIG_STATUS || ac_write_fail=1 -rm -f conf$$subs.awk -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -_ACAWK -cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && - for (key in S) S_is_set[key] = 1 - FS = "" - -} -{ - line = $ 0 - nfields = split(line, field, "@") - substed = 0 - len = length(field[1]) - for (i = 2; i < nfields; i++) { - key = field[i] - keylen = length(key) - if (S_is_set[key]) { - value = S[key] - line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) - len += length(value) + length(field[++i]) - substed = 1 - } else - len += 1 + keylen - } - - print line -} - -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then - sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" -else - cat -fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ - || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 -_ACEOF - -# VPATH may cause trouble with some makes, so we remove sole $(srcdir), -# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and -# trailing colons and then remove the whole line if VPATH becomes empty -# (actually we leave an empty line to preserve line numbers). -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ -h -s/// -s/^/:/ -s/[ ]*$/:/ -s/:\$(srcdir):/:/g -s/:\${srcdir}:/:/g -s/:@srcdir@:/:/g -s/^:*// -s/:*$// -x -s/\(=[ ]*\).*/\1/ -G -s/\n// -s/^[^=]*=[ ]*$// -}' -fi - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -fi # test -n "$CONFIG_FILES" - -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF - -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " -shift -for ac_tag -do - case $ac_tag in - :[FHLC]) ac_mode=$ac_tag; continue;; - esac - case $ac_mode$ac_tag in - :[FHL]*:*);; - :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; - :[FH]-) ac_tag=-:-;; - :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; - esac - ac_save_IFS=$IFS - IFS=: - set x $ac_tag - IFS=$ac_save_IFS - shift - ac_file=$1 - shift - - case $ac_mode in - :L) ac_source=$1;; - :[FH]) - ac_file_inputs= - for ac_f - do - case $ac_f in - -) ac_f="$ac_tmp/stdin";; - *) # Look for the file first in the build tree, then in the source tree - # (if the path is not absolute). The absolute path cannot be DOS-style, - # because $ac_f cannot contain `:'. - test -f "$ac_f" || - case $ac_f in - [\\/$]*) false;; - *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; - esac || - as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; - esac - case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - as_fn_append ac_file_inputs " '$ac_f'" - done - - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ - configure_input='Generated from '` - printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' - `' by configure.' - if test x"$ac_file" != x-; then - configure_input="$ac_file. $configure_input" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 -printf "%s\n" "$as_me: creating $ac_file" >&6;} - fi - # Neutralize special characters interpreted by sed in replacement strings. - case $configure_input in #( - *\&* | *\|* | *\\* ) - ac_sed_conf_input=`printf "%s\n" "$configure_input" | - sed 's/[\\\\&|]/\\\\&/g'`;; #( - *) ac_sed_conf_input=$configure_input;; - esac - - case $ac_tag in - *:-:* | *:-) cat >"$ac_tmp/stdin" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - esac - ;; - esac - - ac_dir=`$as_dirname -- "$ac_file" || -$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$ac_file" : 'X\(//\)[^/]' \| \ - X"$ac_file" : 'X\(//\)$' \| \ - X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || -printf "%s\n" X"$ac_file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - as_dir="$ac_dir"; as_fn_mkdir_p - ac_builddir=. - -case "$ac_dir" in -.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; -*) - ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'` - # A ".." for each directory in $ac_dir_suffix. - ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` - case $ac_top_builddir_sub in - "") ac_top_builddir_sub=. ac_top_build_prefix= ;; - *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; - esac ;; -esac -ac_abs_top_builddir=$ac_pwd -ac_abs_builddir=$ac_pwd$ac_dir_suffix -# for backward compatibility: -ac_top_builddir=$ac_top_build_prefix - -case $srcdir in - .) # We are building in place. - ac_srcdir=. - ac_top_srcdir=$ac_top_builddir_sub - ac_abs_top_srcdir=$ac_pwd ;; - [\\/]* | ?:[\\/]* ) # Absolute name. - ac_srcdir=$srcdir$ac_dir_suffix; - ac_top_srcdir=$srcdir - ac_abs_top_srcdir=$srcdir ;; - *) # Relative name. - ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix - ac_top_srcdir=$ac_top_build_prefix$srcdir - ac_abs_top_srcdir=$ac_pwd/$srcdir ;; -esac -ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix - - - case $ac_mode in - :F) - # - # CONFIG_FILE - # - -_ACEOF - -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -# If the template does not know about datarootdir, expand it. -# FIXME: This hack should be removed a few years after 2.60. -ac_datarootdir_hack=; ac_datarootdir_seen= -ac_sed_dataroot=' -/datarootdir/ { - p - q -} -/@datadir@/p -/@docdir@/p -/@infodir@/p -/@localedir@/p -/@mandir@/p' -case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in -*datarootdir*) ac_datarootdir_seen=yes;; -*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 -printf "%s\n" "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} -_ACEOF -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - ac_datarootdir_hack=' - s&@datadir@&$datadir&g - s&@docdir@&$docdir&g - s&@infodir@&$infodir&g - s&@localedir@&$localedir&g - s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; -esac -_ACEOF - -# Neutralize VPATH when `$srcdir' = `.'. -# Shell code in configure.ac might set extrasub. -# FIXME: do we really want to maintain this feature? -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -ac_sed_extra="$ac_vpsub -$extrasub -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -:t -/@[a-zA-Z_][a-zA-Z_0-9]*@/!b -s|@configure_input@|$ac_sed_conf_input|;t t -s&@top_builddir@&$ac_top_builddir_sub&;t t -s&@top_build_prefix@&$ac_top_build_prefix&;t t -s&@srcdir@&$ac_srcdir&;t t -s&@abs_srcdir@&$ac_abs_srcdir&;t t -s&@top_srcdir@&$ac_top_srcdir&;t t -s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t -s&@builddir@&$ac_builddir&;t t -s&@abs_builddir@&$ac_abs_builddir&;t t -s&@abs_top_builddir@&$ac_abs_top_builddir&;t t -$ac_datarootdir_hack -" -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ - >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - -test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ - "$ac_tmp/out"`; test -z "$ac_out"; } && - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&5 -printf "%s\n" "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined" >&2;} - - rm -f "$ac_tmp/stdin" - case $ac_file in - -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; - *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; - esac \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - printf "%s\n" "/* $configure_input */" >&1 \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - fi - else - printf "%s\n" "/* $configure_input */" >&1 \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error $? "could not create -" "$LINENO" 5 - fi - ;; - - - esac - - - case $ac_file$ac_mode in - "src/Makevars.tmp":F) - if test -f src/Makevars && cmp -s src/Makevars.tmp src/Makevars; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating src/Makevars" >&5 -printf "%s\n" "$as_me: creating src/Makevars" >&6;} - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: src/Makevars is unchanged" >&5 -printf "%s\n" "$as_me: src/Makevars is unchanged" >&6;} - rm src/Makevars.tmp - else - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating src/Makevars" >&5 -printf "%s\n" "$as_me: creating src/Makevars" >&6;} - mv src/Makevars.tmp src/Makevars - fi - - ;; - - esac -done # for ac_tag - - -as_fn_exit 0 -_ACEOF -ac_clean_files=$ac_clean_files_save - -test $ac_write_fail = 0 || - as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 - - -# configure is writing to config.log, and then calls config.status. -# config.status does its own redirection, appending to config.log. -# Unfortunately, on DOS this fails, as config.log is still kept open -# by configure, so config.status won't be able to write to it; its -# output is simply discarded. So we exec the FD to /dev/null, -# effectively closing config.log, so it can be properly (re)opened and -# appended to by config.status. When coming back to configure, we -# need to make the FD available again. -if test "$no_create" != yes; then - ac_cs_success=: - ac_config_status_args= - test "$silent" = yes && - ac_config_status_args="$ac_config_status_args --quiet" - exec 5>/dev/null - $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false - exec 5>>config.log - # Use ||, not &&, to avoid exiting from the if with $? = 1, which - # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit 1 -fi -if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 -printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +# Set version of igraph +# FIXME: Ensure this is written when vendoring +if ! [ -f ./vendor/cigraph/IGRAPH_VERSION ]; then + echo "0.10.0" >> ./vendor/cigraph/IGRAPH_VERSION fi +# Build igraph with cmake +cmake -S . -B build -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -echo "" -echo "*** Compiler settings used:" -echo " CC=${CC}" -echo " LD=${LD}" -echo " CFLAGS=${CFLAGS}" -echo " CPPFLAGS=${CPPFLAGS}" -echo " CXX=${CXX}" -echo " CXXFLAGS=${CXXFLAGS}" -echo " LDFLAGS=${LDFLAGS}" -echo " LIBS=${LIBS}" +cmake --build build --config Release +cmake --install build --config Release diff --git a/configure.ac b/configure.ac deleted file mode 100644 index da9f6763181..00000000000 --- a/configure.ac +++ /dev/null @@ -1,180 +0,0 @@ -AC_INIT(igraph) -AC_CONFIG_SRCDIR(src/rinterface.c) -AC_CONFIG_HEADERS(src/config.h) - -: ${R_HOME=`R RHOME`} -if test -z "${R_HOME}"; then - echo "could not determine R_HOME" - exit 1 -fi -CC=`"${R_HOME}/bin/R" CMD config CC` -CXX=`"${R_HOME}/bin/R" CMD config CXX11` -if test -z "$CXX"; then - AC_MSG_ERROR([No C++11 compiler is available]) -fi -CXX11STD=`"${R_HOME}/bin/R" CMD config CXX11STD` -CXX="${CXX} ${CXX11STD}" -FC=`"${R_HOME}/bin/R" CMD config FC` -CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS` -CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXX11FLAGS` -CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS` -FCFLAGS=`"${R_HOME}/bin/R" CMD config FCFLAGS` -FLIBS=`"${R_HOME}/bin/R" CMD config FLIBS` -LDFLAGS=`"${R_HOME}/bin/R" CMD config LDFLAGS` - -AC_LANG(C) -AC_PROG_CC - -AC_LANG(C++) -AC_PROG_CXX - -# Fortran compiler, we need to check if it is the GNU compiler -AC_PROG_FC -if test "x$ac_cv_fc_compiler_gnu" = xyes; then - AC_DEFINE([HAVE_GFORTRAN], [1], [Define to 1 if using the GNU Fortran compiler]) -fi - -LIBS_SAVE=$LIBS -LIBS="$LIBS -lm" -AC_CHECK_FUNCS([expm1 fmin finite log2 log1p rint rintf round stpcpy strcasecmp _stricmp strdup]) -AC_CHECK_FUNCS(isfinite, - [AC_DEFINE(HAVE_ISFINITE, 1)], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[double f = 0.0; isfinite(f)]])], - [AC_DEFINE(HAVE_ISFINITE, 1)], - [AC_MSG_FAILURE([isfinite() not available])] - )] -) -LIBS=$LIBS_SAVE - -AC_CHECK_HEADER([sys/times.h], - [AC_DEFINE([HAVE_TIMES_H], [1], [Define to 1 if you have the sys/times.h header])]) - -AC_CHECK_HEADERS([ \ - net/if.h \ - netinet/in.h \ - net/if_dl.h \ - sys/sockio.h \ - sys/un.h \ - sys/socket.h \ - sys/ioctl.h \ - sys/time.h \ - sys/file.h \ - ]) - -AC_CHECK_MEMBER([struct sockaddr.sa_len], - AC_DEFINE_UNQUOTED([HAVE_SA_LEN], [1], [Define if struct sockaddr contains sa_len]), [], - [#include - #include ]) - -graphml_support=yes -AC_ARG_ENABLE(graphml, - AS_HELP_STRING([--disable-graphml], [Disable support for GraphML format]), - [graphml_support=$enableval], [graphml_support=yes]) - -HAVE_LIBXML=0 -if test $graphml_support = yes; then - AC_PATH_PROG([XML2CONFIG], [xml2-config], [none]) - if test "$XML2CONFIG" = "none"; then - graphml_support=no - else - # xml2-config puts only preprocessor flags in --cflags (i.e. -D and -I) so - # we can put them in XML2_CPPFLAGS. This might not be true for other - # libraries, though. - XML2_CPPFLAGS=`$XML2CONFIG --cflags` - XML2_LIBS=`$XML2CONFIG --libs` - OLDLIBS=${LIBS} - LIBS=${XML2_LIBS} - AC_CHECK_LIB([xml2], [xmlSAXUserParseFile], [ - OLDCPPFLAGS=${CPPFLAGS} - CPPFLAGS=${XML2_CPPFLAGS} - AC_CHECK_HEADER([libxml/parser.h], [ - HAVE_LIBXML=1 - AC_DEFINE([HAVE_LIBXML], [1], [Define to 1 if you have the libxml2 libraries installed]) - ], [ - graphml_support=no - ]) - CPPFLAGS=${OLDCPPFLAGS} - ], [ - graphml_support=no - ]) - LIBS=${OLDLIBS} - fi -fi -AC_SUBST(HAVE_LIBXML) -AC_SUBST(XML2_LIBS) -AC_SUBST(XML2_CPPFLAGS) - -AC_DEFINE([INTERNAL_GMP], [1], [Define to 1 if you use the vendored mini-GMP library]) - -AC_LANG_PUSH([C++]) -HAVE_GMP=0 -INTERNAL_GMP=1 -GMP_LIBS="" -gmp_support=no -AC_CHECK_LIB([gmp], [__gmpz_add], [ - AC_CHECK_HEADER([gmp.h], [ - HAVE_GMP=1 - INTERNAL_GMP=0 - AC_DEFINE([HAVE_GMP], [1], [Define to 1 if you have the GMP library]) - gmp_support=yes - GMP_LIBS="-lgmp" - ]) -]) -AC_SUBST(HAVE_GMP) -AC_SUBST(INTERNAL_GMP) -AC_SUBST(GMP_LIBS) -AC_LANG_POP([C++]) - -HAVE_GLPK=0 -GLPK_LIBS="" -glpk_support=no -AC_ARG_ENABLE(glpk, AS_HELP_STRING([--disable-glpk], [Compile without the GLPK library])) -if test "x$enable_glpk" != "xno"; then - AC_CHECK_LIB([glpk], [glp_read_mps], [ - AC_CHECK_HEADER([glpk.h], [ - AC_EGREP_CPP(yes, [ - #include - #if GLP_MAJOR_VERSION > 4 || (GLP_MAJOR_VERSION == 4 && GLP_MINOR_VERSION >= 57) - yes - #endif - ], [ - HAVE_GLPK=1 - AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have the GLPK library]) - glpk_support=yes - GLPK_LIBS="-lglpk" - ]) - ]) - ]) -fi -AC_SUBST(HAVE_GLPK) -AC_SUBST(GLPK_LIBS) - -AC_DEFINE(IGRAPH_THREAD_LOCAL, [], [We don't care about thread-local storage in R]) - -AC_CONFIG_FILES([src/Makevars.tmp:src/Makevars.in], [ - if test -f src/Makevars && cmp -s src/Makevars.tmp src/Makevars; then - AC_MSG_NOTICE([creating src/Makevars]) - AC_MSG_NOTICE([src/Makevars is unchanged]) - rm src/Makevars.tmp - else - AC_MSG_NOTICE([creating src/Makevars]) - mv src/Makevars.tmp src/Makevars - fi - ] -) - -AC_OUTPUT - -echo "" -echo "*** Compiler settings used:" -echo " CC=${CC}" -echo " LD=${LD}" -echo " CFLAGS=${CFLAGS}" -echo " CPPFLAGS=${CPPFLAGS}" -echo " CXX=${CXX}" -echo " CXXFLAGS=${CXXFLAGS}" -echo " LDFLAGS=${LDFLAGS}" -echo " LIBS=${LIBS}" diff --git a/configure.win b/configure.win old mode 100644 new mode 100755 index e69de29bb2d..ed8305ea856 --- a/configure.win +++ b/configure.win @@ -0,0 +1,20 @@ +#! /bin/sh + +set -eux pipefail + +cd src + +# Set version of igraph +# FIXME: Ensure this is written when vendoring +if ! [ -f ./vendor/cigraph/IGRAPH_VERSION ]; then + echo "0.10.0" >> ./vendor/cigraph/IGRAPH_VERSION +fi + +# Build igraph with cmake +cmake -H. -Bbuild -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DCMAKE_SHARED_LIBRARY_PREFIX_CXX="" + +cmake --build build +cmake --install build + +cp -r ./install/include/igraph ./include +cp ./install/lib/libigraph.a . diff --git a/patches/001-fix-cxsparse-include.patch b/patches/001-fix-cxsparse-include.patch deleted file mode 100644 index 24befc95517..00000000000 --- a/patches/001-fix-cxsparse-include.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/core/core/sparsemat.c b/src/core/core/sparsemat.c -index 7bc016660..c7c836e22 100644 ---- a/src/core/core/sparsemat.c -+++ b/src/core/core/sparsemat.c -@@ -21,7 +21,7 @@ - - */ - --#include -+#include - - #include "igraph_sparsemat.h" - #include "igraph_error.h" diff --git a/patches/002-workaround-gml-creator.patch b/patches/002-workaround-gml-creator.patch deleted file mode 100644 index f7ea9ff937b..00000000000 --- a/patches/002-workaround-gml-creator.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/src/core/io/gml.c b/src/core/io/gml.c -index 77c7f0541..375523ee6 100644 ---- a/src/core/io/gml.c -+++ b/src/core/io/gml.c -@@ -611,8 +611,8 @@ int igraph_write_graph_gml(const igraph_t *graph, FILE *outstream, - timestr[strlen(timestr) - 1] = '\0'; /* nicely remove \n */ - - CHECK(fprintf(outstream, -- "Creator \"igraph version %s %s\"\nVersion 1\ngraph\n[\n", -- IGRAPH_VERSION, creator ? creator : timestr)); -+ "Creator \"igraph %s\"\nVersion 1\ngraph\n[\n", -+ creator ? creator : timestr)); - - IGRAPH_STRVECTOR_INIT_FINALLY(&gnames, 0); - IGRAPH_STRVECTOR_INIT_FINALLY(&vnames, 0); diff --git a/src/.gitignore b/src/.gitignore index 20f5b6289cd..ef3da83e600 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,5 +1,6 @@ *.o *.so +*.a /config.h /config.h.in~ /Makevars diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000000..21cc6db63c1 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.18...3.25) + +# Declare the project and language +project( + rigraph + DESCRIPTION "R interface for igraph library" + HOMEPAGE_URL https://igraph.org + LANGUAGES C CXX +) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +# Compile igraph with USING_R definition +add_compile_definitions(USING_R) + +execute_process(COMMAND bash "-c" "Rscript -e 'cat(R.home(\"include\"))'" OUTPUT_VARIABLE R_INCLUDE) +execute_process(COMMAND bash "-c" "Rscript -e 'x <- desc::desc_get_deps(); pkgs <- x$package[x$type == \"LinkingTo\"]; paths <- file.path(.libPaths()[[1]], pkgs, \"include\"); cat(paths, sep = \";\")'" OUTPUT_VARIABLE R_LIBRARIES_INCLUDES) + +include_directories(${R_INCLUDE} ${R_LIBRARIES_INCLUDES} vendor/cigraph/include) + +set(IGRAPH_INTEGER_SIZE 32) +set(IGRAPH_OPENMP_SUPPORT OFF) +set(IGRAPH_USE_INTERNAL_GLPK ON) +set(IGRAPH_USE_INTERNAL_LAPACK ON) +set(IGRAPH_USE_INTERNAL_GMP ON) +add_subdirectory(vendor/cigraph) + +add_subdirectory(vendor/simpleraytracer) +add_subdirectory(vendor/uuid) diff --git a/src/Makevars b/src/Makevars new file mode 100644 index 00000000000..31c14391ad3 --- /dev/null +++ b/src/Makevars @@ -0,0 +1,13 @@ +PKG_CFLAGS=$(C_VISIBILITY) +PKG_CXXFLAGS=$(CXX_VISIBILITY) +PKG_FFLAGS=$(F_VISIBILITY) + +PKG_CPPFLAGS=-DUSING_R -I. -Icore -Iinstall/include/igraph -Ivendor \ + -DNDEBUG -DNTIMER -DNPRINT \ + -DINTERNAL_ARPACK \ + -DPRPACK_IGRAPH_SUPPORT -DIGRAPH_THREAD_LOCAL=/**/ -fPIC +PKG_LIBS=$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -Linstall/lib -luuid -ligraph -lsimpleraytracer -lxml2 + +all: $(SHLIB) + +OBJECTS=rinterface.o rinterface_extra.o rrandom.o lazyeval.o init.o cpp11.o cpprinterface.o diff --git a/src/Makevars.in b/src/Makevars.in deleted file mode 100644 index f381b98bbb9..00000000000 --- a/src/Makevars.in +++ /dev/null @@ -1,13 +0,0 @@ -PKG_CFLAGS=$(C_VISIBILITY) -PKG_CXXFLAGS=$(CXX_VISIBILITY) -PKG_FFLAGS=$(F_VISIBILITY) - -PKG_CPPFLAGS=-DUSING_R -I. -Icore -Iinclude -Ivendor \ - @XML2_CPPFLAGS@ -DNDEBUG -DNTIMER -DNPRINT \ - -DINTERNAL_ARPACK \ - -DPRPACK_IGRAPH_SUPPORT -DIGRAPH_THREAD_LOCAL=/**/ -PKG_LIBS=@XML2_LIBS@ @GMP_LIBS@ @GLPK_LIBS@ $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) - -all: $(SHLIB) - -OBJECTS=core/centrality/betweenness.o core/centrality/centrality_other.o core/centrality/centralization.o core/centrality/closeness.o core/centrality/coreness.o core/centrality/prpack.o core/centrality/prpack/prpack_base_graph.o core/centrality/prpack/prpack_igraph_graph.o core/centrality/prpack/prpack_preprocessed_ge_graph.o core/centrality/prpack/prpack_preprocessed_gs_graph.o core/centrality/prpack/prpack_preprocessed_scc_graph.o core/centrality/prpack/prpack_preprocessed_schur_graph.o core/centrality/prpack/prpack_result.o core/centrality/prpack/prpack_solver.o core/centrality/prpack/prpack_utils.o core/cliques/cliquer/cliquer.o core/cliques/cliquer/cliquer_graph.o core/cliques/cliquer/reorder.o core/cliques/cliquer_wrapper.o core/cliques/cliques.o core/cliques/glet.o core/cliques/maximal_cliques.o core/community/community_misc.o core/community/edge_betweenness.o core/community/fast_modularity.o core/community/fluid.o core/community/infomap/infomap.o core/community/infomap/infomap_FlowGraph.o core/community/infomap/infomap_Greedy.o core/community/infomap/infomap_Node.o core/community/label_propagation.o core/community/leading_eigenvector.o core/community/leiden.o core/community/louvain.o core/community/modularity.o core/community/optimal_modularity.o core/community/spinglass/NetDataTypes.o core/community/spinglass/NetRoutines.o core/community/spinglass/clustertool.o core/community/spinglass/pottsmodel_2.o core/community/walktrap/walktrap.o core/community/walktrap/walktrap_communities.o core/community/walktrap/walktrap_graph.o core/community/walktrap/walktrap_heap.o core/connectivity/cohesive_blocks.o core/connectivity/components.o core/connectivity/separators.o core/constructors/adjacency.o core/constructors/atlas.o core/constructors/basic_constructors.o core/constructors/de_bruijn.o core/constructors/famous.o core/constructors/full.o core/constructors/kautz.o core/constructors/lcf.o core/constructors/linegraph.o core/constructors/prufer.o core/constructors/regular.o core/core/array.o core/core/buckets.o core/core/cutheap.o core/core/dqueue.o core/core/error.o core/core/estack.o core/core/fixed_vectorlist.o core/core/grid.o core/core/heap.o core/core/indheap.o core/core/interruption.o core/core/marked_queue.o core/core/matrix.o core/core/memory.o core/core/printing.o core/core/progress.o core/core/psumtree.o core/core/set.o core/core/sparsemat.o core/core/spmatrix.o core/core/stack.o core/core/statusbar.o core/core/strvector.o core/core/trie.o core/core/vector.o core/core/vector_ptr.o core/flow/flow.o core/flow/st-cuts.o core/games/barabasi.o core/games/callaway_traits.o core/games/citations.o core/games/correlated.o core/games/degree_sequence.o core/games/degree_sequence_vl/gengraph_box_list.o core/games/degree_sequence_vl/gengraph_degree_sequence.o core/games/degree_sequence_vl/gengraph_graph_molloy_hash.o core/games/degree_sequence_vl/gengraph_graph_molloy_optimized.o core/games/degree_sequence_vl/gengraph_mr-connected.o core/games/degree_sequence_vl/gengraph_powerlaw.o core/games/degree_sequence_vl/gengraph_random.o core/games/dotproduct.o core/games/erdos_renyi.o core/games/establishment.o core/games/forestfire.o core/games/grg.o core/games/growing_random.o core/games/islands.o core/games/k_regular.o core/games/preference.o core/games/recent_degree.o core/games/sbm.o core/games/static_fitness.o core/games/tree.o core/games/watts_strogatz.o core/graph/adjlist.o core/graph/attributes.o core/graph/basic_query.o core/graph/cattributes.o core/graph/iterators.o core/graph/type_indexededgelist.o core/graph/visitors.o core/hrg/hrg.o core/hrg/hrg_types.o core/internal/glpk_support.o core/internal/hacks.o core/internal/lsap.o core/internal/qsort.o core/internal/qsort_r.o core/internal/zeroin.o core/io/dimacs.o core/io/dl-lexer.o core/io/dl-parser.o core/io/dl.o core/io/dot.o core/io/edgelist.o core/io/gml-lexer.o core/io/gml-parser.o core/io/gml-tree.o core/io/gml.o core/io/graphdb.o core/io/graphml.o core/io/leda.o core/io/lgl-lexer.o core/io/lgl-parser.o core/io/lgl.o core/io/ncol-lexer.o core/io/ncol-parser.o core/io/ncol.o core/io/pajek-lexer.o core/io/pajek-parser.o core/io/pajek.o core/isomorphism/bliss.o core/isomorphism/bliss/defs.o core/isomorphism/bliss/graph.o core/isomorphism/bliss/heap.o core/isomorphism/bliss/orbit.o core/isomorphism/bliss/partition.o core/isomorphism/bliss/uintseqhash.o core/isomorphism/bliss/utils.o core/isomorphism/isoclasses.o core/isomorphism/isomorphism_misc.o core/isomorphism/lad.o core/isomorphism/queries.o core/isomorphism/vf2.o core/layout/circular.o core/layout/davidson_harel.o core/layout/drl/DensityGrid.o core/layout/drl/DensityGrid_3d.o core/layout/drl/drl_graph.o core/layout/drl/drl_graph_3d.o core/layout/drl/drl_layout.o core/layout/drl/drl_layout_3d.o core/layout/drl/drl_parse.o core/layout/fruchterman_reingold.o core/layout/gem.o core/layout/graphopt.o core/layout/kamada_kawai.o core/layout/large_graph.o core/layout/layout_bipartite.o core/layout/layout_grid.o core/layout/layout_random.o core/layout/mds.o core/layout/merge_dla.o core/layout/merge_grid.o core/layout/reingold_tilford.o core/layout/sugiyama.o core/linalg/arpack.o core/linalg/blas.o core/linalg/eigen.o core/linalg/lapack.o core/math/bfgs.o core/math/complex.o core/math/utils.o core/misc/bipartite.o core/misc/chordality.o core/misc/cocitation.o core/misc/coloring.o core/misc/conversion.o core/misc/degree_sequence.o core/misc/embedding.o core/misc/feedback_arc_set.o core/misc/graphicality.o core/misc/matching.o core/misc/microscopic_update.o core/misc/mixing.o core/misc/motifs.o core/misc/other.o core/misc/scan.o core/misc/sir.o core/misc/spanning_trees.o core/operators/add_edge.o core/operators/complementer.o core/operators/compose.o core/operators/connect_neighborhood.o core/operators/contract.o core/operators/difference.o core/operators/disjoint_union.o core/operators/intersection.o core/operators/misc_internal.o core/operators/permute.o core/operators/reverse.o core/operators/rewire.o core/operators/rewire_edges.o core/operators/simplify.o core/operators/subgraph.o core/operators/union.o core/paths/all_shortest_paths.o core/paths/bellman_ford.o core/paths/dijkstra.o core/paths/distances.o core/paths/eulerian.o core/paths/histogram.o core/paths/johnson.o core/paths/random_walk.o core/paths/shortest_paths.o core/paths/simple_paths.o core/paths/unweighted.o core/properties/basic_properties.o core/properties/constraint.o core/properties/convergence_degree.o core/properties/dag.o core/properties/degrees.o core/properties/girth.o core/properties/loops.o core/properties/multiplicity.o core/properties/neighborhood.o core/properties/spectral.o core/properties/trees.o core/properties/triangles.o core/random/random.o core/scg/scg.o core/scg/scg_approximate_methods.o core/scg/scg_exact_scg.o core/scg/scg_kmeans.o core/scg/scg_optimal_method.o core/scg/scg_utils.o core/version.o vendor/cs/cs_add.o vendor/cs/cs_amd.o vendor/cs/cs_chol.o vendor/cs/cs_cholsol.o vendor/cs/cs_compress.o vendor/cs/cs_counts.o vendor/cs/cs_cumsum.o vendor/cs/cs_dfs.o vendor/cs/cs_dmperm.o vendor/cs/cs_droptol.o vendor/cs/cs_dropzeros.o vendor/cs/cs_dupl.o vendor/cs/cs_entry.o vendor/cs/cs_ereach.o vendor/cs/cs_etree.o vendor/cs/cs_fkeep.o vendor/cs/cs_gaxpy.o vendor/cs/cs_happly.o vendor/cs/cs_house.o vendor/cs/cs_ipvec.o vendor/cs/cs_leaf.o vendor/cs/cs_load.o vendor/cs/cs_lsolve.o vendor/cs/cs_ltsolve.o vendor/cs/cs_lu.o vendor/cs/cs_lusol.o vendor/cs/cs_malloc.o vendor/cs/cs_maxtrans.o vendor/cs/cs_multiply.o vendor/cs/cs_norm.o vendor/cs/cs_permute.o vendor/cs/cs_pinv.o vendor/cs/cs_post.o vendor/cs/cs_print.o vendor/cs/cs_pvec.o vendor/cs/cs_qr.o vendor/cs/cs_qrsol.o vendor/cs/cs_randperm.o vendor/cs/cs_reach.o vendor/cs/cs_scatter.o vendor/cs/cs_scc.o vendor/cs/cs_schol.o vendor/cs/cs_spsolve.o vendor/cs/cs_sqr.o vendor/cs/cs_symperm.o vendor/cs/cs_tdfs.o vendor/cs/cs_transpose.o vendor/cs/cs_updown.o vendor/cs/cs_usolve.o vendor/cs/cs_util.o vendor/cs/cs_utsolve.o vendor/mini-gmp/mini-gmp.o vendor/plfit/gss.o vendor/plfit/hzeta.o vendor/plfit/kolmogorov.o vendor/plfit/lbfgs.o vendor/plfit/mt.o vendor/plfit/options.o vendor/plfit/platform.o vendor/plfit/plfit.o vendor/plfit/plfit_error.o vendor/plfit/rbinom.o vendor/plfit/sampling.o vendor/arpack/dgetv0.o vendor/arpack/dlaqrb.o vendor/arpack/dmout.o vendor/arpack/dnaitr.o vendor/arpack/dnapps.o vendor/arpack/dnaup2.o vendor/arpack/dnaupd.o vendor/arpack/dnconv.o vendor/arpack/dneigh.o vendor/arpack/dneupd.o vendor/arpack/dngets.o vendor/arpack/dsaitr.o vendor/arpack/dsapps.o vendor/arpack/dsaup2.o vendor/arpack/dsaupd.o vendor/arpack/dsconv.o vendor/arpack/dseigt.o vendor/arpack/dsesrt.o vendor/arpack/dseupd.o vendor/arpack/dsgets.o vendor/arpack/dsortc.o vendor/arpack/dsortr.o vendor/arpack/dstatn.o vendor/arpack/dstats.o vendor/arpack/dstqrb.o vendor/arpack/dvout.o vendor/arpack/ivout.o vendor/arpack/second.o vendor/arpack/wrap.o vendor/simpleraytracer/Color.o vendor/simpleraytracer/Light.o vendor/simpleraytracer/Point.o vendor/simpleraytracer/RIgraphRay.o vendor/simpleraytracer/Ray.o vendor/simpleraytracer/RayTracer.o vendor/simpleraytracer/RayVector.o vendor/simpleraytracer/Shape.o vendor/simpleraytracer/Sphere.o vendor/simpleraytracer/Triangle.o vendor/simpleraytracer/unit_limiter.o vendor/uuid/R.o vendor/uuid/clear.o vendor/uuid/compare.o vendor/uuid/copy.o vendor/uuid/gen_uuid.o vendor/uuid/isnull.o vendor/uuid/pack.o vendor/uuid/parse.o vendor/uuid/unpack.o vendor/uuid/unparse.o rinterface.o rinterface_extra.o rrandom.o lazyeval.o init.o cpp11.o cpprinterface.o diff --git a/src/Makevars.win b/src/Makevars.win index 13836b895bf..49db6d9f3e8 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -11,4 +11,4 @@ PKG_CPPFLAGS = -I${LIB_XML}/include/libxml2 -I${LIB_XML}/include -DLIBXML_STATIC PKG_LIBS = -L${LIB_XML}/lib -lxml2 -liconv -lz -lws2_32 -lstdc++ -L${GLPK_HOME}/lib \ -lglpk -lgmp -lgfortran -L$(LIB_GMP)/lib $(BLAS_LIBS) $(LAPACK_LIBS) -OBJECTS=core/centrality/betweenness.o core/centrality/centrality_other.o core/centrality/centralization.o core/centrality/closeness.o core/centrality/coreness.o core/centrality/prpack.o core/centrality/prpack/prpack_base_graph.o core/centrality/prpack/prpack_igraph_graph.o core/centrality/prpack/prpack_preprocessed_ge_graph.o core/centrality/prpack/prpack_preprocessed_gs_graph.o core/centrality/prpack/prpack_preprocessed_scc_graph.o core/centrality/prpack/prpack_preprocessed_schur_graph.o core/centrality/prpack/prpack_result.o core/centrality/prpack/prpack_solver.o core/centrality/prpack/prpack_utils.o core/cliques/cliquer/cliquer.o core/cliques/cliquer/cliquer_graph.o core/cliques/cliquer/reorder.o core/cliques/cliquer_wrapper.o core/cliques/cliques.o core/cliques/glet.o core/cliques/maximal_cliques.o core/community/community_misc.o core/community/edge_betweenness.o core/community/fast_modularity.o core/community/fluid.o core/community/infomap/infomap.o core/community/infomap/infomap_FlowGraph.o core/community/infomap/infomap_Greedy.o core/community/infomap/infomap_Node.o core/community/label_propagation.o core/community/leading_eigenvector.o core/community/leiden.o core/community/louvain.o core/community/modularity.o core/community/optimal_modularity.o core/community/spinglass/NetDataTypes.o core/community/spinglass/NetRoutines.o core/community/spinglass/clustertool.o core/community/spinglass/pottsmodel_2.o core/community/walktrap/walktrap.o core/community/walktrap/walktrap_communities.o core/community/walktrap/walktrap_graph.o core/community/walktrap/walktrap_heap.o core/connectivity/cohesive_blocks.o core/connectivity/components.o core/connectivity/separators.o core/constructors/adjacency.o core/constructors/atlas.o core/constructors/basic_constructors.o core/constructors/de_bruijn.o core/constructors/famous.o core/constructors/full.o core/constructors/kautz.o core/constructors/lcf.o core/constructors/linegraph.o core/constructors/prufer.o core/constructors/regular.o core/core/array.o core/core/buckets.o core/core/cutheap.o core/core/dqueue.o core/core/error.o core/core/estack.o core/core/fixed_vectorlist.o core/core/grid.o core/core/heap.o core/core/indheap.o core/core/interruption.o core/core/marked_queue.o core/core/matrix.o core/core/memory.o core/core/printing.o core/core/progress.o core/core/psumtree.o core/core/set.o core/core/sparsemat.o core/core/spmatrix.o core/core/stack.o core/core/statusbar.o core/core/strvector.o core/core/trie.o core/core/vector.o core/core/vector_ptr.o core/flow/flow.o core/flow/st-cuts.o core/games/barabasi.o core/games/callaway_traits.o core/games/citations.o core/games/correlated.o core/games/degree_sequence.o core/games/degree_sequence_vl/gengraph_box_list.o core/games/degree_sequence_vl/gengraph_degree_sequence.o core/games/degree_sequence_vl/gengraph_graph_molloy_hash.o core/games/degree_sequence_vl/gengraph_graph_molloy_optimized.o core/games/degree_sequence_vl/gengraph_mr-connected.o core/games/degree_sequence_vl/gengraph_powerlaw.o core/games/degree_sequence_vl/gengraph_random.o core/games/dotproduct.o core/games/erdos_renyi.o core/games/establishment.o core/games/forestfire.o core/games/grg.o core/games/growing_random.o core/games/islands.o core/games/k_regular.o core/games/preference.o core/games/recent_degree.o core/games/sbm.o core/games/static_fitness.o core/games/tree.o core/games/watts_strogatz.o core/graph/adjlist.o core/graph/attributes.o core/graph/basic_query.o core/graph/cattributes.o core/graph/iterators.o core/graph/type_indexededgelist.o core/graph/visitors.o core/hrg/hrg.o core/hrg/hrg_types.o core/internal/glpk_support.o core/internal/hacks.o core/internal/lsap.o core/internal/qsort.o core/internal/qsort_r.o core/internal/zeroin.o core/io/dimacs.o core/io/dl-lexer.o core/io/dl-parser.o core/io/dl.o core/io/dot.o core/io/edgelist.o core/io/gml-lexer.o core/io/gml-parser.o core/io/gml-tree.o core/io/gml.o core/io/graphdb.o core/io/graphml.o core/io/leda.o core/io/lgl-lexer.o core/io/lgl-parser.o core/io/lgl.o core/io/ncol-lexer.o core/io/ncol-parser.o core/io/ncol.o core/io/pajek-lexer.o core/io/pajek-parser.o core/io/pajek.o core/isomorphism/bliss.o core/isomorphism/bliss/defs.o core/isomorphism/bliss/graph.o core/isomorphism/bliss/heap.o core/isomorphism/bliss/orbit.o core/isomorphism/bliss/partition.o core/isomorphism/bliss/uintseqhash.o core/isomorphism/bliss/utils.o core/isomorphism/isoclasses.o core/isomorphism/isomorphism_misc.o core/isomorphism/lad.o core/isomorphism/queries.o core/isomorphism/vf2.o core/layout/circular.o core/layout/davidson_harel.o core/layout/drl/DensityGrid.o core/layout/drl/DensityGrid_3d.o core/layout/drl/drl_graph.o core/layout/drl/drl_graph_3d.o core/layout/drl/drl_layout.o core/layout/drl/drl_layout_3d.o core/layout/drl/drl_parse.o core/layout/fruchterman_reingold.o core/layout/gem.o core/layout/graphopt.o core/layout/kamada_kawai.o core/layout/large_graph.o core/layout/layout_bipartite.o core/layout/layout_grid.o core/layout/layout_random.o core/layout/mds.o core/layout/merge_dla.o core/layout/merge_grid.o core/layout/reingold_tilford.o core/layout/sugiyama.o core/linalg/arpack.o core/linalg/blas.o core/linalg/eigen.o core/linalg/lapack.o core/math/bfgs.o core/math/complex.o core/math/utils.o core/misc/bipartite.o core/misc/chordality.o core/misc/cocitation.o core/misc/coloring.o core/misc/conversion.o core/misc/degree_sequence.o core/misc/embedding.o core/misc/feedback_arc_set.o core/misc/graphicality.o core/misc/matching.o core/misc/microscopic_update.o core/misc/mixing.o core/misc/motifs.o core/misc/other.o core/misc/scan.o core/misc/sir.o core/misc/spanning_trees.o core/operators/add_edge.o core/operators/complementer.o core/operators/compose.o core/operators/connect_neighborhood.o core/operators/contract.o core/operators/difference.o core/operators/disjoint_union.o core/operators/intersection.o core/operators/misc_internal.o core/operators/permute.o core/operators/reverse.o core/operators/rewire.o core/operators/rewire_edges.o core/operators/simplify.o core/operators/subgraph.o core/operators/union.o core/paths/all_shortest_paths.o core/paths/bellman_ford.o core/paths/dijkstra.o core/paths/distances.o core/paths/eulerian.o core/paths/histogram.o core/paths/johnson.o core/paths/random_walk.o core/paths/shortest_paths.o core/paths/simple_paths.o core/paths/unweighted.o core/properties/basic_properties.o core/properties/constraint.o core/properties/convergence_degree.o core/properties/dag.o core/properties/degrees.o core/properties/girth.o core/properties/loops.o core/properties/multiplicity.o core/properties/neighborhood.o core/properties/spectral.o core/properties/trees.o core/properties/triangles.o core/random/random.o core/scg/scg.o core/scg/scg_approximate_methods.o core/scg/scg_exact_scg.o core/scg/scg_kmeans.o core/scg/scg_optimal_method.o core/scg/scg_utils.o core/version.o vendor/cs/cs_add.o vendor/cs/cs_amd.o vendor/cs/cs_chol.o vendor/cs/cs_cholsol.o vendor/cs/cs_compress.o vendor/cs/cs_counts.o vendor/cs/cs_cumsum.o vendor/cs/cs_dfs.o vendor/cs/cs_dmperm.o vendor/cs/cs_droptol.o vendor/cs/cs_dropzeros.o vendor/cs/cs_dupl.o vendor/cs/cs_entry.o vendor/cs/cs_ereach.o vendor/cs/cs_etree.o vendor/cs/cs_fkeep.o vendor/cs/cs_gaxpy.o vendor/cs/cs_happly.o vendor/cs/cs_house.o vendor/cs/cs_ipvec.o vendor/cs/cs_leaf.o vendor/cs/cs_load.o vendor/cs/cs_lsolve.o vendor/cs/cs_ltsolve.o vendor/cs/cs_lu.o vendor/cs/cs_lusol.o vendor/cs/cs_malloc.o vendor/cs/cs_maxtrans.o vendor/cs/cs_multiply.o vendor/cs/cs_norm.o vendor/cs/cs_permute.o vendor/cs/cs_pinv.o vendor/cs/cs_post.o vendor/cs/cs_print.o vendor/cs/cs_pvec.o vendor/cs/cs_qr.o vendor/cs/cs_qrsol.o vendor/cs/cs_randperm.o vendor/cs/cs_reach.o vendor/cs/cs_scatter.o vendor/cs/cs_scc.o vendor/cs/cs_schol.o vendor/cs/cs_spsolve.o vendor/cs/cs_sqr.o vendor/cs/cs_symperm.o vendor/cs/cs_tdfs.o vendor/cs/cs_transpose.o vendor/cs/cs_updown.o vendor/cs/cs_usolve.o vendor/cs/cs_util.o vendor/cs/cs_utsolve.o vendor/mini-gmp/mini-gmp.o vendor/plfit/gss.o vendor/plfit/hzeta.o vendor/plfit/kolmogorov.o vendor/plfit/lbfgs.o vendor/plfit/mt.o vendor/plfit/options.o vendor/plfit/platform.o vendor/plfit/plfit.o vendor/plfit/plfit_error.o vendor/plfit/rbinom.o vendor/plfit/sampling.o vendor/arpack/dgetv0.o vendor/arpack/dlaqrb.o vendor/arpack/dmout.o vendor/arpack/dnaitr.o vendor/arpack/dnapps.o vendor/arpack/dnaup2.o vendor/arpack/dnaupd.o vendor/arpack/dnconv.o vendor/arpack/dneigh.o vendor/arpack/dneupd.o vendor/arpack/dngets.o vendor/arpack/dsaitr.o vendor/arpack/dsapps.o vendor/arpack/dsaup2.o vendor/arpack/dsaupd.o vendor/arpack/dsconv.o vendor/arpack/dseigt.o vendor/arpack/dsesrt.o vendor/arpack/dseupd.o vendor/arpack/dsgets.o vendor/arpack/dsortc.o vendor/arpack/dsortr.o vendor/arpack/dstatn.o vendor/arpack/dstats.o vendor/arpack/dstqrb.o vendor/arpack/dvout.o vendor/arpack/ivout.o vendor/arpack/second.o vendor/arpack/wrap.o vendor/simpleraytracer/Color.o vendor/simpleraytracer/Light.o vendor/simpleraytracer/Point.o vendor/simpleraytracer/RIgraphRay.o vendor/simpleraytracer/Ray.o vendor/simpleraytracer/RayTracer.o vendor/simpleraytracer/RayVector.o vendor/simpleraytracer/Shape.o vendor/simpleraytracer/Sphere.o vendor/simpleraytracer/Triangle.o vendor/simpleraytracer/unit_limiter.o vendor/uuid/R.o vendor/uuid/clear.o vendor/uuid/compare.o vendor/uuid/copy.o vendor/uuid/gen_uuid.o vendor/uuid/isnull.o vendor/uuid/pack.o vendor/uuid/parse.o vendor/uuid/unpack.o vendor/uuid/unparse.o rinterface.o rinterface_extra.o rrandom.o lazyeval.o init.o cpp11.o cpprinterface.o +OBJECTS=libigraph.a rinterface.o rinterface_extra.o rrandom.o lazyeval.o init.o cpp11.o cpprinterface.o diff --git a/src/config.h b/src/config.h new file mode 100644 index 00000000000..fdcfb8a6771 --- /dev/null +++ b/src/config.h @@ -0,0 +1,85 @@ +/* src/config.h. Generated from config.h.in by configure. */ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `fmin' function. */ +#define HAVE_FMIN 1 + +/* Define to 1 if using the GNU Fortran compiler */ +#define HAVE_GFORTRAN 1 + +/* Define to 1 if you have the GLPK library */ +#define HAVE_GLPK 1 + +/* Define to 1 if you have the `isfinite' function. */ +#define HAVE_ISFINITE 1 + +/* Define to 1 if you have the libxml2 libraries installed */ +#define HAVE_LIBXML 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. */ +#define HAVE_LOG2 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NET_IF_DL_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define if struct sockaddr contains sa_len */ +/* #undef HAVE_SA_LEN */ + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `stpcpy' function. */ +#define HAVE_STPCPY 1 + +/* Define to 1 if you have the `strcasecmp' function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SOCKIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `_stricmp' function. */ +/* #undef HAVE__STRICMP */ + +/* We don't care about thread-local storage in R */ +#define IGRAPH_THREAD_LOCAL /**/ + +/* Define to 1 if you use the vendored mini-GMP library */ +#define INTERNAL_GMP 1 + +#define HAVE_ISFINITE 1 diff --git a/src/cpp11.cpp b/src/cpp11.cpp index 40fd1a48b35..4121333c293 100644 --- a/src/cpp11.cpp +++ b/src/cpp11.cpp @@ -1,7 +1,6 @@ // Generated by cpp11: do not edit by hand // clang-format off -#include "igraph_types.hpp" #include "cpp11/declarations.hpp" #include @@ -28,13 +27,14 @@ extern SEXP R_igraph_adjlist(SEXP, SEXP, SEXP); extern SEXP R_igraph_all_minimal_st_separators(SEXP); extern SEXP R_igraph_all_st_cuts(SEXP, SEXP, SEXP); extern SEXP R_igraph_all_st_mincuts(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_almost_equals(SEXP, SEXP, SEXP); extern SEXP R_igraph_are_connected(SEXP, SEXP, SEXP); extern SEXP R_igraph_arpack(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_arpack_unpack_complex(SEXP, SEXP, SEXP); extern SEXP R_igraph_articulation_points(SEXP); -extern SEXP R_igraph_assortativity(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_assortativity(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_assortativity_degree(SEXP, SEXP); -extern SEXP R_igraph_assortativity_nominal(SEXP, SEXP, SEXP); +extern SEXP R_igraph_assortativity_nominal(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_asymmetric_preference_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_atlas(SEXP); extern SEXP R_igraph_authority_score(SEXP, SEXP, SEXP, SEXP); @@ -46,9 +46,12 @@ extern SEXP R_igraph_avg_nearest_neighbor_degree(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_barabasi_aging_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_barabasi_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_betweenness_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_betweenness_subset(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_bfs(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_biadjacency(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_bibcoupling(SEXP, SEXP); extern SEXP R_igraph_biconnected_components(SEXP); +extern SEXP R_igraph_bipartite_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_bipartite_game_gnm(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_bipartite_game_gnp(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_bipartite_projection(SEXP, SEXP, SEXP, SEXP); @@ -65,13 +68,14 @@ extern SEXP R_igraph_centralization_degree(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_centralization_degree_tmax(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_centralization_eigenvector_centrality(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_centralization_eigenvector_centrality_tmax(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_circulant(SEXP, SEXP, SEXP); extern SEXP R_igraph_cited_type_game(SEXP, SEXP, SEXP, SEXP, SEXP); 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_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_clusters(SEXP, SEXP); +extern SEXP R_igraph_cmp_epsilon(SEXP, SEXP, SEXP); extern SEXP R_igraph_cocitation(SEXP, SEXP); extern SEXP R_igraph_cohesion(SEXP, SEXP); extern SEXP R_igraph_cohesive_blocks(SEXP); @@ -89,9 +93,11 @@ extern SEXP R_igraph_compare_communities(SEXP, SEXP, SEXP); extern SEXP R_igraph_complementer(SEXP, SEXP); extern SEXP R_igraph_compose(SEXP, SEXP, SEXP); extern SEXP R_igraph_connect_neighborhood(SEXP, SEXP, SEXP); +extern SEXP R_igraph_connected_components(SEXP, SEXP); extern SEXP R_igraph_constraint(SEXP, SEXP, SEXP); extern SEXP R_igraph_contract_vertices(SEXP, SEXP, SEXP); extern SEXP R_igraph_convex_hull(SEXP); +extern SEXP R_igraph_copy(SEXP); extern SEXP R_igraph_coreness(SEXP, SEXP); extern SEXP R_igraph_correlated_game(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_correlated_pair_game(SEXP, SEXP, SEXP, SEXP, SEXP); @@ -106,25 +112,40 @@ extern SEXP R_igraph_degree(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_degree_sequence_game(SEXP, SEXP, SEXP); extern SEXP R_igraph_delete_edges(SEXP, SEXP); extern SEXP R_igraph_delete_vertices(SEXP, SEXP); +extern SEXP R_igraph_delete_vertices_idx(SEXP, SEXP); extern SEXP R_igraph_density(SEXP, SEXP); +extern SEXP R_igraph_deterministic_optimal_imitation(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_dfs(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_diameter(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_difference(SEXP, SEXP); extern SEXP R_igraph_dim_select(SEXP); extern SEXP R_igraph_disjoint_union(SEXP); +extern SEXP R_igraph_distances(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_bellman_ford(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_dijkstra(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_dijkstra_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_floyd_warshall(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_distances_johnson(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_diversity(SEXP, SEXP, SEXP); extern SEXP R_igraph_dominator_tree(SEXP, SEXP, SEXP); extern SEXP R_igraph_dot_product_game(SEXP, SEXP); extern SEXP R_igraph_dyad_census(SEXP); +extern SEXP R_igraph_ecc(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_eccentricity(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_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); extern SEXP R_igraph_edge_disjoint_paths(SEXP, SEXP, SEXP); extern SEXP R_igraph_edges(SEXP, SEXP); extern SEXP R_igraph_eigen_adjacency(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_eigen_matrix(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_eigen_matrix_symmetric(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_eigenvector_centrality(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_empty(SEXP, SEXP); +extern SEXP R_igraph_empty_attrs(SEXP, SEXP, SEXP); extern SEXP R_igraph_erdos_renyi_game(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_es_adj(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_es_pairs(SEXP, SEXP, SEXP); @@ -132,6 +153,7 @@ extern SEXP R_igraph_es_path(SEXP, SEXP, SEXP); extern SEXP R_igraph_establishment_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_eulerian_cycle(SEXP); extern SEXP R_igraph_eulerian_path(SEXP); +extern SEXP R_igraph_even_tarjan_reduction(SEXP); extern SEXP R_igraph_extended_chordal_ring(SEXP, SEXP, SEXP); extern SEXP R_igraph_famous(SEXP); extern SEXP R_igraph_farthest_points(SEXP, SEXP, SEXP, SEXP); @@ -142,7 +164,11 @@ extern SEXP R_igraph_from_prufer(SEXP); extern SEXP R_igraph_full(SEXP, SEXP, SEXP); extern SEXP R_igraph_full_bipartite(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_full_citation(SEXP, SEXP); +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); +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_shortest_paths(SEXP, SEXP, SEXP, SEXP); @@ -150,21 +176,32 @@ extern SEXP R_igraph_get_all_shortest_paths_dijkstra(SEXP, SEXP, SEXP, SEXP, SEX extern SEXP R_igraph_get_all_simple_paths(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_all_simple_paths_pp(SEXP); extern SEXP R_igraph_get_attr_mode(SEXP, SEXP); +extern SEXP R_igraph_get_biadjacency(SEXP, SEXP); extern SEXP R_igraph_get_diameter(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_edge(SEXP, SEXP); extern SEXP R_igraph_get_edgelist(SEXP, SEXP); -extern SEXP R_igraph_get_eids(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_eids(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_graph_id(SEXP); -extern SEXP R_igraph_get_incidence(SEXP, SEXP); extern SEXP R_igraph_get_isomorphisms_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_k_shortest_paths(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_laplacian(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_laplacian_sparse(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_shortest_path(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_shortest_path_bellman_ford(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_shortest_path_dijkstra(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_get_shortest_paths(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_get_stochastic(SEXP, SEXP); -extern SEXP R_igraph_get_stochastic_sparsemat(SEXP, SEXP); +extern SEXP R_igraph_get_stochastic(SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_stochastic_sparse(SEXP, SEXP, SEXP); extern SEXP R_igraph_get_subisomorphisms_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_widest_path(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_get_widest_paths(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_getsphere(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_girth(SEXP, SEXP); extern SEXP R_igraph_global_efficiency(SEXP, SEXP, SEXP); +extern SEXP R_igraph_gomory_hu_tree(SEXP, SEXP); extern SEXP R_igraph_graph_adjacency(SEXP, SEXP); +extern SEXP R_igraph_graph_center(SEXP, SEXP); +extern SEXP R_igraph_graph_count(SEXP, SEXP); extern SEXP R_igraph_graph_version(SEXP); extern SEXP R_igraph_graphlets(SEXP, SEXP, SEXP); extern SEXP R_igraph_graphlets_candidate_basis(SEXP, SEXP); @@ -172,14 +209,20 @@ extern SEXP R_igraph_graphlets_project(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_grg_game(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_growing_random_game(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_harmonic_centrality_cutoff(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_has_attribute_table(SEXP); extern SEXP R_igraph_has_loop(SEXP); extern SEXP R_igraph_has_multiple(SEXP); +extern SEXP R_igraph_has_mutual(SEXP, SEXP); extern SEXP R_igraph_hrg_consensus(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_hrg_create(SEXP, SEXP); extern SEXP R_igraph_hrg_dendrogram(SEXP); extern SEXP R_igraph_hrg_fit(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_hrg_game(SEXP); extern SEXP R_igraph_hrg_predict(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_hrg_resize(SEXP, SEXP); +extern SEXP R_igraph_hrg_sample(SEXP); +extern SEXP R_igraph_hrg_sample_many(SEXP, SEXP); +extern SEXP R_igraph_hrg_size(SEXP); extern SEXP R_igraph_hsbm_game(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_hsbm_list_game(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_hub_score(SEXP, SEXP, SEXP, SEXP); @@ -191,20 +234,24 @@ extern SEXP R_igraph_incident_edges(SEXP, SEXP, SEXP); extern SEXP R_igraph_independence_number(SEXP); extern SEXP R_igraph_independent_vertex_sets(SEXP, SEXP, SEXP); extern SEXP R_igraph_induced_subgraph(SEXP, SEXP, SEXP); +extern SEXP R_igraph_induced_subgraph_map(SEXP, SEXP, SEXP); extern SEXP R_igraph_intersection(SEXP, SEXP); +extern SEXP R_igraph_is_acyclic(SEXP); extern SEXP R_igraph_is_bipartite(SEXP); extern SEXP R_igraph_is_chordal(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_is_connected(SEXP, SEXP); extern SEXP R_igraph_is_dag(SEXP); extern SEXP R_igraph_is_directed(SEXP); extern SEXP R_igraph_is_eulerian(SEXP); +extern SEXP R_igraph_is_forest(SEXP, SEXP); extern SEXP R_igraph_is_graphical(SEXP, SEXP, SEXP); extern SEXP R_igraph_is_loop(SEXP, SEXP); extern SEXP R_igraph_is_matching(SEXP, SEXP, SEXP); extern SEXP R_igraph_is_maximal_matching(SEXP, SEXP, SEXP); extern SEXP R_igraph_is_minimal_separator(SEXP, SEXP); extern SEXP R_igraph_is_multiple(SEXP, SEXP); -extern SEXP R_igraph_is_mutual(SEXP, SEXP); +extern SEXP R_igraph_is_mutual(SEXP, SEXP, SEXP); +extern SEXP R_igraph_is_perfect(SEXP); extern SEXP R_igraph_is_separator(SEXP, SEXP); extern SEXP R_igraph_is_simple(SEXP); extern SEXP R_igraph_is_tree(SEXP, SEXP); @@ -212,10 +259,10 @@ extern SEXP R_igraph_isoclass(SEXP); extern SEXP R_igraph_isoclass_create(SEXP, SEXP, SEXP); extern SEXP R_igraph_isoclass_subgraph(SEXP, SEXP); extern SEXP R_igraph_isomorphic(SEXP, SEXP); -extern SEXP R_igraph_isomorphic_34(SEXP, SEXP); extern SEXP R_igraph_isomorphic_bliss(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_isomorphic_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_k_regular_game(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_kary_tree(SEXP, SEXP, SEXP); extern SEXP R_igraph_kautz(SEXP, SEXP); extern SEXP R_igraph_laplacian(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_laplacian_spectral_embedding(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); @@ -246,6 +293,9 @@ extern SEXP R_igraph_layout_reingold_tilford(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_layout_sphere(SEXP); extern SEXP R_igraph_layout_star(SEXP, SEXP, SEXP); extern SEXP R_igraph_layout_sugiyama(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_umap(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_umap_3d(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_layout_umap_compute_weights(SEXP, SEXP, SEXP); extern SEXP R_igraph_lcf_vector(SEXP, SEXP, SEXP); extern SEXP R_igraph_linegraph(SEXP); extern SEXP R_igraph_list_triangles(SEXP); @@ -257,22 +307,26 @@ extern SEXP R_igraph_local_scan_1_ecount_them(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_local_scan_k_ecount(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_local_scan_k_ecount_them(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_local_scan_neighborhood_ecount(SEXP, SEXP, SEXP); +extern SEXP R_igraph_local_scan_subset_ecount(SEXP, SEXP, SEXP); extern SEXP R_igraph_make_weak_ref(SEXP, SEXP, SEXP); extern SEXP R_igraph_maxflow(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_maximal_cliques(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_maximal_cliques_count(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_maximal_cliques_file(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_maximal_cliques_hist(SEXP, SEXP, SEXP); +extern SEXP R_igraph_maximal_cliques_subset(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_maximal_independent_vertex_sets(SEXP); extern SEXP R_igraph_maximum_bipartite_matching(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_maximum_cardinality_search(SEXP); extern SEXP R_igraph_mincut(SEXP, SEXP); extern SEXP R_igraph_mincut_value(SEXP, SEXP); +extern SEXP R_igraph_minimum_cycle_basis(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_minimum_size_separators(SEXP); extern SEXP R_igraph_minimum_spanning_tree_prim(SEXP, SEXP); extern SEXP R_igraph_minimum_spanning_tree_unweighted(SEXP); extern SEXP R_igraph_modularity(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_modularity_matrix(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_moran_process(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_motifs_randesu(SEXP, SEXP, SEXP); extern SEXP R_igraph_motifs_randesu_estimate(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_motifs_randesu_no(SEXP, SEXP, SEXP); @@ -290,14 +344,17 @@ extern SEXP R_igraph_no_clusters(SEXP, SEXP); 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_preference_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_progress(SEXP, SEXP); extern SEXP R_igraph_radius(SEXP, SEXP); extern SEXP R_igraph_random_edge_walk(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_random_sample(SEXP, SEXP, SEXP); extern SEXP R_igraph_random_spanning_tree(SEXP, SEXP); -extern SEXP R_igraph_random_walk(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_random_walk(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_read_graph_dimacs(SEXP, SEXP); +extern SEXP R_igraph_read_graph_dimacs_flow(SEXP, SEXP); extern SEXP R_igraph_read_graph_dl(SEXP, SEXP); extern SEXP R_igraph_read_graph_edgelist(SEXP, SEXP, SEXP); extern SEXP R_igraph_read_graph_gml(SEXP); @@ -309,35 +366,42 @@ extern SEXP R_igraph_read_graph_pajek(SEXP); extern SEXP R_igraph_realize_degree_sequence(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_recent_degree_aging_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_reciprocity(SEXP, SEXP, SEXP); +extern SEXP R_igraph_regular_tree(SEXP, SEXP, SEXP); +extern SEXP R_igraph_residual_graph(SEXP, SEXP, SEXP); extern SEXP R_igraph_reverse_edges(SEXP, SEXP); +extern SEXP R_igraph_reverse_residual_graph(SEXP, SEXP, SEXP); extern SEXP R_igraph_rewire(SEXP, SEXP, SEXP); extern SEXP R_igraph_rewire_directed_edges(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_rewire_edges(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_ring(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_roots_for_tree_layout(SEXP, SEXP, SEXP); +extern SEXP R_igraph_roulette_wheel_imitation(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_running_mean(SEXP, SEXP); extern SEXP R_igraph_sample_dirichlet(SEXP, SEXP); extern SEXP R_igraph_sample_sphere_surface(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_sample_sphere_volume(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_sbm_game(SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_scg_adjacency(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_scg_grouping(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_scg_laplacian(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_scg_norm_eps(SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_scg_semiprojectors(SEXP, SEXP, SEXP, SEXP, SEXP); -extern SEXP R_igraph_scg_stochastic(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_set_verbose(SEXP); extern SEXP R_igraph_shortest_paths(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_similarity_dice(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_dice_es(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_dice_pairs(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_similarity_inverse_log_weighted(SEXP, SEXP, SEXP); extern SEXP R_igraph_similarity_jaccard(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_jaccard_es(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_similarity_jaccard_pairs(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_simple_interconnected_islands_game(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_simplify(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_simplify_and_colorize(SEXP); extern SEXP R_igraph_sir(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_solve_lsap(SEXP, SEXP); +extern SEXP R_igraph_spanner(SEXP, SEXP, SEXP); +extern SEXP R_igraph_sparse_adjacency(SEXP, SEXP, SEXP); +extern SEXP R_igraph_sparse_weighted_adjacency(SEXP, SEXP, SEXP); extern SEXP R_igraph_spinglass_community(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_spinglass_my_community(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_split_join_distance(SEXP, SEXP); +extern SEXP R_igraph_square_lattice(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_st_edge_connectivity(SEXP, SEXP, SEXP); extern SEXP R_igraph_st_mincut(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_st_mincut_value(SEXP, SEXP, SEXP, SEXP); @@ -345,29 +409,42 @@ extern SEXP R_igraph_st_vertex_connectivity(SEXP, SEXP, SEXP); extern SEXP R_igraph_star(SEXP, SEXP, SEXP); extern SEXP R_igraph_static_fitness_game(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_static_power_law_game(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_status(SEXP); +extern SEXP R_igraph_stochastic_imitation(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_strength(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_strerror(SEXP); extern SEXP R_igraph_subcomponent(SEXP, SEXP, SEXP); -extern SEXP R_igraph_subgraph_edges(SEXP, SEXP, SEXP); +extern SEXP R_igraph_subgraph_from_edges(SEXP, SEXP, SEXP); +extern SEXP R_igraph_subisomorphic(SEXP, SEXP); +extern SEXP R_igraph_subisomorphic_function_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_subisomorphic_lad(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_subisomorphic_vf2(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_symmetric_tree(SEXP, SEXP); extern SEXP R_igraph_to_directed(SEXP, SEXP); extern SEXP R_igraph_to_prufer(SEXP); extern SEXP R_igraph_to_undirected(SEXP, SEXP, SEXP); extern SEXP R_igraph_topological_sorting(SEXP, SEXP); +extern SEXP R_igraph_transitive_closure_dag(SEXP); extern SEXP R_igraph_transitivity_avglocal_undirected(SEXP, SEXP); extern SEXP R_igraph_transitivity_barrat(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_transitivity_local_undirected(SEXP, SEXP, SEXP); extern SEXP R_igraph_transitivity_local_undirected_all(SEXP, SEXP); extern SEXP R_igraph_transitivity_undirected(SEXP, SEXP); extern SEXP R_igraph_tree(SEXP, SEXP, SEXP); +extern SEXP R_igraph_tree_from_parent_vector(SEXP, SEXP); extern SEXP R_igraph_tree_game(SEXP, SEXP, SEXP); extern SEXP R_igraph_triad_census(SEXP); +extern SEXP R_igraph_triangular_lattice(SEXP, SEXP, SEXP); +extern SEXP R_igraph_trussness(SEXP); +extern SEXP R_igraph_turan(SEXP, SEXP); extern SEXP R_igraph_unfold_tree(SEXP, SEXP, SEXP); extern SEXP R_igraph_union(SEXP, SEXP); extern SEXP R_igraph_vcount(SEXP); +extern SEXP R_igraph_version(SEXP); extern SEXP R_igraph_vertex_coloring_greedy(SEXP, SEXP); extern SEXP R_igraph_vertex_connectivity(SEXP, SEXP); extern SEXP R_igraph_vertex_disjoint_paths(SEXP, SEXP, SEXP); +extern SEXP R_igraph_voronoi(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_vs_adj(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_vs_nei(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_walktrap_community(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP); @@ -378,6 +455,10 @@ extern SEXP R_igraph_weak_ref_value(SEXP); extern SEXP R_igraph_weighted_adjacency(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_weighted_clique_number(SEXP, SEXP); extern SEXP R_igraph_weighted_cliques(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_weighted_sparsemat(SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_wheel(SEXP, SEXP, SEXP); +extern SEXP R_igraph_widest_path_widths_dijkstra(SEXP, SEXP, SEXP, SEXP, SEXP); +extern SEXP R_igraph_widest_path_widths_floyd_warshall(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_dimacs(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_dot(SEXP, SEXP); extern SEXP R_igraph_write_graph_edgelist(SEXP, SEXP); @@ -387,7 +468,6 @@ extern SEXP R_igraph_write_graph_leda(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_lgl(SEXP, SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_ncol(SEXP, SEXP, SEXP, SEXP); extern SEXP R_igraph_write_graph_pajek(SEXP, SEXP); -extern SEXP UUID_gen(SEXP); extern SEXP make_lazy(SEXP, SEXP, SEXP); extern SEXP make_lazy_dots(SEXP, SEXP); extern SEXP promise_env_(SEXP); @@ -407,13 +487,14 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_all_minimal_st_separators", (DL_FUNC) &R_igraph_all_minimal_st_separators, 1}, {"R_igraph_all_st_cuts", (DL_FUNC) &R_igraph_all_st_cuts, 3}, {"R_igraph_all_st_mincuts", (DL_FUNC) &R_igraph_all_st_mincuts, 4}, + {"R_igraph_almost_equals", (DL_FUNC) &R_igraph_almost_equals, 3}, {"R_igraph_are_connected", (DL_FUNC) &R_igraph_are_connected, 3}, {"R_igraph_arpack", (DL_FUNC) &R_igraph_arpack, 5}, {"R_igraph_arpack_unpack_complex", (DL_FUNC) &R_igraph_arpack_unpack_complex, 3}, {"R_igraph_articulation_points", (DL_FUNC) &R_igraph_articulation_points, 1}, - {"R_igraph_assortativity", (DL_FUNC) &R_igraph_assortativity, 4}, + {"R_igraph_assortativity", (DL_FUNC) &R_igraph_assortativity, 5}, {"R_igraph_assortativity_degree", (DL_FUNC) &R_igraph_assortativity_degree, 2}, - {"R_igraph_assortativity_nominal", (DL_FUNC) &R_igraph_assortativity_nominal, 3}, + {"R_igraph_assortativity_nominal", (DL_FUNC) &R_igraph_assortativity_nominal, 4}, {"R_igraph_asymmetric_preference_game", (DL_FUNC) &R_igraph_asymmetric_preference_game, 6}, {"R_igraph_atlas", (DL_FUNC) &R_igraph_atlas, 1}, {"R_igraph_authority_score", (DL_FUNC) &R_igraph_authority_score, 4}, @@ -425,9 +506,12 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_barabasi_aging_game", (DL_FUNC) &R_igraph_barabasi_aging_game, 12}, {"R_igraph_barabasi_game", (DL_FUNC) &R_igraph_barabasi_game, 9}, {"R_igraph_betweenness_cutoff", (DL_FUNC) &R_igraph_betweenness_cutoff, 5}, + {"R_igraph_betweenness_subset", (DL_FUNC) &R_igraph_betweenness_subset, 6}, {"R_igraph_bfs", (DL_FUNC) &R_igraph_bfs, 15}, + {"R_igraph_biadjacency", (DL_FUNC) &R_igraph_biadjacency, 4}, {"R_igraph_bibcoupling", (DL_FUNC) &R_igraph_bibcoupling, 2}, {"R_igraph_biconnected_components", (DL_FUNC) &R_igraph_biconnected_components, 1}, + {"R_igraph_bipartite_game", (DL_FUNC) &R_igraph_bipartite_game, 7}, {"R_igraph_bipartite_game_gnm", (DL_FUNC) &R_igraph_bipartite_game_gnm, 5}, {"R_igraph_bipartite_game_gnp", (DL_FUNC) &R_igraph_bipartite_game_gnp, 5}, {"R_igraph_bipartite_projection", (DL_FUNC) &R_igraph_bipartite_projection, 4}, @@ -444,13 +528,14 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_centralization_degree_tmax", (DL_FUNC) &R_igraph_centralization_degree_tmax, 4}, {"R_igraph_centralization_eigenvector_centrality", (DL_FUNC) &R_igraph_centralization_eigenvector_centrality, 5}, {"R_igraph_centralization_eigenvector_centrality_tmax", (DL_FUNC) &R_igraph_centralization_eigenvector_centrality_tmax, 4}, + {"R_igraph_circulant", (DL_FUNC) &R_igraph_circulant, 3}, {"R_igraph_cited_type_game", (DL_FUNC) &R_igraph_cited_type_game, 5}, {"R_igraph_citing_cited_type_game", (DL_FUNC) &R_igraph_citing_cited_type_game, 5}, {"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_cutoff", (DL_FUNC) &R_igraph_closeness_cutoff, 6}, - {"R_igraph_clusters", (DL_FUNC) &R_igraph_clusters, 2}, + {"R_igraph_cmp_epsilon", (DL_FUNC) &R_igraph_cmp_epsilon, 3}, {"R_igraph_cocitation", (DL_FUNC) &R_igraph_cocitation, 2}, {"R_igraph_cohesion", (DL_FUNC) &R_igraph_cohesion, 2}, {"R_igraph_cohesive_blocks", (DL_FUNC) &R_igraph_cohesive_blocks, 1}, @@ -468,9 +553,11 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_complementer", (DL_FUNC) &R_igraph_complementer, 2}, {"R_igraph_compose", (DL_FUNC) &R_igraph_compose, 3}, {"R_igraph_connect_neighborhood", (DL_FUNC) &R_igraph_connect_neighborhood, 3}, + {"R_igraph_connected_components", (DL_FUNC) &R_igraph_connected_components, 2}, {"R_igraph_constraint", (DL_FUNC) &R_igraph_constraint, 3}, {"R_igraph_contract_vertices", (DL_FUNC) &R_igraph_contract_vertices, 3}, {"R_igraph_convex_hull", (DL_FUNC) &R_igraph_convex_hull, 1}, + {"R_igraph_copy", (DL_FUNC) &R_igraph_copy, 1}, {"R_igraph_coreness", (DL_FUNC) &R_igraph_coreness, 2}, {"R_igraph_correlated_game", (DL_FUNC) &R_igraph_correlated_game, 4}, {"R_igraph_correlated_pair_game", (DL_FUNC) &R_igraph_correlated_pair_game, 5}, @@ -485,25 +572,40 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_degree_sequence_game", (DL_FUNC) &R_igraph_degree_sequence_game, 3}, {"R_igraph_delete_edges", (DL_FUNC) &R_igraph_delete_edges, 2}, {"R_igraph_delete_vertices", (DL_FUNC) &R_igraph_delete_vertices, 2}, + {"R_igraph_delete_vertices_idx", (DL_FUNC) &R_igraph_delete_vertices_idx, 2}, {"R_igraph_density", (DL_FUNC) &R_igraph_density, 2}, + {"R_igraph_deterministic_optimal_imitation", (DL_FUNC) &R_igraph_deterministic_optimal_imitation, 6}, {"R_igraph_dfs", (DL_FUNC) &R_igraph_dfs, 12}, {"R_igraph_diameter", (DL_FUNC) &R_igraph_diameter, 4}, {"R_igraph_difference", (DL_FUNC) &R_igraph_difference, 2}, {"R_igraph_dim_select", (DL_FUNC) &R_igraph_dim_select, 1}, {"R_igraph_disjoint_union", (DL_FUNC) &R_igraph_disjoint_union, 1}, + {"R_igraph_distances", (DL_FUNC) &R_igraph_distances, 4}, + {"R_igraph_distances_bellman_ford", (DL_FUNC) &R_igraph_distances_bellman_ford, 5}, + {"R_igraph_distances_cutoff", (DL_FUNC) &R_igraph_distances_cutoff, 5}, + {"R_igraph_distances_dijkstra", (DL_FUNC) &R_igraph_distances_dijkstra, 5}, + {"R_igraph_distances_dijkstra_cutoff", (DL_FUNC) &R_igraph_distances_dijkstra_cutoff, 6}, + {"R_igraph_distances_floyd_warshall", (DL_FUNC) &R_igraph_distances_floyd_warshall, 6}, + {"R_igraph_distances_johnson", (DL_FUNC) &R_igraph_distances_johnson, 4}, {"R_igraph_diversity", (DL_FUNC) &R_igraph_diversity, 3}, {"R_igraph_dominator_tree", (DL_FUNC) &R_igraph_dominator_tree, 3}, {"R_igraph_dot_product_game", (DL_FUNC) &R_igraph_dot_product_game, 2}, {"R_igraph_dyad_census", (DL_FUNC) &R_igraph_dyad_census, 1}, + {"R_igraph_ecc", (DL_FUNC) &R_igraph_ecc, 5}, {"R_igraph_eccentricity", (DL_FUNC) &R_igraph_eccentricity, 3}, + {"R_igraph_eccentricity_dijkstra", (DL_FUNC) &R_igraph_eccentricity_dijkstra, 4}, {"R_igraph_ecount", (DL_FUNC) &R_igraph_ecount, 1}, {"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}, {"R_igraph_edge_disjoint_paths", (DL_FUNC) &R_igraph_edge_disjoint_paths, 3}, {"R_igraph_edges", (DL_FUNC) &R_igraph_edges, 2}, {"R_igraph_eigen_adjacency", (DL_FUNC) &R_igraph_eigen_adjacency, 4}, + {"R_igraph_eigen_matrix", (DL_FUNC) &R_igraph_eigen_matrix, 7}, + {"R_igraph_eigen_matrix_symmetric", (DL_FUNC) &R_igraph_eigen_matrix_symmetric, 7}, {"R_igraph_eigenvector_centrality", (DL_FUNC) &R_igraph_eigenvector_centrality, 5}, {"R_igraph_empty", (DL_FUNC) &R_igraph_empty, 2}, + {"R_igraph_empty_attrs", (DL_FUNC) &R_igraph_empty_attrs, 3}, {"R_igraph_erdos_renyi_game", (DL_FUNC) &R_igraph_erdos_renyi_game, 5}, {"R_igraph_es_adj", (DL_FUNC) &R_igraph_es_adj, 4}, {"R_igraph_es_pairs", (DL_FUNC) &R_igraph_es_pairs, 3}, @@ -511,6 +613,7 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_establishment_game", (DL_FUNC) &R_igraph_establishment_game, 6}, {"R_igraph_eulerian_cycle", (DL_FUNC) &R_igraph_eulerian_cycle, 1}, {"R_igraph_eulerian_path", (DL_FUNC) &R_igraph_eulerian_path, 1}, + {"R_igraph_even_tarjan_reduction", (DL_FUNC) &R_igraph_even_tarjan_reduction, 1}, {"R_igraph_extended_chordal_ring", (DL_FUNC) &R_igraph_extended_chordal_ring, 3}, {"R_igraph_famous", (DL_FUNC) &R_igraph_famous, 1}, {"R_igraph_farthest_points", (DL_FUNC) &R_igraph_farthest_points, 4}, @@ -521,7 +624,11 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_full", (DL_FUNC) &R_igraph_full, 3}, {"R_igraph_full_bipartite", (DL_FUNC) &R_igraph_full_bipartite, 4}, {"R_igraph_full_citation", (DL_FUNC) &R_igraph_full_citation, 2}, + {"R_igraph_full_multipartite", (DL_FUNC) &R_igraph_full_multipartite, 3}, + {"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, 3}, + {"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_shortest_paths", (DL_FUNC) &R_igraph_get_all_shortest_paths, 4}, @@ -529,21 +636,32 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_get_all_simple_paths", (DL_FUNC) &R_igraph_get_all_simple_paths, 5}, {"R_igraph_get_all_simple_paths_pp", (DL_FUNC) &R_igraph_get_all_simple_paths_pp, 1}, {"R_igraph_get_attr_mode", (DL_FUNC) &R_igraph_get_attr_mode, 2}, + {"R_igraph_get_biadjacency", (DL_FUNC) &R_igraph_get_biadjacency, 2}, {"R_igraph_get_diameter", (DL_FUNC) &R_igraph_get_diameter, 4}, {"R_igraph_get_edge", (DL_FUNC) &R_igraph_get_edge, 2}, {"R_igraph_get_edgelist", (DL_FUNC) &R_igraph_get_edgelist, 2}, - {"R_igraph_get_eids", (DL_FUNC) &R_igraph_get_eids, 5}, + {"R_igraph_get_eids", (DL_FUNC) &R_igraph_get_eids, 4}, {"R_igraph_get_graph_id", (DL_FUNC) &R_igraph_get_graph_id, 1}, - {"R_igraph_get_incidence", (DL_FUNC) &R_igraph_get_incidence, 2}, {"R_igraph_get_isomorphisms_vf2", (DL_FUNC) &R_igraph_get_isomorphisms_vf2, 6}, + {"R_igraph_get_k_shortest_paths", (DL_FUNC) &R_igraph_get_k_shortest_paths, 6}, + {"R_igraph_get_laplacian", (DL_FUNC) &R_igraph_get_laplacian, 4}, + {"R_igraph_get_laplacian_sparse", (DL_FUNC) &R_igraph_get_laplacian_sparse, 4}, + {"R_igraph_get_shortest_path", (DL_FUNC) &R_igraph_get_shortest_path, 4}, + {"R_igraph_get_shortest_path_bellman_ford", (DL_FUNC) &R_igraph_get_shortest_path_bellman_ford, 5}, + {"R_igraph_get_shortest_path_dijkstra", (DL_FUNC) &R_igraph_get_shortest_path_dijkstra, 5}, {"R_igraph_get_shortest_paths", (DL_FUNC) &R_igraph_get_shortest_paths, 10}, - {"R_igraph_get_stochastic", (DL_FUNC) &R_igraph_get_stochastic, 2}, - {"R_igraph_get_stochastic_sparsemat", (DL_FUNC) &R_igraph_get_stochastic_sparsemat, 2}, + {"R_igraph_get_stochastic", (DL_FUNC) &R_igraph_get_stochastic, 3}, + {"R_igraph_get_stochastic_sparse", (DL_FUNC) &R_igraph_get_stochastic_sparse, 3}, {"R_igraph_get_subisomorphisms_vf2", (DL_FUNC) &R_igraph_get_subisomorphisms_vf2, 6}, + {"R_igraph_get_widest_path", (DL_FUNC) &R_igraph_get_widest_path, 5}, + {"R_igraph_get_widest_paths", (DL_FUNC) &R_igraph_get_widest_paths, 5}, {"R_igraph_getsphere", (DL_FUNC) &R_igraph_getsphere, 8}, {"R_igraph_girth", (DL_FUNC) &R_igraph_girth, 2}, {"R_igraph_global_efficiency", (DL_FUNC) &R_igraph_global_efficiency, 3}, + {"R_igraph_gomory_hu_tree", (DL_FUNC) &R_igraph_gomory_hu_tree, 2}, {"R_igraph_graph_adjacency", (DL_FUNC) &R_igraph_graph_adjacency, 2}, + {"R_igraph_graph_center", (DL_FUNC) &R_igraph_graph_center, 2}, + {"R_igraph_graph_count", (DL_FUNC) &R_igraph_graph_count, 2}, {"R_igraph_graph_version", (DL_FUNC) &R_igraph_graph_version, 1}, {"R_igraph_graphlets", (DL_FUNC) &R_igraph_graphlets, 3}, {"R_igraph_graphlets_candidate_basis", (DL_FUNC) &R_igraph_graphlets_candidate_basis, 2}, @@ -551,14 +669,20 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_grg_game", (DL_FUNC) &R_igraph_grg_game, 4}, {"R_igraph_growing_random_game", (DL_FUNC) &R_igraph_growing_random_game, 4}, {"R_igraph_harmonic_centrality_cutoff", (DL_FUNC) &R_igraph_harmonic_centrality_cutoff, 6}, + {"R_igraph_has_attribute_table", (DL_FUNC) &R_igraph_has_attribute_table, 1}, {"R_igraph_has_loop", (DL_FUNC) &R_igraph_has_loop, 1}, {"R_igraph_has_multiple", (DL_FUNC) &R_igraph_has_multiple, 1}, + {"R_igraph_has_mutual", (DL_FUNC) &R_igraph_has_mutual, 2}, {"R_igraph_hrg_consensus", (DL_FUNC) &R_igraph_hrg_consensus, 4}, {"R_igraph_hrg_create", (DL_FUNC) &R_igraph_hrg_create, 2}, {"R_igraph_hrg_dendrogram", (DL_FUNC) &R_igraph_hrg_dendrogram, 1}, {"R_igraph_hrg_fit", (DL_FUNC) &R_igraph_hrg_fit, 4}, {"R_igraph_hrg_game", (DL_FUNC) &R_igraph_hrg_game, 1}, {"R_igraph_hrg_predict", (DL_FUNC) &R_igraph_hrg_predict, 5}, + {"R_igraph_hrg_resize", (DL_FUNC) &R_igraph_hrg_resize, 2}, + {"R_igraph_hrg_sample", (DL_FUNC) &R_igraph_hrg_sample, 1}, + {"R_igraph_hrg_sample_many", (DL_FUNC) &R_igraph_hrg_sample_many, 2}, + {"R_igraph_hrg_size", (DL_FUNC) &R_igraph_hrg_size, 1}, {"R_igraph_hsbm_game", (DL_FUNC) &R_igraph_hsbm_game, 5}, {"R_igraph_hsbm_list_game", (DL_FUNC) &R_igraph_hsbm_list_game, 5}, {"R_igraph_hub_score", (DL_FUNC) &R_igraph_hub_score, 4}, @@ -570,20 +694,24 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_independence_number", (DL_FUNC) &R_igraph_independence_number, 1}, {"R_igraph_independent_vertex_sets", (DL_FUNC) &R_igraph_independent_vertex_sets, 3}, {"R_igraph_induced_subgraph", (DL_FUNC) &R_igraph_induced_subgraph, 3}, + {"R_igraph_induced_subgraph_map", (DL_FUNC) &R_igraph_induced_subgraph_map, 3}, {"R_igraph_intersection", (DL_FUNC) &R_igraph_intersection, 2}, + {"R_igraph_is_acyclic", (DL_FUNC) &R_igraph_is_acyclic, 1}, {"R_igraph_is_bipartite", (DL_FUNC) &R_igraph_is_bipartite, 1}, {"R_igraph_is_chordal", (DL_FUNC) &R_igraph_is_chordal, 5}, {"R_igraph_is_connected", (DL_FUNC) &R_igraph_is_connected, 2}, {"R_igraph_is_dag", (DL_FUNC) &R_igraph_is_dag, 1}, {"R_igraph_is_directed", (DL_FUNC) &R_igraph_is_directed, 1}, {"R_igraph_is_eulerian", (DL_FUNC) &R_igraph_is_eulerian, 1}, + {"R_igraph_is_forest", (DL_FUNC) &R_igraph_is_forest, 2}, {"R_igraph_is_graphical", (DL_FUNC) &R_igraph_is_graphical, 3}, {"R_igraph_is_loop", (DL_FUNC) &R_igraph_is_loop, 2}, {"R_igraph_is_matching", (DL_FUNC) &R_igraph_is_matching, 3}, {"R_igraph_is_maximal_matching", (DL_FUNC) &R_igraph_is_maximal_matching, 3}, {"R_igraph_is_minimal_separator", (DL_FUNC) &R_igraph_is_minimal_separator, 2}, {"R_igraph_is_multiple", (DL_FUNC) &R_igraph_is_multiple, 2}, - {"R_igraph_is_mutual", (DL_FUNC) &R_igraph_is_mutual, 2}, + {"R_igraph_is_mutual", (DL_FUNC) &R_igraph_is_mutual, 3}, + {"R_igraph_is_perfect", (DL_FUNC) &R_igraph_is_perfect, 1}, {"R_igraph_is_separator", (DL_FUNC) &R_igraph_is_separator, 2}, {"R_igraph_is_simple", (DL_FUNC) &R_igraph_is_simple, 1}, {"R_igraph_is_tree", (DL_FUNC) &R_igraph_is_tree, 2}, @@ -591,10 +719,10 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_isoclass_create", (DL_FUNC) &R_igraph_isoclass_create, 3}, {"R_igraph_isoclass_subgraph", (DL_FUNC) &R_igraph_isoclass_subgraph, 2}, {"R_igraph_isomorphic", (DL_FUNC) &R_igraph_isomorphic, 2}, - {"R_igraph_isomorphic_34", (DL_FUNC) &R_igraph_isomorphic_34, 2}, {"R_igraph_isomorphic_bliss", (DL_FUNC) &R_igraph_isomorphic_bliss, 5}, {"R_igraph_isomorphic_vf2", (DL_FUNC) &R_igraph_isomorphic_vf2, 6}, {"R_igraph_k_regular_game", (DL_FUNC) &R_igraph_k_regular_game, 4}, + {"R_igraph_kary_tree", (DL_FUNC) &R_igraph_kary_tree, 3}, {"R_igraph_kautz", (DL_FUNC) &R_igraph_kautz, 2}, {"R_igraph_laplacian", (DL_FUNC) &R_igraph_laplacian, 4}, {"R_igraph_laplacian_spectral_embedding", (DL_FUNC) &R_igraph_laplacian_spectral_embedding, 7}, @@ -625,6 +753,9 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_layout_sphere", (DL_FUNC) &R_igraph_layout_sphere, 1}, {"R_igraph_layout_star", (DL_FUNC) &R_igraph_layout_star, 3}, {"R_igraph_layout_sugiyama", (DL_FUNC) &R_igraph_layout_sugiyama, 6}, + {"R_igraph_layout_umap", (DL_FUNC) &R_igraph_layout_umap, 7}, + {"R_igraph_layout_umap_3d", (DL_FUNC) &R_igraph_layout_umap_3d, 7}, + {"R_igraph_layout_umap_compute_weights", (DL_FUNC) &R_igraph_layout_umap_compute_weights, 3}, {"R_igraph_lcf_vector", (DL_FUNC) &R_igraph_lcf_vector, 3}, {"R_igraph_linegraph", (DL_FUNC) &R_igraph_linegraph, 1}, {"R_igraph_list_triangles", (DL_FUNC) &R_igraph_list_triangles, 1}, @@ -636,22 +767,26 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_local_scan_k_ecount", (DL_FUNC) &R_igraph_local_scan_k_ecount, 4}, {"R_igraph_local_scan_k_ecount_them", (DL_FUNC) &R_igraph_local_scan_k_ecount_them, 5}, {"R_igraph_local_scan_neighborhood_ecount", (DL_FUNC) &R_igraph_local_scan_neighborhood_ecount, 3}, + {"R_igraph_local_scan_subset_ecount", (DL_FUNC) &R_igraph_local_scan_subset_ecount, 3}, {"R_igraph_make_weak_ref", (DL_FUNC) &R_igraph_make_weak_ref, 3}, {"R_igraph_maxflow", (DL_FUNC) &R_igraph_maxflow, 4}, {"R_igraph_maximal_cliques", (DL_FUNC) &R_igraph_maximal_cliques, 4}, {"R_igraph_maximal_cliques_count", (DL_FUNC) &R_igraph_maximal_cliques_count, 4}, {"R_igraph_maximal_cliques_file", (DL_FUNC) &R_igraph_maximal_cliques_file, 5}, {"R_igraph_maximal_cliques_hist", (DL_FUNC) &R_igraph_maximal_cliques_hist, 3}, + {"R_igraph_maximal_cliques_subset", (DL_FUNC) &R_igraph_maximal_cliques_subset, 5}, {"R_igraph_maximal_independent_vertex_sets", (DL_FUNC) &R_igraph_maximal_independent_vertex_sets, 1}, {"R_igraph_maximum_bipartite_matching", (DL_FUNC) &R_igraph_maximum_bipartite_matching, 4}, {"R_igraph_maximum_cardinality_search", (DL_FUNC) &R_igraph_maximum_cardinality_search, 1}, {"R_igraph_mincut", (DL_FUNC) &R_igraph_mincut, 2}, {"R_igraph_mincut_value", (DL_FUNC) &R_igraph_mincut_value, 2}, + {"R_igraph_minimum_cycle_basis", (DL_FUNC) &R_igraph_minimum_cycle_basis, 5}, {"R_igraph_minimum_size_separators", (DL_FUNC) &R_igraph_minimum_size_separators, 1}, {"R_igraph_minimum_spanning_tree_prim", (DL_FUNC) &R_igraph_minimum_spanning_tree_prim, 2}, {"R_igraph_minimum_spanning_tree_unweighted", (DL_FUNC) &R_igraph_minimum_spanning_tree_unweighted, 1}, {"R_igraph_modularity", (DL_FUNC) &R_igraph_modularity, 5}, {"R_igraph_modularity_matrix", (DL_FUNC) &R_igraph_modularity_matrix, 4}, + {"R_igraph_moran_process", (DL_FUNC) &R_igraph_moran_process, 5}, {"R_igraph_motifs_randesu", (DL_FUNC) &R_igraph_motifs_randesu, 3}, {"R_igraph_motifs_randesu_estimate", (DL_FUNC) &R_igraph_motifs_randesu_estimate, 5}, {"R_igraph_motifs_randesu_no", (DL_FUNC) &R_igraph_motifs_randesu_no, 3}, @@ -669,14 +804,17 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_path_length_hist", (DL_FUNC) &R_igraph_path_length_hist, 2}, {"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_preference_game", (DL_FUNC) &R_igraph_preference_game, 7}, + {"R_igraph_progress", (DL_FUNC) &R_igraph_progress, 2}, {"R_igraph_radius", (DL_FUNC) &R_igraph_radius, 2}, {"R_igraph_random_edge_walk", (DL_FUNC) &R_igraph_random_edge_walk, 6}, {"R_igraph_random_sample", (DL_FUNC) &R_igraph_random_sample, 3}, {"R_igraph_random_spanning_tree", (DL_FUNC) &R_igraph_random_spanning_tree, 2}, - {"R_igraph_random_walk", (DL_FUNC) &R_igraph_random_walk, 5}, + {"R_igraph_random_walk", (DL_FUNC) &R_igraph_random_walk, 6}, {"R_igraph_read_graph_dimacs", (DL_FUNC) &R_igraph_read_graph_dimacs, 2}, + {"R_igraph_read_graph_dimacs_flow", (DL_FUNC) &R_igraph_read_graph_dimacs_flow, 2}, {"R_igraph_read_graph_dl", (DL_FUNC) &R_igraph_read_graph_dl, 2}, {"R_igraph_read_graph_edgelist", (DL_FUNC) &R_igraph_read_graph_edgelist, 3}, {"R_igraph_read_graph_gml", (DL_FUNC) &R_igraph_read_graph_gml, 1}, @@ -688,35 +826,42 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_realize_degree_sequence", (DL_FUNC) &R_igraph_realize_degree_sequence, 4}, {"R_igraph_recent_degree_aging_game", (DL_FUNC) &R_igraph_recent_degree_aging_game, 10}, {"R_igraph_reciprocity", (DL_FUNC) &R_igraph_reciprocity, 3}, + {"R_igraph_regular_tree", (DL_FUNC) &R_igraph_regular_tree, 3}, + {"R_igraph_residual_graph", (DL_FUNC) &R_igraph_residual_graph, 3}, {"R_igraph_reverse_edges", (DL_FUNC) &R_igraph_reverse_edges, 2}, + {"R_igraph_reverse_residual_graph", (DL_FUNC) &R_igraph_reverse_residual_graph, 3}, {"R_igraph_rewire", (DL_FUNC) &R_igraph_rewire, 3}, {"R_igraph_rewire_directed_edges", (DL_FUNC) &R_igraph_rewire_directed_edges, 4}, {"R_igraph_rewire_edges", (DL_FUNC) &R_igraph_rewire_edges, 4}, {"R_igraph_ring", (DL_FUNC) &R_igraph_ring, 4}, + {"R_igraph_roots_for_tree_layout", (DL_FUNC) &R_igraph_roots_for_tree_layout, 3}, + {"R_igraph_roulette_wheel_imitation", (DL_FUNC) &R_igraph_roulette_wheel_imitation, 6}, {"R_igraph_running_mean", (DL_FUNC) &R_igraph_running_mean, 2}, {"R_igraph_sample_dirichlet", (DL_FUNC) &R_igraph_sample_dirichlet, 2}, {"R_igraph_sample_sphere_surface", (DL_FUNC) &R_igraph_sample_sphere_surface, 4}, {"R_igraph_sample_sphere_volume", (DL_FUNC) &R_igraph_sample_sphere_volume, 4}, {"R_igraph_sbm_game", (DL_FUNC) &R_igraph_sbm_game, 5}, - {"R_igraph_scg_adjacency", (DL_FUNC) &R_igraph_scg_adjacency, 14}, - {"R_igraph_scg_grouping", (DL_FUNC) &R_igraph_scg_grouping, 7}, - {"R_igraph_scg_laplacian", (DL_FUNC) &R_igraph_scg_laplacian, 16}, - {"R_igraph_scg_norm_eps", (DL_FUNC) &R_igraph_scg_norm_eps, 5}, - {"R_igraph_scg_semiprojectors", (DL_FUNC) &R_igraph_scg_semiprojectors, 5}, - {"R_igraph_scg_stochastic", (DL_FUNC) &R_igraph_scg_stochastic, 17}, {"R_igraph_set_verbose", (DL_FUNC) &R_igraph_set_verbose, 1}, {"R_igraph_shortest_paths", (DL_FUNC) &R_igraph_shortest_paths, 6}, {"R_igraph_similarity_dice", (DL_FUNC) &R_igraph_similarity_dice, 4}, + {"R_igraph_similarity_dice_es", (DL_FUNC) &R_igraph_similarity_dice_es, 4}, + {"R_igraph_similarity_dice_pairs", (DL_FUNC) &R_igraph_similarity_dice_pairs, 4}, {"R_igraph_similarity_inverse_log_weighted", (DL_FUNC) &R_igraph_similarity_inverse_log_weighted, 3}, {"R_igraph_similarity_jaccard", (DL_FUNC) &R_igraph_similarity_jaccard, 4}, + {"R_igraph_similarity_jaccard_es", (DL_FUNC) &R_igraph_similarity_jaccard_es, 4}, + {"R_igraph_similarity_jaccard_pairs", (DL_FUNC) &R_igraph_similarity_jaccard_pairs, 4}, {"R_igraph_simple_interconnected_islands_game", (DL_FUNC) &R_igraph_simple_interconnected_islands_game, 4}, {"R_igraph_simplify", (DL_FUNC) &R_igraph_simplify, 4}, {"R_igraph_simplify_and_colorize", (DL_FUNC) &R_igraph_simplify_and_colorize, 1}, {"R_igraph_sir", (DL_FUNC) &R_igraph_sir, 4}, {"R_igraph_solve_lsap", (DL_FUNC) &R_igraph_solve_lsap, 2}, + {"R_igraph_spanner", (DL_FUNC) &R_igraph_spanner, 3}, + {"R_igraph_sparse_adjacency", (DL_FUNC) &R_igraph_sparse_adjacency, 3}, + {"R_igraph_sparse_weighted_adjacency", (DL_FUNC) &R_igraph_sparse_weighted_adjacency, 3}, {"R_igraph_spinglass_community", (DL_FUNC) &R_igraph_spinglass_community, 11}, {"R_igraph_spinglass_my_community", (DL_FUNC) &R_igraph_spinglass_my_community, 6}, {"R_igraph_split_join_distance", (DL_FUNC) &R_igraph_split_join_distance, 2}, + {"R_igraph_square_lattice", (DL_FUNC) &R_igraph_square_lattice, 5}, {"R_igraph_st_edge_connectivity", (DL_FUNC) &R_igraph_st_edge_connectivity, 3}, {"R_igraph_st_mincut", (DL_FUNC) &R_igraph_st_mincut, 4}, {"R_igraph_st_mincut_value", (DL_FUNC) &R_igraph_st_mincut_value, 4}, @@ -724,29 +869,42 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_star", (DL_FUNC) &R_igraph_star, 3}, {"R_igraph_static_fitness_game", (DL_FUNC) &R_igraph_static_fitness_game, 5}, {"R_igraph_static_power_law_game", (DL_FUNC) &R_igraph_static_power_law_game, 7}, + {"R_igraph_status", (DL_FUNC) &R_igraph_status, 1}, + {"R_igraph_stochastic_imitation", (DL_FUNC) &R_igraph_stochastic_imitation, 6}, {"R_igraph_strength", (DL_FUNC) &R_igraph_strength, 5}, + {"R_igraph_strerror", (DL_FUNC) &R_igraph_strerror, 1}, {"R_igraph_subcomponent", (DL_FUNC) &R_igraph_subcomponent, 3}, - {"R_igraph_subgraph_edges", (DL_FUNC) &R_igraph_subgraph_edges, 3}, + {"R_igraph_subgraph_from_edges", (DL_FUNC) &R_igraph_subgraph_from_edges, 3}, + {"R_igraph_subisomorphic", (DL_FUNC) &R_igraph_subisomorphic, 2}, + {"R_igraph_subisomorphic_function_vf2", (DL_FUNC) &R_igraph_subisomorphic_function_vf2, 7}, {"R_igraph_subisomorphic_lad", (DL_FUNC) &R_igraph_subisomorphic_lad, 7}, {"R_igraph_subisomorphic_vf2", (DL_FUNC) &R_igraph_subisomorphic_vf2, 6}, + {"R_igraph_symmetric_tree", (DL_FUNC) &R_igraph_symmetric_tree, 2}, {"R_igraph_to_directed", (DL_FUNC) &R_igraph_to_directed, 2}, {"R_igraph_to_prufer", (DL_FUNC) &R_igraph_to_prufer, 1}, {"R_igraph_to_undirected", (DL_FUNC) &R_igraph_to_undirected, 3}, {"R_igraph_topological_sorting", (DL_FUNC) &R_igraph_topological_sorting, 2}, + {"R_igraph_transitive_closure_dag", (DL_FUNC) &R_igraph_transitive_closure_dag, 1}, {"R_igraph_transitivity_avglocal_undirected", (DL_FUNC) &R_igraph_transitivity_avglocal_undirected, 2}, {"R_igraph_transitivity_barrat", (DL_FUNC) &R_igraph_transitivity_barrat, 4}, {"R_igraph_transitivity_local_undirected", (DL_FUNC) &R_igraph_transitivity_local_undirected, 3}, {"R_igraph_transitivity_local_undirected_all", (DL_FUNC) &R_igraph_transitivity_local_undirected_all, 2}, {"R_igraph_transitivity_undirected", (DL_FUNC) &R_igraph_transitivity_undirected, 2}, {"R_igraph_tree", (DL_FUNC) &R_igraph_tree, 3}, + {"R_igraph_tree_from_parent_vector", (DL_FUNC) &R_igraph_tree_from_parent_vector, 2}, {"R_igraph_tree_game", (DL_FUNC) &R_igraph_tree_game, 3}, {"R_igraph_triad_census", (DL_FUNC) &R_igraph_triad_census, 1}, + {"R_igraph_triangular_lattice", (DL_FUNC) &R_igraph_triangular_lattice, 3}, + {"R_igraph_trussness", (DL_FUNC) &R_igraph_trussness, 1}, + {"R_igraph_turan", (DL_FUNC) &R_igraph_turan, 2}, {"R_igraph_unfold_tree", (DL_FUNC) &R_igraph_unfold_tree, 3}, {"R_igraph_union", (DL_FUNC) &R_igraph_union, 2}, {"R_igraph_vcount", (DL_FUNC) &R_igraph_vcount, 1}, + {"R_igraph_version", (DL_FUNC) &R_igraph_version, 1}, {"R_igraph_vertex_coloring_greedy", (DL_FUNC) &R_igraph_vertex_coloring_greedy, 2}, {"R_igraph_vertex_connectivity", (DL_FUNC) &R_igraph_vertex_connectivity, 2}, {"R_igraph_vertex_disjoint_paths", (DL_FUNC) &R_igraph_vertex_disjoint_paths, 3}, + {"R_igraph_voronoi", (DL_FUNC) &R_igraph_voronoi, 5}, {"R_igraph_vs_adj", (DL_FUNC) &R_igraph_vs_adj, 4}, {"R_igraph_vs_nei", (DL_FUNC) &R_igraph_vs_nei, 4}, {"R_igraph_walktrap_community", (DL_FUNC) &R_igraph_walktrap_community, 6}, @@ -757,6 +915,10 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_weighted_adjacency", (DL_FUNC) &R_igraph_weighted_adjacency, 4}, {"R_igraph_weighted_clique_number", (DL_FUNC) &R_igraph_weighted_clique_number, 2}, {"R_igraph_weighted_cliques", (DL_FUNC) &R_igraph_weighted_cliques, 5}, + {"R_igraph_weighted_sparsemat", (DL_FUNC) &R_igraph_weighted_sparsemat, 4}, + {"R_igraph_wheel", (DL_FUNC) &R_igraph_wheel, 3}, + {"R_igraph_widest_path_widths_dijkstra", (DL_FUNC) &R_igraph_widest_path_widths_dijkstra, 5}, + {"R_igraph_widest_path_widths_floyd_warshall", (DL_FUNC) &R_igraph_widest_path_widths_floyd_warshall, 5}, {"R_igraph_write_graph_dimacs", (DL_FUNC) &R_igraph_write_graph_dimacs, 5}, {"R_igraph_write_graph_dot", (DL_FUNC) &R_igraph_write_graph_dot, 2}, {"R_igraph_write_graph_edgelist", (DL_FUNC) &R_igraph_write_graph_edgelist, 2}, @@ -766,7 +928,6 @@ static const R_CallMethodDef CallEntries[] = { {"R_igraph_write_graph_lgl", (DL_FUNC) &R_igraph_write_graph_lgl, 5}, {"R_igraph_write_graph_ncol", (DL_FUNC) &R_igraph_write_graph_ncol, 4}, {"R_igraph_write_graph_pajek", (DL_FUNC) &R_igraph_write_graph_pajek, 2}, - {"UUID_gen", (DL_FUNC) &UUID_gen, 1}, {"_igraph_igraph_hcass2", (DL_FUNC) &_igraph_igraph_hcass2, 3}, {"make_lazy", (DL_FUNC) &make_lazy, 3}, {"make_lazy_dots", (DL_FUNC) &make_lazy_dots, 2}, diff --git a/src/igraph_types.hpp b/src/igraph_types.hpp deleted file mode 100644 index fbdc9f1ced8..00000000000 --- a/src/igraph_types.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "igraph_types.h" \ No newline at end of file diff --git a/src/include/igraph_config.h b/src/include/igraph_config.h new file mode 100644 index 00000000000..37f82813629 --- /dev/null +++ b/src/include/igraph_config.h @@ -0,0 +1,55 @@ +/* -*- mode: C -*- */ +/* + IGraph library. + Copyright (C) 2011-2022 The igraph development team + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + +*/ + +#ifndef IGRAPH_CONFIG_H +#define IGRAPH_CONFIG_H + +#include "igraph_decls.h" + +__BEGIN_DECLS + +/** + * \define IGRAPH_INTEGER_SIZE + * + * Specifies the size of igraph's integer data type; must be one of 32 (for + * 32-bit integers) or 64 (for 64-bit integers). + */ +#define IGRAPH_INTEGER_SIZE 32 + +#define IGRAPH_DEPRECATED_ENUMVAL __attribute__ ((deprecated)) + +/** + * \define IGRAPH_BOOL_TYPE + * + * Specifies the C type to be used for igraph_bool_t. This is added here _only_ + * to support the R interface, where we want to be able to create views into + * R boolean vectors and treat them as an igraph_vector_bool_t, which requires + * us to align igraph_bool_t with R's boolean type. + * + * Any other use-case of overriding igraph's bool type is completely + * unsupported. + */ +#define IGRAPH_BOOL_TYPE bool + +__END_DECLS + +#endif diff --git a/src/include/igraph_cycles.h b/src/include/igraph_cycles.h new file mode 100644 index 00000000000..dd5870003b3 --- /dev/null +++ b/src/include/igraph_cycles.h @@ -0,0 +1,30 @@ + +#ifndef IGRAPH_CYCLES_H +#define IGRAPH_CYCLES_H + +#include "igraph_datatype.h" +#include "igraph_decls.h" +#include "igraph_error.h" +#include "igraph_types.h" +#include "igraph_vector_list.h" + +__BEGIN_DECLS + +IGRAPH_EXPORT igraph_error_t igraph_fundamental_cycles( + const igraph_t *graph, + igraph_vector_int_list_t *result, + igraph_integer_t start_vid, + igraph_integer_t bfs_cutoff, + const igraph_vector_t *weights); + +IGRAPH_EXPORT igraph_error_t igraph_minimum_cycle_basis( + const igraph_t *graph, + igraph_vector_int_list_t *result, + igraph_integer_t bfs_cutoff, + igraph_bool_t complete, + igraph_bool_t use_cycle_order, + const igraph_vector_t *weights); + +__END_DECLS + +#endif diff --git a/src/include/igraph_graph_list.h b/src/include/igraph_graph_list.h new file mode 100644 index 00000000000..7f8232621a0 --- /dev/null +++ b/src/include/igraph_graph_list.h @@ -0,0 +1,60 @@ +/* -*- mode: C -*- */ +/* + IGraph library. + Copyright (C) 2022 The igraph development team + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + +*/ + +#ifndef IGRAPH_GRAPH_LIST_H +#define IGRAPH_GRAPH_LIST_H + +#include "igraph_datatype.h" +#include "igraph_decls.h" +#include "igraph_error.h" +#include "igraph_types.h" +#include "igraph_vector.h" + +__BEGIN_DECLS + +/* -------------------------------------------------- */ +/* List of graphs */ +/* -------------------------------------------------- */ + +#define GRAPH_LIST +#define BASE_GRAPH +#define EXTRA_TYPE_FIELDS igraph_bool_t directed; +#include "igraph_pmt.h" +#include "igraph_typed_list_pmt.h" +#include "igraph_pmt_off.h" +#undef EXTRA_TYPE_FIELDS +#undef BASE_GRAPH +#undef GRAPH_LIST + +void igraph_graph_list_set_directed(igraph_graph_list_t* list, igraph_bool_t directed); + +/* -------------------------------------------------- */ +/* Helper macros */ +/* -------------------------------------------------- */ + +#define IGRAPH_GRAPH_LIST_INIT_FINALLY(v, size) \ + do { IGRAPH_CHECK(igraph_graph_list_init(v, size)); \ + IGRAPH_FINALLY(igraph_graph_list_destroy, v); } while (0) + +__END_DECLS + +#endif diff --git a/src/include/igraph_matrix_list.h b/src/include/igraph_matrix_list.h new file mode 100644 index 00000000000..1e44cf8d405 --- /dev/null +++ b/src/include/igraph_matrix_list.h @@ -0,0 +1,59 @@ +/* -*- mode: C -*- */ +/* + IGraph library. + Copyright (C) 2022 The igraph development team + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + +*/ + +#ifndef IGRAPH_MATRIX_LIST_H +#define IGRAPH_MATRIX_LIST_H + +#include "igraph_decls.h" +#include "igraph_error.h" +#include "igraph_matrix.h" +#include "igraph_types.h" + +__BEGIN_DECLS + +/* -------------------------------------------------- */ +/* Flexible list of matrices */ +/* -------------------------------------------------- */ + +/* Indicate to igraph_typed_list_pmt.h that we are going to work with _matrices_ + * of the base type, not the base type directly */ +#define MATRIX_LIST + +#define BASE_IGRAPH_REAL +#include "igraph_pmt.h" +#include "igraph_typed_list_pmt.h" +#include "igraph_pmt_off.h" +#undef BASE_IGRAPH_REAL + +#undef MATRIX_LIST + +/* -------------------------------------------------- */ +/* Helper macros */ +/* -------------------------------------------------- */ + +#define IGRAPH_MATRIX_LIST_INIT_FINALLY(v, size) \ + do { IGRAPH_CHECK(igraph_matrix_list_init(v, size)); \ + IGRAPH_FINALLY(igraph_matrix_list_destroy, v); } while (0) + +__END_DECLS + +#endif diff --git a/src/include/igraph_typed_list_pmt.h b/src/include/igraph_typed_list_pmt.h new file mode 100644 index 00000000000..20ebba392ee --- /dev/null +++ b/src/include/igraph_typed_list_pmt.h @@ -0,0 +1,119 @@ +/* -*- mode: C -*- */ +/* + IGraph library. + Copyright (C) 2021 The igraph development team + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + +*/ + +#if defined(VECTOR_LIST) + /* It was indicated that every item in a list is a vector of the base type + * so let's define ITEM_TYPE appropriately */ + #define ITEM_TYPE BASE_VECTOR +#elif defined(MATRIX_LIST) + /* It was indicated that every item in a list is a matrix of the base type + * so let's define ITEM_TYPE appropriately */ + #define ITEM_TYPE BASE_MATRIX +#else + #define ITEM_TYPE BASE +#endif + +/** + * Vector list, dealing with lists of typed vectors efficiently. + * \ingroup types + */ + +typedef struct { + ITEM_TYPE* stor_begin; + ITEM_TYPE* stor_end; + ITEM_TYPE* end; +#ifdef EXTRA_TYPE_FIELDS + EXTRA_TYPE_FIELDS +#endif +} TYPE; + +/*--------------------*/ +/* Allocation */ +/*--------------------*/ + +IGRAPH_EXPORT igraph_error_t FUNCTION(init)(TYPE* v, igraph_integer_t size); +IGRAPH_EXPORT void FUNCTION(destroy)(TYPE* v); + +/*--------------------*/ +/* Accessing elements */ +/*--------------------*/ + +IGRAPH_EXPORT ITEM_TYPE* FUNCTION(get_ptr)(const TYPE* v, igraph_integer_t pos); +IGRAPH_EXPORT void FUNCTION(set)(TYPE* v, igraph_integer_t pos, ITEM_TYPE* e); +IGRAPH_EXPORT ITEM_TYPE* FUNCTION(tail_ptr)(const TYPE *v); + +/*-----------------*/ +/* List properties */ +/*-----------------*/ + +IGRAPH_EXPORT igraph_integer_t FUNCTION(capacity)(const TYPE* v); +IGRAPH_EXPORT igraph_bool_t FUNCTION(empty)(const TYPE* v); +IGRAPH_EXPORT igraph_integer_t FUNCTION(size)(const TYPE* v); + +/*------------------------*/ +/* Resizing operations */ +/*------------------------*/ + +IGRAPH_EXPORT void FUNCTION(clear)(TYPE* v); +IGRAPH_EXPORT igraph_error_t FUNCTION(reserve)(TYPE* v, igraph_integer_t capacity); +IGRAPH_EXPORT igraph_error_t FUNCTION(resize)(TYPE* v, igraph_integer_t new_size); + +/*------------------------*/ +/* Adding/removing items */ +/*------------------------*/ + +IGRAPH_EXPORT void FUNCTION(discard)(TYPE* v, igraph_integer_t index); +IGRAPH_EXPORT void FUNCTION(discard_back)(TYPE* v); +IGRAPH_EXPORT void FUNCTION(discard_fast)(TYPE* v, igraph_integer_t index); +IGRAPH_EXPORT igraph_error_t FUNCTION(insert)(TYPE* v, igraph_integer_t pos, ITEM_TYPE* e); +IGRAPH_EXPORT igraph_error_t FUNCTION(insert_copy)(TYPE* v, igraph_integer_t pos, const ITEM_TYPE* e); +IGRAPH_EXPORT igraph_error_t FUNCTION(insert_new)(TYPE* v, igraph_integer_t pos, ITEM_TYPE** result); +IGRAPH_EXPORT igraph_error_t FUNCTION(push_back)(TYPE* v, ITEM_TYPE* e); +IGRAPH_EXPORT igraph_error_t FUNCTION(push_back_copy)(TYPE* v, const ITEM_TYPE* e); +IGRAPH_EXPORT igraph_error_t FUNCTION(push_back_new)(TYPE* v, ITEM_TYPE** result); +IGRAPH_EXPORT ITEM_TYPE FUNCTION(pop_back)(TYPE* v); +IGRAPH_EXPORT igraph_error_t FUNCTION(remove)(TYPE* v, igraph_integer_t index, ITEM_TYPE* e); +IGRAPH_EXPORT igraph_error_t FUNCTION(remove_fast)(TYPE* v, igraph_integer_t index, ITEM_TYPE* e); +IGRAPH_EXPORT void FUNCTION(replace)(TYPE* v, igraph_integer_t pos, ITEM_TYPE* e); +IGRAPH_EXPORT void FUNCTION(remove_consecutive_duplicates)(TYPE *v, igraph_bool_t (*eq)(const ITEM_TYPE*, const ITEM_TYPE*)); + +/*------------------*/ +/* Exchanging items */ +/*------------------*/ + +IGRAPH_EXPORT igraph_error_t FUNCTION(permute)(TYPE *v, const igraph_vector_int_t *index); +IGRAPH_EXPORT igraph_error_t FUNCTION(reverse)(TYPE *v); +IGRAPH_EXPORT igraph_error_t FUNCTION(swap)(TYPE *v1, TYPE *v2); +IGRAPH_EXPORT igraph_error_t FUNCTION(swap_elements)(TYPE* v, igraph_integer_t i, igraph_integer_t j); + +/*-----------*/ +/* Sorting */ +/*-----------*/ + +IGRAPH_EXPORT void FUNCTION(sort)( + TYPE *v, int (*cmp)(const ITEM_TYPE*, const ITEM_TYPE*)); +IGRAPH_EXPORT igraph_error_t FUNCTION(sort_ind)( + TYPE *v, igraph_vector_int_t *ind, + int (*cmp)(const ITEM_TYPE*, const ITEM_TYPE*) +); + +#undef ITEM_TYPE diff --git a/src/include/igraph_vector_list.h b/src/include/igraph_vector_list.h new file mode 100644 index 00000000000..f1d299dc948 --- /dev/null +++ b/src/include/igraph_vector_list.h @@ -0,0 +1,73 @@ +/* -*- mode: C -*- */ +/* + IGraph library. + Copyright (C) 2022 The igraph development team + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA + +*/ + +#ifndef IGRAPH_VECTOR_LIST_H +#define IGRAPH_VECTOR_LIST_H + +#include "igraph_decls.h" +#include "igraph_types.h" +#include "igraph_vector.h" + +__BEGIN_DECLS + +/* -------------------------------------------------- */ +/* Flexible list of vectors */ +/* -------------------------------------------------- */ + +/* Indicate to igraph_typed_list_pmt.h that we are going to work with _vectors_ + * of the base type, not the base type directly */ +#define VECTOR_LIST + +#define BASE_IGRAPH_REAL +#include "igraph_pmt.h" +#include "igraph_typed_list_pmt.h" +#include "igraph_pmt_off.h" +#undef BASE_IGRAPH_REAL + +#define BASE_INT +#include "igraph_pmt.h" +#include "igraph_typed_list_pmt.h" +#include "igraph_pmt_off.h" +#undef BASE_INT + +#undef VECTOR_LIST + +/* -------------------------------------------------- */ +/* Helper macros */ +/* -------------------------------------------------- */ + +#define IGRAPH_VECTOR_LIST_INIT_FINALLY(v, size) \ + do { IGRAPH_CHECK(igraph_vector_list_init(v, size)); \ + IGRAPH_FINALLY(igraph_vector_list_destroy, v); } while (0) +#define IGRAPH_VECTOR_BOOL_LIST_INIT_FINALLY(v, size) \ + do { IGRAPH_CHECK(igraph_vector_bool_list_init(v, size)); \ + IGRAPH_FINALLY(igraph_vector_bool_list_destroy, v); } while (0) +#define IGRAPH_VECTOR_CHAR_LIST_INIT_FINALLY(v, size) \ + do { IGRAPH_CHECK(igraph_vector_char_list_init(v, size)); \ + IGRAPH_FINALLY(igraph_vector_char_list_destroy, v); } while (0) +#define IGRAPH_VECTOR_INT_LIST_INIT_FINALLY(v, size) \ + do { IGRAPH_CHECK(igraph_vector_int_list_init(v, size)); \ + IGRAPH_FINALLY(igraph_vector_int_list_destroy, v); } while (0) + +__END_DECLS + +#endif diff --git a/src/rinterface.c b/src/rinterface.c index d8e60f655b3..67120336511 100644 --- a/src/rinterface.c +++ b/src/rinterface.c @@ -22,7 +22,7 @@ */ #include "igraph.h" -#include "graph/neighbors.h" +#include "igraph_neighborhood.h" #include "config.h" @@ -55,25 +55,24 @@ SEXP R_igraph_vector_to_SEXP(const igraph_vector_t *v); SEXP R_igraph_vector_int_to_SEXP(const igraph_vector_int_t *v); SEXP R_igraph_vector_int_to_SEXPp1(const igraph_vector_int_t *v); SEXP R_igraph_vector_bool_to_SEXP(const igraph_vector_bool_t *v); -SEXP R_igraph_vector_long_to_SEXP(const igraph_vector_long_t *v); SEXP R_igraph_vector_complex_to_SEXP(const igraph_vector_complex_t* v); SEXP R_igraph_0orvector_to_SEXP(const igraph_vector_t *v); +SEXP R_igraph_0orvector_int_to_SEXP(const igraph_vector_int_t *v); SEXP R_igraph_0orvector_bool_to_SEXP(const igraph_vector_bool_t *v); -SEXP R_igraph_0orvector_long_to_SEXP(const igraph_vector_long_t *v); SEXP R_igraph_0orvector_complex_to_SEXP(const igraph_vector_complex_t *v); SEXP R_igraph_matrix_to_SEXP(const igraph_matrix_t *m); +SEXP R_igraph_matrix_int_to_SEXP(const igraph_matrix_int_t *m); SEXP R_igraph_matrix_complex_to_SEXP(const igraph_matrix_complex_t *m); SEXP R_igraph_0ormatrix_complex_to_SEXP(const igraph_matrix_complex_t *m); SEXP R_igraph_strvector_to_SEXP(const igraph_strvector_t *m); SEXP R_igraph_to_SEXP(const igraph_t *graph); SEXP R_igraph_vectorlist_to_SEXP(const igraph_vector_ptr_t *ptr); -SEXP R_igraph_vectorlist_int_to_SEXP(const igraph_vector_ptr_t *ptr); -void R_igraph_vectorlist_int_destroy(igraph_vector_ptr_t *ptr); +SEXP R_igraph_vector_int_list_to_SEXP(const igraph_vector_int_list_t *list); SEXP R_igraph_0orvectorlist_to_SEXP(const igraph_vector_ptr_t *ptr); void R_igraph_vectorlist_destroy(igraph_vector_ptr_t *ptr); SEXP R_igraph_matrixlist_to_SEXP(const igraph_vector_ptr_t *ptr); void R_igraph_matrixlist_destroy(igraph_vector_ptr_t *ptr); -SEXP R_igraph_graphlist_to_SEXP(const igraph_vector_ptr_t *ptr); +SEXP R_igraph_graphlist_to_SEXP(const igraph_graph_list_t *list); void R_igraph_graphlist_destroy(igraph_vector_ptr_t *ptr); SEXP R_igraph_hrg_to_SEXP(const igraph_hrg_t *hrg); SEXP R_igraph_plfit_result_to_SEXP(const igraph_plfit_result_t *plfit); @@ -87,7 +86,9 @@ int R_igraph_SEXP_to_strvector(SEXP rval, igraph_strvector_t *sv); int R_igraph_SEXP_to_strvector_copy(SEXP rval, igraph_strvector_t *sv); int R_SEXP_to_vector(SEXP sv, igraph_vector_t *v); int R_SEXP_to_vector_copy(SEXP sv, igraph_vector_t *v); +int R_SEXP_to_vector_int_copy(SEXP sv, igraph_vector_int_t *v); int R_SEXP_to_matrix(SEXP pakl, igraph_matrix_t *akl); +int R_SEXP_to_matrix_int(SEXP pakl, igraph_matrix_int_t *akl); int R_SEXP_to_matrix_complex(SEXP pakl, igraph_matrix_complex_t *akl); int R_SEXP_to_igraph_matrix_copy(SEXP pakl, igraph_matrix_t *akl); int R_SEXP_to_igraph(SEXP graph, igraph_t *res); @@ -97,14 +98,13 @@ int R_SEXP_to_igraph_es(SEXP rit, igraph_t *graph, igraph_es_t *it); int R_SEXP_to_igraph_adjlist(SEXP vectorlist, igraph_adjlist_t *ptr); int R_igraph_SEXP_to_0orvectorlist(SEXP vectorlist, igraph_vector_ptr_t *ptr); -int R_igraph_SEXP_to_vectorlist(SEXP vectorlist, igraph_vector_ptr_t *ptr); -int R_igraph_SEXP_to_vectorlist_int(SEXP vectorlist, - igraph_vector_ptr_t *ptr); -int R_igraph_SEXP_to_matrixlist(SEXP matrixlist, igraph_vector_ptr_t *ptr); +int R_igraph_SEXP_to_vectorlist(SEXP vectorlist, igraph_vector_list_t *list); +int R_igraph_SEXP_to_vector_int_list(SEXP vectorlist, + igraph_vector_int_list_t *list); +int R_igraph_SEXP_to_matrixlist(SEXP matrixlist, igraph_matrix_list_t *list); int R_SEXP_to_vector_bool(SEXP sv, igraph_vector_bool_t *v); int R_SEXP_to_vector_bool_copy(SEXP sv, igraph_vector_bool_t *v); int R_SEXP_to_vector_int(SEXP sv, igraph_vector_int_t *v); -int R_SEXP_to_vector_long_copy(SEXP sv, igraph_vector_long_t *v); int R_SEXP_to_hrg(SEXP shrg, igraph_hrg_t *hrg); int R_SEXP_to_hrg_copy(SEXP shrg, igraph_hrg_t *hrg); int R_SEXP_to_sparsemat(SEXP pakl, igraph_sparsemat_t *akl); @@ -114,11 +114,11 @@ int R_SEXP_to_attr_comb(SEXP input, igraph_attribute_combination_t *comb); SEXP R_igraph_bliss_info_to_SEXP(const igraph_bliss_info_t *info); int R_SEXP_to_igraph_eigen_which(SEXP in, igraph_eigen_which_t *out); int R_SEXP_to_igraph_arpack_options(SEXP in, igraph_arpack_options_t *opt); -SEXP R_igraph_vector_long_to_SEXPp1(const igraph_vector_long_t *v); SEXP R_igraph_vectorlist_to_SEXP_p1(const igraph_vector_ptr_t *ptr); -SEXP R_igraph_0orvector_to_SEXPp1(const igraph_vector_t *v); -SEXP R_igraph_0ormatrix_to_SEXP(const igraph_matrix_t *m); +SEXP R_igraph_0orvector_int_to_SEXPp1(const igraph_vector_int_t *v); +SEXP R_igraph_0ormatrix_int_to_SEXP(const igraph_matrix_t *m); SEXP R_igraph_vector_to_SEXPp1(const igraph_vector_t *v); +SEXP R_igraph_vector_int_to_SEXPp1(const igraph_vector_int_t *v); SEXP R_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt); /***********************************************/ @@ -154,103 +154,122 @@ SEXP R_igraph_empty(SEXP n, SEXP directed) { } /*-------------------------------------------/ -/ igraph_vcount / +/ igraph_copy / /-------------------------------------------*/ -SEXP R_igraph_vcount(SEXP graph) { +SEXP R_igraph_copy(SEXP from) { /* Declarations */ - igraph_t c_graph; - igraph_integer_t c_result; + igraph_t c_to; + igraph_t c_from; + SEXP to; + SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); + R_SEXP_to_igraph(from, &c_from); /* Call igraph */ - c_result=igraph_vcount(&c_graph); + IGRAPH_R_CHECK(igraph_copy(&c_to, &c_from)); /* Convert output */ - - PROTECT(r_result=NEW_INTEGER(1)); - INTEGER(r_result)[0]=c_result; + IGRAPH_FINALLY(igraph_destroy, &c_to); + PROTECT(to=R_igraph_to_SEXP(&c_to)); + igraph_destroy(&c_to); + IGRAPH_FINALLY_CLEAN(1); + r_result = to; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_full_citation / +/ igraph_delete_vertices_idx / /-------------------------------------------*/ -SEXP R_igraph_full_citation(SEXP n, SEXP directed) { +SEXP R_igraph_delete_vertices_idx(SEXP graph, SEXP vertices) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_n; - igraph_bool_t c_directed; - SEXP graph; + igraph_vs_t c_vertices; + igraph_vector_int_t c_idx; + igraph_vector_int_t c_invidx; + SEXP idx; + SEXP invidx; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - c_n=INTEGER(n)[0]; - c_directed=LOGICAL(directed)[0]; + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + if (0 != igraph_vector_int_init(&c_idx, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_idx); + if (0 != igraph_vector_int_init(&c_invidx, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_invidx); /* Call igraph */ - IGRAPH_R_CHECK(igraph_full_citation(&c_graph, c_n, c_directed)); + IGRAPH_R_CHECK(igraph_delete_vertices_idx(&c_graph, c_vertices, &c_idx, &c_invidx)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + PROTECT(idx=R_igraph_vector_int_to_SEXP(&c_idx)); + igraph_vector_int_destroy(&c_idx); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(invidx=R_igraph_vector_int_to_SEXP(&c_invidx)); + igraph_vector_int_destroy(&c_invidx); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, idx); + SET_VECTOR_ELT(r_result, 2, invidx); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("idx")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("invidx")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_extended_chordal_ring / +/ igraph_vcount / /-------------------------------------------*/ -SEXP R_igraph_extended_chordal_ring(SEXP nodes, SEXP W, SEXP directed) { +SEXP R_igraph_vcount(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_nodes; - igraph_matrix_t c_W; - igraph_bool_t c_directed; - SEXP graph; - + igraph_integer_t c_result; SEXP r_result; /* Convert input */ - c_nodes=INTEGER(nodes)[0]; - R_SEXP_to_matrix(W, &c_W); - c_directed=LOGICAL(directed)[0]; + R_SEXP_to_igraph(graph, &c_graph); /* Call igraph */ - IGRAPH_R_CHECK(igraph_extended_chordal_ring(&c_graph, c_nodes, &c_W, c_directed)); + c_result=igraph_vcount(&c_graph); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + + PROTECT(r_result=NEW_INTEGER(1)); + INTEGER(r_result)[0]=c_result; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_lcf_vector / +/ igraph_empty_attrs / /-------------------------------------------*/ -SEXP R_igraph_lcf_vector(SEXP n, SEXP shifts, SEXP repeats) { +SEXP R_igraph_empty_attrs(SEXP n, SEXP directed) { /* Declarations */ igraph_t c_graph; igraph_integer_t c_n; - igraph_vector_t c_shifts; - igraph_integer_t c_repeats; + igraph_bool_t c_directed; + SEXP graph; SEXP r_result; /* Convert input */ c_n=INTEGER(n)[0]; - R_SEXP_to_vector(shifts, &c_shifts); - c_repeats=INTEGER(repeats)[0]; + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_lcf_vector(&c_graph, c_n, &c_shifts, c_repeats)); + IGRAPH_R_CHECK(igraph_empty_attrs(&c_graph, c_n, c_directed, 0)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -264,64 +283,58 @@ SEXP R_igraph_lcf_vector(SEXP n, SEXP shifts, SEXP repeats) { } /*-------------------------------------------/ -/ igraph_adjlist / +/ igraph_get_all_eids_between / /-------------------------------------------*/ -SEXP R_igraph_adjlist(SEXP adjlist, SEXP mode, SEXP duplicate) { +SEXP R_igraph_get_all_eids_between(SEXP graph, SEXP from, SEXP to, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_adjlist_t c_adjlist; - igraph_neimode_t c_mode; - igraph_bool_t c_duplicate; - SEXP graph; + igraph_vector_int_t c_eids; + igraph_integer_t c_from; + igraph_integer_t c_to; + igraph_bool_t c_directed; + SEXP eids; SEXP r_result; /* Convert input */ - if (0 != R_SEXP_to_igraph_adjlist(adjlist, &c_adjlist)) { + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_eids, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_duplicate=LOGICAL(duplicate)[0]; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_eids); + c_from = (igraph_integer_t) REAL(from)[0]; + c_to = (igraph_integer_t) REAL(to)[0]; + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_adjlist(&c_graph, &c_adjlist, c_mode, c_duplicate)); + IGRAPH_R_CHECK(igraph_get_all_eids_between(&c_graph, &c_eids, c_from, c_to, c_directed)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); + PROTECT(eids=R_igraph_vector_int_to_SEXP(&c_eids)); + igraph_vector_int_destroy(&c_eids); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + r_result = eids; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_full_bipartite / +/ igraph_sparse_adjacency / /-------------------------------------------*/ -SEXP R_igraph_full_bipartite(SEXP n1, SEXP n2, SEXP directed, SEXP mode) { +SEXP R_igraph_sparse_adjacency(SEXP adjmatrix, SEXP mode, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_integer_t c_n1; - igraph_integer_t c_n2; - igraph_bool_t c_directed; - igraph_neimode_t c_mode; + igraph_sparsemat_t c_adjmatrix; + igraph_adjacency_t c_mode; + igraph_loops_t c_loops; SEXP graph; - SEXP types; SEXP r_result, r_names; /* Convert input */ - if (0 != igraph_vector_bool_init(&c_types, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); - types=R_GlobalEnv; /* hack to have a non-NULL value */ - c_n1=INTEGER(n1)[0]; - c_n2=INTEGER(n2)[0]; - c_directed=LOGICAL(directed)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + R_SEXP_to_sparsemat(adjmatrix, &c_adjmatrix); + c_mode = (igraph_adjacency_t) Rf_asInteger(mode); + c_loops = (igraph_loops_t) Rf_asInteger(loops); /* Call igraph */ - IGRAPH_R_CHECK(igraph_full_bipartite(&c_graph, (Rf_isNull(types) ? 0 : &c_types), c_n1, c_n2, c_directed, c_mode)); + IGRAPH_R_CHECK(igraph_sparse_adjacency(&c_graph, &c_adjmatrix, c_mode, c_loops)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); @@ -330,13 +343,13 @@ SEXP R_igraph_full_bipartite(SEXP n1, SEXP n2, SEXP directed, SEXP mode) { PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(types=R_igraph_0orvector_bool_to_SEXP(&c_types)); - igraph_vector_bool_destroy(&c_types); + PROTECT(adjmatrix=R_igraph_sparsemat_to_SEXP(&c_adjmatrix)); + igraph_sparsemat_destroy(&c_adjmatrix); IGRAPH_FINALLY_CLEAN(1); SET_VECTOR_ELT(r_result, 0, graph); - SET_VECTOR_ELT(r_result, 1, types); + SET_VECTOR_ELT(r_result, 1, adjmatrix); SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("adjmatrix")); SET_NAMES(r_result, r_names); UNPROTECT(3); @@ -345,175 +358,142 @@ SEXP R_igraph_full_bipartite(SEXP n1, SEXP n2, SEXP directed, SEXP mode) { } /*-------------------------------------------/ -/ igraph_realize_degree_sequence / +/ igraph_sparse_weighted_adjacency / /-------------------------------------------*/ -SEXP R_igraph_realize_degree_sequence(SEXP out_deg, SEXP in_deg, SEXP allowed_edge_types, SEXP method) { +SEXP R_igraph_sparse_weighted_adjacency(SEXP adjmatrix, SEXP mode, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_out_deg; - igraph_vector_t c_in_deg; - igraph_edge_type_sw_t c_allowed_edge_types; - igraph_realize_degseq_t c_method; + igraph_sparsemat_t c_adjmatrix; + igraph_adjacency_t c_mode; + igraph_vector_t c_weights; + igraph_loops_t c_loops; SEXP graph; + SEXP weights; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_vector(out_deg, &c_out_deg); - if (!Rf_isNull(in_deg)) { R_SEXP_to_vector(in_deg, &c_in_deg); } - c_allowed_edge_types = (igraph_edge_type_sw_t) Rf_asInteger(allowed_edge_types); - c_method = (igraph_realize_degseq_t) Rf_asInteger(method); + R_SEXP_to_sparsemat(adjmatrix, &c_adjmatrix); + c_mode = (igraph_adjacency_t) Rf_asInteger(mode); + if (0 != igraph_vector_init(&c_weights, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_weights); + weights=R_GlobalEnv; /* hack to have a non-NULL value */ + c_loops = (igraph_loops_t) Rf_asInteger(loops); /* Call igraph */ - IGRAPH_R_CHECK(igraph_realize_degree_sequence(&c_graph, &c_out_deg, (Rf_isNull(in_deg) ? 0 : &c_in_deg), c_allowed_edge_types, c_method)); + IGRAPH_R_CHECK(igraph_sparse_weighted_adjacency(&c_graph, &c_adjmatrix, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_loops)); /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + PROTECT(adjmatrix=R_igraph_sparsemat_to_SEXP(&c_adjmatrix)); + igraph_sparsemat_destroy(&c_adjmatrix); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(weights=R_igraph_0orvector_to_SEXP(&c_weights)); + igraph_vector_destroy(&c_weights); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, adjmatrix); + SET_VECTOR_ELT(r_result, 2, weights); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("adjmatrix")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("weights")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_preference_game / +/ igraph_wheel / /-------------------------------------------*/ -SEXP R_igraph_preference_game(SEXP nodes, SEXP types, SEXP type_dist, SEXP fixed_sizes, SEXP pref_matrix, SEXP directed, SEXP loops) { +SEXP R_igraph_wheel(SEXP n, SEXP mode, SEXP center) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_nodes; - igraph_integer_t c_types; - igraph_vector_t c_type_dist; - igraph_bool_t c_fixed_sizes; - igraph_matrix_t c_pref_matrix; - igraph_vector_t c_node_type_vec; - igraph_bool_t c_directed; - igraph_bool_t c_loops; + igraph_integer_t c_n; + igraph_wheel_mode_t c_mode; + igraph_integer_t c_center; SEXP graph; - SEXP node_type_vec; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - c_nodes=INTEGER(nodes)[0]; - c_types=INTEGER(types)[0]; - R_SEXP_to_vector(type_dist, &c_type_dist); - c_fixed_sizes=LOGICAL(fixed_sizes)[0]; - R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); - if (0 != igraph_vector_init(&c_node_type_vec, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_node_type_vec); - c_directed=LOGICAL(directed)[0]; - c_loops=LOGICAL(loops)[0]; + c_n=INTEGER(n)[0]; + c_mode = (igraph_wheel_mode_t) Rf_asInteger(mode); + c_center=INTEGER(center)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_preference_game(&c_graph, c_nodes, c_types, &c_type_dist, c_fixed_sizes, &c_pref_matrix, &c_node_type_vec, c_directed, c_loops)); + IGRAPH_R_CHECK(igraph_wheel(&c_graph, c_n, c_mode, c_center)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(node_type_vec=R_igraph_vector_to_SEXP(&c_node_type_vec)); - igraph_vector_destroy(&c_node_type_vec); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, graph); - SET_VECTOR_ELT(r_result, 1, node_type_vec); - SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("node_type_vec")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_asymmetric_preference_game / +/ igraph_square_lattice / /-------------------------------------------*/ -SEXP R_igraph_asymmetric_preference_game(SEXP nodes, SEXP out_types, SEXP in_types, SEXP type_dist_matrix, SEXP pref_matrix, SEXP loops) { +SEXP R_igraph_square_lattice(SEXP dimvector, SEXP nei, SEXP directed, SEXP mutual, SEXP periodic) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_nodes; - igraph_integer_t c_out_types; - igraph_integer_t c_in_types; - igraph_matrix_t c_type_dist_matrix; - igraph_matrix_t c_pref_matrix; - igraph_vector_t c_node_type_in_vec; - igraph_vector_t c_node_type_out_vec; - igraph_bool_t c_loops; + igraph_vector_int_t c_dimvector; + igraph_integer_t c_nei; + igraph_bool_t c_directed; + igraph_bool_t c_mutual; + igraph_vector_bool_t c_periodic; SEXP graph; - SEXP node_type_in_vec; - SEXP node_type_out_vec; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - c_nodes=INTEGER(nodes)[0]; - c_out_types=INTEGER(out_types)[0]; - c_in_types=INTEGER(in_types)[0]; - R_SEXP_to_matrix(type_dist_matrix, &c_type_dist_matrix); - R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); - if (0 != igraph_vector_init(&c_node_type_in_vec, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_node_type_in_vec); - if (0 != igraph_vector_init(&c_node_type_out_vec, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_node_type_out_vec); - c_loops=LOGICAL(loops)[0]; + R_SEXP_to_vector_int(dimvector, &c_dimvector); + c_nei=INTEGER(nei)[0]; + c_directed=LOGICAL(directed)[0]; + c_mutual=LOGICAL(mutual)[0]; + R_SEXP_to_vector_bool(periodic, &c_periodic); /* Call igraph */ - IGRAPH_R_CHECK(igraph_asymmetric_preference_game(&c_graph, c_nodes, c_out_types, c_in_types, &c_type_dist_matrix, &c_pref_matrix, &c_node_type_in_vec, &c_node_type_out_vec, c_loops)); + IGRAPH_R_CHECK(igraph_square_lattice(&c_graph, &c_dimvector, c_nei, c_directed, c_mutual, &c_periodic)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(node_type_in_vec=R_igraph_vector_to_SEXP(&c_node_type_in_vec)); - igraph_vector_destroy(&c_node_type_in_vec); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(node_type_out_vec=R_igraph_vector_to_SEXP(&c_node_type_out_vec)); - igraph_vector_destroy(&c_node_type_out_vec); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, graph); - SET_VECTOR_ELT(r_result, 1, node_type_in_vec); - SET_VECTOR_ELT(r_result, 2, node_type_out_vec); - SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("node_type_in_vec")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("node_type_out_vec")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_rewire_edges / +/ igraph_triangular_lattice / /-------------------------------------------*/ -SEXP R_igraph_rewire_edges(SEXP graph, SEXP prob, SEXP loops, SEXP multiple) { +SEXP R_igraph_triangular_lattice(SEXP dimvector, SEXP directed, SEXP mutual) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_prob; - igraph_bool_t c_loops; - igraph_bool_t c_multiple; + igraph_vector_int_t c_dimvector; + igraph_bool_t c_directed; + igraph_bool_t c_mutual; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph_copy(graph, &c_graph); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - c_prob=REAL(prob)[0]; - c_loops=LOGICAL(loops)[0]; - c_multiple=LOGICAL(multiple)[0]; + R_SEXP_to_vector_int(dimvector, &c_dimvector); + c_directed=LOGICAL(directed)[0]; + c_mutual=LOGICAL(mutual)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_rewire_edges(&c_graph, c_prob, c_loops, c_multiple)); + IGRAPH_R_CHECK(igraph_triangular_lattice(&c_graph, &c_dimvector, c_directed, c_mutual)); /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); @@ -524,26 +504,26 @@ SEXP R_igraph_rewire_edges(SEXP graph, SEXP prob, SEXP loops, SEXP multiple) { } /*-------------------------------------------/ -/ igraph_rewire_directed_edges / +/ igraph_kary_tree / /-------------------------------------------*/ -SEXP R_igraph_rewire_directed_edges(SEXP graph, SEXP prob, SEXP loops, SEXP mode) { +SEXP R_igraph_kary_tree(SEXP n, SEXP children, SEXP type) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_prob; - igraph_bool_t c_loops; - igraph_neimode_t c_mode; + igraph_integer_t c_n; + igraph_integer_t c_children; + igraph_tree_mode_t c_type; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph_copy(graph, &c_graph); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - c_prob=REAL(prob)[0]; - c_loops=LOGICAL(loops)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_n=INTEGER(n)[0]; + c_children=INTEGER(children)[0]; + c_type = (igraph_tree_mode_t) Rf_asInteger(type); /* Call igraph */ - IGRAPH_R_CHECK(igraph_rewire_directed_edges(&c_graph, c_prob, c_loops, c_mode)); + IGRAPH_R_CHECK(igraph_kary_tree(&c_graph, c_n, c_children, c_type)); /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); @@ -554,27 +534,21 @@ SEXP R_igraph_rewire_directed_edges(SEXP graph, SEXP prob, SEXP loops, SEXP mode } /*-------------------------------------------/ -/ igraph_forest_fire_game / +/ igraph_symmetric_tree / /-------------------------------------------*/ -SEXP R_igraph_forest_fire_game(SEXP nodes, SEXP fw_prob, SEXP bw_factor, SEXP ambs, SEXP directed) { +SEXP R_igraph_symmetric_tree(SEXP branches, SEXP type) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_nodes; - igraph_real_t c_fw_prob; - igraph_real_t c_bw_factor; - igraph_integer_t c_ambs; - igraph_bool_t c_directed; + igraph_vector_int_t c_branches; + igraph_tree_mode_t c_type; SEXP graph; SEXP r_result; /* Convert input */ - c_nodes=INTEGER(nodes)[0]; - c_fw_prob=REAL(fw_prob)[0]; - c_bw_factor=REAL(bw_factor)[0]; - c_ambs=INTEGER(ambs)[0]; - c_directed=LOGICAL(directed)[0]; + R_SEXP_to_vector_int(branches, &c_branches); + c_type = (igraph_tree_mode_t) Rf_asInteger(type); /* Call igraph */ - IGRAPH_R_CHECK(igraph_forest_fire_game(&c_graph, c_nodes, c_fw_prob, c_bw_factor, c_ambs, c_directed)); + IGRAPH_R_CHECK(igraph_symmetric_tree(&c_graph, &c_branches, c_type)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -588,27 +562,23 @@ SEXP R_igraph_forest_fire_game(SEXP nodes, SEXP fw_prob, SEXP bw_factor, SEXP am } /*-------------------------------------------/ -/ igraph_static_fitness_game / +/ igraph_regular_tree / /-------------------------------------------*/ -SEXP R_igraph_static_fitness_game(SEXP no_of_edges, SEXP fitness_out, SEXP fitness_in, SEXP loops, SEXP multiple) { +SEXP R_igraph_regular_tree(SEXP h, SEXP k, SEXP type) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_no_of_edges; - igraph_vector_t c_fitness_out; - igraph_vector_t c_fitness_in; - igraph_bool_t c_loops; - igraph_bool_t c_multiple; + igraph_integer_t c_h; + igraph_integer_t c_k; + igraph_tree_mode_t c_type; SEXP graph; SEXP r_result; /* Convert input */ - c_no_of_edges=INTEGER(no_of_edges)[0]; - R_SEXP_to_vector(fitness_out, &c_fitness_out); - if (!Rf_isNull(fitness_in)) { R_SEXP_to_vector(fitness_in, &c_fitness_in); } - c_loops=LOGICAL(loops)[0]; - c_multiple=LOGICAL(multiple)[0]; + c_h=INTEGER(h)[0]; + c_k=INTEGER(k)[0]; + c_type = (igraph_tree_mode_t) Rf_asInteger(type); /* Call igraph */ - IGRAPH_R_CHECK(igraph_static_fitness_game(&c_graph, c_no_of_edges, &c_fitness_out, (Rf_isNull(fitness_in) ? 0 : &c_fitness_in), c_loops, c_multiple)); + IGRAPH_R_CHECK(igraph_regular_tree(&c_graph, c_h, c_k, c_type)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -622,31 +592,21 @@ SEXP R_igraph_static_fitness_game(SEXP no_of_edges, SEXP fitness_out, SEXP fitne } /*-------------------------------------------/ -/ igraph_static_power_law_game / +/ igraph_full_citation / /-------------------------------------------*/ -SEXP R_igraph_static_power_law_game(SEXP no_of_nodes, SEXP no_of_edges, SEXP exponent_out, SEXP exponent_in, SEXP loops, SEXP multiple, SEXP finite_size_correction) { +SEXP R_igraph_full_citation(SEXP n, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_no_of_nodes; - igraph_integer_t c_no_of_edges; - igraph_real_t c_exponent_out; - igraph_real_t c_exponent_in; - igraph_bool_t c_loops; - igraph_bool_t c_multiple; - igraph_bool_t c_finite_size_correction; + igraph_integer_t c_n; + igraph_bool_t c_directed; SEXP graph; SEXP r_result; /* Convert input */ - c_no_of_nodes=INTEGER(no_of_nodes)[0]; - c_no_of_edges=INTEGER(no_of_edges)[0]; - c_exponent_out=REAL(exponent_out)[0]; - c_exponent_in=REAL(exponent_in)[0]; - c_loops=LOGICAL(loops)[0]; - c_multiple=LOGICAL(multiple)[0]; - c_finite_size_correction=LOGICAL(finite_size_correction)[0]; + c_n=INTEGER(n)[0]; + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_static_power_law_game(&c_graph, c_no_of_nodes, c_no_of_edges, c_exponent_out, c_exponent_in, c_loops, c_multiple, c_finite_size_correction)); + IGRAPH_R_CHECK(igraph_full_citation(&c_graph, c_n, c_directed)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -660,25 +620,23 @@ SEXP R_igraph_static_power_law_game(SEXP no_of_nodes, SEXP no_of_edges, SEXP exp } /*-------------------------------------------/ -/ igraph_k_regular_game / +/ igraph_extended_chordal_ring / /-------------------------------------------*/ -SEXP R_igraph_k_regular_game(SEXP no_of_nodes, SEXP k, SEXP directed, SEXP multiple) { +SEXP R_igraph_extended_chordal_ring(SEXP nodes, SEXP W, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_no_of_nodes; - igraph_integer_t c_k; + igraph_integer_t c_nodes; + igraph_matrix_int_t c_W; igraph_bool_t c_directed; - igraph_bool_t c_multiple; SEXP graph; SEXP r_result; /* Convert input */ - c_no_of_nodes=INTEGER(no_of_nodes)[0]; - c_k=INTEGER(k)[0]; + c_nodes=INTEGER(nodes)[0]; + R_SEXP_to_matrix_int(W, &c_W); c_directed=LOGICAL(directed)[0]; - c_multiple=LOGICAL(multiple)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_k_regular_game(&c_graph, c_no_of_nodes, c_k, c_directed, c_multiple)); + IGRAPH_R_CHECK(igraph_extended_chordal_ring(&c_graph, c_nodes, &c_W, c_directed)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -692,27 +650,23 @@ SEXP R_igraph_k_regular_game(SEXP no_of_nodes, SEXP k, SEXP directed, SEXP multi } /*-------------------------------------------/ -/ igraph_sbm_game / +/ igraph_lcf_vector / /-------------------------------------------*/ -SEXP R_igraph_sbm_game(SEXP n, SEXP pref_matrix, SEXP block_sizes, SEXP directed, SEXP loops) { +SEXP R_igraph_lcf_vector(SEXP n, SEXP shifts, SEXP repeats) { /* Declarations */ igraph_t c_graph; igraph_integer_t c_n; - igraph_matrix_t c_pref_matrix; - igraph_vector_int_t c_block_sizes; - igraph_bool_t c_directed; - igraph_bool_t c_loops; + igraph_vector_int_t c_shifts; + igraph_integer_t c_repeats; SEXP graph; SEXP r_result; /* Convert input */ c_n=INTEGER(n)[0]; - R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); - R_SEXP_to_vector_int(block_sizes, &c_block_sizes); - c_directed=LOGICAL(directed)[0]; - c_loops=LOGICAL(loops)[0]; + R_SEXP_to_vector_int(shifts, &c_shifts); + c_repeats=INTEGER(repeats)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_sbm_game(&c_graph, c_n, &c_pref_matrix, &c_block_sizes, c_directed, c_loops)); + IGRAPH_R_CHECK(igraph_lcf_vector(&c_graph, c_n, &c_shifts, c_repeats)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -726,27 +680,25 @@ SEXP R_igraph_sbm_game(SEXP n, SEXP pref_matrix, SEXP block_sizes, SEXP directed } /*-------------------------------------------/ -/ igraph_hsbm_game / +/ igraph_adjlist / /-------------------------------------------*/ -SEXP R_igraph_hsbm_game(SEXP n, SEXP m, SEXP rho, SEXP C, SEXP p) { +SEXP R_igraph_adjlist(SEXP adjlist, SEXP mode, SEXP duplicate) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_n; - igraph_integer_t c_m; - igraph_vector_t c_rho; - igraph_matrix_t c_C; - igraph_real_t c_p; + igraph_adjlist_t c_adjlist; + igraph_neimode_t c_mode; + igraph_bool_t c_duplicate; SEXP graph; SEXP r_result; /* Convert input */ - c_n=INTEGER(n)[0]; - c_m=INTEGER(m)[0]; - R_SEXP_to_vector(rho, &c_rho); - R_SEXP_to_matrix(C, &c_C); - c_p=REAL(p)[0]; + if (0 != R_SEXP_to_igraph_adjlist(adjlist, &c_adjlist)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_duplicate=LOGICAL(duplicate)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_hsbm_game(&c_graph, c_n, c_m, &c_rho, &c_C, c_p)); + IGRAPH_R_CHECK(igraph_adjlist(&c_graph, &c_adjlist, c_mode, c_duplicate)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -760,111 +712,92 @@ SEXP R_igraph_hsbm_game(SEXP n, SEXP m, SEXP rho, SEXP C, SEXP p) { } /*-------------------------------------------/ -/ igraph_hsbm_list_game / +/ igraph_full_bipartite / /-------------------------------------------*/ -SEXP R_igraph_hsbm_list_game(SEXP n, SEXP mlist, SEXP rholist, SEXP Clist, SEXP p) { +SEXP R_igraph_full_bipartite(SEXP n1, SEXP n2, SEXP directed, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_n; - igraph_vector_int_t c_mlist; - igraph_vector_ptr_t c_rholist; - igraph_vector_ptr_t c_Clist; - igraph_real_t c_p; + igraph_vector_bool_t c_types; + igraph_integer_t c_n1; + igraph_integer_t c_n2; + igraph_bool_t c_directed; + igraph_neimode_t c_mode; SEXP graph; + SEXP types; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - c_n=INTEGER(n)[0]; - R_SEXP_to_vector_int(mlist, &c_mlist); - R_igraph_SEXP_to_vectorlist(rholist, &c_rholist); - R_igraph_SEXP_to_matrixlist(Clist, &c_Clist); - c_p=REAL(p)[0]; + if (0 != igraph_vector_bool_init(&c_types, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); + c_n1=INTEGER(n1)[0]; + c_n2=INTEGER(n2)[0]; + c_directed=LOGICAL(directed)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hsbm_list_game(&c_graph, c_n, &c_mlist, &c_rholist, &c_Clist, c_p)); + IGRAPH_R_CHECK(igraph_full_bipartite(&c_graph, &c_types, c_n1, c_n2, c_directed, c_mode)); /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; - - UNPROTECT(1); - return(r_result); -} - -/*-------------------------------------------/ -/ igraph_correlated_game / -/-------------------------------------------*/ -SEXP R_igraph_correlated_game(SEXP old_graph, SEXP corr, SEXP p, SEXP permutation) { - /* Declarations */ - igraph_t c_old_graph; - igraph_t c_new_graph; - igraph_real_t c_corr; - igraph_real_t c_p; - igraph_vector_t c_permutation; - SEXP new_graph; - - SEXP r_result; - /* Convert input */ - R_SEXP_to_igraph(old_graph, &c_old_graph); - c_corr=REAL(corr)[0]; - c_p=REAL(p)[0]; - if (!Rf_isNull(permutation)) { R_SEXP_to_vector(permutation, &c_permutation); } - /* Call igraph */ - IGRAPH_R_CHECK(igraph_correlated_game(&c_old_graph, &c_new_graph, c_corr, c_p, (Rf_isNull(permutation) ? 0 : &c_permutation))); - - /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_new_graph); - PROTECT(new_graph=R_igraph_to_SEXP(&c_new_graph)); - igraph_destroy(&c_new_graph); + PROTECT(types=R_igraph_vector_bool_to_SEXP(&c_types)); + igraph_vector_bool_destroy(&c_types); IGRAPH_FINALLY_CLEAN(1); - r_result = new_graph; + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, types); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_correlated_pair_game / +/ igraph_full_multipartite / /-------------------------------------------*/ -SEXP R_igraph_correlated_pair_game(SEXP n, SEXP corr, SEXP p, SEXP directed, SEXP permutation) { +SEXP R_igraph_full_multipartite(SEXP n, SEXP directed, SEXP mode) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_integer_t c_n; - igraph_real_t c_corr; - igraph_real_t c_p; + igraph_t c_graph; + igraph_vector_int_t c_types; + igraph_vector_int_t c_n; igraph_bool_t c_directed; - igraph_vector_t c_permutation; - SEXP graph1; - SEXP graph2; + igraph_neimode_t c_mode; + SEXP graph; + SEXP types; SEXP r_result, r_names; /* Convert input */ - c_n=INTEGER(n)[0]; - c_corr=REAL(corr)[0]; - c_p=REAL(p)[0]; + if (0 != igraph_vector_int_init(&c_types, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_types); + R_SEXP_to_vector_int(n, &c_n); c_directed=LOGICAL(directed)[0]; - if (!Rf_isNull(permutation)) { R_SEXP_to_vector(permutation, &c_permutation); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_correlated_pair_game(&c_graph1, &c_graph2, c_n, c_corr, c_p, c_directed, (Rf_isNull(permutation) ? 0 : &c_permutation))); + IGRAPH_R_CHECK(igraph_full_multipartite(&c_graph, &c_types, &c_n, c_directed, c_mode)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); - IGRAPH_FINALLY(igraph_destroy, &c_graph1); - PROTECT(graph1=R_igraph_to_SEXP(&c_graph1)); - igraph_destroy(&c_graph1); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - IGRAPH_FINALLY(igraph_destroy, &c_graph2); - PROTECT(graph2=R_igraph_to_SEXP(&c_graph2)); - igraph_destroy(&c_graph2); + PROTECT(types=R_igraph_vector_int_to_SEXP(&c_types)); + igraph_vector_int_destroy(&c_types); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, graph1); - SET_VECTOR_ELT(r_result, 1, graph2); - SET_STRING_ELT(r_names, 0, Rf_mkChar("graph1")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("graph2")); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, types); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); SET_NAMES(r_result, r_names); UNPROTECT(3); @@ -873,21 +806,25 @@ SEXP R_igraph_correlated_pair_game(SEXP n, SEXP corr, SEXP p, SEXP directed, SEX } /*-------------------------------------------/ -/ igraph_dot_product_game / +/ igraph_realize_degree_sequence / /-------------------------------------------*/ -SEXP R_igraph_dot_product_game(SEXP vecs, SEXP directed) { +SEXP R_igraph_realize_degree_sequence(SEXP out_deg, SEXP in_deg, SEXP allowed_edge_types, SEXP method) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_vecs; - igraph_bool_t c_directed; + igraph_vector_int_t c_out_deg; + igraph_vector_int_t c_in_deg; + igraph_edge_type_sw_t c_allowed_edge_types; + igraph_realize_degseq_t c_method; SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_matrix(vecs, &c_vecs); - c_directed=LOGICAL(directed)[0]; + R_SEXP_to_vector_int(out_deg, &c_out_deg); + if (!Rf_isNull(in_deg)) { R_SEXP_to_vector_int(in_deg, &c_in_deg); } + c_allowed_edge_types = (igraph_edge_type_sw_t) Rf_asInteger(allowed_edge_types); + c_method = (igraph_realize_degseq_t) Rf_asInteger(method); /* Call igraph */ - IGRAPH_R_CHECK(igraph_dot_product_game(&c_graph, &c_vecs, c_directed)); + IGRAPH_R_CHECK(igraph_realize_degree_sequence(&c_graph, &c_out_deg, (Rf_isNull(in_deg) ? 0 : &c_in_deg), c_allowed_edge_types, c_method)); /* Convert output */ IGRAPH_FINALLY(igraph_destroy, &c_graph); @@ -901,275 +838,219 @@ SEXP R_igraph_dot_product_game(SEXP vecs, SEXP directed) { } /*-------------------------------------------/ -/ igraph_sample_sphere_surface / +/ igraph_circulant / /-------------------------------------------*/ -SEXP R_igraph_sample_sphere_surface(SEXP dim, SEXP n, SEXP radius, SEXP positive) { +SEXP R_igraph_circulant(SEXP n, SEXP shifts, SEXP directed) { /* Declarations */ - igraph_integer_t c_dim; + igraph_t c_graph; igraph_integer_t c_n; - igraph_real_t c_radius; - igraph_bool_t c_positive; - igraph_matrix_t c_res; - SEXP res; + igraph_vector_int_t c_shifts; + igraph_bool_t c_directed; + SEXP graph; SEXP r_result; /* Convert input */ - c_dim=INTEGER(dim)[0]; c_n=INTEGER(n)[0]; - c_radius=REAL(radius)[0]; - c_positive=LOGICAL(positive)[0]; - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + R_SEXP_to_vector_int(shifts, &c_shifts); + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_sample_sphere_surface(c_dim, c_n, c_radius, c_positive, &c_res)); + IGRAPH_R_CHECK(igraph_circulant(&c_graph, c_n, &c_shifts, c_directed)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_sample_sphere_volume / +/ igraph_generalized_petersen / /-------------------------------------------*/ -SEXP R_igraph_sample_sphere_volume(SEXP dim, SEXP n, SEXP radius, SEXP positive) { +SEXP R_igraph_generalized_petersen(SEXP n, SEXP k) { /* Declarations */ - igraph_integer_t c_dim; + igraph_t c_graph; igraph_integer_t c_n; - igraph_real_t c_radius; - igraph_bool_t c_positive; - igraph_matrix_t c_res; - SEXP res; + igraph_integer_t c_k; + SEXP graph; SEXP r_result; /* Convert input */ - c_dim=INTEGER(dim)[0]; c_n=INTEGER(n)[0]; - c_radius=REAL(radius)[0]; - c_positive=LOGICAL(positive)[0]; - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_k=INTEGER(k)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_sample_sphere_volume(c_dim, c_n, c_radius, c_positive, &c_res)); + IGRAPH_R_CHECK(igraph_generalized_petersen(&c_graph, c_n, c_k)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_sample_dirichlet / +/ igraph_turan / /-------------------------------------------*/ -SEXP R_igraph_sample_dirichlet(SEXP n, SEXP alpha) { +SEXP R_igraph_turan(SEXP n, SEXP r) { /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_types; igraph_integer_t c_n; - igraph_vector_t c_alpha; - igraph_matrix_t c_res; - SEXP res; + igraph_integer_t c_r; + SEXP graph; + SEXP types; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - c_n=INTEGER(n)[0]; - R_SEXP_to_vector(alpha, &c_alpha); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { + if (0 != igraph_vector_int_init(&c_types, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_types); + c_n=INTEGER(n)[0]; + c_r=INTEGER(r)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_sample_dirichlet(c_n, &c_alpha, &c_res)); + IGRAPH_R_CHECK(igraph_turan(&c_graph, &c_types, c_n, c_r)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(types=R_igraph_vector_int_to_SEXP(&c_types)); + igraph_vector_int_destroy(&c_types); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, types); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_closeness / +/ igraph_weighted_sparsemat / /-------------------------------------------*/ -SEXP R_igraph_closeness(SEXP graph, SEXP vids, SEXP mode, SEXP weights, SEXP normalized) { +SEXP R_igraph_weighted_sparsemat(SEXP A, SEXP directed, SEXP attr, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vector_t c_reachable_count; - igraph_bool_t c_all_reachable; - igraph_vs_t c_vids; - igraph_neimode_t c_mode; - igraph_vector_t c_weights; - igraph_bool_t c_normalized; - SEXP res; - SEXP reachable_count; - SEXP all_reachable; + igraph_sparsemat_t c_A; + igraph_bool_t c_directed; + const char* c_attr; + igraph_bool_t c_loops; + SEXP graph; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (0 != igraph_vector_init(&c_reachable_count, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_reachable_count); - reachable_count=R_GlobalEnv; /* hack to have a non-NULL value */ - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_normalized=LOGICAL(normalized)[0]; + R_SEXP_to_sparsemat(A, &c_A); + c_directed=LOGICAL(directed)[0]; + c_loops=LOGICAL(loops)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_closeness(&c_graph, &c_res, (Rf_isNull(reachable_count) ? 0 : &c_reachable_count), &c_all_reachable, c_vids, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_normalized)); + IGRAPH_R_CHECK(igraph_weighted_sparsemat(&c_graph, &c_A, c_directed, c_attr, c_loops)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(reachable_count=R_igraph_0orvector_to_SEXP(&c_reachable_count)); - igraph_vector_destroy(&c_reachable_count); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(all_reachable=NEW_LOGICAL(1)); - LOGICAL(all_reachable)[0]=c_all_reachable; - igraph_vs_destroy(&c_vids); - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, reachable_count); - SET_VECTOR_ELT(r_result, 2, all_reachable); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("reachable_count")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("all_reachable")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_closeness_cutoff / +/ igraph_erdos_renyi_game / /-------------------------------------------*/ -SEXP R_igraph_closeness_cutoff(SEXP graph, SEXP vids, SEXP mode, SEXP weights, SEXP normalized, SEXP cutoff) { +SEXP R_igraph_erdos_renyi_game(SEXP type, SEXP n, SEXP p_or_m, SEXP directed, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vector_t c_reachable_count; - igraph_bool_t c_all_reachable; - igraph_vs_t c_vids; - igraph_neimode_t c_mode; - igraph_vector_t c_weights; - igraph_bool_t c_normalized; - igraph_real_t c_cutoff; - SEXP res; - SEXP reachable_count; - SEXP all_reachable; + igraph_erdos_renyi_t c_type; + igraph_integer_t c_n; + igraph_real_t c_p_or_m; + igraph_bool_t c_directed; + igraph_bool_t c_loops; + SEXP graph; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (0 != igraph_vector_init(&c_reachable_count, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_reachable_count); - reachable_count=R_GlobalEnv; /* hack to have a non-NULL value */ - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_normalized=LOGICAL(normalized)[0]; - c_cutoff=REAL(cutoff)[0]; + c_type = (igraph_erdos_renyi_t) Rf_asInteger(type); + c_n=INTEGER(n)[0]; + c_p_or_m=REAL(p_or_m)[0]; + c_directed=LOGICAL(directed)[0]; + c_loops=LOGICAL(loops)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_closeness_cutoff(&c_graph, &c_res, (Rf_isNull(reachable_count) ? 0 : &c_reachable_count), &c_all_reachable, c_vids, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_normalized, c_cutoff)); + IGRAPH_R_CHECK(igraph_erdos_renyi_game(&c_graph, c_type, c_n, c_p_or_m, c_directed, c_loops)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(reachable_count=R_igraph_0orvector_to_SEXP(&c_reachable_count)); - igraph_vector_destroy(&c_reachable_count); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(all_reachable=NEW_LOGICAL(1)); - LOGICAL(all_reachable)[0]=c_all_reachable; - igraph_vs_destroy(&c_vids); - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, reachable_count); - SET_VECTOR_ELT(r_result, 2, all_reachable); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("reachable_count")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("all_reachable")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_get_all_shortest_paths / +/ igraph_preference_game / /-------------------------------------------*/ -SEXP R_igraph_get_all_shortest_paths(SEXP graph, SEXP from, SEXP to, SEXP mode) { +SEXP R_igraph_preference_game(SEXP nodes, SEXP types, SEXP type_dist, SEXP fixed_sizes, SEXP pref_matrix, SEXP directed, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_vector_ptr_t c_res; - igraph_vector_t c_nrgeo; - igraph_integer_t c_from; - igraph_vs_t c_to; - igraph_neimode_t c_mode; - SEXP res; - SEXP nrgeo; + igraph_integer_t c_nodes; + igraph_integer_t c_types; + igraph_vector_t c_type_dist; + igraph_bool_t c_fixed_sizes; + igraph_matrix_t c_pref_matrix; + igraph_vector_int_t c_node_type_vec; + igraph_bool_t c_directed; + igraph_bool_t c_loops; + SEXP graph; + SEXP node_type_vec; SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_res); - if (0 != igraph_vector_init(&c_nrgeo, 0)) { + c_nodes=INTEGER(nodes)[0]; + c_types=INTEGER(types)[0]; + R_SEXP_to_vector(type_dist, &c_type_dist); + c_fixed_sizes=LOGICAL(fixed_sizes)[0]; + R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); + if (0 != igraph_vector_int_init(&c_node_type_vec, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_nrgeo); - c_from = (igraph_integer_t) REAL(from)[0]; - R_SEXP_to_igraph_vs(to, &c_graph, &c_to); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_node_type_vec); + c_directed=LOGICAL(directed)[0]; + c_loops=LOGICAL(loops)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_all_shortest_paths(&c_graph, &c_res, &c_nrgeo, c_from, c_to, c_mode)); + IGRAPH_R_CHECK(igraph_preference_game(&c_graph, c_nodes, c_types, &c_type_dist, c_fixed_sizes, &c_pref_matrix, &c_node_type_vec, c_directed, c_loops)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(res=R_igraph_vectorlist_to_SEXP_p1(&c_res)); - R_igraph_vectorlist_destroy(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(nrgeo=R_igraph_vector_to_SEXP(&c_nrgeo)); - igraph_vector_destroy(&c_nrgeo); + PROTECT(node_type_vec=R_igraph_vector_int_to_SEXP(&c_node_type_vec)); + igraph_vector_int_destroy(&c_node_type_vec); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_to); - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, nrgeo); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("nrgeo")); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, node_type_vec); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("node_type_vec")); SET_NAMES(r_result, r_names); UNPROTECT(3); @@ -1178,394 +1059,362 @@ SEXP R_igraph_get_all_shortest_paths(SEXP graph, SEXP from, SEXP to, SEXP mode) } /*-------------------------------------------/ -/ igraph_get_all_shortest_paths_dijkstra / +/ igraph_asymmetric_preference_game / /-------------------------------------------*/ -SEXP R_igraph_get_all_shortest_paths_dijkstra(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { +SEXP R_igraph_asymmetric_preference_game(SEXP nodes, SEXP out_types, SEXP in_types, SEXP type_dist_matrix, SEXP pref_matrix, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_vector_ptr_t c_res; - igraph_vector_t c_nrgeo; - igraph_integer_t c_from; - igraph_vs_t c_to; - igraph_vector_t c_weights; - igraph_neimode_t c_mode; - SEXP res; - SEXP nrgeo; + igraph_integer_t c_nodes; + igraph_integer_t c_out_types; + igraph_integer_t c_in_types; + igraph_matrix_t c_type_dist_matrix; + igraph_matrix_t c_pref_matrix; + igraph_vector_int_t c_node_type_out_vec; + igraph_vector_int_t c_node_type_in_vec; + igraph_bool_t c_loops; + SEXP graph; + SEXP node_type_out_vec; + SEXP node_type_in_vec; SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_res, 0)) { + c_nodes=INTEGER(nodes)[0]; + c_out_types=INTEGER(out_types)[0]; + c_in_types=INTEGER(in_types)[0]; + R_SEXP_to_matrix(type_dist_matrix, &c_type_dist_matrix); + R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); + if (0 != igraph_vector_int_init(&c_node_type_out_vec, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_res); - if (0 != igraph_vector_init(&c_nrgeo, 0)) { + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_node_type_out_vec); + if (0 != igraph_vector_int_init(&c_node_type_in_vec, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_nrgeo); - c_from = (igraph_integer_t) REAL(from)[0]; - R_SEXP_to_igraph_vs(to, &c_graph, &c_to); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_node_type_in_vec); + c_loops=LOGICAL(loops)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_all_shortest_paths_dijkstra(&c_graph, &c_res, &c_nrgeo, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_asymmetric_preference_game(&c_graph, c_nodes, c_out_types, c_in_types, &c_type_dist_matrix, &c_pref_matrix, &c_node_type_out_vec, &c_node_type_in_vec, c_loops)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(res=R_igraph_vectorlist_to_SEXP_p1(&c_res)); - R_igraph_vectorlist_destroy(&c_res); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(nrgeo=R_igraph_vector_to_SEXP(&c_nrgeo)); - igraph_vector_destroy(&c_nrgeo); + PROTECT(node_type_out_vec=R_igraph_vector_int_to_SEXP(&c_node_type_out_vec)); + igraph_vector_int_destroy(&c_node_type_out_vec); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_to); - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, nrgeo); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("nrgeo")); + PROTECT(node_type_in_vec=R_igraph_vector_int_to_SEXP(&c_node_type_in_vec)); + igraph_vector_int_destroy(&c_node_type_in_vec); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, node_type_out_vec); + SET_VECTOR_ELT(r_result, 2, node_type_in_vec); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("node_type_out_vec")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("node_type_in_vec")); SET_NAMES(r_result, r_names); - UNPROTECT(3); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_get_all_simple_paths / +/ igraph_rewire_edges / /-------------------------------------------*/ -SEXP R_igraph_get_all_simple_paths(SEXP graph, SEXP from, SEXP to, SEXP cutoff, SEXP mode) { +SEXP R_igraph_rewire_edges(SEXP graph, SEXP prob, SEXP loops, SEXP multiple) { /* Declarations */ igraph_t c_graph; - igraph_vector_int_t c_res; - igraph_integer_t c_from; - igraph_vs_t c_to; - igraph_integer_t c_cutoff; - igraph_neimode_t c_mode; - SEXP res; + igraph_real_t c_prob; + igraph_bool_t c_loops; + igraph_bool_t c_multiple; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); - c_from = (igraph_integer_t) REAL(from)[0]; - R_SEXP_to_igraph_vs(to, &c_graph, &c_to); - c_cutoff=INTEGER(cutoff)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + c_prob=REAL(prob)[0]; + c_loops=LOGICAL(loops)[0]; + c_multiple=LOGICAL(multiple)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_all_simple_paths(&c_graph, &c_res, c_from, c_to, c_cutoff, c_mode)); + IGRAPH_R_CHECK(igraph_rewire_edges(&c_graph, c_prob, c_loops, c_multiple)); /* Convert output */ - PROTECT(res=R_igraph_vector_int_to_SEXPp1(&c_res)); - igraph_vector_int_destroy(&c_res); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_to); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_betweenness_cutoff / +/ igraph_rewire_directed_edges / /-------------------------------------------*/ -SEXP R_igraph_betweenness_cutoff(SEXP graph, SEXP vids, SEXP directed, SEXP weights, SEXP cutoff) { +SEXP R_igraph_rewire_directed_edges(SEXP graph, SEXP prob, SEXP loops, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vs_t c_vids; - igraph_bool_t c_directed; - igraph_vector_t c_weights; - igraph_real_t c_cutoff; - SEXP res; + igraph_real_t c_prob; + igraph_bool_t c_loops; + igraph_neimode_t c_mode; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_directed=LOGICAL(directed)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_cutoff=REAL(cutoff)[0]; + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + c_prob=REAL(prob)[0]; + c_loops=LOGICAL(loops)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_betweenness_cutoff(&c_graph, &c_res, c_vids, c_directed, (Rf_isNull(weights) ? 0 : &c_weights), c_cutoff)); + IGRAPH_R_CHECK(igraph_rewire_directed_edges(&c_graph, c_prob, c_loops, c_mode)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_edge_betweenness / +/ igraph_forest_fire_game / /-------------------------------------------*/ -SEXP R_igraph_edge_betweenness(SEXP graph, SEXP directed, SEXP weights) { +SEXP R_igraph_forest_fire_game(SEXP nodes, SEXP fw_prob, SEXP bw_factor, SEXP ambs, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; + igraph_integer_t c_nodes; + igraph_real_t c_fw_prob; + igraph_real_t c_bw_factor; + igraph_integer_t c_ambs; igraph_bool_t c_directed; - igraph_vector_t c_weights; - SEXP res; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_nodes=INTEGER(nodes)[0]; + c_fw_prob=REAL(fw_prob)[0]; + c_bw_factor=REAL(bw_factor)[0]; + c_ambs=INTEGER(ambs)[0]; c_directed=LOGICAL(directed)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_edge_betweenness(&c_graph, &c_res, c_directed, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_forest_fire_game(&c_graph, c_nodes, c_fw_prob, c_bw_factor, c_ambs, c_directed)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_edge_betweenness_cutoff / +/ igraph_static_fitness_game / /-------------------------------------------*/ -SEXP R_igraph_edge_betweenness_cutoff(SEXP graph, SEXP directed, SEXP weights, SEXP cutoff) { +SEXP R_igraph_static_fitness_game(SEXP no_of_edges, SEXP fitness_out, SEXP fitness_in, SEXP loops, SEXP multiple) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_bool_t c_directed; - igraph_vector_t c_weights; - igraph_real_t c_cutoff; - SEXP res; + igraph_integer_t c_no_of_edges; + igraph_vector_t c_fitness_out; + igraph_vector_t c_fitness_in; + igraph_bool_t c_loops; + igraph_bool_t c_multiple; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - c_directed=LOGICAL(directed)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_cutoff=REAL(cutoff)[0]; + c_no_of_edges=INTEGER(no_of_edges)[0]; + R_SEXP_to_vector(fitness_out, &c_fitness_out); + R_SEXP_to_vector(fitness_in, &c_fitness_in); + c_loops=LOGICAL(loops)[0]; + c_multiple=LOGICAL(multiple)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_edge_betweenness_cutoff(&c_graph, &c_res, c_directed, (Rf_isNull(weights) ? 0 : &c_weights), c_cutoff)); + IGRAPH_R_CHECK(igraph_static_fitness_game(&c_graph, c_no_of_edges, &c_fitness_out, &c_fitness_in, c_loops, c_multiple)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_harmonic_centrality_cutoff / +/ igraph_static_power_law_game / /-------------------------------------------*/ -SEXP R_igraph_harmonic_centrality_cutoff(SEXP graph, SEXP vids, SEXP mode, SEXP weights, SEXP normalized, SEXP cutoff) { +SEXP R_igraph_static_power_law_game(SEXP no_of_nodes, SEXP no_of_edges, SEXP exponent_out, SEXP exponent_in, SEXP loops, SEXP multiple, SEXP finite_size_correction) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vs_t c_vids; - igraph_neimode_t c_mode; - igraph_vector_t c_weights; - igraph_bool_t c_normalized; - igraph_real_t c_cutoff; - SEXP res; + igraph_integer_t c_no_of_nodes; + igraph_integer_t c_no_of_edges; + igraph_real_t c_exponent_out; + igraph_real_t c_exponent_in; + igraph_bool_t c_loops; + igraph_bool_t c_multiple; + igraph_bool_t c_finite_size_correction; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_normalized=LOGICAL(normalized)[0]; - c_cutoff=REAL(cutoff)[0]; + c_no_of_nodes=INTEGER(no_of_nodes)[0]; + c_no_of_edges=INTEGER(no_of_edges)[0]; + c_exponent_out=REAL(exponent_out)[0]; + c_exponent_in=REAL(exponent_in)[0]; + c_loops=LOGICAL(loops)[0]; + c_multiple=LOGICAL(multiple)[0]; + c_finite_size_correction=LOGICAL(finite_size_correction)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_harmonic_centrality_cutoff(&c_graph, &c_res, c_vids, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_normalized, c_cutoff)); + IGRAPH_R_CHECK(igraph_static_power_law_game(&c_graph, c_no_of_nodes, c_no_of_edges, c_exponent_out, c_exponent_in, c_loops, c_multiple, c_finite_size_correction)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_personalized_pagerank / +/ igraph_k_regular_game / /-------------------------------------------*/ -SEXP R_igraph_personalized_pagerank(SEXP graph, SEXP algo, SEXP vids, SEXP directed, SEXP damping, SEXP personalized, SEXP weights, SEXP options) { +SEXP R_igraph_k_regular_game(SEXP no_of_nodes, SEXP k, SEXP directed, SEXP multiple) { /* Declarations */ igraph_t c_graph; - igraph_pagerank_algo_t c_algo; - igraph_vector_t c_vector; - igraph_real_t c_value; - igraph_vs_t c_vids; + igraph_integer_t c_no_of_nodes; + igraph_integer_t c_k; igraph_bool_t c_directed; - igraph_real_t c_damping; - igraph_vector_t c_personalized; - igraph_vector_t c_weights; - igraph_arpack_options_t c_options1; - void* c_options; - SEXP vector; - SEXP value; + igraph_bool_t c_multiple; + SEXP graph; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - c_algo = (igraph_pagerank_algo_t) Rf_asInteger(algo); - if (0 != igraph_vector_init(&c_vector, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); + c_no_of_nodes=INTEGER(no_of_nodes)[0]; + c_k=INTEGER(k)[0]; c_directed=LOGICAL(directed)[0]; - c_damping=REAL(damping)[0]; - if (!Rf_isNull(personalized)) { R_SEXP_to_vector(personalized, &c_personalized); } - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { - R_SEXP_to_igraph_arpack_options(options, &c_options1); - c_options = &c_options1; - } else { - c_options = 0; - } + c_multiple=LOGICAL(multiple)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_personalized_pagerank(&c_graph, c_algo, &c_vector, &c_value, c_vids, c_directed, c_damping, (Rf_isNull(personalized) ? 0 : &c_personalized), (Rf_isNull(weights) ? 0 : &c_weights), c_options)); + IGRAPH_R_CHECK(igraph_k_regular_game(&c_graph, c_no_of_nodes, c_k, c_directed, c_multiple)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); - igraph_vector_destroy(&c_vector); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - PROTECT(value=NEW_NUMERIC(1)); - REAL(value)[0]=c_value; - igraph_vs_destroy(&c_vids); - if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { - PROTECT(options = R_igraph_arpack_options_to_SEXP(&c_options1)); - } else { - PROTECT(options); - } - SET_VECTOR_ELT(r_result, 0, vector); - SET_VECTOR_ELT(r_result, 1, value); - SET_VECTOR_ELT(r_result, 2, options); - SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_induced_subgraph / +/ igraph_sbm_game / /-------------------------------------------*/ -SEXP R_igraph_induced_subgraph(SEXP graph, SEXP vids, SEXP impl) { +SEXP R_igraph_sbm_game(SEXP n, SEXP pref_matrix, SEXP block_sizes, SEXP directed, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_t c_res; - igraph_vs_t c_vids; - igraph_subgraph_implementation_t c_impl; - SEXP res; + igraph_integer_t c_n; + igraph_matrix_t c_pref_matrix; + igraph_vector_int_t c_block_sizes; + igraph_bool_t c_directed; + igraph_bool_t c_loops; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_impl = (igraph_subgraph_implementation_t) Rf_asInteger(impl); + c_n=INTEGER(n)[0]; + R_SEXP_to_matrix(pref_matrix, &c_pref_matrix); + R_SEXP_to_vector_int(block_sizes, &c_block_sizes); + c_directed=LOGICAL(directed)[0]; + c_loops=LOGICAL(loops)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_induced_subgraph(&c_graph, &c_res, c_vids, c_impl)); + IGRAPH_R_CHECK(igraph_sbm_game(&c_graph, c_n, &c_pref_matrix, &c_block_sizes, c_directed, c_loops)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_res); - PROTECT(res=R_igraph_to_SEXP(&c_res)); - igraph_destroy(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_subgraph_edges / +/ igraph_hsbm_game / /-------------------------------------------*/ -SEXP R_igraph_subgraph_edges(SEXP graph, SEXP eids, SEXP delete_vertices) { +SEXP R_igraph_hsbm_game(SEXP n, SEXP m, SEXP rho, SEXP C, SEXP p) { /* Declarations */ igraph_t c_graph; - igraph_t c_res; - igraph_es_t c_eids; - igraph_bool_t c_delete_vertices; - SEXP res; + igraph_integer_t c_n; + igraph_integer_t c_m; + igraph_vector_t c_rho; + igraph_matrix_t c_C; + igraph_real_t c_p; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_igraph_es(eids, &c_graph, &c_eids); - c_delete_vertices=LOGICAL(delete_vertices)[0]; + c_n=INTEGER(n)[0]; + c_m=INTEGER(m)[0]; + R_SEXP_to_vector(rho, &c_rho); + R_SEXP_to_matrix(C, &c_C); + c_p=REAL(p)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_subgraph_edges(&c_graph, &c_res, c_eids, c_delete_vertices)); + IGRAPH_R_CHECK(igraph_hsbm_game(&c_graph, c_n, c_m, &c_rho, &c_C, c_p)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_res); - PROTECT(res=R_igraph_to_SEXP(&c_res)); - igraph_destroy(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_es_destroy(&c_eids); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_reverse_edges / +/ igraph_hsbm_list_game / /-------------------------------------------*/ -SEXP R_igraph_reverse_edges(SEXP graph, SEXP eids) { +SEXP R_igraph_hsbm_list_game(SEXP n, SEXP mlist, SEXP rholist, SEXP Clist, SEXP p) { /* Declarations */ igraph_t c_graph; - igraph_es_t c_eids; - - SEXP r_result; + igraph_integer_t c_n; + igraph_vector_int_t c_mlist; + igraph_vector_list_t c_rholist; + igraph_matrix_list_t c_Clist; + igraph_real_t c_p; + SEXP graph; + + SEXP r_result; /* Convert input */ - R_SEXP_to_igraph_copy(graph, &c_graph); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - R_SEXP_to_igraph_es(eids, &c_graph, &c_eids); + c_n=INTEGER(n)[0]; + R_SEXP_to_vector_int(mlist, &c_mlist); + R_igraph_SEXP_to_vectorlist(rholist, &c_rholist); + R_igraph_SEXP_to_matrixlist(Clist, &c_Clist); + c_p=REAL(p)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_reverse_edges(&c_graph, c_eids)); + IGRAPH_R_CHECK(igraph_hsbm_list_game(&c_graph, c_n, &c_mlist, &c_rholist, &c_Clist, c_p)); /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_es_destroy(&c_eids); r_result = graph; UNPROTECT(1); @@ -1573,81 +1422,77 @@ SEXP R_igraph_reverse_edges(SEXP graph, SEXP eids) { } /*-------------------------------------------/ -/ igraph_average_path_length_dijkstra / +/ igraph_correlated_game / /-------------------------------------------*/ -SEXP R_igraph_average_path_length_dijkstra(SEXP graph, SEXP weights, SEXP directed, SEXP unconn) { +SEXP R_igraph_correlated_game(SEXP old_graph, SEXP corr, SEXP p, SEXP permutation) { /* Declarations */ - igraph_t c_graph; - igraph_real_t c_res; - igraph_real_t c_unconn_pairs; - igraph_vector_t c_weights; - igraph_bool_t c_directed; - igraph_bool_t c_unconn; - SEXP res; - SEXP unconn_pairs; + igraph_t c_old_graph; + igraph_t c_new_graph; + igraph_real_t c_corr; + igraph_real_t c_p; + igraph_vector_int_t c_permutation; + SEXP new_graph; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_directed=LOGICAL(directed)[0]; - c_unconn=LOGICAL(unconn)[0]; + R_SEXP_to_igraph(old_graph, &c_old_graph); + c_corr=REAL(corr)[0]; + c_p=REAL(p)[0]; + R_SEXP_to_vector_int(permutation, &c_permutation); /* Call igraph */ - IGRAPH_R_CHECK(igraph_average_path_length_dijkstra(&c_graph, &c_res, &c_unconn_pairs, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_unconn)); + IGRAPH_R_CHECK(igraph_correlated_game(&c_old_graph, &c_new_graph, c_corr, c_p, &c_permutation)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; - PROTECT(unconn_pairs=NEW_NUMERIC(1)); - REAL(unconn_pairs)[0]=c_unconn_pairs; - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, unconn_pairs); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("unconnected")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + IGRAPH_FINALLY(igraph_destroy, &c_new_graph); + PROTECT(new_graph=R_igraph_to_SEXP(&c_new_graph)); + igraph_destroy(&c_new_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = new_graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_path_length_hist / +/ igraph_correlated_pair_game / /-------------------------------------------*/ -SEXP R_igraph_path_length_hist(SEXP graph, SEXP directed) { +SEXP R_igraph_correlated_pair_game(SEXP n, SEXP corr, SEXP p, SEXP directed, SEXP permutation) { /* Declarations */ - igraph_t c_graph; - igraph_vector_t c_res; - igraph_real_t c_unconnected; + igraph_t c_graph1; + igraph_t c_graph2; + igraph_integer_t c_n; + igraph_real_t c_corr; + igraph_real_t c_p; igraph_bool_t c_directed; - SEXP res; - SEXP unconnected; + igraph_vector_int_t c_permutation; + SEXP graph1; + SEXP graph2; SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_n=INTEGER(n)[0]; + c_corr=REAL(corr)[0]; + c_p=REAL(p)[0]; c_directed=LOGICAL(directed)[0]; + R_SEXP_to_vector_int(permutation, &c_permutation); /* Call igraph */ - IGRAPH_R_CHECK(igraph_path_length_hist(&c_graph, &c_res, &c_unconnected, c_directed)); + IGRAPH_R_CHECK(igraph_correlated_pair_game(&c_graph1, &c_graph2, c_n, c_corr, c_p, c_directed, &c_permutation)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + IGRAPH_FINALLY(igraph_destroy, &c_graph1); + PROTECT(graph1=R_igraph_to_SEXP(&c_graph1)); + igraph_destroy(&c_graph1); IGRAPH_FINALLY_CLEAN(1); - PROTECT(unconnected=NEW_NUMERIC(1)); - REAL(unconnected)[0]=c_unconnected; - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, unconnected); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("unconnected")); + IGRAPH_FINALLY(igraph_destroy, &c_graph2); + PROTECT(graph2=R_igraph_to_SEXP(&c_graph2)); + igraph_destroy(&c_graph2); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph1); + SET_VECTOR_ELT(r_result, 1, graph2); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph1")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("graph2")); SET_NAMES(r_result, r_names); UNPROTECT(3); @@ -1656,32 +1501,27 @@ SEXP R_igraph_path_length_hist(SEXP graph, SEXP directed) { } /*-------------------------------------------/ -/ igraph_simplify / +/ igraph_dot_product_game / /-------------------------------------------*/ -SEXP R_igraph_simplify(SEXP graph, SEXP remove_multiple, SEXP remove_loops, SEXP edge_attr_comb) { +SEXP R_igraph_dot_product_game(SEXP vecs, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_bool_t c_remove_multiple; - igraph_bool_t c_remove_loops; - igraph_attribute_combination_t c_edge_attr_comb; + igraph_matrix_t c_vecs; + igraph_bool_t c_directed; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph_copy(graph, &c_graph); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - c_remove_multiple=LOGICAL(remove_multiple)[0]; - c_remove_loops=LOGICAL(remove_loops)[0]; - R_SEXP_to_attr_comb(edge_attr_comb, &c_edge_attr_comb); - IGRAPH_FINALLY(igraph_attribute_combination_destroy, &c_edge_attr_comb); + R_SEXP_to_matrix(vecs, &c_vecs); + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_simplify(&c_graph, c_remove_multiple, c_remove_loops, &c_edge_attr_comb)); + IGRAPH_R_CHECK(igraph_dot_product_game(&c_graph, &c_vecs, c_directed)); /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_attribute_combination_destroy(&c_edge_attr_comb); - IGRAPH_FINALLY_CLEAN(1); r_result = graph; UNPROTECT(1); @@ -1689,64 +1529,69 @@ SEXP R_igraph_simplify(SEXP graph, SEXP remove_multiple, SEXP remove_loops, SEXP } /*-------------------------------------------/ -/ igraph_feedback_arc_set / +/ igraph_sample_sphere_surface / /-------------------------------------------*/ -SEXP R_igraph_feedback_arc_set(SEXP graph, SEXP weights, SEXP algo) { +SEXP R_igraph_sample_sphere_surface(SEXP dim, SEXP n, SEXP radius, SEXP positive) { /* Declarations */ - igraph_t c_graph; - igraph_vector_t c_result; - igraph_vector_t c_weights; - igraph_fas_algorithm_t c_algo; - SEXP result; + igraph_integer_t c_dim; + igraph_integer_t c_n; + igraph_real_t c_radius; + igraph_bool_t c_positive; + igraph_matrix_t c_res; + SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_result, 0)) { + c_dim=INTEGER(dim)[0]; + c_n=INTEGER(n)[0]; + c_radius=REAL(radius)[0]; + c_positive=LOGICAL(positive)[0]; + if (0 != igraph_matrix_init(&c_res, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_result); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_algo = (igraph_fas_algorithm_t) Rf_asInteger(algo); + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_feedback_arc_set(&c_graph, &c_result, (Rf_isNull(weights) ? 0 : &c_weights), c_algo)); + IGRAPH_R_CHECK(igraph_sample_sphere_surface(c_dim, c_n, c_radius, c_positive, &c_res)); /* Convert output */ - PROTECT(result=R_igraph_vector_to_SEXPp1(&c_result)); - igraph_vector_destroy(&c_result); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = result; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_loop / +/ igraph_sample_sphere_volume / /-------------------------------------------*/ -SEXP R_igraph_is_loop(SEXP graph, SEXP es) { +SEXP R_igraph_sample_sphere_volume(SEXP dim, SEXP n, SEXP radius, SEXP positive) { /* Declarations */ - igraph_t c_graph; - igraph_vector_bool_t c_res; - igraph_es_t c_es; + igraph_integer_t c_dim; + igraph_integer_t c_n; + igraph_real_t c_radius; + igraph_bool_t c_positive; + igraph_matrix_t c_res; SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_bool_init(&c_res, 0)) { + c_dim=INTEGER(dim)[0]; + c_n=INTEGER(n)[0]; + c_radius=REAL(radius)[0]; + c_positive=LOGICAL(positive)[0]; + if (0 != igraph_matrix_init(&c_res, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); - R_SEXP_to_igraph_es(es, &c_graph, &c_es); + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_loop(&c_graph, &c_res, c_es)); + IGRAPH_R_CHECK(igraph_sample_sphere_volume(c_dim, c_n, c_radius, c_positive, &c_res)); /* Convert output */ - PROTECT(res=R_igraph_vector_bool_to_SEXP(&c_res)); - igraph_vector_bool_destroy(&c_res); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - igraph_es_destroy(&c_es); r_result = res; UNPROTECT(1); @@ -1754,23 +1599,30 @@ SEXP R_igraph_is_loop(SEXP graph, SEXP es) { } /*-------------------------------------------/ -/ igraph_is_dag / +/ igraph_sample_dirichlet / /-------------------------------------------*/ -SEXP R_igraph_is_dag(SEXP graph) { +SEXP R_igraph_sample_dirichlet(SEXP n, SEXP alpha) { /* Declarations */ - igraph_t c_graph; - igraph_bool_t c_res; + igraph_integer_t c_n; + igraph_vector_t c_alpha; + igraph_matrix_t c_res; SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); + c_n=INTEGER(n)[0]; + R_SEXP_to_vector(alpha, &c_alpha); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_dag(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_sample_dirichlet(c_n, &c_alpha, &c_res)); /* Convert output */ - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -1778,79 +1630,150 @@ SEXP R_igraph_is_dag(SEXP graph) { } /*-------------------------------------------/ -/ igraph_is_simple / +/ igraph_closeness / /-------------------------------------------*/ -SEXP R_igraph_is_simple(SEXP graph) { +SEXP R_igraph_closeness(SEXP graph, SEXP vids, SEXP mode, SEXP weights, SEXP normalized) { /* Declarations */ igraph_t c_graph; - igraph_bool_t c_res; + igraph_vector_t c_res; + igraph_vector_int_t c_reachable_count; + igraph_bool_t c_all_reachable; + igraph_vs_t c_vids; + igraph_neimode_t c_mode; + igraph_vector_t c_weights; + igraph_bool_t c_normalized; SEXP res; + SEXP reachable_count; + SEXP all_reachable; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (0 != igraph_vector_int_init(&c_reachable_count, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_reachable_count); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_normalized=LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_simple(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_closeness(&c_graph, &c_res, &c_reachable_count, &c_all_reachable, c_vids, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_normalized)); /* Convert output */ - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; - r_result = res; + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(reachable_count=R_igraph_vector_int_to_SEXP(&c_reachable_count)); + igraph_vector_int_destroy(&c_reachable_count); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(all_reachable=NEW_LOGICAL(1)); + LOGICAL(all_reachable)[0]=c_all_reachable; + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, reachable_count); + SET_VECTOR_ELT(r_result, 2, all_reachable); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("reachable_count")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("all_reachable")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_multiple / +/ igraph_closeness_cutoff / /-------------------------------------------*/ -SEXP R_igraph_is_multiple(SEXP graph, SEXP es) { +SEXP R_igraph_closeness_cutoff(SEXP graph, SEXP vids, SEXP mode, SEXP weights, SEXP normalized, SEXP cutoff) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_res; - igraph_es_t c_es; + igraph_vector_t c_res; + igraph_vector_int_t c_reachable_count; + igraph_bool_t c_all_reachable; + igraph_vs_t c_vids; + igraph_neimode_t c_mode; + igraph_vector_t c_weights; + igraph_bool_t c_normalized; + igraph_real_t c_cutoff; SEXP res; + SEXP reachable_count; + SEXP all_reachable; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_bool_init(&c_res, 0)) { + if (0 != igraph_vector_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); - R_SEXP_to_igraph_es(es, &c_graph, &c_es); + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (0 != igraph_vector_int_init(&c_reachable_count, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_reachable_count); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_normalized=LOGICAL(normalized)[0]; + c_cutoff=REAL(cutoff)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_multiple(&c_graph, &c_res, c_es)); + IGRAPH_R_CHECK(igraph_closeness_cutoff(&c_graph, &c_res, &c_reachable_count, &c_all_reachable, c_vids, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_normalized, c_cutoff)); /* Convert output */ - PROTECT(res=R_igraph_vector_bool_to_SEXP(&c_res)); - igraph_vector_bool_destroy(&c_res); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - igraph_es_destroy(&c_es); - r_result = res; + PROTECT(reachable_count=R_igraph_vector_int_to_SEXP(&c_reachable_count)); + igraph_vector_int_destroy(&c_reachable_count); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(all_reachable=NEW_LOGICAL(1)); + LOGICAL(all_reachable)[0]=c_all_reachable; + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, reachable_count); + SET_VECTOR_ELT(r_result, 2, all_reachable); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("reachable_count")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("all_reachable")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_has_loop / +/ igraph_distances / /-------------------------------------------*/ -SEXP R_igraph_has_loop(SEXP graph) { +SEXP R_igraph_distances(SEXP graph, SEXP from, SEXP to, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_bool_t c_res; + igraph_matrix_t c_res; + igraph_vs_t c_from; + igraph_vs_t c_to; + igraph_neimode_t c_mode; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_has_loop(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_distances(&c_graph, &c_res, c_from, c_to, c_mode)); /* Convert output */ - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -1858,23 +1781,34 @@ SEXP R_igraph_has_loop(SEXP graph) { } /*-------------------------------------------/ -/ igraph_has_multiple / +/ igraph_distances_cutoff / /-------------------------------------------*/ -SEXP R_igraph_has_multiple(SEXP graph) { +SEXP R_igraph_distances_cutoff(SEXP graph, SEXP from, SEXP to, SEXP mode, SEXP cutoff) { /* Declarations */ igraph_t c_graph; - igraph_bool_t c_res; + igraph_matrix_t c_res; + igraph_vs_t c_from; + igraph_vs_t c_to; + igraph_neimode_t c_mode; + igraph_real_t c_cutoff; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_cutoff=REAL(cutoff)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_has_multiple(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_distances_cutoff(&c_graph, &c_res, c_from, c_to, c_mode, c_cutoff)); /* Convert output */ - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -1882,302 +1816,344 @@ SEXP R_igraph_has_multiple(SEXP graph) { } /*-------------------------------------------/ -/ igraph_count_multiple / +/ igraph_get_shortest_path / /-------------------------------------------*/ -SEXP R_igraph_count_multiple(SEXP graph, SEXP es) { +SEXP R_igraph_get_shortest_path(SEXP graph, SEXP from, SEXP to, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_es_t c_es; - SEXP res; + igraph_vector_int_t c_vertices; + igraph_vector_int_t c_edges; + igraph_integer_t c_from; + igraph_integer_t c_to; + igraph_neimode_t c_mode; + SEXP vertices; + SEXP edges; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + if (0 != igraph_vector_int_init(&c_vertices, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - R_SEXP_to_igraph_es(es, &c_graph, &c_es); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); + if (0 != igraph_vector_int_init(&c_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); + c_from = (igraph_integer_t) REAL(from)[0]; + c_to = (igraph_integer_t) REAL(to)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_count_multiple(&c_graph, &c_res, c_es)); + IGRAPH_R_CHECK(igraph_get_shortest_path(&c_graph, &c_vertices, &c_edges, c_from, c_to, c_mode)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(vertices=R_igraph_vector_int_to_SEXP(&c_vertices)); + igraph_vector_int_destroy(&c_vertices); IGRAPH_FINALLY_CLEAN(1); - igraph_es_destroy(&c_es); - r_result = res; + PROTECT(edges=R_igraph_vector_int_to_SEXP(&c_edges)); + igraph_vector_int_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vertices); + SET_VECTOR_ELT(r_result, 1, edges); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vertices")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edges")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_eigenvector_centrality / +/ igraph_get_shortest_path_bellman_ford / /-------------------------------------------*/ -SEXP R_igraph_eigenvector_centrality(SEXP graph, SEXP directed, SEXP scale, SEXP weights, SEXP options) { +SEXP R_igraph_get_shortest_path_bellman_ford(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_vector; - igraph_real_t c_value; - igraph_bool_t c_directed; - igraph_bool_t c_scale; + igraph_vector_int_t c_vertices; + igraph_vector_int_t c_edges; + igraph_integer_t c_from; + igraph_integer_t c_to; igraph_vector_t c_weights; - igraph_arpack_options_t c_options; - SEXP vector; - SEXP value; + igraph_neimode_t c_mode; + SEXP vertices; + SEXP edges; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_vector, 0)) { + if (0 != igraph_vector_int_init(&c_vertices, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); - c_directed=LOGICAL(directed)[0]; - c_scale=LOGICAL(scale)[0]; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); + if (0 != igraph_vector_int_init(&c_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); + c_from = (igraph_integer_t) REAL(from)[0]; + c_to = (igraph_integer_t) REAL(to)[0]; if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - R_SEXP_to_igraph_arpack_options(options, &c_options); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_eigenvector_centrality(&c_graph, &c_vector, &c_value, c_directed, c_scale, (Rf_isNull(weights) ? 0 : &c_weights), &c_options)); + IGRAPH_R_CHECK(igraph_get_shortest_path_bellman_ford(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); - igraph_vector_destroy(&c_vector); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(vertices=R_igraph_vector_int_to_SEXP(&c_vertices)); + igraph_vector_int_destroy(&c_vertices); IGRAPH_FINALLY_CLEAN(1); - PROTECT(value=NEW_NUMERIC(1)); - REAL(value)[0]=c_value; - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); - SET_VECTOR_ELT(r_result, 0, vector); - SET_VECTOR_ELT(r_result, 1, value); - SET_VECTOR_ELT(r_result, 2, options); - SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); + PROTECT(edges=R_igraph_vector_int_to_SEXP(&c_edges)); + igraph_vector_int_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vertices); + SET_VECTOR_ELT(r_result, 1, edges); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vertices")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edges")); SET_NAMES(r_result, r_names); - UNPROTECT(4); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hub_score / +/ igraph_get_shortest_path_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_hub_score(SEXP graph, SEXP scale, SEXP weights, SEXP options) { +SEXP R_igraph_get_shortest_path_dijkstra(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_vector; - igraph_real_t c_value; - igraph_bool_t c_scale; + igraph_vector_int_t c_vertices; + igraph_vector_int_t c_edges; + igraph_integer_t c_from; + igraph_integer_t c_to; igraph_vector_t c_weights; - igraph_arpack_options_t c_options; - SEXP vector; - SEXP value; + igraph_neimode_t c_mode; + SEXP vertices; + SEXP edges; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_vector, 0)) { + if (0 != igraph_vector_int_init(&c_vertices, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); - c_scale=LOGICAL(scale)[0]; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); + if (0 != igraph_vector_int_init(&c_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); + c_from = (igraph_integer_t) REAL(from)[0]; + c_to = (igraph_integer_t) REAL(to)[0]; if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - R_SEXP_to_igraph_arpack_options(options, &c_options); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hub_score(&c_graph, &c_vector, &c_value, c_scale, (Rf_isNull(weights) ? 0 : &c_weights), &c_options)); + IGRAPH_R_CHECK(igraph_get_shortest_path_dijkstra(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); - igraph_vector_destroy(&c_vector); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(vertices=R_igraph_vector_int_to_SEXP(&c_vertices)); + igraph_vector_int_destroy(&c_vertices); IGRAPH_FINALLY_CLEAN(1); - PROTECT(value=NEW_NUMERIC(1)); - REAL(value)[0]=c_value; - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); - SET_VECTOR_ELT(r_result, 0, vector); - SET_VECTOR_ELT(r_result, 1, value); - SET_VECTOR_ELT(r_result, 2, options); - SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); + PROTECT(edges=R_igraph_vector_int_to_SEXP(&c_edges)); + igraph_vector_int_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vertices); + SET_VECTOR_ELT(r_result, 1, edges); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vertices")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edges")); SET_NAMES(r_result, r_names); - UNPROTECT(4); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_authority_score / +/ igraph_get_shortest_path_astar / /-------------------------------------------*/ -SEXP R_igraph_authority_score(SEXP graph, SEXP scale, SEXP weights, SEXP options) { +SEXP R_igraph_get_shortest_path_astar(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_vector; - igraph_real_t c_value; - igraph_bool_t c_scale; + igraph_vector_int_t c_vertices; + igraph_vector_int_t c_edges; + igraph_integer_t c_from; + igraph_integer_t c_to; igraph_vector_t c_weights; - igraph_arpack_options_t c_options; - SEXP vector; - SEXP value; + igraph_neimode_t c_mode; + + + SEXP vertices; + SEXP edges; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_vector, 0)) { + if (0 != igraph_vector_int_init(&c_vertices, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); - c_scale=LOGICAL(scale)[0]; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); + if (0 != igraph_vector_int_init(&c_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); + c_from = (igraph_integer_t) REAL(from)[0]; + c_to = (igraph_integer_t) REAL(to)[0]; if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - R_SEXP_to_igraph_arpack_options(options, &c_options); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_authority_score(&c_graph, &c_vector, &c_value, c_scale, (Rf_isNull(weights) ? 0 : &c_weights), &c_options)); + IGRAPH_R_CHECK(igraph_get_shortest_path_astar(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode, 0, 0)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); - igraph_vector_destroy(&c_vector); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(vertices=R_igraph_vector_int_to_SEXP(&c_vertices)); + igraph_vector_int_destroy(&c_vertices); IGRAPH_FINALLY_CLEAN(1); - PROTECT(value=NEW_NUMERIC(1)); - REAL(value)[0]=c_value; - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); - SET_VECTOR_ELT(r_result, 0, vector); - SET_VECTOR_ELT(r_result, 1, value); - SET_VECTOR_ELT(r_result, 2, options); - SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); + PROTECT(edges=R_igraph_vector_int_to_SEXP(&c_edges)); + igraph_vector_int_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vertices); + SET_VECTOR_ELT(r_result, 1, edges); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vertices")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edges")); SET_NAMES(r_result, r_names); - UNPROTECT(4); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_arpack_unpack_complex / +/ igraph_get_all_shortest_paths / /-------------------------------------------*/ -SEXP R_igraph_arpack_unpack_complex(SEXP vectors, SEXP values, SEXP nev) { +SEXP R_igraph_get_all_shortest_paths(SEXP graph, SEXP from, SEXP to, SEXP mode) { /* Declarations */ - igraph_matrix_t c_vectors; - igraph_matrix_t c_values; - long int c_nev; + igraph_t c_graph; + igraph_vector_int_list_t c_vertices; + igraph_vector_int_list_t c_edges; + igraph_vector_int_t c_nrgeo; + igraph_integer_t c_from; + igraph_vs_t c_to; + igraph_neimode_t c_mode; + SEXP vertices; + SEXP edges; + SEXP nrgeo; SEXP r_result, r_names; /* Convert input */ - if (0 != R_SEXP_to_igraph_matrix_copy(vectors, &c_vectors)) { + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_list_init(&c_vertices, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_vectors); - if (0 != R_SEXP_to_igraph_matrix_copy(values, &c_values)) { + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_vertices); + if (0 != igraph_vector_int_list_init(&c_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_edges); + if (0 != igraph_vector_int_init(&c_nrgeo, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_values); - c_nev=INTEGER(nev)[0]; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_nrgeo); + c_from = (igraph_integer_t) REAL(from)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_arpack_unpack_complex(&c_vectors, &c_values, c_nev)); + IGRAPH_R_CHECK(igraph_get_all_shortest_paths(&c_graph, &c_vertices, &c_edges, &c_nrgeo, c_from, c_to, c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(vectors=R_igraph_matrix_to_SEXP(&c_vectors)); - igraph_matrix_destroy(&c_vectors); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(vertices=R_igraph_vector_int_list_to_SEXP(&c_vertices)); + igraph_vector_int_list_destroy(&c_vertices); IGRAPH_FINALLY_CLEAN(1); - PROTECT(values=R_igraph_matrix_to_SEXP(&c_values)); - igraph_matrix_destroy(&c_values); + PROTECT(edges=R_igraph_vector_int_list_to_SEXP(&c_edges)); + igraph_vector_int_list_destroy(&c_edges); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, vectors); - SET_VECTOR_ELT(r_result, 1, values); - SET_STRING_ELT(r_names, 0, Rf_mkChar("vectors")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("values")); + PROTECT(nrgeo=R_igraph_vector_int_to_SEXP(&c_nrgeo)); + igraph_vector_int_destroy(&c_nrgeo); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vertices); + SET_VECTOR_ELT(r_result, 1, edges); + SET_VECTOR_ELT(r_result, 2, nrgeo); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vertices")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edges")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("nrgeo")); SET_NAMES(r_result, r_names); - UNPROTECT(3); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_unfold_tree / +/ igraph_distances_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_unfold_tree(SEXP graph, SEXP mode, SEXP roots) { +SEXP R_igraph_distances_dijkstra(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_t c_tree; + igraph_matrix_t c_res; + igraph_vs_t c_from; + igraph_vs_t c_to; + igraph_vector_t c_weights; igraph_neimode_t c_mode; - igraph_vector_t c_roots; - igraph_vector_t c_vertex_index; - SEXP tree; - SEXP vertex_index; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - R_SEXP_to_vector(roots, &c_roots); - if (0 != igraph_vector_init(&c_vertex_index, 0)) { + if (0 != igraph_matrix_init(&c_res, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_vertex_index); - vertex_index=R_GlobalEnv; /* hack to have a non-NULL value */ + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_unfold_tree(&c_graph, &c_tree, c_mode, &c_roots, (Rf_isNull(vertex_index) ? 0 : &c_vertex_index))); + IGRAPH_R_CHECK(igraph_distances_dijkstra(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - IGRAPH_FINALLY(igraph_destroy, &c_tree); - PROTECT(tree=R_igraph_to_SEXP(&c_tree)); - igraph_destroy(&c_tree); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(vertex_index=R_igraph_0orvector_to_SEXPp1(&c_vertex_index)); - igraph_vector_destroy(&c_vertex_index); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, tree); - SET_VECTOR_ELT(r_result, 1, vertex_index); - SET_STRING_ELT(r_names, 0, Rf_mkChar("tree")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("vertex_index")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_mutual / +/ igraph_distances_dijkstra_cutoff / /-------------------------------------------*/ -SEXP R_igraph_is_mutual(SEXP graph, SEXP es) { +SEXP R_igraph_distances_dijkstra_cutoff(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode, SEXP cutoff) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_res; - igraph_es_t c_es; + igraph_matrix_t c_res; + igraph_vs_t c_from; + igraph_vs_t c_to; + igraph_vector_t c_weights; + igraph_neimode_t c_mode; + igraph_real_t c_cutoff; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_bool_init(&c_res, 0)) { + if (0 != igraph_matrix_init(&c_res, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); - R_SEXP_to_igraph_es(es, &c_graph, &c_es); + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_cutoff=REAL(cutoff)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_mutual(&c_graph, &c_res, c_es)); + IGRAPH_R_CHECK(igraph_distances_dijkstra_cutoff(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode, c_cutoff)); /* Convert output */ - PROTECT(res=R_igraph_vector_bool_to_SEXP(&c_res)); - igraph_vector_bool_destroy(&c_res); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - igraph_es_destroy(&c_es); r_result = res; UNPROTECT(1); @@ -2185,137 +2161,130 @@ SEXP R_igraph_is_mutual(SEXP graph, SEXP es) { } /*-------------------------------------------/ -/ igraph_maximum_cardinality_search / +/ igraph_get_all_shortest_paths_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_maximum_cardinality_search(SEXP graph) { +SEXP R_igraph_get_all_shortest_paths_dijkstra(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_alpha; - igraph_vector_t c_alpham1; - SEXP alpha; - SEXP alpham1; + igraph_vector_int_list_t c_vertices; + igraph_vector_int_list_t c_edges; + igraph_vector_int_t c_nrgeo; + igraph_integer_t c_from; + igraph_vs_t c_to; + igraph_vector_t c_weights; + igraph_neimode_t c_mode; + SEXP vertices; + SEXP edges; + SEXP nrgeo; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_alpha, 0)) { + if (0 != igraph_vector_int_list_init(&c_vertices, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_alpha); - if (0 != igraph_vector_init(&c_alpham1, 0)) { + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_vertices); + if (0 != igraph_vector_int_list_init(&c_edges, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_alpham1); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_edges); + if (0 != igraph_vector_int_init(&c_nrgeo, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_nrgeo); + c_from = (igraph_integer_t) REAL(from)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_maximum_cardinality_search(&c_graph, &c_alpha, &c_alpham1)); + IGRAPH_R_CHECK(igraph_get_all_shortest_paths_dijkstra(&c_graph, &c_vertices, &c_edges, &c_nrgeo, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(alpha=R_igraph_vector_to_SEXPp1(&c_alpha)); - igraph_vector_destroy(&c_alpha); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(vertices=R_igraph_vector_int_list_to_SEXP(&c_vertices)); + igraph_vector_int_list_destroy(&c_vertices); IGRAPH_FINALLY_CLEAN(1); - PROTECT(alpham1=R_igraph_vector_to_SEXPp1(&c_alpham1)); - igraph_vector_destroy(&c_alpham1); + PROTECT(edges=R_igraph_vector_int_list_to_SEXP(&c_edges)); + igraph_vector_int_list_destroy(&c_edges); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, alpha); - SET_VECTOR_ELT(r_result, 1, alpham1); - SET_STRING_ELT(r_names, 0, Rf_mkChar("alpha")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("alpham1")); + PROTECT(nrgeo=R_igraph_vector_int_to_SEXP(&c_nrgeo)); + igraph_vector_int_destroy(&c_nrgeo); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vertices); + SET_VECTOR_ELT(r_result, 1, edges); + SET_VECTOR_ELT(r_result, 2, nrgeo); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vertices")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edges")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("nrgeo")); SET_NAMES(r_result, r_names); - UNPROTECT(3); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_avg_nearest_neighbor_degree / +/ igraph_distances_bellman_ford / /-------------------------------------------*/ -SEXP R_igraph_avg_nearest_neighbor_degree(SEXP graph, SEXP vids, SEXP mode, SEXP neighbor_degree_mode, SEXP weights) { +SEXP R_igraph_distances_bellman_ford(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vs_t c_vids; - igraph_neimode_t c_mode; - igraph_neimode_t c_neighbor_degree_mode; - igraph_vector_t c_knn; - igraph_vector_t c_knnk; + igraph_matrix_t c_res; + igraph_vs_t c_from; + igraph_vs_t c_to; igraph_vector_t c_weights; - SEXP knn; - SEXP knnk; + igraph_neimode_t c_mode; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_neighbor_degree_mode = (igraph_neimode_t) Rf_asInteger(neighbor_degree_mode); - if (0 != igraph_vector_init(&c_knn, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_knn); - if (0 != igraph_vector_init(&c_knnk, 0)) { + if (0 != igraph_matrix_init(&c_res, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_knnk); - knnk=R_GlobalEnv; /* hack to have a non-NULL value */ + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_avg_nearest_neighbor_degree(&c_graph, c_vids, c_mode, c_neighbor_degree_mode, &c_knn, (Rf_isNull(knnk) ? 0 : &c_knnk), (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_distances_bellman_ford(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - igraph_vs_destroy(&c_vids); - PROTECT(knn=R_igraph_vector_to_SEXP(&c_knn)); - igraph_vector_destroy(&c_knn); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(knnk=R_igraph_0orvector_to_SEXP(&c_knnk)); - igraph_vector_destroy(&c_knnk); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, knn); - SET_VECTOR_ELT(r_result, 1, knnk); - SET_STRING_ELT(r_names, 0, Rf_mkChar("knn")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("knnk")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_strength / +/ igraph_distances_johnson / /-------------------------------------------*/ -SEXP R_igraph_strength(SEXP graph, SEXP vids, SEXP mode, SEXP loops, SEXP weights) { +SEXP R_igraph_distances_johnson(SEXP graph, SEXP from, SEXP to, SEXP weights) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vs_t c_vids; - igraph_neimode_t c_mode; - igraph_bool_t c_loops; + igraph_matrix_t c_res; + igraph_vs_t c_from; + igraph_vs_t c_to; igraph_vector_t c_weights; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + if (0 != igraph_matrix_init(&c_res, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_loops=LOGICAL(loops)[0]; + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_strength(&c_graph, &c_res, c_vids, c_mode, c_loops, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_distances_johnson(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); r_result = res; UNPROTECT(1); @@ -2323,107 +2292,125 @@ SEXP R_igraph_strength(SEXP graph, SEXP vids, SEXP mode, SEXP loops, SEXP weight } /*-------------------------------------------/ -/ igraph_centralization / +/ igraph_distances_floyd_warshall / /-------------------------------------------*/ -SEXP R_igraph_centralization(SEXP scores, SEXP theoretical_max, SEXP normalized) { +SEXP R_igraph_distances_floyd_warshall(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode, SEXP method) { /* Declarations */ - igraph_vector_t c_scores; - igraph_real_t c_theoretical_max; - igraph_bool_t c_normalized; - igraph_real_t c_result; + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_vs_t c_from; + igraph_vs_t c_to; + igraph_vector_t c_weights; + igraph_neimode_t c_mode; + igraph_floyd_warshall_algorithm_t c_method; + SEXP res; + SEXP r_result; /* Convert input */ - R_SEXP_to_vector(scores, &c_scores); - c_theoretical_max=REAL(theoretical_max)[0]; - c_normalized=LOGICAL(normalized)[0]; + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_method = (igraph_floyd_warshall_algorithm_t) Rf_asInteger(method); /* Call igraph */ - c_result=igraph_centralization(&c_scores, c_theoretical_max, c_normalized); + IGRAPH_R_CHECK(igraph_distances_floyd_warshall(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode, c_method)); /* Convert output */ - - PROTECT(r_result=NEW_NUMERIC(1)); - REAL(r_result)[0]=c_result; + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_degree / +/ igraph_voronoi / /-------------------------------------------*/ -SEXP R_igraph_centralization_degree(SEXP graph, SEXP mode, SEXP loops, SEXP normalized) { +SEXP R_igraph_voronoi(SEXP graph, SEXP generators, SEXP weights, SEXP mode, SEXP tiebreaker) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; + igraph_vector_int_t c_membership; + igraph_vector_t c_distances; + igraph_vector_int_t c_generators; + igraph_vector_t c_weights; igraph_neimode_t c_mode; - igraph_bool_t c_loops; - igraph_real_t c_centralization; - igraph_real_t c_theoretical_max; - igraph_bool_t c_normalized; - SEXP res; - SEXP centralization; - SEXP theoretical_max; + igraph_voronoi_tiebreaker_t c_tiebreaker; + SEXP membership; + SEXP distances; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + if (0 != igraph_vector_int_init(&c_membership, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); + if (0 != igraph_vector_init(&c_distances, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_distances); + R_SEXP_to_vector_int(generators, &c_generators); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_loops=LOGICAL(loops)[0]; - c_normalized=LOGICAL(normalized)[0]; + c_tiebreaker = (igraph_voronoi_tiebreaker_t) Rf_asInteger(tiebreaker); /* Call igraph */ - IGRAPH_R_CHECK(igraph_centralization_degree(&c_graph, &c_res, c_mode, c_loops, &c_centralization, &c_theoretical_max, c_normalized)); + IGRAPH_R_CHECK(igraph_voronoi(&c_graph, &c_membership, &c_distances, &c_generators, (Rf_isNull(weights) ? 0 : &c_weights), c_mode, c_tiebreaker)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); + igraph_vector_int_destroy(&c_membership); IGRAPH_FINALLY_CLEAN(1); - PROTECT(centralization=NEW_NUMERIC(1)); - REAL(centralization)[0]=c_centralization; - PROTECT(theoretical_max=NEW_NUMERIC(1)); - REAL(theoretical_max)[0]=c_theoretical_max; - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, centralization); - SET_VECTOR_ELT(r_result, 2, theoretical_max); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("centralization")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("theoretical_max")); + PROTECT(distances=R_igraph_vector_to_SEXP(&c_distances)); + igraph_vector_destroy(&c_distances); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, membership); + SET_VECTOR_ELT(r_result, 1, distances); + SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("distances")); SET_NAMES(r_result, r_names); - UNPROTECT(4); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_degree_tmax / +/ igraph_get_all_simple_paths / /-------------------------------------------*/ -SEXP R_igraph_centralization_degree_tmax(SEXP graph, SEXP nodes, SEXP mode, SEXP loops) { +SEXP R_igraph_get_all_simple_paths(SEXP graph, SEXP from, SEXP to, SEXP cutoff, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_nodes; + igraph_vector_int_t c_res; + igraph_integer_t c_from; + igraph_vs_t c_to; + igraph_integer_t c_cutoff; igraph_neimode_t c_mode; - igraph_bool_t c_loops; - igraph_real_t c_res; SEXP res; SEXP r_result; /* Convert input */ - if (!Rf_isNull(graph)) { R_SEXP_to_igraph(graph, &c_graph); } - c_nodes=INTEGER(nodes)[0]; + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + c_from = (igraph_integer_t) REAL(from)[0]; + c_cutoff=INTEGER(cutoff)[0]; c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_loops=LOGICAL(loops)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_centralization_degree_tmax((Rf_isNull(graph) ? 0 : &c_graph), c_nodes, c_mode, c_loops, &c_res)); + IGRAPH_R_CHECK(igraph_get_all_simple_paths(&c_graph, &c_res, c_from, c_to, c_cutoff, c_mode)); /* Convert output */ - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; + PROTECT(res=R_igraph_vector_int_to_SEXP(&c_res)); + igraph_vector_int_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -2431,155 +2418,216 @@ SEXP R_igraph_centralization_degree_tmax(SEXP graph, SEXP nodes, SEXP mode, SEXP } /*-------------------------------------------/ -/ igraph_centralization_betweenness / +/ igraph_get_k_shortest_paths / /-------------------------------------------*/ -SEXP R_igraph_centralization_betweenness(SEXP graph, SEXP directed, SEXP normalized) { +SEXP R_igraph_get_k_shortest_paths(SEXP graph, SEXP weights, SEXP k, SEXP from, SEXP to, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_bool_t c_directed; - igraph_real_t c_centralization; - igraph_real_t c_theoretical_max; - igraph_bool_t c_normalized; - SEXP res; - SEXP centralization; - SEXP theoretical_max; + igraph_vector_t c_weights; + igraph_vector_int_list_t c_vertex_paths; + igraph_vector_int_list_t c_edge_paths; + igraph_integer_t c_k; + igraph_integer_t c_from; + igraph_integer_t c_to; + igraph_neimode_t c_mode; + SEXP vertex_paths; + SEXP edge_paths; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (0 != igraph_vector_int_list_init(&c_vertex_paths, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - c_directed=LOGICAL(directed)[0]; - c_normalized=LOGICAL(normalized)[0]; + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_vertex_paths); + if (0 != igraph_vector_int_list_init(&c_edge_paths, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_edge_paths); + c_k=INTEGER(k)[0]; + c_from = (igraph_integer_t) REAL(from)[0]; + c_to = (igraph_integer_t) REAL(to)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_centralization_betweenness(&c_graph, &c_res, c_directed, &c_centralization, &c_theoretical_max, c_normalized)); + IGRAPH_R_CHECK(igraph_get_k_shortest_paths(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_vertex_paths, &c_edge_paths, c_k, c_from, c_to, c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(centralization=NEW_NUMERIC(1)); - REAL(centralization)[0]=c_centralization; - PROTECT(theoretical_max=NEW_NUMERIC(1)); - REAL(theoretical_max)[0]=c_theoretical_max; - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, centralization); - SET_VECTOR_ELT(r_result, 2, theoretical_max); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("centralization")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("theoretical_max")); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(vertex_paths=R_igraph_vector_int_list_to_SEXP(&c_vertex_paths)); + igraph_vector_int_list_destroy(&c_vertex_paths); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edge_paths=R_igraph_vector_int_list_to_SEXP(&c_edge_paths)); + igraph_vector_int_list_destroy(&c_edge_paths); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vertex_paths); + SET_VECTOR_ELT(r_result, 1, edge_paths); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vertex_paths")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edge_paths")); SET_NAMES(r_result, r_names); - UNPROTECT(4); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_betweenness_tmax / +/ igraph_get_widest_path / /-------------------------------------------*/ -SEXP R_igraph_centralization_betweenness_tmax(SEXP graph, SEXP nodes, SEXP directed) { +SEXP R_igraph_get_widest_path(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_nodes; - igraph_bool_t c_directed; - igraph_real_t c_res; - SEXP res; + igraph_vector_int_t c_vertices; + igraph_vector_int_t c_edges; + igraph_integer_t c_from; + igraph_integer_t c_to; + igraph_vector_t c_weights; + igraph_neimode_t c_mode; + SEXP vertices; + SEXP edges; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - if (!Rf_isNull(graph)) { R_SEXP_to_igraph(graph, &c_graph); } - c_nodes=INTEGER(nodes)[0]; - c_directed=LOGICAL(directed)[0]; + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_vertices, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); + if (0 != igraph_vector_int_init(&c_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); + c_from = (igraph_integer_t) REAL(from)[0]; + c_to = (igraph_integer_t) REAL(to)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_centralization_betweenness_tmax((Rf_isNull(graph) ? 0 : &c_graph), c_nodes, c_directed, &c_res)); + IGRAPH_R_CHECK(igraph_get_widest_path(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); /* Convert output */ - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; - r_result = res; + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(vertices=R_igraph_vector_int_to_SEXP(&c_vertices)); + igraph_vector_int_destroy(&c_vertices); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edges=R_igraph_vector_int_to_SEXP(&c_edges)); + igraph_vector_int_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vertices); + SET_VECTOR_ELT(r_result, 1, edges); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vertices")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edges")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_closeness / +/ igraph_get_widest_paths / /-------------------------------------------*/ -SEXP R_igraph_centralization_closeness(SEXP graph, SEXP mode, SEXP normalized) { +SEXP R_igraph_get_widest_paths(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; + igraph_vector_int_list_t c_vertices; + igraph_vector_int_list_t c_edges; + igraph_integer_t c_from; + igraph_vs_t c_to; + igraph_vector_t c_weights; igraph_neimode_t c_mode; - igraph_real_t c_centralization; - igraph_real_t c_theoretical_max; - igraph_bool_t c_normalized; - SEXP res; - SEXP centralization; - SEXP theoretical_max; + igraph_vector_int_t c_parents; + igraph_vector_int_t c_inbound_edges; + SEXP vertices; + SEXP edges; + SEXP parents; + SEXP inbound_edges; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + if (0 != igraph_vector_int_list_init(&c_vertices, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_vertices); + if (0 != igraph_vector_int_list_init(&c_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_edges); + c_from = (igraph_integer_t) REAL(from)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_normalized=LOGICAL(normalized)[0]; + if (0 != igraph_vector_int_init(&c_parents, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_parents); + if (0 != igraph_vector_int_init(&c_inbound_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_inbound_edges); /* Call igraph */ - IGRAPH_R_CHECK(igraph_centralization_closeness(&c_graph, &c_res, c_mode, &c_centralization, &c_theoretical_max, c_normalized)); + IGRAPH_R_CHECK(igraph_get_widest_paths(&c_graph, &c_vertices, &c_edges, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode, &c_parents, &c_inbound_edges)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(centralization=NEW_NUMERIC(1)); - REAL(centralization)[0]=c_centralization; - PROTECT(theoretical_max=NEW_NUMERIC(1)); - REAL(theoretical_max)[0]=c_theoretical_max; - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, centralization); - SET_VECTOR_ELT(r_result, 2, theoretical_max); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("centralization")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("theoretical_max")); + PROTECT(r_result=NEW_LIST(4)); + PROTECT(r_names=NEW_CHARACTER(4)); + PROTECT(vertices=R_igraph_vector_int_list_to_SEXP(&c_vertices)); + igraph_vector_int_list_destroy(&c_vertices); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edges=R_igraph_vector_int_list_to_SEXP(&c_edges)); + igraph_vector_int_list_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(parents=R_igraph_vector_int_to_SEXP(&c_parents)); + igraph_vector_int_destroy(&c_parents); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(inbound_edges=R_igraph_vector_int_to_SEXP(&c_inbound_edges)); + igraph_vector_int_destroy(&c_inbound_edges); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vertices); + SET_VECTOR_ELT(r_result, 1, edges); + SET_VECTOR_ELT(r_result, 2, parents); + SET_VECTOR_ELT(r_result, 3, inbound_edges); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vertices")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edges")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("parents")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("inbound_edges")); SET_NAMES(r_result, r_names); - UNPROTECT(4); + UNPROTECT(5); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_closeness_tmax / +/ igraph_widest_path_widths_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_centralization_closeness_tmax(SEXP graph, SEXP nodes, SEXP mode) { +SEXP R_igraph_widest_path_widths_dijkstra(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_nodes; + igraph_matrix_t c_res; + igraph_vs_t c_from; + igraph_vs_t c_to; + igraph_vector_t c_weights; igraph_neimode_t c_mode; - igraph_real_t c_res; SEXP res; SEXP r_result; /* Convert input */ - if (!Rf_isNull(graph)) { R_SEXP_to_igraph(graph, &c_graph); } - c_nodes=INTEGER(nodes)[0]; + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_centralization_closeness_tmax((Rf_isNull(graph) ? 0 : &c_graph), c_nodes, c_mode, &c_res)); + IGRAPH_R_CHECK(igraph_widest_path_widths_dijkstra(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); /* Convert output */ - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -2587,120 +2635,103 @@ SEXP R_igraph_centralization_closeness_tmax(SEXP graph, SEXP nodes, SEXP mode) { } /*-------------------------------------------/ -/ igraph_centralization_eigenvector_centrality / +/ igraph_widest_path_widths_floyd_warshall / /-------------------------------------------*/ -SEXP R_igraph_centralization_eigenvector_centrality(SEXP graph, SEXP directed, SEXP scale, SEXP options, SEXP normalized) { +SEXP R_igraph_widest_path_widths_floyd_warshall(SEXP graph, SEXP from, SEXP to, SEXP weights, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_vector; - igraph_real_t c_value; - igraph_bool_t c_directed; - igraph_bool_t c_scale; - igraph_arpack_options_t c_options; - igraph_real_t c_centralization; - igraph_real_t c_theoretical_max; - igraph_bool_t c_normalized; - SEXP vector; - SEXP value; - SEXP centralization; - SEXP theoretical_max; + igraph_matrix_t c_res; + igraph_vs_t c_from; + igraph_vs_t c_to; + igraph_vector_t c_weights; + igraph_neimode_t c_mode; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_vector, 0)) { + if (0 != igraph_matrix_init(&c_res, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); - c_directed=LOGICAL(directed)[0]; - c_scale=LOGICAL(scale)[0]; - R_SEXP_to_igraph_arpack_options(options, &c_options); - c_normalized=LOGICAL(normalized)[0]; + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_centralization_eigenvector_centrality(&c_graph, &c_vector, &c_value, c_directed, c_scale, &c_options, &c_centralization, &c_theoretical_max, c_normalized)); + IGRAPH_R_CHECK(igraph_widest_path_widths_floyd_warshall(&c_graph, &c_res, c_from, c_to, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(5)); - PROTECT(r_names=NEW_CHARACTER(5)); - PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); - igraph_vector_destroy(&c_vector); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - PROTECT(value=NEW_NUMERIC(1)); - REAL(value)[0]=c_value; - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); - PROTECT(centralization=NEW_NUMERIC(1)); - REAL(centralization)[0]=c_centralization; - PROTECT(theoretical_max=NEW_NUMERIC(1)); - REAL(theoretical_max)[0]=c_theoretical_max; - SET_VECTOR_ELT(r_result, 0, vector); - SET_VECTOR_ELT(r_result, 1, value); - SET_VECTOR_ELT(r_result, 2, options); - SET_VECTOR_ELT(r_result, 3, centralization); - SET_VECTOR_ELT(r_result, 4, theoretical_max); - SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); - SET_STRING_ELT(r_names, 3, Rf_mkChar("centralization")); - SET_STRING_ELT(r_names, 4, Rf_mkChar("theoretical_max")); - SET_NAMES(r_result, r_names); - UNPROTECT(6); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_centralization_eigenvector_centrality_tmax / +/ igraph_spanner / /-------------------------------------------*/ -SEXP R_igraph_centralization_eigenvector_centrality_tmax(SEXP graph, SEXP nodes, SEXP directed, SEXP scale) { +SEXP R_igraph_spanner(SEXP graph, SEXP stretch, SEXP weights) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_nodes; - igraph_bool_t c_directed; - igraph_bool_t c_scale; - igraph_real_t c_res; - SEXP res; + igraph_vector_int_t c_spanner; + igraph_real_t c_stretch; + igraph_vector_t c_weights; + SEXP spanner; SEXP r_result; /* Convert input */ - if (!Rf_isNull(graph)) { R_SEXP_to_igraph(graph, &c_graph); } - c_nodes=INTEGER(nodes)[0]; - c_directed=LOGICAL(directed)[0]; - c_scale=LOGICAL(scale)[0]; + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_spanner, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_spanner); + c_stretch=REAL(stretch)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_centralization_eigenvector_centrality_tmax((Rf_isNull(graph) ? 0 : &c_graph), c_nodes, c_directed, c_scale, &c_res)); + IGRAPH_R_CHECK(igraph_spanner(&c_graph, &c_spanner, c_stretch, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; - r_result = res; + PROTECT(spanner=R_igraph_vector_int_to_SEXP(&c_spanner)); + igraph_vector_int_destroy(&c_spanner); + IGRAPH_FINALLY_CLEAN(1); + r_result = spanner; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_assortativity_nominal / +/ igraph_betweenness_cutoff / /-------------------------------------------*/ -SEXP R_igraph_assortativity_nominal(SEXP graph, SEXP types, SEXP directed) { +SEXP R_igraph_betweenness_cutoff(SEXP graph, SEXP vids, SEXP directed, SEXP weights, SEXP cutoff) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_types; - igraph_real_t c_res; + igraph_vector_t c_res; + igraph_vs_t c_vids; igraph_bool_t c_directed; + igraph_vector_t c_weights; + igraph_real_t c_cutoff; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_vector(types, &c_types); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); c_directed=LOGICAL(directed)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_cutoff=REAL(cutoff)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_assortativity_nominal(&c_graph, &c_types, &c_res, c_directed)); + IGRAPH_R_CHECK(igraph_betweenness_cutoff(&c_graph, &c_res, c_vids, c_directed, (Rf_isNull(weights) ? 0 : &c_weights), c_cutoff)); /* Convert output */ - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -2708,29 +2739,35 @@ SEXP R_igraph_assortativity_nominal(SEXP graph, SEXP types, SEXP directed) { } /*-------------------------------------------/ -/ igraph_assortativity / +/ igraph_betweenness_subset / /-------------------------------------------*/ -SEXP R_igraph_assortativity(SEXP graph, SEXP types1, SEXP types2, SEXP directed) { +SEXP R_igraph_betweenness_subset(SEXP graph, SEXP vids, SEXP directed, SEXP sources, SEXP targets, SEXP weights) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_types1; - igraph_vector_t c_types2; - igraph_real_t c_res; + igraph_vector_t c_res; + igraph_vs_t c_vids; igraph_bool_t c_directed; + igraph_vs_t c_sources; + igraph_vs_t c_targets; + igraph_vector_t c_weights; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_vector(types1, &c_types1); - if (!Rf_isNull(types2)) { R_SEXP_to_vector(types2, &c_types2); } + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); c_directed=LOGICAL(directed)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_assortativity(&c_graph, &c_types1, (Rf_isNull(types2) ? 0 : &c_types2), &c_res, c_directed)); + IGRAPH_R_CHECK(igraph_betweenness_subset(&c_graph, &c_res, c_vids, c_directed, c_sources, c_targets, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -2738,25 +2775,32 @@ SEXP R_igraph_assortativity(SEXP graph, SEXP types1, SEXP types2, SEXP directed) } /*-------------------------------------------/ -/ igraph_assortativity_degree / +/ igraph_edge_betweenness / /-------------------------------------------*/ -SEXP R_igraph_assortativity_degree(SEXP graph, SEXP directed) { +SEXP R_igraph_edge_betweenness(SEXP graph, SEXP directed, SEXP weights) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_res; + igraph_vector_t c_res; igraph_bool_t c_directed; + igraph_vector_t c_weights; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); c_directed=LOGICAL(directed)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_assortativity_degree(&c_graph, &c_res, c_directed)); + IGRAPH_R_CHECK(igraph_edge_betweenness(&c_graph, &c_res, c_directed, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -2764,45 +2808,52 @@ SEXP R_igraph_assortativity_degree(SEXP graph, SEXP directed) { } /*-------------------------------------------/ -/ igraph_contract_vertices / +/ igraph_edge_betweenness_cutoff / /-------------------------------------------*/ -SEXP R_igraph_contract_vertices(SEXP graph, SEXP mapping, SEXP vertex_attr_comb) { +SEXP R_igraph_edge_betweenness_cutoff(SEXP graph, SEXP directed, SEXP weights, SEXP cutoff) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_mapping; - igraph_attribute_combination_t c_vertex_attr_comb; + igraph_vector_t c_res; + igraph_bool_t c_directed; + igraph_vector_t c_weights; + igraph_real_t c_cutoff; + SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph_copy(graph, &c_graph); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - R_SEXP_to_vector(mapping, &c_mapping); - R_SEXP_to_attr_comb(vertex_attr_comb, &c_vertex_attr_comb); - IGRAPH_FINALLY(igraph_attribute_combination_destroy, &c_vertex_attr_comb); + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_directed=LOGICAL(directed)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_cutoff=REAL(cutoff)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_contract_vertices(&c_graph, &c_mapping, &c_vertex_attr_comb)); + IGRAPH_R_CHECK(igraph_edge_betweenness_cutoff(&c_graph, &c_res, c_directed, (Rf_isNull(weights) ? 0 : &c_weights), c_cutoff)); /* Convert output */ - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - igraph_attribute_combination_destroy(&c_vertex_attr_comb); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_eccentricity / +/ igraph_edge_betweenness_subset / /-------------------------------------------*/ -SEXP R_igraph_eccentricity(SEXP graph, SEXP vids, SEXP mode) { +SEXP R_igraph_edge_betweenness_subset(SEXP graph, SEXP eids, SEXP directed, SEXP sources, SEXP targets, SEXP weights) { /* Declarations */ igraph_t c_graph; igraph_vector_t c_res; - igraph_vs_t c_vids; - igraph_neimode_t c_mode; + igraph_es_t c_eids; + igraph_bool_t c_directed; + igraph_vs_t c_sources; + igraph_vs_t c_targets; + igraph_vector_t c_weights; SEXP res; SEXP r_result; @@ -2812,16 +2863,15 @@ SEXP R_igraph_eccentricity(SEXP graph, SEXP vids, SEXP mode) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_directed=LOGICAL(directed)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_eccentricity(&c_graph, &c_res, c_vids, c_mode)); + IGRAPH_R_CHECK(igraph_edge_betweenness_subset(&c_graph, &c_res, c_eids, c_directed, c_sources, c_targets, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); r_result = res; UNPROTECT(1); @@ -2829,163 +2879,226 @@ SEXP R_igraph_eccentricity(SEXP graph, SEXP vids, SEXP mode) { } /*-------------------------------------------/ -/ igraph_radius / +/ igraph_harmonic_centrality_cutoff / /-------------------------------------------*/ -SEXP R_igraph_radius(SEXP graph, SEXP mode) { +SEXP R_igraph_harmonic_centrality_cutoff(SEXP graph, SEXP vids, SEXP mode, SEXP weights, SEXP normalized, SEXP cutoff) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_radius; + igraph_vector_t c_res; + igraph_vs_t c_vids; igraph_neimode_t c_mode; - SEXP radius; + igraph_vector_t c_weights; + igraph_bool_t c_normalized; + igraph_real_t c_cutoff; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); c_mode = (igraph_neimode_t) Rf_asInteger(mode); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_normalized=LOGICAL(normalized)[0]; + c_cutoff=REAL(cutoff)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_radius(&c_graph, &c_radius, c_mode)); + IGRAPH_R_CHECK(igraph_harmonic_centrality_cutoff(&c_graph, &c_res, c_vids, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), c_normalized, c_cutoff)); /* Convert output */ - PROTECT(radius=NEW_NUMERIC(1)); - REAL(radius)[0]=c_radius; - r_result = radius; + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_diversity / +/ igraph_personalized_pagerank / /-------------------------------------------*/ -SEXP R_igraph_diversity(SEXP graph, SEXP weights, SEXP vids) { +SEXP R_igraph_personalized_pagerank(SEXP graph, SEXP algo, SEXP vids, SEXP directed, SEXP damping, SEXP personalized, SEXP weights, SEXP options) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_weights; - igraph_vector_t c_res; + igraph_pagerank_algo_t c_algo; + igraph_vector_t c_vector; + igraph_real_t c_value; igraph_vs_t c_vids; - SEXP res; + igraph_bool_t c_directed; + igraph_real_t c_damping; + igraph_vector_t c_personalized; + igraph_vector_t c_weights; + igraph_arpack_options_t c_options1; + void* c_options; + SEXP vector; + SEXP value; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_vector_init(&c_res, 0)) { + c_algo = (igraph_pagerank_algo_t) Rf_asInteger(algo); + if (0 != igraph_vector_init(&c_vector, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); + IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); + c_directed=LOGICAL(directed)[0]; + c_damping=REAL(damping)[0]; + R_SEXP_to_vector(personalized, &c_personalized); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { + R_SEXP_to_igraph_arpack_options(options, &c_options1); + c_options = &c_options1; + } else { + c_options = 0; + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_diversity(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_res, c_vids)); + IGRAPH_R_CHECK(igraph_personalized_pagerank(&c_graph, c_algo, &c_vector, &c_value, c_vids, c_directed, c_damping, &c_personalized, (Rf_isNull(weights) ? 0 : &c_weights), c_options)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); + igraph_vector_destroy(&c_vector); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); - r_result = res; + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { + PROTECT(options = R_igraph_arpack_options_to_SEXP(&c_options1)); + } else { + PROTECT(options); + } + SET_VECTOR_ELT(r_result, 0, vector); + SET_VECTOR_ELT(r_result, 1, value); + SET_VECTOR_ELT(r_result, 2, options); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_random_walk / +/ igraph_personalized_pagerank_vs / /-------------------------------------------*/ -SEXP R_igraph_random_walk(SEXP graph, SEXP start, SEXP mode, SEXP steps, SEXP stuck) { +SEXP R_igraph_personalized_pagerank_vs(SEXP graph, SEXP algo, SEXP vids, SEXP directed, SEXP damping, SEXP reset_vids, SEXP weights, SEXP options) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_walk; - igraph_integer_t c_start; - igraph_neimode_t c_mode; - igraph_integer_t c_steps; - igraph_random_walk_stuck_t c_stuck; - SEXP walk; + igraph_pagerank_algo_t c_algo; + igraph_vector_t c_vector; + igraph_real_t c_value; + igraph_vs_t c_vids; + igraph_bool_t c_directed; + igraph_real_t c_damping; + igraph_vs_t c_reset_vids; + igraph_vector_t c_weights; + igraph_arpack_options_t c_options1; + void* c_options; + SEXP vector; + SEXP value; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_walk, 0)) { + c_algo = (igraph_pagerank_algo_t) Rf_asInteger(algo); + if (0 != igraph_vector_init(&c_vector, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_walk); - c_start = (igraph_integer_t) REAL(start)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_steps=INTEGER(steps)[0]; - c_stuck = (igraph_random_walk_stuck_t) Rf_asInteger(stuck); + IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); + c_directed=LOGICAL(directed)[0]; + c_damping=REAL(damping)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { + R_SEXP_to_igraph_arpack_options(options, &c_options1); + c_options = &c_options1; + } else { + c_options = 0; + } /* Call igraph */ - IGRAPH_R_CHECK(igraph_random_walk(&c_graph, &c_walk, c_start, c_mode, c_steps, c_stuck)); + IGRAPH_R_CHECK(igraph_personalized_pagerank_vs(&c_graph, c_algo, &c_vector, &c_value, c_vids, c_directed, c_damping, c_reset_vids, (Rf_isNull(weights) ? 0 : &c_weights), c_options)); /* Convert output */ - PROTECT(walk=R_igraph_vector_to_SEXPp1(&c_walk)); - igraph_vector_destroy(&c_walk); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); + igraph_vector_destroy(&c_vector); IGRAPH_FINALLY_CLEAN(1); - r_result = walk; + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + if (c_algo == IGRAPH_PAGERANK_ALGO_ARPACK) { + PROTECT(options = R_igraph_arpack_options_to_SEXP(&c_options1)); + } else { + PROTECT(options); + } + SET_VECTOR_ELT(r_result, 0, vector); + SET_VECTOR_ELT(r_result, 1, value); + SET_VECTOR_ELT(r_result, 2, options); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_random_edge_walk / +/ igraph_induced_subgraph / /-------------------------------------------*/ -SEXP R_igraph_random_edge_walk(SEXP graph, SEXP weights, SEXP start, SEXP mode, SEXP steps, SEXP stuck) { +SEXP R_igraph_induced_subgraph(SEXP graph, SEXP vids, SEXP impl) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_weights; - igraph_vector_t c_edgewalk; - igraph_integer_t c_start; - igraph_neimode_t c_mode; - igraph_integer_t c_steps; - igraph_random_walk_stuck_t c_stuck; - SEXP edgewalk; + igraph_t c_res; + igraph_vs_t c_vids; + igraph_subgraph_implementation_t c_impl; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_vector_init(&c_edgewalk, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_edgewalk); - c_start = (igraph_integer_t) REAL(start)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_steps=INTEGER(steps)[0]; - c_stuck = (igraph_random_walk_stuck_t) Rf_asInteger(stuck); + c_impl = (igraph_subgraph_implementation_t) Rf_asInteger(impl); /* Call igraph */ - IGRAPH_R_CHECK(igraph_random_edge_walk(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_edgewalk, c_start, c_mode, c_steps, c_stuck)); + IGRAPH_R_CHECK(igraph_induced_subgraph(&c_graph, &c_res, c_vids, c_impl)); /* Convert output */ - PROTECT(edgewalk=R_igraph_vector_to_SEXPp1(&c_edgewalk)); - igraph_vector_destroy(&c_edgewalk); + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + igraph_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = edgewalk; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_global_efficiency / +/ igraph_subgraph_from_edges / /-------------------------------------------*/ -SEXP R_igraph_global_efficiency(SEXP graph, SEXP weights, SEXP directed) { +SEXP R_igraph_subgraph_from_edges(SEXP graph, SEXP eids, SEXP delete_vertices) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_res; - igraph_vector_t c_weights; - igraph_bool_t c_directed; + igraph_t c_res; + igraph_es_t c_eids; + igraph_bool_t c_delete_vertices; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_directed=LOGICAL(directed)[0]; + c_delete_vertices=LOGICAL(delete_vertices)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_global_efficiency(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_directed)); + IGRAPH_R_CHECK(igraph_subgraph_from_edges(&c_graph, &c_res, c_eids, c_delete_vertices)); /* Convert output */ - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + igraph_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); r_result = res; UNPROTECT(1); @@ -2993,505 +3106,361 @@ SEXP R_igraph_global_efficiency(SEXP graph, SEXP weights, SEXP directed) { } /*-------------------------------------------/ -/ igraph_local_efficiency / +/ igraph_reverse_edges / /-------------------------------------------*/ -SEXP R_igraph_local_efficiency(SEXP graph, SEXP vids, SEXP weights, SEXP directed, SEXP mode) { +SEXP R_igraph_reverse_edges(SEXP graph, SEXP eids) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vs_t c_vids; - igraph_vector_t c_weights; - igraph_bool_t c_directed; - igraph_neimode_t c_mode; - SEXP res; + igraph_es_t c_eids; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_directed=LOGICAL(directed)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_efficiency(&c_graph, &c_res, c_vids, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_mode)); + IGRAPH_R_CHECK(igraph_reverse_edges(&c_graph, c_eids)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); - r_result = res; + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_average_local_efficiency / +/ igraph_average_path_length_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_average_local_efficiency(SEXP graph, SEXP weights, SEXP directed, SEXP mode) { +SEXP R_igraph_average_path_length_dijkstra(SEXP graph, SEXP weights, SEXP directed, SEXP unconn) { /* Declarations */ igraph_t c_graph; igraph_real_t c_res; + igraph_real_t c_unconn_pairs; igraph_vector_t c_weights; igraph_bool_t c_directed; - igraph_neimode_t c_mode; + igraph_bool_t c_unconn; SEXP res; + SEXP unconn_pairs; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } c_directed=LOGICAL(directed)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_unconn=LOGICAL(unconn)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_average_local_efficiency(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_mode)); + IGRAPH_R_CHECK(igraph_average_path_length_dijkstra(&c_graph, &c_res, &c_unconn_pairs, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_unconn)); /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); PROTECT(res=NEW_NUMERIC(1)); REAL(res)[0]=c_res; - r_result = res; + PROTECT(unconn_pairs=NEW_NUMERIC(1)); + REAL(unconn_pairs)[0]=c_unconn_pairs; + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, unconn_pairs); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("unconnected")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_graphical / +/ igraph_path_length_hist / /-------------------------------------------*/ -SEXP R_igraph_is_graphical(SEXP out_deg, SEXP in_deg, SEXP allowed_edge_types) { +SEXP R_igraph_path_length_hist(SEXP graph, SEXP directed) { /* Declarations */ - igraph_vector_t c_out_deg; - igraph_vector_t c_in_deg; - igraph_edge_type_sw_t c_allowed_edge_types; - igraph_bool_t c_res; + igraph_t c_graph; + igraph_vector_t c_res; + igraph_real_t c_unconnected; + igraph_bool_t c_directed; SEXP res; + SEXP unconnected; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_vector(out_deg, &c_out_deg); - if (!Rf_isNull(in_deg)) { R_SEXP_to_vector(in_deg, &c_in_deg); } - c_allowed_edge_types = (igraph_edge_type_sw_t) Rf_asInteger(allowed_edge_types); + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_graphical(&c_out_deg, (Rf_isNull(in_deg) ? 0 : &c_in_deg), c_allowed_edge_types, &c_res)); + IGRAPH_R_CHECK(igraph_path_length_hist(&c_graph, &c_res, &c_unconnected, c_directed)); /* Convert output */ - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; - r_result = res; + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(unconnected=NEW_NUMERIC(1)); + REAL(unconnected)[0]=c_unconnected; + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, unconnected); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("unconnected")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_bipartite_projection_size / +/ igraph_simplify / /-------------------------------------------*/ -SEXP R_igraph_bipartite_projection_size(SEXP graph, SEXP types) { +SEXP R_igraph_simplify(SEXP graph, SEXP remove_multiple, SEXP remove_loops, SEXP edge_attr_comb) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_integer_t c_vcount1; - igraph_integer_t c_ecount1; - igraph_integer_t c_vcount2; - igraph_integer_t c_ecount2; - SEXP vcount1; - SEXP ecount1; - SEXP vcount2; - SEXP ecount2; + igraph_bool_t c_remove_multiple; + igraph_bool_t c_remove_loops; + igraph_attribute_combination_t c_edge_attr_comb; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - c_vcount1=0; - c_ecount1=0; - c_vcount2=0; - c_ecount2=0; + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + c_remove_multiple=LOGICAL(remove_multiple)[0]; + c_remove_loops=LOGICAL(remove_loops)[0]; + R_SEXP_to_attr_comb(edge_attr_comb, &c_edge_attr_comb); + IGRAPH_FINALLY(igraph_attribute_combination_destroy, &c_edge_attr_comb); /* Call igraph */ - IGRAPH_R_CHECK(igraph_bipartite_projection_size(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_vcount1, &c_ecount1, &c_vcount2, &c_ecount2)); + IGRAPH_R_CHECK(igraph_simplify(&c_graph, c_remove_multiple, c_remove_loops, &c_edge_attr_comb)); /* Convert output */ - PROTECT(r_result=NEW_LIST(4)); - PROTECT(r_names=NEW_CHARACTER(4)); - PROTECT(vcount1=NEW_INTEGER(1)); - INTEGER(vcount1)[0]=c_vcount1; - PROTECT(ecount1=NEW_INTEGER(1)); - INTEGER(ecount1)[0]=c_ecount1; - PROTECT(vcount2=NEW_INTEGER(1)); - INTEGER(vcount2)[0]=c_vcount2; - PROTECT(ecount2=NEW_INTEGER(1)); - INTEGER(ecount2)[0]=c_ecount2; - SET_VECTOR_ELT(r_result, 0, vcount1); - SET_VECTOR_ELT(r_result, 1, ecount1); - SET_VECTOR_ELT(r_result, 2, vcount2); - SET_VECTOR_ELT(r_result, 3, ecount2); - SET_STRING_ELT(r_names, 0, Rf_mkChar("vcount1")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("ecount1")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("vcount2")); - SET_STRING_ELT(r_names, 3, Rf_mkChar("ecount2")); - SET_NAMES(r_result, r_names); - UNPROTECT(5); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + igraph_attribute_combination_destroy(&c_edge_attr_comb); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_create_bipartite / +/ igraph_ecc / /-------------------------------------------*/ -SEXP R_igraph_create_bipartite(SEXP types, SEXP edges, SEXP directed) { +SEXP R_igraph_ecc(SEXP graph, SEXP eids, SEXP k, SEXP offset, SEXP normalize) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_vector_t c_edges; - igraph_bool_t c_directed; - SEXP graph; + igraph_vector_t c_res; + igraph_es_t c_eids; + igraph_integer_t c_k; + igraph_bool_t c_offset; + igraph_bool_t c_normalize; + SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_vector_bool(types, &c_types); - R_SEXP_to_vector(edges, &c_edges); - c_directed=LOGICAL(directed)[0]; + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_k=INTEGER(k)[0]; + c_offset=LOGICAL(offset)[0]; + c_normalize=LOGICAL(normalize)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_create_bipartite(&c_graph, &c_types, &c_edges, c_directed)); + IGRAPH_R_CHECK(igraph_ecc(&c_graph, &c_res, c_eids, c_k, c_offset, c_normalize)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_incidence / +/ igraph_feedback_arc_set / /-------------------------------------------*/ -SEXP R_igraph_incidence(SEXP incidence, SEXP directed, SEXP mode, SEXP multiple) { +SEXP R_igraph_feedback_arc_set(SEXP graph, SEXP weights, SEXP algo) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_matrix_t c_incidence; - igraph_bool_t c_directed; - igraph_neimode_t c_mode; - igraph_bool_t c_multiple; - SEXP graph; - SEXP types; + igraph_vector_int_t c_result; + igraph_vector_t c_weights; + igraph_fas_algorithm_t c_algo; + SEXP result; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - if (0 != igraph_vector_bool_init(&c_types, 0)) { + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_result, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); - R_SEXP_to_matrix(incidence, &c_incidence); - c_directed=LOGICAL(directed)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_multiple=LOGICAL(multiple)[0]; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_result); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_algo = (igraph_fas_algorithm_t) Rf_asInteger(algo); /* Call igraph */ - IGRAPH_R_CHECK(igraph_incidence(&c_graph, &c_types, &c_incidence, c_directed, c_mode, c_multiple)); + IGRAPH_R_CHECK(igraph_feedback_arc_set(&c_graph, &c_result, (Rf_isNull(weights) ? 0 : &c_weights), c_algo)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); + PROTECT(result=R_igraph_vector_int_to_SEXP(&c_result)); + igraph_vector_int_destroy(&c_result); IGRAPH_FINALLY_CLEAN(1); - PROTECT(types=R_igraph_vector_bool_to_SEXP(&c_types)); - igraph_vector_bool_destroy(&c_types); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, graph); - SET_VECTOR_ELT(r_result, 1, types); - SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = result; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_get_incidence / +/ igraph_is_loop / /-------------------------------------------*/ -SEXP R_igraph_get_incidence(SEXP graph, SEXP types) { +SEXP R_igraph_is_loop(SEXP graph, SEXP es) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_matrix_t c_res; - igraph_vector_t c_row_ids; - igraph_vector_t c_col_ids; + igraph_vector_bool_t c_res; + igraph_es_t c_es; SEXP res; - SEXP row_ids; - SEXP col_ids; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - if (0 != igraph_vector_init(&c_row_ids, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_row_ids); - row_ids=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_col_ids, 0)) { + if (0 != igraph_vector_bool_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_col_ids); - col_ids=R_GlobalEnv; /* hack to have a non-NULL value */ + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_incidence(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_res, (Rf_isNull(row_ids) ? 0 : &c_row_ids), (Rf_isNull(col_ids) ? 0 : &c_col_ids))); + IGRAPH_R_CHECK(igraph_is_loop(&c_graph, &c_res, c_es)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(row_ids=R_igraph_0orvector_to_SEXP(&c_row_ids)); - igraph_vector_destroy(&c_row_ids); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(col_ids=R_igraph_0orvector_to_SEXP(&c_col_ids)); - igraph_vector_destroy(&c_col_ids); + PROTECT(res=R_igraph_vector_bool_to_SEXP(&c_res)); + igraph_vector_bool_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, row_ids); - SET_VECTOR_ELT(r_result, 2, col_ids); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("row_ids")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("col_ids")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_bipartite / +/ igraph_is_dag / /-------------------------------------------*/ -SEXP R_igraph_is_bipartite(SEXP graph) { +SEXP R_igraph_is_dag(SEXP graph) { /* Declarations */ igraph_t c_graph; igraph_bool_t c_res; - igraph_vector_bool_t c_type; SEXP res; - SEXP type; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_bool_init(&c_type, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_type); - type=R_GlobalEnv; /* hack to have a non-NULL value */ /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_bipartite(&c_graph, &c_res, (Rf_isNull(type) ? 0 : &c_type))); + IGRAPH_R_CHECK(igraph_is_dag(&c_graph, &c_res)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); PROTECT(res=NEW_LOGICAL(1)); LOGICAL(res)[0]=c_res; - PROTECT(type=R_igraph_0orvector_bool_to_SEXP(&c_type)); - igraph_vector_bool_destroy(&c_type); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, type); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("type")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_bipartite_game_gnp / +/ igraph_is_acyclic / /-------------------------------------------*/ -SEXP R_igraph_bipartite_game_gnp(SEXP n1, SEXP n2, SEXP p, SEXP directed, SEXP mode) { +SEXP R_igraph_is_acyclic(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_integer_t c_n1; - igraph_integer_t c_n2; - igraph_real_t c_p; - igraph_bool_t c_directed; - igraph_neimode_t c_mode; - SEXP graph; - SEXP types; + igraph_bool_t c_res; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - if (0 != igraph_vector_bool_init(&c_types, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); - types=R_GlobalEnv; /* hack to have a non-NULL value */ - c_n1=INTEGER(n1)[0]; - c_n2=INTEGER(n2)[0]; - c_p=REAL(p)[0]; - c_directed=LOGICAL(directed)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + R_SEXP_to_igraph(graph, &c_graph); /* Call igraph */ - IGRAPH_R_CHECK(igraph_bipartite_game_gnp(&c_graph, (Rf_isNull(types) ? 0 : &c_types), c_n1, c_n2, c_p, c_directed, c_mode)); + IGRAPH_R_CHECK(igraph_is_acyclic(&c_graph, &c_res)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(types=R_igraph_0orvector_bool_to_SEXP(&c_types)); - igraph_vector_bool_destroy(&c_types); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, graph); - SET_VECTOR_ELT(r_result, 1, types); - SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_bipartite_game_gnm / +/ igraph_is_simple / /-------------------------------------------*/ -SEXP R_igraph_bipartite_game_gnm(SEXP n1, SEXP n2, SEXP m, SEXP directed, SEXP mode) { +SEXP R_igraph_is_simple(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_integer_t c_n1; - igraph_integer_t c_n2; - igraph_integer_t c_m; - igraph_bool_t c_directed; - igraph_neimode_t c_mode; - SEXP graph; - SEXP types; + igraph_bool_t c_res; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - if (0 != igraph_vector_bool_init(&c_types, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); - types=R_GlobalEnv; /* hack to have a non-NULL value */ - c_n1=INTEGER(n1)[0]; - c_n2=INTEGER(n2)[0]; - c_m=INTEGER(m)[0]; - c_directed=LOGICAL(directed)[0]; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + R_SEXP_to_igraph(graph, &c_graph); /* Call igraph */ - IGRAPH_R_CHECK(igraph_bipartite_game_gnm(&c_graph, (Rf_isNull(types) ? 0 : &c_types), c_n1, c_n2, c_m, c_directed, c_mode)); + IGRAPH_R_CHECK(igraph_is_simple(&c_graph, &c_res)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(types=R_igraph_0orvector_bool_to_SEXP(&c_types)); - igraph_vector_bool_destroy(&c_types); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, graph); - SET_VECTOR_ELT(r_result, 1, types); - SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_clusters / +/ igraph_is_multiple / /-------------------------------------------*/ -SEXP R_igraph_clusters(SEXP graph, SEXP mode) { +SEXP R_igraph_is_multiple(SEXP graph, SEXP es) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_membership; - igraph_vector_t c_csize; - igraph_integer_t c_no; - igraph_connectedness_t c_mode; - SEXP membership; - SEXP csize; - SEXP no; + igraph_vector_bool_t c_res; + igraph_es_t c_es; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); - if (0 != igraph_vector_init(&c_csize, 0)) { + if (0 != igraph_vector_bool_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_csize); - c_no=0; - c_mode=REAL(mode)[0]; + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_clusters(&c_graph, &c_membership, &c_csize, &c_no, c_mode)); + IGRAPH_R_CHECK(igraph_is_multiple(&c_graph, &c_res, c_es)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(membership=R_igraph_vector_to_SEXP(&c_membership)); - igraph_vector_destroy(&c_membership); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(csize=R_igraph_vector_to_SEXP(&c_csize)); - igraph_vector_destroy(&c_csize); + PROTECT(res=R_igraph_vector_bool_to_SEXP(&c_res)); + igraph_vector_bool_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - PROTECT(no=NEW_INTEGER(1)); - INTEGER(no)[0]=c_no; - SET_VECTOR_ELT(r_result, 0, membership); - SET_VECTOR_ELT(r_result, 1, csize); - SET_VECTOR_ELT(r_result, 2, no); - SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("csize")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("no")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_connected / +/ igraph_has_loop / /-------------------------------------------*/ -SEXP R_igraph_is_connected(SEXP graph, SEXP mode) { +SEXP R_igraph_has_loop(SEXP graph) { /* Declarations */ igraph_t c_graph; igraph_bool_t c_res; - igraph_connectedness_t c_mode; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_mode=REAL(mode)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_connected(&c_graph, &c_res, c_mode)); + IGRAPH_R_CHECK(igraph_has_loop(&c_graph, &c_res)); /* Convert output */ PROTECT(res=NEW_LOGICAL(1)); @@ -3503,28 +3472,23 @@ SEXP R_igraph_is_connected(SEXP graph, SEXP mode) { } /*-------------------------------------------/ -/ igraph_articulation_points / +/ igraph_has_multiple / /-------------------------------------------*/ -SEXP R_igraph_articulation_points(SEXP graph) { +SEXP R_igraph_has_multiple(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; + igraph_bool_t c_res; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_articulation_points(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_has_multiple(&c_graph, &c_res)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXPp1(&c_res)); - igraph_vector_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -3532,102 +3496,53 @@ SEXP R_igraph_articulation_points(SEXP graph) { } /*-------------------------------------------/ -/ igraph_biconnected_components / +/ igraph_count_multiple / /-------------------------------------------*/ -SEXP R_igraph_biconnected_components(SEXP graph) { +SEXP R_igraph_count_multiple(SEXP graph, SEXP es) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_no; - igraph_vector_ptr_t c_tree_edges; - igraph_vector_ptr_t c_component_edges; - igraph_vector_ptr_t c_components; - igraph_vector_t c_articulation_points; - SEXP no; - SEXP tree_edges; - SEXP component_edges; - SEXP components; - SEXP articulation_points; + igraph_vector_int_t c_res; + igraph_es_t c_es; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_no=0; - if (0 != igraph_vector_ptr_init(&c_tree_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_tree_edges); - if (0 != igraph_vector_ptr_init(&c_component_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_component_edges); - if (0 != igraph_vector_ptr_init(&c_components, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_components); - if (0 != igraph_vector_init(&c_articulation_points, 0)) { + if (0 != igraph_vector_int_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_articulation_points); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_biconnected_components(&c_graph, &c_no, &c_tree_edges, &c_component_edges, &c_components, &c_articulation_points)); + IGRAPH_R_CHECK(igraph_count_multiple(&c_graph, &c_res, c_es)); /* Convert output */ - PROTECT(r_result=NEW_LIST(5)); - PROTECT(r_names=NEW_CHARACTER(5)); - PROTECT(no=NEW_INTEGER(1)); - INTEGER(no)[0]=c_no; - PROTECT(tree_edges=R_igraph_vectorlist_to_SEXP_p1(&c_tree_edges)); - R_igraph_vectorlist_destroy(&c_tree_edges); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(component_edges=R_igraph_vectorlist_to_SEXP_p1(&c_component_edges)); - R_igraph_vectorlist_destroy(&c_component_edges); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(components=R_igraph_vectorlist_to_SEXP_p1(&c_components)); - R_igraph_vectorlist_destroy(&c_components); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(articulation_points=R_igraph_vector_to_SEXPp1(&c_articulation_points)); - igraph_vector_destroy(&c_articulation_points); + PROTECT(res=R_igraph_vector_int_to_SEXP(&c_res)); + igraph_vector_int_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, no); - SET_VECTOR_ELT(r_result, 1, tree_edges); - SET_VECTOR_ELT(r_result, 2, component_edges); - SET_VECTOR_ELT(r_result, 3, components); - SET_VECTOR_ELT(r_result, 4, articulation_points); - SET_STRING_ELT(r_names, 0, Rf_mkChar("no")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("tree_edges")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("component_edges")); - SET_STRING_ELT(r_names, 3, Rf_mkChar("components")); - SET_STRING_ELT(r_names, 4, Rf_mkChar("articulation_points")); - SET_NAMES(r_result, r_names); - UNPROTECT(6); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_bridges / +/ igraph_is_perfect / /-------------------------------------------*/ -SEXP R_igraph_bridges(SEXP graph) { +SEXP R_igraph_is_perfect(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; + igraph_bool_t c_res; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_bridges(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_is_perfect(&c_graph, &c_res)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXPp1(&c_res)); - igraph_vector_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -3635,188 +3550,285 @@ SEXP R_igraph_bridges(SEXP graph) { } /*-------------------------------------------/ -/ igraph_cliques / +/ igraph_eigenvector_centrality / /-------------------------------------------*/ -SEXP R_igraph_cliques(SEXP graph, SEXP min_size, SEXP max_size) { +SEXP R_igraph_eigenvector_centrality(SEXP graph, SEXP directed, SEXP scale, SEXP weights, SEXP options) { /* Declarations */ igraph_t c_graph; - igraph_vector_ptr_t c_res; - igraph_integer_t c_min_size; - igraph_integer_t c_max_size; - SEXP res; + igraph_vector_t c_vector; + igraph_real_t c_value; + igraph_bool_t c_directed; + igraph_bool_t c_scale; + igraph_vector_t c_weights; + igraph_arpack_options_t c_options; + SEXP vector; + SEXP value; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_res, 0)) { + if (0 != igraph_vector_init(&c_vector, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_res); - c_min_size=INTEGER(min_size)[0]; - c_max_size=INTEGER(max_size)[0]; + IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); + c_directed=LOGICAL(directed)[0]; + c_scale=LOGICAL(scale)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_igraph_arpack_options(options, &c_options); /* Call igraph */ - IGRAPH_R_CHECK(igraph_cliques(&c_graph, &c_res, c_min_size, c_max_size)); + IGRAPH_R_CHECK(igraph_eigenvector_centrality(&c_graph, &c_vector, &c_value, c_directed, c_scale, (Rf_isNull(weights) ? 0 : &c_weights), &c_options)); /* Convert output */ - PROTECT(res=R_igraph_vectorlist_to_SEXP_p1(&c_res)); - R_igraph_vectorlist_destroy(&c_res); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); + igraph_vector_destroy(&c_vector); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + SET_VECTOR_ELT(r_result, 0, vector); + SET_VECTOR_ELT(r_result, 1, value); + SET_VECTOR_ELT(r_result, 2, options); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_clique_size_hist / +/ igraph_hub_score / /-------------------------------------------*/ -SEXP R_igraph_clique_size_hist(SEXP graph, SEXP min_size, SEXP max_size) { +SEXP R_igraph_hub_score(SEXP graph, SEXP scale, SEXP weights, SEXP options) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_hist; - igraph_integer_t c_min_size; - igraph_integer_t c_max_size; - SEXP hist; + igraph_vector_t c_vector; + igraph_real_t c_value; + igraph_bool_t c_scale; + igraph_vector_t c_weights; + igraph_arpack_options_t c_options; + SEXP vector; + SEXP value; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_hist, 0)) { + if (0 != igraph_vector_init(&c_vector, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_hist); - c_min_size=INTEGER(min_size)[0]; - c_max_size=INTEGER(max_size)[0]; + IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); + c_scale=LOGICAL(scale)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_igraph_arpack_options(options, &c_options); /* Call igraph */ - IGRAPH_R_CHECK(igraph_clique_size_hist(&c_graph, &c_hist, c_min_size, c_max_size)); + IGRAPH_R_CHECK(igraph_hub_score(&c_graph, &c_vector, &c_value, c_scale, (Rf_isNull(weights) ? 0 : &c_weights), &c_options)); /* Convert output */ - PROTECT(hist=R_igraph_vector_to_SEXP(&c_hist)); - igraph_vector_destroy(&c_hist); - IGRAPH_FINALLY_CLEAN(1); - r_result = hist; + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); + igraph_vector_destroy(&c_vector); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + SET_VECTOR_ELT(r_result, 0, vector); + SET_VECTOR_ELT(r_result, 1, value); + SET_VECTOR_ELT(r_result, 2, options); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_largest_cliques / +/ igraph_authority_score / /-------------------------------------------*/ -SEXP R_igraph_largest_cliques(SEXP graph) { +SEXP R_igraph_authority_score(SEXP graph, SEXP scale, SEXP weights, SEXP options) { /* Declarations */ igraph_t c_graph; - igraph_vector_ptr_t c_res; - SEXP res; + igraph_vector_t c_vector; + igraph_real_t c_value; + igraph_bool_t c_scale; + igraph_vector_t c_weights; + igraph_arpack_options_t c_options; + SEXP vector; + SEXP value; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_res, 0)) { + if (0 != igraph_vector_init(&c_vector, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_res); + IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); + c_scale=LOGICAL(scale)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_igraph_arpack_options(options, &c_options); /* Call igraph */ - IGRAPH_R_CHECK(igraph_largest_cliques(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_authority_score(&c_graph, &c_vector, &c_value, c_scale, (Rf_isNull(weights) ? 0 : &c_weights), &c_options)); /* Convert output */ - PROTECT(res=R_igraph_vectorlist_to_SEXP_p1(&c_res)); - R_igraph_vectorlist_destroy(&c_res); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); + igraph_vector_destroy(&c_vector); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + SET_VECTOR_ELT(r_result, 0, vector); + SET_VECTOR_ELT(r_result, 1, value); + SET_VECTOR_ELT(r_result, 2, options); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_maximal_cliques_hist / +/ igraph_hub_and_authority_scores / /-------------------------------------------*/ -SEXP R_igraph_maximal_cliques_hist(SEXP graph, SEXP min_size, SEXP max_size) { +SEXP R_igraph_hub_and_authority_scores(SEXP graph, SEXP scale, SEXP weights, SEXP options) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_hist; - igraph_integer_t c_min_size; - igraph_integer_t c_max_size; - SEXP hist; + igraph_vector_t c_hub_vector; + igraph_vector_t c_authority_vector; + igraph_real_t c_value; + igraph_bool_t c_scale; + igraph_vector_t c_weights; + igraph_arpack_options_t c_options; + SEXP hub_vector; + SEXP authority_vector; + SEXP value; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_hist, 0)) { + if (0 != igraph_vector_init(&c_hub_vector, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_hist); - c_min_size=INTEGER(min_size)[0]; - c_max_size=INTEGER(max_size)[0]; + IGRAPH_FINALLY(igraph_vector_destroy, &c_hub_vector); + if (0 != igraph_vector_init(&c_authority_vector, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_authority_vector); + c_scale=LOGICAL(scale)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_igraph_arpack_options(options, &c_options); /* Call igraph */ - IGRAPH_R_CHECK(igraph_maximal_cliques_hist(&c_graph, &c_hist, c_min_size, c_max_size)); + IGRAPH_R_CHECK(igraph_hub_and_authority_scores(&c_graph, &c_hub_vector, &c_authority_vector, &c_value, c_scale, (Rf_isNull(weights) ? 0 : &c_weights), &c_options)); /* Convert output */ - PROTECT(hist=R_igraph_vector_to_SEXP(&c_hist)); - igraph_vector_destroy(&c_hist); + PROTECT(r_result=NEW_LIST(4)); + PROTECT(r_names=NEW_CHARACTER(4)); + PROTECT(hub_vector=R_igraph_vector_to_SEXP(&c_hub_vector)); + igraph_vector_destroy(&c_hub_vector); IGRAPH_FINALLY_CLEAN(1); - r_result = hist; + PROTECT(authority_vector=R_igraph_vector_to_SEXP(&c_authority_vector)); + igraph_vector_destroy(&c_authority_vector); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + SET_VECTOR_ELT(r_result, 0, hub_vector); + SET_VECTOR_ELT(r_result, 1, authority_vector); + SET_VECTOR_ELT(r_result, 2, value); + SET_VECTOR_ELT(r_result, 3, options); + SET_STRING_ELT(r_names, 0, Rf_mkChar("hub_vector")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("authority_vector")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("options")); + SET_NAMES(r_result, r_names); + UNPROTECT(5); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_clique_number / +/ igraph_unfold_tree / /-------------------------------------------*/ -SEXP R_igraph_clique_number(SEXP graph) { +SEXP R_igraph_unfold_tree(SEXP graph, SEXP mode, SEXP roots) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_no; - SEXP no; + igraph_t c_tree; + igraph_neimode_t c_mode; + igraph_vector_int_t c_roots; + igraph_vector_int_t c_vertex_index; + SEXP tree; + SEXP vertex_index; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_no=0; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + R_SEXP_to_vector_int(roots, &c_roots); + if (0 != igraph_vector_int_init(&c_vertex_index, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_index); /* Call igraph */ - IGRAPH_R_CHECK(igraph_clique_number(&c_graph, &c_no)); + IGRAPH_R_CHECK(igraph_unfold_tree(&c_graph, &c_tree, c_mode, &c_roots, &c_vertex_index)); /* Convert output */ - PROTECT(no=NEW_INTEGER(1)); - INTEGER(no)[0]=c_no; - r_result = no; + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + IGRAPH_FINALLY(igraph_destroy, &c_tree); + PROTECT(tree=R_igraph_to_SEXP(&c_tree)); + igraph_destroy(&c_tree); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(vertex_index=R_igraph_vector_int_to_SEXP(&c_vertex_index)); + igraph_vector_int_destroy(&c_vertex_index); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, tree); + SET_VECTOR_ELT(r_result, 1, vertex_index); + SET_STRING_ELT(r_names, 0, Rf_mkChar("tree")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("vertex_index")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_weighted_cliques / +/ igraph_is_mutual / /-------------------------------------------*/ -SEXP R_igraph_weighted_cliques(SEXP graph, SEXP vertex_weights, SEXP min_weight, SEXP max_weight, SEXP maximal) { +SEXP R_igraph_is_mutual(SEXP graph, SEXP es, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_vertex_weights; - igraph_vector_ptr_t c_res; - igraph_real_t c_min_weight; - igraph_real_t c_max_weight; - igraph_bool_t c_maximal; + igraph_vector_bool_t c_res; + igraph_es_t c_es; + igraph_bool_t c_loops; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } - if (0 != igraph_vector_ptr_init(&c_res, 0)) { + if (0 != igraph_vector_bool_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_res); - c_min_weight=REAL(min_weight)[0]; - c_max_weight=REAL(max_weight)[0]; - c_maximal=LOGICAL(maximal)[0]; + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_res); + c_loops=LOGICAL(loops)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_weighted_cliques(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res, c_min_weight, c_max_weight, c_maximal)); + IGRAPH_R_CHECK(igraph_is_mutual(&c_graph, &c_res, c_es, c_loops)); /* Convert output */ - PROTECT(res=R_igraph_vectorlist_to_SEXP_p1(&c_res)); - R_igraph_vectorlist_destroy(&c_res); + PROTECT(res=R_igraph_vector_bool_to_SEXP(&c_res)); + igraph_vector_bool_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); r_result = res; @@ -3825,30 +3837,25 @@ SEXP R_igraph_weighted_cliques(SEXP graph, SEXP vertex_weights, SEXP min_weight, } /*-------------------------------------------/ -/ igraph_largest_weighted_cliques / +/ igraph_has_mutual / /-------------------------------------------*/ -SEXP R_igraph_largest_weighted_cliques(SEXP graph, SEXP vertex_weights) { +SEXP R_igraph_has_mutual(SEXP graph, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_vertex_weights; - igraph_vector_ptr_t c_res; + igraph_bool_t c_res; + igraph_bool_t c_loops; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } - if (0 != igraph_vector_ptr_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_res); + c_loops=LOGICAL(loops)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_largest_weighted_cliques(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res)); + IGRAPH_R_CHECK(igraph_has_mutual(&c_graph, &c_res, c_loops)); /* Convert output */ - PROTECT(res=R_igraph_vectorlist_to_SEXP_p1(&c_res)); - R_igraph_vectorlist_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -3856,88 +3863,131 @@ SEXP R_igraph_largest_weighted_cliques(SEXP graph, SEXP vertex_weights) { } /*-------------------------------------------/ -/ igraph_weighted_clique_number / +/ igraph_maximum_cardinality_search / /-------------------------------------------*/ -SEXP R_igraph_weighted_clique_number(SEXP graph, SEXP vertex_weights) { +SEXP R_igraph_maximum_cardinality_search(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_vertex_weights; - igraph_real_t c_res; - SEXP res; + igraph_vector_int_t c_alpha; + igraph_vector_int_t c_alpham1; + SEXP alpha; + SEXP alpham1; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } + if (0 != igraph_vector_int_init(&c_alpha, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_alpha); + if (0 != igraph_vector_int_init(&c_alpham1, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_alpham1); /* Call igraph */ - IGRAPH_R_CHECK(igraph_weighted_clique_number(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res)); + IGRAPH_R_CHECK(igraph_maximum_cardinality_search(&c_graph, &c_alpha, &c_alpham1)); /* Convert output */ - PROTECT(res=NEW_NUMERIC(1)); - REAL(res)[0]=c_res; - r_result = res; + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(alpha=R_igraph_vector_int_to_SEXP(&c_alpha)); + igraph_vector_int_destroy(&c_alpha); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(alpham1=R_igraph_vector_int_to_SEXP(&c_alpham1)); + igraph_vector_int_destroy(&c_alpham1); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, alpha); + SET_VECTOR_ELT(r_result, 1, alpham1); + SET_STRING_ELT(r_names, 0, Rf_mkChar("alpha")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("alpham1")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_layout_star / +/ igraph_avg_nearest_neighbor_degree / /-------------------------------------------*/ -SEXP R_igraph_layout_star(SEXP graph, SEXP center, SEXP order) { +SEXP R_igraph_avg_nearest_neighbor_degree(SEXP graph, SEXP vids, SEXP mode, SEXP neighbor_degree_mode, SEXP weights) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_integer_t c_center; - igraph_vector_t c_order; - SEXP res; + igraph_vs_t c_vids; + igraph_neimode_t c_mode; + igraph_neimode_t c_neighbor_degree_mode; + igraph_vector_t c_knn; + igraph_vector_t c_knnk; + igraph_vector_t c_weights; + SEXP knn; + SEXP knnk; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_neighbor_degree_mode = (igraph_neimode_t) Rf_asInteger(neighbor_degree_mode); + if (0 != igraph_vector_init(&c_knn, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - c_center = (igraph_integer_t) REAL(center)[0]; - if (!Rf_isNull(order)) { R_SEXP_to_vector(order, &c_order); } + IGRAPH_FINALLY(igraph_vector_destroy, &c_knn); + if (0 != igraph_vector_init(&c_knnk, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_knnk); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_star(&c_graph, &c_res, c_center, (Rf_isNull(order) ? 0 : &c_order))); + IGRAPH_R_CHECK(igraph_avg_nearest_neighbor_degree(&c_graph, c_vids, c_mode, c_neighbor_degree_mode, &c_knn, &c_knnk, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(knn=R_igraph_vector_to_SEXP(&c_knn)); + igraph_vector_destroy(&c_knn); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(knnk=R_igraph_vector_to_SEXP(&c_knnk)); + igraph_vector_destroy(&c_knnk); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, knn); + SET_VECTOR_ELT(r_result, 1, knnk); + SET_STRING_ELT(r_names, 0, Rf_mkChar("knn")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("knnk")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_layout_grid / +/ igraph_strength / /-------------------------------------------*/ -SEXP R_igraph_layout_grid(SEXP graph, SEXP width) { +SEXP R_igraph_strength(SEXP graph, SEXP vids, SEXP mode, SEXP loops, SEXP weights) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - long int c_width; + igraph_vector_t c_res; + igraph_vs_t c_vids; + igraph_neimode_t c_mode; + igraph_bool_t c_loops; + igraph_vector_t c_weights; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { + if (0 != igraph_vector_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - c_width=INTEGER(width)[0]; + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_loops=LOGICAL(loops)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_grid(&c_graph, &c_res, c_width)); + IGRAPH_R_CHECK(igraph_strength(&c_graph, &c_res, c_vids, c_mode, c_loops, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); r_result = res; @@ -3946,104 +3996,107 @@ SEXP R_igraph_layout_grid(SEXP graph, SEXP width) { } /*-------------------------------------------/ -/ igraph_layout_grid_3d / +/ igraph_centralization / /-------------------------------------------*/ -SEXP R_igraph_layout_grid_3d(SEXP graph, SEXP width, SEXP height) { +SEXP R_igraph_centralization(SEXP scores, SEXP theoretical_max, SEXP normalized) { /* Declarations */ - igraph_t c_graph; - igraph_matrix_t c_res; - long int c_width; - long int c_height; - SEXP res; - + igraph_vector_t c_scores; + igraph_real_t c_theoretical_max; + igraph_bool_t c_normalized; + igraph_real_t c_result; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - c_width=INTEGER(width)[0]; - c_height=INTEGER(height)[0]; + R_SEXP_to_vector(scores, &c_scores); + c_theoretical_max=REAL(theoretical_max)[0]; + c_normalized=LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_grid_3d(&c_graph, &c_res, c_width, c_height)); + c_result=igraph_centralization(&c_scores, c_theoretical_max, c_normalized); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - r_result = res; + + PROTECT(r_result=NEW_NUMERIC(1)); + REAL(r_result)[0]=c_result; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_layout_drl / +/ igraph_centralization_degree / /-------------------------------------------*/ -SEXP R_igraph_layout_drl(SEXP graph, SEXP res, SEXP use_seed, SEXP options, SEXP weights, SEXP fixed) { +SEXP R_igraph_centralization_degree(SEXP graph, SEXP mode, SEXP loops, SEXP normalized) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_bool_t c_use_seed; - igraph_layout_drl_options_t c_options; - igraph_vector_t c_weights; - igraph_vector_bool_t c_fixed; + igraph_vector_t c_res; + igraph_neimode_t c_mode; + igraph_bool_t c_loops; + igraph_real_t c_centralization; + igraph_real_t c_theoretical_max; + igraph_bool_t c_normalized; + SEXP res; + SEXP centralization; + SEXP theoretical_max; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { + if (0 != igraph_vector_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - c_use_seed=LOGICAL(use_seed)[0]; - R_SEXP_to_igraph_layout_drl_options(options, &c_options); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (!Rf_isNull(fixed)) { R_SEXP_to_vector_bool(fixed, &c_fixed); } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_loops=LOGICAL(loops)[0]; + c_normalized=LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_drl(&c_graph, &c_res, c_use_seed, &c_options, (Rf_isNull(weights) ? 0 : &c_weights), (Rf_isNull(fixed) ? 0 : &c_fixed))); + IGRAPH_R_CHECK(igraph_centralization_degree(&c_graph, &c_res, c_mode, c_loops, &c_centralization, &c_theoretical_max, c_normalized)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(centralization=NEW_NUMERIC(1)); + REAL(centralization)[0]=c_centralization; + PROTECT(theoretical_max=NEW_NUMERIC(1)); + REAL(theoretical_max)[0]=c_theoretical_max; + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, centralization); + SET_VECTOR_ELT(r_result, 2, theoretical_max); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("centralization")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("theoretical_max")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_layout_drl_3d / +/ igraph_centralization_degree_tmax / /-------------------------------------------*/ -SEXP R_igraph_layout_drl_3d(SEXP graph, SEXP res, SEXP use_seed, SEXP options, SEXP weights, SEXP fixed) { +SEXP R_igraph_centralization_degree_tmax(SEXP graph, SEXP nodes, SEXP mode, SEXP loops) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_bool_t c_use_seed; - igraph_layout_drl_options_t c_options; - igraph_vector_t c_weights; - igraph_vector_bool_t c_fixed; + igraph_integer_t c_nodes; + igraph_neimode_t c_mode; + igraph_bool_t c_loops; + igraph_real_t c_res; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - c_use_seed=LOGICAL(use_seed)[0]; - R_SEXP_to_igraph_layout_drl_options(options, &c_options); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (!Rf_isNull(fixed)) { R_SEXP_to_vector_bool(fixed, &c_fixed); } + c_nodes=INTEGER(nodes)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_loops=LOGICAL(loops)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_drl_3d(&c_graph, &c_res, c_use_seed, &c_options, (Rf_isNull(weights) ? 0 : &c_weights), (Rf_isNull(fixed) ? 0 : &c_fixed))); + IGRAPH_R_CHECK(igraph_centralization_degree_tmax(&c_graph, c_nodes, c_mode, c_loops, &c_res)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -4051,63 +4104,48 @@ SEXP R_igraph_layout_drl_3d(SEXP graph, SEXP res, SEXP use_seed, SEXP options, S } /*-------------------------------------------/ -/ igraph_layout_sugiyama / +/ igraph_centralization_betweenness / /-------------------------------------------*/ -SEXP R_igraph_layout_sugiyama(SEXP graph, SEXP layers, SEXP hgap, SEXP vgap, SEXP maxiter, SEXP weights) { +SEXP R_igraph_centralization_betweenness(SEXP graph, SEXP directed, SEXP normalized) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_t c_extd_graph; - igraph_vector_t c_extd_to_orig_eids; - igraph_vector_t c_layers; - igraph_real_t c_hgap; - igraph_real_t c_vgap; - long int c_maxiter; - igraph_vector_t c_weights; + igraph_vector_t c_res; + igraph_bool_t c_directed; + igraph_real_t c_centralization; + igraph_real_t c_theoretical_max; + igraph_bool_t c_normalized; SEXP res; - SEXP extd_graph; - SEXP extd_to_orig_eids; + SEXP centralization; + SEXP theoretical_max; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - extd_graph=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_extd_to_orig_eids, 0)) { + if (0 != igraph_vector_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_extd_to_orig_eids); - extd_to_orig_eids=R_GlobalEnv; /* hack to have a non-NULL value */ - if (!Rf_isNull(layers)) { R_SEXP_to_vector(layers, &c_layers); } - c_hgap=REAL(hgap)[0]; - c_vgap=REAL(vgap)[0]; - c_maxiter=INTEGER(maxiter)[0]; - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_directed=LOGICAL(directed)[0]; + c_normalized=LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_sugiyama(&c_graph, &c_res, (Rf_isNull(extd_graph) ? 0 : &c_extd_graph), (Rf_isNull(extd_to_orig_eids) ? 0 : &c_extd_to_orig_eids), (Rf_isNull(layers) ? 0 : &c_layers), c_hgap, c_vgap, c_maxiter, (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_centralization_betweenness(&c_graph, &c_res, c_directed, &c_centralization, &c_theoretical_max, c_normalized)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - IGRAPH_FINALLY(igraph_destroy, &c_extd_graph); - PROTECT(extd_graph=R_igraph_to_SEXP(&c_extd_graph)); - igraph_destroy(&c_extd_graph); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(extd_to_orig_eids=R_igraph_0orvector_to_SEXPp1(&c_extd_to_orig_eids)); - igraph_vector_destroy(&c_extd_to_orig_eids); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); + PROTECT(centralization=NEW_NUMERIC(1)); + REAL(centralization)[0]=c_centralization; + PROTECT(theoretical_max=NEW_NUMERIC(1)); + REAL(theoretical_max)[0]=c_theoretical_max; SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, extd_graph); - SET_VECTOR_ELT(r_result, 2, extd_to_orig_eids); + SET_VECTOR_ELT(r_result, 1, centralization); + SET_VECTOR_ELT(r_result, 2, theoretical_max); SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("extd_graph")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("extd_to_orig_eids")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("centralization")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("theoretical_max")); SET_NAMES(r_result, r_names); UNPROTECT(4); @@ -4116,32 +4154,27 @@ SEXP R_igraph_layout_sugiyama(SEXP graph, SEXP layers, SEXP hgap, SEXP vgap, SEX } /*-------------------------------------------/ -/ igraph_layout_mds / +/ igraph_centralization_betweenness_tmax / /-------------------------------------------*/ -SEXP R_igraph_layout_mds(SEXP graph, SEXP dist, SEXP dim) { +SEXP R_igraph_centralization_betweenness_tmax(SEXP graph, SEXP nodes, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_matrix_t c_dist; - long int c_dim; + igraph_integer_t c_nodes; + igraph_bool_t c_directed; + igraph_real_t c_res; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - if (!Rf_isNull(dist)) { R_SEXP_to_matrix(dist, &c_dist); } - c_dim=INTEGER(dim)[0]; + c_nodes=INTEGER(nodes)[0]; + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_mds(&c_graph, &c_res, (Rf_isNull(dist) ? 0 : &c_dist), c_dim)); + IGRAPH_R_CHECK(igraph_centralization_betweenness_tmax(&c_graph, c_nodes, c_directed, &c_res)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -4149,74 +4182,77 @@ SEXP R_igraph_layout_mds(SEXP graph, SEXP dist, SEXP dim) { } /*-------------------------------------------/ -/ igraph_layout_bipartite / +/ igraph_centralization_closeness / /-------------------------------------------*/ -SEXP R_igraph_layout_bipartite(SEXP graph, SEXP types, SEXP hgap, SEXP vgap, SEXP maxiter) { +SEXP R_igraph_centralization_closeness(SEXP graph, SEXP mode, SEXP normalized) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_matrix_t c_res; - igraph_real_t c_hgap; - igraph_real_t c_vgap; - long int c_maxiter; + igraph_vector_t c_res; + igraph_neimode_t c_mode; + igraph_real_t c_centralization; + igraph_real_t c_theoretical_max; + igraph_bool_t c_normalized; SEXP res; + SEXP centralization; + SEXP theoretical_max; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - if (0 != igraph_matrix_init(&c_res, 0, 0)) { + if (0 != igraph_vector_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - c_hgap=REAL(hgap)[0]; - c_vgap=REAL(vgap)[0]; - c_maxiter=INTEGER(maxiter)[0]; + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_normalized=LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_bipartite(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_res, c_hgap, c_vgap, c_maxiter)); + IGRAPH_R_CHECK(igraph_centralization_closeness(&c_graph, &c_res, c_mode, &c_centralization, &c_theoretical_max, c_normalized)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(centralization=NEW_NUMERIC(1)); + REAL(centralization)[0]=c_centralization; + PROTECT(theoretical_max=NEW_NUMERIC(1)); + REAL(theoretical_max)[0]=c_theoretical_max; + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, centralization); + SET_VECTOR_ELT(r_result, 2, theoretical_max); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("centralization")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("theoretical_max")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_layout_gem / +/ igraph_centralization_closeness_tmax / /-------------------------------------------*/ -SEXP R_igraph_layout_gem(SEXP graph, SEXP res, SEXP use_seed, SEXP maxiter, SEXP temp_max, SEXP temp_min, SEXP temp_init) { +SEXP R_igraph_centralization_closeness_tmax(SEXP graph, SEXP nodes, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_bool_t c_use_seed; - igraph_integer_t c_maxiter; - igraph_real_t c_temp_max; - igraph_real_t c_temp_min; - igraph_real_t c_temp_init; + igraph_integer_t c_nodes; + igraph_neimode_t c_mode; + igraph_real_t c_res; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - c_use_seed=LOGICAL(use_seed)[0]; - c_maxiter=INTEGER(maxiter)[0]; - c_temp_max=REAL(temp_max)[0]; - c_temp_min=REAL(temp_min)[0]; - c_temp_init=REAL(temp_init)[0]; + c_nodes=INTEGER(nodes)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_gem(&c_graph, &c_res, c_use_seed, c_maxiter, c_temp_max, c_temp_min, c_temp_init)); + IGRAPH_R_CHECK(igraph_centralization_closeness_tmax(&c_graph, c_nodes, c_mode, &c_res)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -4224,81 +4260,92 @@ SEXP R_igraph_layout_gem(SEXP graph, SEXP res, SEXP use_seed, SEXP maxiter, SEXP } /*-------------------------------------------/ -/ igraph_layout_davidson_harel / +/ igraph_centralization_eigenvector_centrality / /-------------------------------------------*/ -SEXP R_igraph_layout_davidson_harel(SEXP graph, SEXP res, SEXP use_seed, SEXP maxiter, SEXP fineiter, SEXP cool_fact, SEXP weight_node_dist, SEXP weight_border, SEXP weight_edge_lengths, SEXP weight_edge_crossings, SEXP weight_node_edge_dist) { +SEXP R_igraph_centralization_eigenvector_centrality(SEXP graph, SEXP directed, SEXP scale, SEXP options, SEXP normalized) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_bool_t c_use_seed; - igraph_integer_t c_maxiter; - igraph_integer_t c_fineiter; - igraph_real_t c_cool_fact; - igraph_real_t c_weight_node_dist; - igraph_real_t c_weight_border; - igraph_real_t c_weight_edge_lengths; - igraph_real_t c_weight_edge_crossings; - igraph_real_t c_weight_node_edge_dist; + igraph_vector_t c_vector; + igraph_real_t c_value; + igraph_bool_t c_directed; + igraph_bool_t c_scale; + igraph_arpack_options_t c_options; + igraph_real_t c_centralization; + igraph_real_t c_theoretical_max; + igraph_bool_t c_normalized; + SEXP vector; + SEXP value; + SEXP centralization; + SEXP theoretical_max; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { + if (0 != igraph_vector_init(&c_vector, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - c_use_seed=LOGICAL(use_seed)[0]; - c_maxiter=INTEGER(maxiter)[0]; - c_fineiter=INTEGER(fineiter)[0]; - c_cool_fact=REAL(cool_fact)[0]; - c_weight_node_dist=REAL(weight_node_dist)[0]; - c_weight_border=REAL(weight_border)[0]; - c_weight_edge_lengths=REAL(weight_edge_lengths)[0]; - c_weight_edge_crossings=REAL(weight_edge_crossings)[0]; - c_weight_node_edge_dist=REAL(weight_node_edge_dist)[0]; + IGRAPH_FINALLY(igraph_vector_destroy, &c_vector); + c_directed=LOGICAL(directed)[0]; + c_scale=LOGICAL(scale)[0]; + R_SEXP_to_igraph_arpack_options(options, &c_options); + c_normalized=LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_layout_davidson_harel(&c_graph, &c_res, c_use_seed, c_maxiter, c_fineiter, c_cool_fact, c_weight_node_dist, c_weight_border, c_weight_edge_lengths, c_weight_edge_crossings, c_weight_node_edge_dist)); + IGRAPH_R_CHECK(igraph_centralization_eigenvector_centrality(&c_graph, &c_vector, &c_value, c_directed, c_scale, &c_options, &c_centralization, &c_theoretical_max, c_normalized)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); + PROTECT(r_result=NEW_LIST(5)); + PROTECT(r_names=NEW_CHARACTER(5)); + PROTECT(vector=R_igraph_vector_to_SEXP(&c_vector)); + igraph_vector_destroy(&c_vector); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(centralization=NEW_NUMERIC(1)); + REAL(centralization)[0]=c_centralization; + PROTECT(theoretical_max=NEW_NUMERIC(1)); + REAL(theoretical_max)[0]=c_theoretical_max; + SET_VECTOR_ELT(r_result, 0, vector); + SET_VECTOR_ELT(r_result, 1, value); + SET_VECTOR_ELT(r_result, 2, options); + SET_VECTOR_ELT(r_result, 3, centralization); + SET_VECTOR_ELT(r_result, 4, theoretical_max); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vector")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("options")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("centralization")); + SET_STRING_ELT(r_names, 4, Rf_mkChar("theoretical_max")); + SET_NAMES(r_result, r_names); + UNPROTECT(6); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_similarity_jaccard / +/ igraph_centralization_eigenvector_centrality_tmax / /-------------------------------------------*/ -SEXP R_igraph_similarity_jaccard(SEXP graph, SEXP vids, SEXP mode, SEXP loops) { +SEXP R_igraph_centralization_eigenvector_centrality_tmax(SEXP graph, SEXP nodes, SEXP directed, SEXP scale) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_vs_t c_vids; - igraph_neimode_t c_mode; - igraph_bool_t c_loops; + igraph_integer_t c_nodes; + igraph_bool_t c_directed; + igraph_bool_t c_scale; + igraph_real_t c_res; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_loops=LOGICAL(loops)[0]; + c_nodes=INTEGER(nodes)[0]; + c_directed=LOGICAL(directed)[0]; + c_scale=LOGICAL(scale)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_similarity_jaccard(&c_graph, &c_res, c_vids, c_mode, c_loops)); + IGRAPH_R_CHECK(igraph_centralization_eigenvector_centrality_tmax(&c_graph, c_nodes, c_directed, c_scale, &c_res)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -4306,35 +4353,29 @@ SEXP R_igraph_similarity_jaccard(SEXP graph, SEXP vids, SEXP mode, SEXP loops) { } /*-------------------------------------------/ -/ igraph_similarity_dice / +/ igraph_assortativity_nominal / /-------------------------------------------*/ -SEXP R_igraph_similarity_dice(SEXP graph, SEXP vids, SEXP mode, SEXP loops) { +SEXP R_igraph_assortativity_nominal(SEXP graph, SEXP types, SEXP directed, SEXP normalized) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_vs_t c_vids; - igraph_neimode_t c_mode; - igraph_bool_t c_loops; + igraph_vector_int_t c_types; + igraph_real_t c_res; + igraph_bool_t c_directed; + igraph_bool_t c_normalized; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); - c_loops=LOGICAL(loops)[0]; + R_SEXP_to_vector_int(types, &c_types); + c_directed=LOGICAL(directed)[0]; + c_normalized=LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_similarity_dice(&c_graph, &c_res, c_vids, c_mode, c_loops)); + IGRAPH_R_CHECK(igraph_assortativity_nominal(&c_graph, &c_types, &c_res, c_directed, c_normalized)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -4342,33 +4383,31 @@ SEXP R_igraph_similarity_dice(SEXP graph, SEXP vids, SEXP mode, SEXP loops) { } /*-------------------------------------------/ -/ igraph_similarity_inverse_log_weighted / +/ igraph_assortativity / /-------------------------------------------*/ -SEXP R_igraph_similarity_inverse_log_weighted(SEXP graph, SEXP vids, SEXP mode) { +SEXP R_igraph_assortativity(SEXP graph, SEXP values, SEXP values_in, SEXP directed, SEXP normalized) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_vs_t c_vids; - igraph_neimode_t c_mode; + igraph_vector_t c_values; + igraph_vector_t c_values_in; + igraph_real_t c_res; + igraph_bool_t c_directed; + igraph_bool_t c_normalized; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + R_SEXP_to_vector(values, &c_values); + R_SEXP_to_vector(values_in, &c_values_in); + c_directed=LOGICAL(directed)[0]; + c_normalized=LOGICAL(normalized)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_similarity_inverse_log_weighted(&c_graph, &c_res, c_vids, c_mode)); + IGRAPH_R_CHECK(igraph_assortativity(&c_graph, &c_values, &c_values_in, &c_res, c_directed, c_normalized)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -4376,23 +4415,21 @@ SEXP R_igraph_similarity_inverse_log_weighted(SEXP graph, SEXP vids, SEXP mode) } /*-------------------------------------------/ -/ igraph_compare_communities / +/ igraph_assortativity_degree / /-------------------------------------------*/ -SEXP R_igraph_compare_communities(SEXP comm1, SEXP comm2, SEXP method) { +SEXP R_igraph_assortativity_degree(SEXP graph, SEXP directed) { /* Declarations */ - igraph_vector_t c_comm1; - igraph_vector_t c_comm2; + igraph_t c_graph; igraph_real_t c_res; - igraph_community_comparison_t c_method; + igraph_bool_t c_directed; SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_vector(comm1, &c_comm1); - R_SEXP_to_vector(comm2, &c_comm2); - c_method = (igraph_community_comparison_t) Rf_asInteger(method); + R_SEXP_to_igraph(graph, &c_graph); + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_compare_communities(&c_comm1, &c_comm2, &c_res, c_method)); + IGRAPH_R_CHECK(igraph_assortativity_degree(&c_graph, &c_res, c_directed)); /* Convert output */ PROTECT(res=NEW_NUMERIC(1)); @@ -4404,321 +4441,252 @@ SEXP R_igraph_compare_communities(SEXP comm1, SEXP comm2, SEXP method) { } /*-------------------------------------------/ -/ igraph_modularity / +/ igraph_contract_vertices / /-------------------------------------------*/ -SEXP R_igraph_modularity(SEXP graph, SEXP membership, SEXP weights, SEXP resolution, SEXP directed) { +SEXP R_igraph_contract_vertices(SEXP graph, SEXP mapping, SEXP vertex_attr_comb) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_membership; - igraph_vector_t c_weights; - igraph_real_t c_resolution; - igraph_bool_t c_directed; - igraph_real_t c_modularity; - SEXP modularity; + igraph_vector_int_t c_mapping; + igraph_attribute_combination_t c_vertex_attr_comb; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_vector(membership, &c_membership); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_resolution=REAL(resolution)[0]; - c_directed=LOGICAL(directed)[0]; + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + R_SEXP_to_vector_int(mapping, &c_mapping); + R_SEXP_to_attr_comb(vertex_attr_comb, &c_vertex_attr_comb); + IGRAPH_FINALLY(igraph_attribute_combination_destroy, &c_vertex_attr_comb); /* Call igraph */ - IGRAPH_R_CHECK(igraph_modularity(&c_graph, &c_membership, (Rf_isNull(weights) ? 0 : &c_weights), c_resolution, c_directed, &c_modularity)); + IGRAPH_R_CHECK(igraph_contract_vertices(&c_graph, &c_mapping, &c_vertex_attr_comb)); /* Convert output */ - PROTECT(modularity=NEW_NUMERIC(1)); - REAL(modularity)[0]=c_modularity; - r_result = modularity; + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + igraph_attribute_combination_destroy(&c_vertex_attr_comb); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_modularity_matrix / +/ igraph_eccentricity / /-------------------------------------------*/ -SEXP R_igraph_modularity_matrix(SEXP graph, SEXP weights, SEXP resolution, SEXP directed) { +SEXP R_igraph_eccentricity(SEXP graph, SEXP vids, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_weights; - igraph_real_t c_resolution; - igraph_matrix_t c_modmat; - igraph_bool_t c_directed; - SEXP modmat; + igraph_vector_t c_res; + igraph_vs_t c_vids; + igraph_neimode_t c_mode; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_resolution=REAL(resolution)[0]; - if (0 != igraph_matrix_init(&c_modmat, 0, 0)) { + if (0 != igraph_vector_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_modmat); - c_directed=LOGICAL(directed)[0]; + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_modularity_matrix(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), c_resolution, &c_modmat, c_directed)); + IGRAPH_R_CHECK(igraph_eccentricity(&c_graph, &c_res, c_vids, c_mode)); /* Convert output */ - PROTECT(modmat=R_igraph_matrix_to_SEXP(&c_modmat)); - igraph_matrix_destroy(&c_modmat); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = modmat; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_fluid_communities / +/ igraph_eccentricity_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_community_fluid_communities(SEXP graph, SEXP no_of_communities) { +SEXP R_igraph_eccentricity_dijkstra(SEXP graph, SEXP weights, SEXP vids, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_no_of_communities; - igraph_vector_t c_membership; - igraph_real_t c_modularity; - SEXP membership; - SEXP modularity; + igraph_vector_t c_weights; + igraph_vector_t c_res; + igraph_vs_t c_vids; + igraph_neimode_t c_mode; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_no_of_communities=INTEGER(no_of_communities)[0]; - if (0 != igraph_vector_init(&c_membership, 0)) { + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (0 != igraph_vector_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_fluid_communities(&c_graph, c_no_of_communities, &c_membership, &c_modularity)); + IGRAPH_R_CHECK(igraph_eccentricity_dijkstra(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_res, c_vids, c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(membership=R_igraph_vector_to_SEXP(&c_membership)); - igraph_vector_destroy(&c_membership); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - PROTECT(modularity=NEW_NUMERIC(1)); - REAL(modularity)[0]=c_modularity; - SET_VECTOR_ELT(r_result, 0, membership); - SET_VECTOR_ELT(r_result, 1, modularity); - SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("modularity")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_label_propagation / +/ igraph_graph_center / /-------------------------------------------*/ -SEXP R_igraph_community_label_propagation(SEXP graph, SEXP weights, SEXP initial, SEXP fixed) { +SEXP R_igraph_graph_center(SEXP graph, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_membership; - igraph_vector_t c_weights; - igraph_vector_t c_initial; - igraph_vector_bool_t c_fixed; - igraph_real_t c_modularity; - SEXP membership; - SEXP modularity; + igraph_vector_int_t c_res; + igraph_neimode_t c_mode; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_membership, 0)) { + if (0 != igraph_vector_int_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (!Rf_isNull(initial)) { R_SEXP_to_vector(initial, &c_initial); } - if (!Rf_isNull(fixed)) { R_SEXP_to_vector_bool(fixed, &c_fixed); } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_label_propagation(&c_graph, &c_membership, (Rf_isNull(weights) ? 0 : &c_weights), (Rf_isNull(initial) ? 0 : &c_initial), (Rf_isNull(fixed) ? 0 : &c_fixed), &c_modularity)); + IGRAPH_R_CHECK(igraph_graph_center(&c_graph, &c_res, c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(membership=R_igraph_vector_to_SEXP(&c_membership)); - igraph_vector_destroy(&c_membership); + PROTECT(res=R_igraph_vector_int_to_SEXP(&c_res)); + igraph_vector_int_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - PROTECT(modularity=NEW_NUMERIC(1)); - REAL(modularity)[0]=c_modularity; - SET_VECTOR_ELT(r_result, 0, membership); - SET_VECTOR_ELT(r_result, 1, modularity); - SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("modularity")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_multilevel / +/ igraph_radius / /-------------------------------------------*/ -SEXP R_igraph_community_multilevel(SEXP graph, SEXP weights, SEXP resolution) { +SEXP R_igraph_radius(SEXP graph, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_weights; - igraph_real_t c_resolution; - igraph_vector_t c_membership; - igraph_matrix_t c_memberships; - igraph_vector_t c_modularity; - SEXP membership; - SEXP memberships; - SEXP modularity; + igraph_real_t c_radius; + igraph_neimode_t c_mode; + SEXP radius; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_resolution=REAL(resolution)[0]; - if (0 != igraph_vector_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); - if (0 != igraph_matrix_init(&c_memberships, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_memberships); - memberships=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_modularity, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_modularity); - modularity=R_GlobalEnv; /* hack to have a non-NULL value */ + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_multilevel(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), c_resolution, &c_membership, (Rf_isNull(memberships) ? 0 : &c_memberships), (Rf_isNull(modularity) ? 0 : &c_modularity))); + IGRAPH_R_CHECK(igraph_radius(&c_graph, &c_radius, c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(membership=R_igraph_vector_to_SEXP(&c_membership)); - igraph_vector_destroy(&c_membership); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(memberships=R_igraph_0ormatrix_to_SEXP(&c_memberships)); - igraph_matrix_destroy(&c_memberships); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(modularity=R_igraph_0orvector_to_SEXP(&c_modularity)); - igraph_vector_destroy(&c_modularity); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, membership); - SET_VECTOR_ELT(r_result, 1, memberships); - SET_VECTOR_ELT(r_result, 2, modularity); - SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("memberships")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("modularity")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + PROTECT(radius=NEW_NUMERIC(1)); + REAL(radius)[0]=c_radius; + r_result = radius; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_optimal_modularity / +/ igraph_pseudo_diameter / /-------------------------------------------*/ -SEXP R_igraph_community_optimal_modularity(SEXP graph, SEXP weights) { +SEXP R_igraph_pseudo_diameter(SEXP graph, SEXP start_vid, SEXP directed, SEXP unconnected) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_modularity; - igraph_vector_t c_membership; - igraph_vector_t c_weights; - SEXP modularity; - SEXP membership; + igraph_real_t c_diameter; + igraph_integer_t c_start_vid; + igraph_integer_t c_from; + igraph_integer_t c_to; + igraph_bool_t c_directed; + igraph_bool_t c_unconnected; + SEXP diameter; + SEXP from; + SEXP to; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); - membership=R_GlobalEnv; /* hack to have a non-NULL value */ - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_start_vid = (igraph_integer_t) REAL(start_vid)[0]; + c_from=0; + c_to=0; + c_directed=LOGICAL(directed)[0]; + c_unconnected=LOGICAL(unconnected)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_optimal_modularity(&c_graph, &c_modularity, (Rf_isNull(membership) ? 0 : &c_membership), (Rf_isNull(weights) ? 0 : &c_weights))); + IGRAPH_R_CHECK(igraph_pseudo_diameter(&c_graph, &c_diameter, c_start_vid, &c_from, &c_to, c_directed, c_unconnected)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(modularity=NEW_NUMERIC(1)); - REAL(modularity)[0]=c_modularity; - PROTECT(membership=R_igraph_0orvector_to_SEXP(&c_membership)); - igraph_vector_destroy(&c_membership); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, modularity); - SET_VECTOR_ELT(r_result, 1, membership); - SET_STRING_ELT(r_names, 0, Rf_mkChar("modularity")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("membership")); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(diameter=NEW_NUMERIC(1)); + REAL(diameter)[0]=c_diameter; + PROTECT(from=NEW_INTEGER(1)); + INTEGER(from)[0]=c_from; + PROTECT(to=NEW_INTEGER(1)); + INTEGER(to)[0]=c_to; + SET_VECTOR_ELT(r_result, 0, diameter); + SET_VECTOR_ELT(r_result, 1, from); + SET_VECTOR_ELT(r_result, 2, to); + SET_STRING_ELT(r_names, 0, Rf_mkChar("diameter")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("from")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("to")); SET_NAMES(r_result, r_names); - UNPROTECT(3); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_leiden / +/ igraph_pseudo_diameter_dijkstra / /-------------------------------------------*/ -SEXP R_igraph_community_leiden(SEXP graph, SEXP weights, SEXP vertex_weights, SEXP resolution_parameter, SEXP beta, SEXP start, SEXP membership) { +SEXP R_igraph_pseudo_diameter_dijkstra(SEXP graph, SEXP weights, SEXP start_vid, SEXP directed, SEXP unconnected) { /* Declarations */ igraph_t c_graph; igraph_vector_t c_weights; - igraph_vector_t c_vertex_weights; - igraph_real_t c_resolution_parameter; - igraph_real_t c_beta; - igraph_bool_t c_start; - igraph_vector_t c_membership; - igraph_integer_t c_nb_clusters; - igraph_real_t c_quality; - SEXP nb_clusters; - SEXP quality; + igraph_real_t c_diameter; + igraph_integer_t c_start_vid; + igraph_integer_t c_from; + igraph_integer_t c_to; + igraph_bool_t c_directed; + igraph_bool_t c_unconnected; + SEXP diameter; + SEXP from; + SEXP to; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } - c_resolution_parameter=REAL(resolution_parameter)[0]; - c_beta=REAL(beta)[0]; - c_start=LOGICAL(start)[0]; - if (!Rf_isNull(membership)) { - if (0 != R_SEXP_to_vector_copy(membership, &c_membership)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - } else { - if (0 != igraph_vector_init(&c_membership, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); - membership=NEW_NUMERIC(0); - c_nb_clusters=0; + c_start_vid = (igraph_integer_t) REAL(start_vid)[0]; + c_from=0; + c_to=0; + c_directed=LOGICAL(directed)[0]; + c_unconnected=LOGICAL(unconnected)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_leiden(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), c_resolution_parameter, c_beta, c_start, (Rf_isNull(membership) ? 0 : &c_membership), &c_nb_clusters, &c_quality)); + IGRAPH_R_CHECK(igraph_pseudo_diameter_dijkstra(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_diameter, c_start_vid, &c_from, &c_to, c_directed, c_unconnected)); /* Convert output */ PROTECT(r_result=NEW_LIST(3)); PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(membership=R_igraph_0orvector_to_SEXP(&c_membership)); - igraph_vector_destroy(&c_membership); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(nb_clusters=NEW_INTEGER(1)); - INTEGER(nb_clusters)[0]=c_nb_clusters; - PROTECT(quality=NEW_NUMERIC(1)); - REAL(quality)[0]=c_quality; - SET_VECTOR_ELT(r_result, 0, membership); - SET_VECTOR_ELT(r_result, 1, nb_clusters); - SET_VECTOR_ELT(r_result, 2, quality); - SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("nb_clusters")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("quality")); + PROTECT(diameter=NEW_NUMERIC(1)); + REAL(diameter)[0]=c_diameter; + PROTECT(from=NEW_INTEGER(1)); + INTEGER(from)[0]=c_from; + PROTECT(to=NEW_INTEGER(1)); + INTEGER(to)[0]=c_to; + SET_VECTOR_ELT(r_result, 0, diameter); + SET_VECTOR_ELT(r_result, 1, from); + SET_VECTOR_ELT(r_result, 2, to); + SET_STRING_ELT(r_names, 0, Rf_mkChar("diameter")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("from")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("to")); SET_NAMES(r_result, r_names); UNPROTECT(4); @@ -4727,674 +4695,779 @@ SEXP R_igraph_community_leiden(SEXP graph, SEXP weights, SEXP vertex_weights, SE } /*-------------------------------------------/ -/ igraph_split_join_distance / +/ igraph_diversity / /-------------------------------------------*/ -SEXP R_igraph_split_join_distance(SEXP comm1, SEXP comm2) { +SEXP R_igraph_diversity(SEXP graph, SEXP weights, SEXP vids) { /* Declarations */ - igraph_vector_t c_comm1; - igraph_vector_t c_comm2; - igraph_integer_t c_distance12; - igraph_integer_t c_distance21; - SEXP distance12; - SEXP distance21; + igraph_t c_graph; + igraph_vector_t c_weights; + igraph_vector_t c_res; + igraph_vs_t c_vids; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - R_SEXP_to_vector(comm1, &c_comm1); - R_SEXP_to_vector(comm2, &c_comm2); - c_distance12=0; - c_distance21=0; + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_split_join_distance(&c_comm1, &c_comm2, &c_distance12, &c_distance21)); + IGRAPH_R_CHECK(igraph_diversity(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_res, c_vids)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(distance12=NEW_INTEGER(1)); - INTEGER(distance12)[0]=c_distance12; - PROTECT(distance21=NEW_INTEGER(1)); - INTEGER(distance21)[0]=c_distance21; - SET_VECTOR_ELT(r_result, 0, distance12); - SET_VECTOR_ELT(r_result, 1, distance21); - SET_STRING_ELT(r_names, 0, Rf_mkChar("distance12")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("distance21")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_fit / +/ igraph_random_walk / /-------------------------------------------*/ -SEXP R_igraph_hrg_fit(SEXP graph, SEXP hrg, SEXP start, SEXP steps) { +SEXP R_igraph_random_walk(SEXP graph, SEXP weights, SEXP start, SEXP mode, SEXP steps, SEXP stuck) { /* Declarations */ igraph_t c_graph; - igraph_hrg_t c_hrg; - igraph_bool_t c_start; - int c_steps; + igraph_vector_t c_weights; + igraph_vector_int_t c_vertices; + igraph_vector_int_t c_edges; + igraph_integer_t c_start; + igraph_neimode_t c_mode; + igraph_integer_t c_steps; + igraph_random_walk_stuck_t c_stuck; + SEXP vertices; + SEXP edges; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (0 != igraph_vector_int_init(&c_vertices, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); - c_start=LOGICAL(start)[0]; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertices); + if (0 != igraph_vector_int_init(&c_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); + c_start = (igraph_integer_t) REAL(start)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); c_steps=INTEGER(steps)[0]; + c_stuck = (igraph_random_walk_stuck_t) Rf_asInteger(stuck); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_fit(&c_graph, &c_hrg, c_start, c_steps)); + IGRAPH_R_CHECK(igraph_random_walk(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_vertices, &c_edges, c_start, c_mode, c_steps, c_stuck)); /* Convert output */ - PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); - igraph_hrg_destroy(&c_hrg); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(vertices=R_igraph_vector_int_to_SEXP(&c_vertices)); + igraph_vector_int_destroy(&c_vertices); IGRAPH_FINALLY_CLEAN(1); - r_result = hrg; + PROTECT(edges=R_igraph_vector_int_to_SEXP(&c_edges)); + igraph_vector_int_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vertices); + SET_VECTOR_ELT(r_result, 1, edges); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vertices")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("edges")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_game / +/ igraph_random_edge_walk / /-------------------------------------------*/ -SEXP R_igraph_hrg_game(SEXP hrg) { +SEXP R_igraph_random_edge_walk(SEXP graph, SEXP weights, SEXP start, SEXP mode, SEXP steps, SEXP stuck) { /* Declarations */ igraph_t c_graph; - igraph_hrg_t c_hrg; - SEXP graph; + igraph_vector_t c_weights; + igraph_vector_int_t c_edgewalk; + igraph_integer_t c_start; + igraph_neimode_t c_mode; + igraph_integer_t c_steps; + igraph_random_walk_stuck_t c_stuck; + SEXP edgewalk; SEXP r_result; /* Convert input */ - R_SEXP_to_hrg(hrg, &c_hrg); + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (0 != igraph_vector_int_init(&c_edgewalk, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edgewalk); + c_start = (igraph_integer_t) REAL(start)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_steps=INTEGER(steps)[0]; + c_stuck = (igraph_random_walk_stuck_t) Rf_asInteger(stuck); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_game(&c_graph, &c_hrg)); + IGRAPH_R_CHECK(igraph_random_edge_walk(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_edgewalk, c_start, c_mode, c_steps, c_stuck)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); + PROTECT(edgewalk=R_igraph_vector_int_to_SEXP(&c_edgewalk)); + igraph_vector_int_destroy(&c_edgewalk); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + r_result = edgewalk; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_dendrogram / +/ igraph_global_efficiency / /-------------------------------------------*/ -SEXP R_igraph_hrg_dendrogram(SEXP hrg) { +SEXP R_igraph_global_efficiency(SEXP graph, SEXP weights, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_hrg_t c_hrg; - SEXP graph; + igraph_real_t c_res; + igraph_vector_t c_weights; + igraph_bool_t c_directed; + SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_hrg(hrg, &c_hrg); + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_dendrogram(&c_graph, &c_hrg)); + IGRAPH_R_CHECK(igraph_global_efficiency(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_directed)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_consensus / +/ igraph_local_efficiency / /-------------------------------------------*/ -SEXP R_igraph_hrg_consensus(SEXP graph, SEXP hrg, SEXP start, SEXP num_samples) { +SEXP R_igraph_local_efficiency(SEXP graph, SEXP vids, SEXP weights, SEXP directed, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_parents; + igraph_vector_t c_res; + igraph_vs_t c_vids; igraph_vector_t c_weights; - igraph_hrg_t c_hrg; - igraph_bool_t c_start; - int c_num_samples; - SEXP parents; - SEXP weights; + igraph_bool_t c_directed; + igraph_neimode_t c_mode; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_parents, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_parents); - if (0 != igraph_vector_init(&c_weights, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_weights); - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { + if (0 != igraph_vector_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); - c_start=LOGICAL(start)[0]; - c_num_samples=INTEGER(num_samples)[0]; + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_directed=LOGICAL(directed)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_consensus(&c_graph, &c_parents, &c_weights, &c_hrg, c_start, c_num_samples)); + IGRAPH_R_CHECK(igraph_local_efficiency(&c_graph, &c_res, c_vids, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(parents=R_igraph_vector_to_SEXP(&c_parents)); - igraph_vector_destroy(&c_parents); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(weights=R_igraph_vector_to_SEXP(&c_weights)); - igraph_vector_destroy(&c_weights); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); - igraph_hrg_destroy(&c_hrg); + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, parents); - SET_VECTOR_ELT(r_result, 1, weights); - SET_VECTOR_ELT(r_result, 2, hrg); - SET_STRING_ELT(r_names, 0, Rf_mkChar("parents")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("weights")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("hrg")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_predict / +/ igraph_average_local_efficiency / /-------------------------------------------*/ -SEXP R_igraph_hrg_predict(SEXP graph, SEXP hrg, SEXP start, SEXP num_samples, SEXP num_bins) { +SEXP R_igraph_average_local_efficiency(SEXP graph, SEXP weights, SEXP directed, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_edges; - igraph_vector_t c_prob; - igraph_hrg_t c_hrg; - igraph_bool_t c_start; - int c_num_samples; - int c_num_bins; - SEXP edges; - SEXP prob; + igraph_real_t c_res; + igraph_vector_t c_weights; + igraph_bool_t c_directed; + igraph_neimode_t c_mode; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_edges, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_edges); - if (0 != igraph_vector_init(&c_prob, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_prob); - if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); - c_start=LOGICAL(start)[0]; - c_num_samples=INTEGER(num_samples)[0]; - c_num_bins=INTEGER(num_bins)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_directed=LOGICAL(directed)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_predict(&c_graph, &c_edges, &c_prob, &c_hrg, c_start, c_num_samples, c_num_bins)); + IGRAPH_R_CHECK(igraph_average_local_efficiency(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_directed, c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(edges=R_igraph_vector_to_SEXPp1(&c_edges)); - igraph_vector_destroy(&c_edges); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(prob=R_igraph_vector_to_SEXP(&c_prob)); - igraph_vector_destroy(&c_prob); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); - igraph_hrg_destroy(&c_hrg); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, edges); - SET_VECTOR_ELT(r_result, 1, prob); - SET_VECTOR_ELT(r_result, 2, hrg); - SET_STRING_ELT(r_names, 0, Rf_mkChar("edges")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("prob")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("hrg")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_hrg_create / +/ igraph_transitive_closure_dag / /-------------------------------------------*/ -SEXP R_igraph_hrg_create(SEXP graph, SEXP prob) { +SEXP R_igraph_transitive_closure_dag(SEXP graph) { /* Declarations */ - igraph_hrg_t c_hrg; igraph_t c_graph; - igraph_vector_t c_prob; - SEXP hrg; + igraph_t c_closure; + SEXP closure; SEXP r_result; /* Convert input */ - if (0 != igraph_hrg_init(&c_hrg, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_vector(prob, &c_prob); /* Call igraph */ - IGRAPH_R_CHECK(igraph_hrg_create(&c_hrg, &c_graph, &c_prob)); + IGRAPH_R_CHECK(igraph_transitive_closure_dag(&c_graph, &c_closure)); /* Convert output */ - PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); - igraph_hrg_destroy(&c_hrg); + IGRAPH_FINALLY(igraph_destroy, &c_closure); + PROTECT(closure=R_igraph_to_SEXP(&c_closure)); + igraph_destroy(&c_closure); IGRAPH_FINALLY_CLEAN(1); - r_result = hrg; + r_result = closure; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_community_infomap / +/ igraph_trussness / /-------------------------------------------*/ -SEXP R_igraph_community_infomap(SEXP graph, SEXP e_weights, SEXP v_weights, SEXP nb_trials) { +SEXP R_igraph_trussness(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_e_weights; - igraph_vector_t c_v_weights; - int c_nb_trials; - igraph_vector_t c_membership; - igraph_real_t c_codelength; - SEXP membership; - SEXP codelength; + igraph_vector_int_t c_trussness; + SEXP trussness; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(e_weights)) { R_SEXP_to_vector(e_weights, &c_e_weights); } - if (!Rf_isNull(v_weights)) { R_SEXP_to_vector(v_weights, &c_v_weights); } - c_nb_trials=INTEGER(nb_trials)[0]; - if (0 != igraph_vector_init(&c_membership, 0)) { + if (0 != igraph_vector_int_init(&c_trussness, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_trussness); /* Call igraph */ - IGRAPH_R_CHECK(igraph_community_infomap(&c_graph, (Rf_isNull(e_weights) ? 0 : &c_e_weights), (Rf_isNull(v_weights) ? 0 : &c_v_weights), c_nb_trials, &c_membership, &c_codelength)); + IGRAPH_R_CHECK(igraph_trussness(&c_graph, &c_trussness)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(membership=R_igraph_vector_to_SEXP(&c_membership)); - igraph_vector_destroy(&c_membership); + PROTECT(trussness=R_igraph_vector_int_to_SEXP(&c_trussness)); + igraph_vector_int_destroy(&c_trussness); IGRAPH_FINALLY_CLEAN(1); - PROTECT(codelength=NEW_NUMERIC(1)); - REAL(codelength)[0]=c_codelength; - SET_VECTOR_ELT(r_result, 0, membership); - SET_VECTOR_ELT(r_result, 1, codelength); - SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("codelength")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = trussness; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_to_directed / +/ igraph_is_graphical / /-------------------------------------------*/ -SEXP R_igraph_to_directed(SEXP graph, SEXP mode) { +SEXP R_igraph_is_graphical(SEXP out_deg, SEXP in_deg, SEXP allowed_edge_types) { /* Declarations */ - igraph_t c_graph; - igraph_to_directed_t c_mode; + igraph_vector_int_t c_out_deg; + igraph_vector_int_t c_in_deg; + igraph_edge_type_sw_t c_allowed_edge_types; + igraph_bool_t c_res; + SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph_copy(graph, &c_graph); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - c_mode = (igraph_to_directed_t) Rf_asInteger(mode); + R_SEXP_to_vector_int(out_deg, &c_out_deg); + R_SEXP_to_vector_int(in_deg, &c_in_deg); + c_allowed_edge_types = (igraph_edge_type_sw_t) Rf_asInteger(allowed_edge_types); /* Call igraph */ - IGRAPH_R_CHECK(igraph_to_directed(&c_graph, c_mode)); + IGRAPH_R_CHECK(igraph_is_graphical(&c_out_deg, &c_in_deg, c_allowed_edge_types, &c_res)); /* Convert output */ - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_to_undirected / +/ igraph_bfs_simple / /-------------------------------------------*/ -SEXP R_igraph_to_undirected(SEXP graph, SEXP mode, SEXP edge_attr_comb) { +SEXP R_igraph_bfs_simple(SEXP graph, SEXP root, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_to_undirected_t c_mode; - igraph_attribute_combination_t c_edge_attr_comb; + igraph_integer_t c_root; + igraph_neimode_t c_mode; + igraph_vector_int_t c_order; + igraph_vector_int_t c_layers; + igraph_vector_int_t c_parents; + SEXP order; + SEXP layers; + SEXP parents; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph_copy(graph, &c_graph); - IGRAPH_FINALLY(igraph_destroy, &c_graph); - c_mode = (igraph_to_undirected_t) Rf_asInteger(mode); - R_SEXP_to_attr_comb(edge_attr_comb, &c_edge_attr_comb); - IGRAPH_FINALLY(igraph_attribute_combination_destroy, &c_edge_attr_comb); + R_SEXP_to_igraph(graph, &c_graph); + c_root = (igraph_integer_t) REAL(root)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + if (0 != igraph_vector_int_init(&c_order, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_order); + if (0 != igraph_vector_int_init(&c_layers, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_layers); + if (0 != igraph_vector_int_init(&c_parents, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_parents); /* Call igraph */ - IGRAPH_R_CHECK(igraph_to_undirected(&c_graph, c_mode, &c_edge_attr_comb)); + IGRAPH_R_CHECK(igraph_bfs_simple(&c_graph, c_root, c_mode, &c_order, &c_layers, &c_parents)); /* Convert output */ - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(order=R_igraph_vector_int_to_SEXP(&c_order)); + igraph_vector_int_destroy(&c_order); IGRAPH_FINALLY_CLEAN(1); - igraph_attribute_combination_destroy(&c_edge_attr_comb); + PROTECT(layers=R_igraph_vector_int_to_SEXP(&c_layers)); + igraph_vector_int_destroy(&c_layers); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + PROTECT(parents=R_igraph_vector_int_to_SEXP(&c_parents)); + igraph_vector_int_destroy(&c_parents); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, order); + SET_VECTOR_ELT(r_result, 1, layers); + SET_VECTOR_ELT(r_result, 2, parents); + SET_STRING_ELT(r_names, 0, Rf_mkChar("order")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("layers")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("parents")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_get_stochastic / +/ igraph_bipartite_projection_size / /-------------------------------------------*/ -SEXP R_igraph_get_stochastic(SEXP graph, SEXP column_wise) { +SEXP R_igraph_bipartite_projection_size(SEXP graph, SEXP types) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_res; - igraph_bool_t c_column_wise; - SEXP res; + igraph_vector_bool_t c_types; + igraph_integer_t c_vcount1; + igraph_integer_t c_ecount1; + igraph_integer_t c_vcount2; + igraph_integer_t c_ecount2; + SEXP vcount1; + SEXP ecount1; + SEXP vcount2; + SEXP ecount2; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_matrix_init(&c_res, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); - c_column_wise=LOGICAL(column_wise)[0]; + if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + c_vcount1=0; + c_ecount1=0; + c_vcount2=0; + c_ecount2=0; /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_stochastic(&c_graph, &c_res, c_column_wise)); + IGRAPH_R_CHECK(igraph_bipartite_projection_size(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_vcount1, &c_ecount1, &c_vcount2, &c_ecount2)); /* Convert output */ - PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); - igraph_matrix_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(r_result=NEW_LIST(4)); + PROTECT(r_names=NEW_CHARACTER(4)); + PROTECT(vcount1=NEW_INTEGER(1)); + INTEGER(vcount1)[0]=c_vcount1; + PROTECT(ecount1=NEW_INTEGER(1)); + INTEGER(ecount1)[0]=c_ecount1; + PROTECT(vcount2=NEW_INTEGER(1)); + INTEGER(vcount2)[0]=c_vcount2; + PROTECT(ecount2=NEW_INTEGER(1)); + INTEGER(ecount2)[0]=c_ecount2; + SET_VECTOR_ELT(r_result, 0, vcount1); + SET_VECTOR_ELT(r_result, 1, ecount1); + SET_VECTOR_ELT(r_result, 2, vcount2); + SET_VECTOR_ELT(r_result, 3, ecount2); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vcount1")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("ecount1")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("vcount2")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("ecount2")); + SET_NAMES(r_result, r_names); + UNPROTECT(5); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_get_stochastic_sparsemat / +/ igraph_create_bipartite / /-------------------------------------------*/ -SEXP R_igraph_get_stochastic_sparsemat(SEXP graph, SEXP column_wise) { +SEXP R_igraph_create_bipartite(SEXP types, SEXP edges, SEXP directed) { /* Declarations */ igraph_t c_graph; - igraph_sparsemat_t c_sparsemat; - igraph_bool_t c_column_wise; - SEXP sparsemat; + igraph_vector_bool_t c_types; + igraph_vector_int_t c_edges; + igraph_bool_t c_directed; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - /* Don't need to init. */ - c_column_wise=LOGICAL(column_wise)[0]; + if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + R_SEXP_to_vector_int(edges, &c_edges); + c_directed=LOGICAL(directed)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_stochastic_sparsemat(&c_graph, &c_sparsemat, c_column_wise)); + IGRAPH_R_CHECK(igraph_create_bipartite(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_edges, c_directed)); /* Convert output */ - PROTECT(sparsemat=R_igraph_sparsemat_to_SEXP(&c_sparsemat)); - igraph_sparsemat_destroy(&c_sparsemat); - r_result = sparsemat; + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_dyad_census / +/ igraph_biadjacency / /-------------------------------------------*/ -SEXP R_igraph_dyad_census(SEXP graph) { +SEXP R_igraph_biadjacency(SEXP incidence, SEXP directed, SEXP mode, SEXP multiple) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_mut; - igraph_integer_t c_asym; - igraph_integer_t c_null; - SEXP mut; - SEXP asym; - SEXP null; + igraph_vector_bool_t c_types; + igraph_matrix_t c_incidence; + igraph_bool_t c_directed; + igraph_neimode_t c_mode; + igraph_bool_t c_multiple; + SEXP graph; + SEXP types; SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - c_mut=0; - c_asym=0; - c_null=0; + if (0 != igraph_vector_bool_init(&c_types, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); + R_SEXP_to_matrix(incidence, &c_incidence); + c_directed=LOGICAL(directed)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_multiple=LOGICAL(multiple)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_dyad_census(&c_graph, &c_mut, &c_asym, &c_null)); + IGRAPH_R_CHECK(igraph_biadjacency(&c_graph, &c_types, &c_incidence, c_directed, c_mode, c_multiple)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(mut=NEW_INTEGER(1)); - INTEGER(mut)[0]=c_mut; - PROTECT(asym=NEW_INTEGER(1)); - INTEGER(asym)[0]=c_asym; - PROTECT(null=NEW_INTEGER(1)); - INTEGER(null)[0]=c_null; - SET_VECTOR_ELT(r_result, 0, mut); - SET_VECTOR_ELT(r_result, 1, asym); - SET_VECTOR_ELT(r_result, 2, null); - SET_STRING_ELT(r_names, 0, Rf_mkChar("mut")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("asym")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("null")); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(types=R_igraph_vector_bool_to_SEXP(&c_types)); + igraph_vector_bool_destroy(&c_types); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, types); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); SET_NAMES(r_result, r_names); - UNPROTECT(4); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_triad_census / +/ igraph_get_biadjacency / /-------------------------------------------*/ -SEXP R_igraph_triad_census(SEXP graph) { +SEXP R_igraph_get_biadjacency(SEXP graph, SEXP types) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; + igraph_vector_bool_t c_types; + igraph_matrix_t c_res; + igraph_vector_int_t c_row_ids; + igraph_vector_int_t c_col_ids; SEXP res; + SEXP row_ids; + SEXP col_ids; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + if (0 != igraph_matrix_init(&c_res, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + if (0 != igraph_vector_int_init(&c_row_ids, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_row_ids); + if (0 != igraph_vector_int_init(&c_col_ids, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_col_ids); /* Call igraph */ - IGRAPH_R_CHECK(igraph_triad_census(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_get_biadjacency(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_res, &c_row_ids, &c_col_ids)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(row_ids=R_igraph_vector_int_to_SEXP(&c_row_ids)); + igraph_vector_int_destroy(&c_row_ids); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(col_ids=R_igraph_vector_int_to_SEXP(&c_col_ids)); + igraph_vector_int_destroy(&c_col_ids); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, row_ids); + SET_VECTOR_ELT(r_result, 2, col_ids); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("row_ids")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("col_ids")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_adjacent_triangles / +/ igraph_is_bipartite / /-------------------------------------------*/ -SEXP R_igraph_adjacent_triangles(SEXP graph, SEXP vids) { +SEXP R_igraph_is_bipartite(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vs_t c_vids; + igraph_bool_t c_res; + igraph_vector_bool_t c_type; SEXP res; + SEXP type; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + if (0 != igraph_vector_bool_init(&c_type, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - R_SEXP_to_igraph_vs(vids, &c_graph, &c_vids); + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_type); /* Call igraph */ - IGRAPH_R_CHECK(igraph_adjacent_triangles(&c_graph, &c_res, c_vids)); + IGRAPH_R_CHECK(igraph_is_bipartite(&c_graph, &c_res, &c_type)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + PROTECT(type=R_igraph_vector_bool_to_SEXP(&c_type)); + igraph_vector_bool_destroy(&c_type); IGRAPH_FINALLY_CLEAN(1); - igraph_vs_destroy(&c_vids); - r_result = res; + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, type); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("type")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_local_scan_0 / +/ igraph_bipartite_game_gnp / /-------------------------------------------*/ -SEXP R_igraph_local_scan_0(SEXP graph, SEXP weights, SEXP mode) { +SEXP R_igraph_bipartite_game_gnp(SEXP n1, SEXP n2, SEXP p, SEXP directed, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vector_t c_weights; + igraph_vector_bool_t c_types; + igraph_integer_t c_n1; + igraph_integer_t c_n2; + igraph_real_t c_p; + igraph_bool_t c_directed; igraph_neimode_t c_mode; - SEXP res; + SEXP graph; + SEXP types; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + if (0 != igraph_vector_bool_init(&c_types, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); + c_n1=INTEGER(n1)[0]; + c_n2=INTEGER(n2)[0]; + c_p=REAL(p)[0]; + c_directed=LOGICAL(directed)[0]; c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_0(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_bipartite_game_gnp(&c_graph, &c_types, c_n1, c_n2, c_p, c_directed, c_mode)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(types=R_igraph_vector_bool_to_SEXP(&c_types)); + igraph_vector_bool_destroy(&c_types); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, types); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_local_scan_0_them / +/ igraph_bipartite_game_gnm / /-------------------------------------------*/ -SEXP R_igraph_local_scan_0_them(SEXP us, SEXP them, SEXP weights_them, SEXP mode) { +SEXP R_igraph_bipartite_game_gnm(SEXP n1, SEXP n2, SEXP m, SEXP directed, SEXP mode) { /* Declarations */ - igraph_t c_us; - igraph_t c_them; - igraph_vector_t c_res; - igraph_vector_t c_weights_them; + igraph_t c_graph; + igraph_vector_bool_t c_types; + igraph_integer_t c_n1; + igraph_integer_t c_n2; + igraph_integer_t c_m; + igraph_bool_t c_directed; igraph_neimode_t c_mode; - SEXP res; + SEXP graph; + SEXP types; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(us, &c_us); - R_SEXP_to_igraph(them, &c_them); - if (0 != igraph_vector_init(&c_res, 0)) { + if (0 != igraph_vector_bool_init(&c_types, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights_them)) { R_SEXP_to_vector(weights_them, &c_weights_them); } + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); + c_n1=INTEGER(n1)[0]; + c_n2=INTEGER(n2)[0]; + c_m=INTEGER(m)[0]; + c_directed=LOGICAL(directed)[0]; c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_0_them(&c_us, &c_them, &c_res, (Rf_isNull(weights_them) ? 0 : &c_weights_them), c_mode)); + IGRAPH_R_CHECK(igraph_bipartite_game_gnm(&c_graph, &c_types, c_n1, c_n2, c_m, c_directed, c_mode)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(types=R_igraph_vector_bool_to_SEXP(&c_types)); + igraph_vector_bool_destroy(&c_types); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, types); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_local_scan_1_ecount / +/ igraph_bipartite_game / /-------------------------------------------*/ -SEXP R_igraph_local_scan_1_ecount(SEXP graph, SEXP weights, SEXP mode) { +SEXP R_igraph_bipartite_game(SEXP type, SEXP n1, SEXP n2, SEXP p, SEXP m, SEXP directed, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vector_t c_weights; + igraph_vector_bool_t c_types; + igraph_erdos_renyi_t c_type; + igraph_integer_t c_n1; + igraph_integer_t c_n2; + igraph_real_t c_p; + igraph_integer_t c_m; + igraph_bool_t c_directed; igraph_neimode_t c_mode; - SEXP res; + SEXP graph; + SEXP types; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { + if (0 != igraph_vector_bool_init(&c_types, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); + c_type = (igraph_erdos_renyi_t) Rf_asInteger(type); + c_n1=INTEGER(n1)[0]; + c_n2=INTEGER(n2)[0]; + c_p=REAL(p)[0]; + c_m=INTEGER(m)[0]; + c_directed=LOGICAL(directed)[0]; c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_1_ecount(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_bipartite_game(&c_graph, &c_types, c_type, c_n1, c_n2, c_p, c_m, c_directed, c_mode)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(types=R_igraph_vector_bool_to_SEXP(&c_types)); + igraph_vector_bool_destroy(&c_types); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, types); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_local_scan_1_ecount_them / +/ igraph_get_laplacian / /-------------------------------------------*/ -SEXP R_igraph_local_scan_1_ecount_them(SEXP us, SEXP them, SEXP weights_them, SEXP mode) { +SEXP R_igraph_get_laplacian(SEXP graph, SEXP mode, SEXP normalization, SEXP weights) { /* Declarations */ - igraph_t c_us; - igraph_t c_them; - igraph_vector_t c_res; - igraph_vector_t c_weights_them; + igraph_t c_graph; + igraph_matrix_t c_res; igraph_neimode_t c_mode; + igraph_laplacian_normalization_t c_normalization; + igraph_vector_t c_weights; SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(us, &c_us); - R_SEXP_to_igraph(them, &c_them); - if (0 != igraph_vector_init(&c_res, 0)) { + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights_them)) { R_SEXP_to_vector(weights_them, &c_weights_them); } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_normalization = (igraph_laplacian_normalization_t) Rf_asInteger(normalization); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_1_ecount_them(&c_us, &c_them, &c_res, (Rf_isNull(weights_them) ? 0 : &c_weights_them), c_mode)); + IGRAPH_R_CHECK(igraph_get_laplacian(&c_graph, &c_res, c_mode, c_normalization, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); r_result = res; @@ -5403,104 +5476,114 @@ SEXP R_igraph_local_scan_1_ecount_them(SEXP us, SEXP them, SEXP weights_them, SE } /*-------------------------------------------/ -/ igraph_local_scan_k_ecount / +/ igraph_get_laplacian_sparse / /-------------------------------------------*/ -SEXP R_igraph_local_scan_k_ecount(SEXP graph, SEXP k, SEXP weights, SEXP mode) { +SEXP R_igraph_get_laplacian_sparse(SEXP graph, SEXP mode, SEXP normalization, SEXP weights) { /* Declarations */ igraph_t c_graph; - int c_k; - igraph_vector_t c_res; - igraph_vector_t c_weights; + igraph_sparsemat_t c_sparseres; igraph_neimode_t c_mode; - SEXP res; + igraph_laplacian_normalization_t c_normalization; + igraph_vector_t c_weights; + SEXP sparseres; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_k=INTEGER(k)[0]; - if (0 != igraph_vector_init(&c_res, 0)) { + if (0 != igraph_sparsemat_init(&c_sparseres, 0, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + IGRAPH_FINALLY(igraph_sparsemat_destroy, &c_sparseres); c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_normalization = (igraph_laplacian_normalization_t) Rf_asInteger(normalization); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_k_ecount(&c_graph, c_k, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + IGRAPH_R_CHECK(igraph_get_laplacian_sparse(&c_graph, &c_sparseres, c_mode, c_normalization, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(sparseres=R_igraph_sparsemat_to_SEXP(&c_sparseres)); + igraph_sparsemat_destroy(&c_sparseres); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = sparseres; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_local_scan_k_ecount_them / +/ igraph_connected_components / /-------------------------------------------*/ -SEXP R_igraph_local_scan_k_ecount_them(SEXP us, SEXP them, SEXP k, SEXP weights_them, SEXP mode) { +SEXP R_igraph_connected_components(SEXP graph, SEXP mode) { /* Declarations */ - igraph_t c_us; - igraph_t c_them; - int c_k; - igraph_vector_t c_res; - igraph_vector_t c_weights_them; - igraph_neimode_t c_mode; - SEXP res; + igraph_t c_graph; + igraph_vector_int_t c_membership; + igraph_vector_int_t c_csize; + igraph_integer_t c_no; + igraph_connectedness_t c_mode; + SEXP membership; + SEXP csize; + SEXP no; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(us, &c_us); - R_SEXP_to_igraph(them, &c_them); - c_k=INTEGER(k)[0]; - if (0 != igraph_vector_init(&c_res, 0)) { + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_membership, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights_them)) { R_SEXP_to_vector(weights_them, &c_weights_them); } - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); + if (0 != igraph_vector_int_init(&c_csize, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_csize); + c_no=0; + c_mode=REAL(mode)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_k_ecount_them(&c_us, &c_them, c_k, &c_res, (Rf_isNull(weights_them) ? 0 : &c_weights_them), c_mode)); + IGRAPH_R_CHECK(igraph_connected_components(&c_graph, &c_membership, &c_csize, &c_no, c_mode)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); + igraph_vector_int_destroy(&c_membership); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + PROTECT(csize=R_igraph_vector_int_to_SEXP(&c_csize)); + igraph_vector_int_destroy(&c_csize); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(no=NEW_INTEGER(1)); + INTEGER(no)[0]=c_no; + SET_VECTOR_ELT(r_result, 0, membership); + SET_VECTOR_ELT(r_result, 1, csize); + SET_VECTOR_ELT(r_result, 2, no); + SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("csize")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("no")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_local_scan_neighborhood_ecount / +/ igraph_is_connected / /-------------------------------------------*/ -SEXP R_igraph_local_scan_neighborhood_ecount(SEXP graph, SEXP weights, SEXP neighborhoods) { +SEXP R_igraph_is_connected(SEXP graph, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_res; - igraph_vector_t c_weights; - igraph_vector_ptr_t c_neighborhoods; + igraph_bool_t c_res; + igraph_connectedness_t c_mode; SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (!Rf_isNull(neighborhoods)) { R_igraph_SEXP_to_vectorlist_int(neighborhoods, &c_neighborhoods); } + c_mode=REAL(mode)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_local_scan_neighborhood_ecount(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), &c_neighborhoods)); + IGRAPH_R_CHECK(igraph_is_connected(&c_graph, &c_res, c_mode)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); - igraph_vector_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; r_result = res; UNPROTECT(1); @@ -5508,9 +5591,9 @@ SEXP R_igraph_local_scan_neighborhood_ecount(SEXP graph, SEXP weights, SEXP neig } /*-------------------------------------------/ -/ igraph_list_triangles / +/ igraph_articulation_points / /-------------------------------------------*/ -SEXP R_igraph_list_triangles(SEXP graph) { +SEXP R_igraph_articulation_points(SEXP graph) { /* Declarations */ igraph_t c_graph; igraph_vector_int_t c_res; @@ -5524,10 +5607,10 @@ SEXP R_igraph_list_triangles(SEXP graph) { } IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_list_triangles(&c_graph, &c_res)); + IGRAPH_R_CHECK(igraph_articulation_points(&c_graph, &c_res)); /* Convert output */ - PROTECT(res=R_igraph_vector_int_to_SEXPp1(&c_res)); + PROTECT(res=R_igraph_vector_int_to_SEXP(&c_res)); igraph_vector_int_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); r_result = res; @@ -5537,1072 +5620,4639 @@ SEXP R_igraph_list_triangles(SEXP graph) { } /*-------------------------------------------/ -/ igraph_maxflow / +/ igraph_biconnected_components / /-------------------------------------------*/ -SEXP R_igraph_maxflow(SEXP graph, SEXP source, SEXP target, SEXP capacity) { +SEXP R_igraph_biconnected_components(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_value; - igraph_vector_t c_flow; - igraph_vector_t c_cut; - igraph_vector_t c_partition1; - igraph_vector_t c_partition2; - igraph_integer_t c_source; - igraph_integer_t c_target; - igraph_vector_t c_capacity; - igraph_maxflow_stats_t c_stats; - SEXP value; - SEXP flow; - SEXP cut; - SEXP partition1; - SEXP partition2; - SEXP stats; + igraph_integer_t c_no; + igraph_vector_int_list_t c_tree_edges; + igraph_vector_int_list_t c_component_edges; + igraph_vector_int_list_t c_components; + igraph_vector_int_t c_articulation_points; + SEXP no; + SEXP tree_edges; + SEXP component_edges; + SEXP components; + SEXP articulation_points; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_flow, 0)) { + c_no=0; + if (0 != igraph_vector_int_list_init(&c_tree_edges, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_flow); - flow=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_cut, 0)) { + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_tree_edges); + if (0 != igraph_vector_int_list_init(&c_component_edges, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_cut); - cut=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_partition1, 0)) { + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_component_edges); + if (0 != igraph_vector_int_list_init(&c_components, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_partition1); - if (0 != igraph_vector_init(&c_partition2, 0)) { + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_components); + if (0 != igraph_vector_int_init(&c_articulation_points, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_partition2); - c_source = (igraph_integer_t) REAL(source)[0]; - c_target = (igraph_integer_t) REAL(target)[0]; - if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_articulation_points); /* Call igraph */ - IGRAPH_R_CHECK(igraph_maxflow(&c_graph, &c_value, (Rf_isNull(flow) ? 0 : &c_flow), (Rf_isNull(cut) ? 0 : &c_cut), &c_partition1, &c_partition2, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity), &c_stats)); + IGRAPH_R_CHECK(igraph_biconnected_components(&c_graph, &c_no, &c_tree_edges, &c_component_edges, &c_components, &c_articulation_points)); /* Convert output */ - PROTECT(r_result=NEW_LIST(6)); - PROTECT(r_names=NEW_CHARACTER(6)); - PROTECT(value=NEW_NUMERIC(1)); - REAL(value)[0]=c_value; - PROTECT(flow=R_igraph_0orvector_to_SEXP(&c_flow)); - igraph_vector_destroy(&c_flow); + PROTECT(r_result=NEW_LIST(5)); + PROTECT(r_names=NEW_CHARACTER(5)); + PROTECT(no=NEW_INTEGER(1)); + INTEGER(no)[0]=c_no; + PROTECT(tree_edges=R_igraph_vector_int_list_to_SEXP(&c_tree_edges)); + igraph_vector_int_list_destroy(&c_tree_edges); IGRAPH_FINALLY_CLEAN(1); - PROTECT(cut=R_igraph_0orvector_to_SEXPp1(&c_cut)); - igraph_vector_destroy(&c_cut); + PROTECT(component_edges=R_igraph_vector_int_list_to_SEXP(&c_component_edges)); + igraph_vector_int_list_destroy(&c_component_edges); IGRAPH_FINALLY_CLEAN(1); - PROTECT(partition1=R_igraph_vector_to_SEXPp1(&c_partition1)); - igraph_vector_destroy(&c_partition1); + PROTECT(components=R_igraph_vector_int_list_to_SEXP(&c_components)); + igraph_vector_int_list_destroy(&c_components); IGRAPH_FINALLY_CLEAN(1); - PROTECT(partition2=R_igraph_vector_to_SEXPp1(&c_partition2)); - igraph_vector_destroy(&c_partition2); + PROTECT(articulation_points=R_igraph_vector_int_to_SEXP(&c_articulation_points)); + igraph_vector_int_destroy(&c_articulation_points); IGRAPH_FINALLY_CLEAN(1); - PROTECT(stats=R_igraph_maxflow_stats_to_SEXP(&c_stats)); - SET_VECTOR_ELT(r_result, 0, value); - SET_VECTOR_ELT(r_result, 1, flow); - SET_VECTOR_ELT(r_result, 2, cut); - SET_VECTOR_ELT(r_result, 3, partition1); - SET_VECTOR_ELT(r_result, 4, partition2); - SET_VECTOR_ELT(r_result, 5, stats); - SET_STRING_ELT(r_names, 0, Rf_mkChar("value")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("flow")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("cut")); - SET_STRING_ELT(r_names, 3, Rf_mkChar("partition1")); - SET_STRING_ELT(r_names, 4, Rf_mkChar("partition2")); - SET_STRING_ELT(r_names, 5, Rf_mkChar("stats")); + SET_VECTOR_ELT(r_result, 0, no); + SET_VECTOR_ELT(r_result, 1, tree_edges); + SET_VECTOR_ELT(r_result, 2, component_edges); + SET_VECTOR_ELT(r_result, 3, components); + SET_VECTOR_ELT(r_result, 4, articulation_points); + SET_STRING_ELT(r_names, 0, Rf_mkChar("no")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("tree_edges")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("component_edges")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("components")); + SET_STRING_ELT(r_names, 4, Rf_mkChar("articulation_points")); SET_NAMES(r_result, r_names); - UNPROTECT(7); + UNPROTECT(6); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_st_mincut / +/ igraph_bridges / /-------------------------------------------*/ -SEXP R_igraph_st_mincut(SEXP graph, SEXP source, SEXP target, SEXP capacity) { +SEXP R_igraph_bridges(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_value; - igraph_vector_t c_cut; - igraph_vector_t c_partition1; - igraph_vector_t c_partition2; - igraph_integer_t c_source; - igraph_integer_t c_target; - igraph_vector_t c_capacity; - SEXP value; - SEXP cut; - SEXP partition1; - SEXP partition2; + igraph_vector_int_t c_res; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_cut, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_cut); - cut=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_partition1, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_partition1); - if (0 != igraph_vector_init(&c_partition2, 0)) { + if (0 != igraph_vector_int_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_partition2); - c_source = (igraph_integer_t) REAL(source)[0]; - c_target = (igraph_integer_t) REAL(target)[0]; - if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_st_mincut(&c_graph, &c_value, (Rf_isNull(cut) ? 0 : &c_cut), &c_partition1, &c_partition2, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity))); + IGRAPH_R_CHECK(igraph_bridges(&c_graph, &c_res)); /* Convert output */ - PROTECT(r_result=NEW_LIST(4)); - PROTECT(r_names=NEW_CHARACTER(4)); - PROTECT(value=NEW_NUMERIC(1)); - REAL(value)[0]=c_value; - PROTECT(cut=R_igraph_0orvector_to_SEXPp1(&c_cut)); - igraph_vector_destroy(&c_cut); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(partition1=R_igraph_vector_to_SEXPp1(&c_partition1)); - igraph_vector_destroy(&c_partition1); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(partition2=R_igraph_vector_to_SEXPp1(&c_partition2)); - igraph_vector_destroy(&c_partition2); + PROTECT(res=R_igraph_vector_int_to_SEXP(&c_res)); + igraph_vector_int_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, value); - SET_VECTOR_ELT(r_result, 1, cut); - SET_VECTOR_ELT(r_result, 2, partition1); - SET_VECTOR_ELT(r_result, 3, partition2); - SET_STRING_ELT(r_names, 0, Rf_mkChar("value")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("cut")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("partition1")); - SET_STRING_ELT(r_names, 3, Rf_mkChar("partition2")); - SET_NAMES(r_result, r_names); - UNPROTECT(5); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_dominator_tree / +/ igraph_cliques / /-------------------------------------------*/ -SEXP R_igraph_dominator_tree(SEXP graph, SEXP root, SEXP mode) { +SEXP R_igraph_cliques(SEXP graph, SEXP min_size, SEXP max_size) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_root; - igraph_vector_t c_dom; - igraph_t c_domtree; - igraph_vector_t c_leftout; - igraph_neimode_t c_mode; - SEXP dom; - SEXP domtree; - SEXP leftout; + igraph_vector_int_list_t c_res; + igraph_integer_t c_min_size; + igraph_integer_t c_max_size; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_root = (igraph_integer_t) REAL(root)[0]; - if (0 != igraph_vector_init(&c_dom, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_dom); - domtree=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_leftout, 0)) { + if (0 != igraph_vector_int_list_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_leftout); - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); + c_min_size=INTEGER(min_size)[0]; + c_max_size=INTEGER(max_size)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_dominator_tree(&c_graph, c_root, &c_dom, (Rf_isNull(domtree) ? 0 : &c_domtree), &c_leftout, c_mode)); + IGRAPH_R_CHECK(igraph_cliques(&c_graph, &c_res, c_min_size, c_max_size)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(dom=R_igraph_vector_to_SEXPp1(&c_dom)); - igraph_vector_destroy(&c_dom); - IGRAPH_FINALLY_CLEAN(1); - IGRAPH_FINALLY(igraph_destroy, &c_domtree); - PROTECT(domtree=R_igraph_to_SEXP(&c_domtree)); - igraph_destroy(&c_domtree); + PROTECT(res=R_igraph_vector_int_list_to_SEXP(&c_res)); + igraph_vector_int_list_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - PROTECT(leftout=R_igraph_vector_to_SEXPp1(&c_leftout)); - igraph_vector_destroy(&c_leftout); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, dom); - SET_VECTOR_ELT(r_result, 1, domtree); - SET_VECTOR_ELT(r_result, 2, leftout); - SET_STRING_ELT(r_names, 0, Rf_mkChar("dom")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("domtree")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("leftout")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_all_st_cuts / +/ igraph_clique_size_hist / /-------------------------------------------*/ -SEXP R_igraph_all_st_cuts(SEXP graph, SEXP source, SEXP target) { +SEXP R_igraph_clique_size_hist(SEXP graph, SEXP min_size, SEXP max_size) { /* Declarations */ igraph_t c_graph; - igraph_vector_ptr_t c_cuts; - igraph_vector_ptr_t c_partition1s; - igraph_integer_t c_source; - igraph_integer_t c_target; - SEXP cuts; - SEXP partition1s; + igraph_vector_t c_hist; + igraph_integer_t c_min_size; + igraph_integer_t c_max_size; + SEXP hist; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_cuts, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_cuts); - if (0 != igraph_vector_ptr_init(&c_partition1s, 0)) { + if (0 != igraph_vector_init(&c_hist, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_partition1s); - c_source = (igraph_integer_t) REAL(source)[0]; - c_target = (igraph_integer_t) REAL(target)[0]; + IGRAPH_FINALLY(igraph_vector_destroy, &c_hist); + c_min_size=INTEGER(min_size)[0]; + c_max_size=INTEGER(max_size)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_all_st_cuts(&c_graph, &c_cuts, &c_partition1s, c_source, c_target)); + IGRAPH_R_CHECK(igraph_clique_size_hist(&c_graph, &c_hist, c_min_size, c_max_size)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(cuts=R_igraph_vectorlist_to_SEXP_p1(&c_cuts)); - R_igraph_vectorlist_destroy(&c_cuts); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(partition1s=R_igraph_vectorlist_to_SEXP_p1(&c_partition1s)); - R_igraph_vectorlist_destroy(&c_partition1s); + PROTECT(hist=R_igraph_vector_to_SEXP(&c_hist)); + igraph_vector_destroy(&c_hist); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, cuts); - SET_VECTOR_ELT(r_result, 1, partition1s); - SET_STRING_ELT(r_names, 0, Rf_mkChar("cuts")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("partition1s")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = hist; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_all_st_mincuts / +/ igraph_largest_cliques / /-------------------------------------------*/ -SEXP R_igraph_all_st_mincuts(SEXP graph, SEXP source, SEXP target, SEXP capacity) { +SEXP R_igraph_largest_cliques(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_value; - igraph_vector_ptr_t c_cuts; - igraph_vector_ptr_t c_partition1s; - igraph_integer_t c_source; - igraph_integer_t c_target; - igraph_vector_t c_capacity; - SEXP value; - SEXP cuts; - SEXP partition1s; + igraph_vector_int_list_t c_res; + SEXP res; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_cuts, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_cuts); - if (0 != igraph_vector_ptr_init(&c_partition1s, 0)) { + if (0 != igraph_vector_int_list_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_partition1s); - c_source = (igraph_integer_t) REAL(source)[0]; - c_target = (igraph_integer_t) REAL(target)[0]; - if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_all_st_mincuts(&c_graph, &c_value, &c_cuts, &c_partition1s, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity))); + IGRAPH_R_CHECK(igraph_largest_cliques(&c_graph, &c_res)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(value=NEW_NUMERIC(1)); - REAL(value)[0]=c_value; - PROTECT(cuts=R_igraph_vectorlist_to_SEXP_p1(&c_cuts)); - R_igraph_vectorlist_destroy(&c_cuts); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(partition1s=R_igraph_vectorlist_to_SEXP_p1(&c_partition1s)); - R_igraph_vectorlist_destroy(&c_partition1s); + PROTECT(res=R_igraph_vector_int_list_to_SEXP(&c_res)); + igraph_vector_int_list_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, value); - SET_VECTOR_ELT(r_result, 1, cuts); - SET_VECTOR_ELT(r_result, 2, partition1s); - SET_STRING_ELT(r_names, 0, Rf_mkChar("value")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("cuts")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("partition1s")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_separator / +/ igraph_maximal_cliques_subset / /-------------------------------------------*/ -SEXP R_igraph_is_separator(SEXP graph, SEXP candidate) { +SEXP R_igraph_maximal_cliques_subset(SEXP graph, SEXP subset, SEXP outfile, SEXP min_size, SEXP max_size) { /* Declarations */ igraph_t c_graph; - igraph_vs_t c_candidate; - igraph_bool_t c_res; + igraph_vector_int_t c_subset; + igraph_vector_int_list_t c_res; + igraph_integer_t c_no; + FILE* c_outfile; + igraph_integer_t c_min_size; + igraph_integer_t c_max_size; SEXP res; + SEXP no; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_igraph_vs(candidate, &c_graph, &c_candidate); + R_SEXP_to_vector_int(subset, &c_subset); + if (0 != igraph_vector_int_list_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); + c_no=0; + c_min_size=INTEGER(min_size)[0]; + c_max_size=INTEGER(max_size)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_separator(&c_graph, c_candidate, &c_res)); + IGRAPH_R_CHECK(igraph_maximal_cliques_subset(&c_graph, &c_subset, &c_res, &c_no, c_outfile, c_min_size, c_max_size)); /* Convert output */ - igraph_vs_destroy(&c_candidate); - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; - r_result = res; + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(res=R_igraph_vector_int_list_to_SEXP(&c_res)); + igraph_vector_int_list_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(no=NEW_INTEGER(1)); + INTEGER(no)[0]=c_no; + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, no); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("no")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_minimal_separator / +/ igraph_maximal_cliques_hist / /-------------------------------------------*/ -SEXP R_igraph_is_minimal_separator(SEXP graph, SEXP candidate) { +SEXP R_igraph_maximal_cliques_hist(SEXP graph, SEXP min_size, SEXP max_size) { /* Declarations */ igraph_t c_graph; - igraph_vs_t c_candidate; - igraph_bool_t c_res; - SEXP res; + igraph_vector_t c_hist; + igraph_integer_t c_min_size; + igraph_integer_t c_max_size; + SEXP hist; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_igraph_vs(candidate, &c_graph, &c_candidate); + if (0 != igraph_vector_init(&c_hist, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_hist); + c_min_size=INTEGER(min_size)[0]; + c_max_size=INTEGER(max_size)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_minimal_separator(&c_graph, c_candidate, &c_res)); + IGRAPH_R_CHECK(igraph_maximal_cliques_hist(&c_graph, &c_hist, c_min_size, c_max_size)); /* Convert output */ - igraph_vs_destroy(&c_candidate); - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; - r_result = res; + PROTECT(hist=R_igraph_vector_to_SEXP(&c_hist)); + igraph_vector_destroy(&c_hist); + IGRAPH_FINALLY_CLEAN(1); + r_result = hist; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_all_minimal_st_separators / +/ igraph_clique_number / /-------------------------------------------*/ -SEXP R_igraph_all_minimal_st_separators(SEXP graph) { +SEXP R_igraph_clique_number(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_ptr_t c_separators; - SEXP separators; + igraph_integer_t c_no; + SEXP no; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_separators, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_separators); + c_no=0; /* Call igraph */ - IGRAPH_R_CHECK(igraph_all_minimal_st_separators(&c_graph, &c_separators)); + IGRAPH_R_CHECK(igraph_clique_number(&c_graph, &c_no)); /* Convert output */ - PROTECT(separators=R_igraph_vectorlist_to_SEXP_p1(&c_separators)); - R_igraph_vectorlist_destroy(&c_separators); - IGRAPH_FINALLY_CLEAN(1); - r_result = separators; + PROTECT(no=NEW_INTEGER(1)); + INTEGER(no)[0]=c_no; + r_result = no; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_minimum_size_separators / +/ igraph_weighted_cliques / /-------------------------------------------*/ -SEXP R_igraph_minimum_size_separators(SEXP graph) { +SEXP R_igraph_weighted_cliques(SEXP graph, SEXP vertex_weights, SEXP min_weight, SEXP max_weight, SEXP maximal) { /* Declarations */ igraph_t c_graph; - igraph_vector_ptr_t c_separators; - SEXP separators; + igraph_vector_t c_vertex_weights; + igraph_vector_int_list_t c_res; + igraph_real_t c_min_weight; + igraph_real_t c_max_weight; + igraph_bool_t c_maximal; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_separators, 0)) { + if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } + if (0 != igraph_vector_int_list_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_separators); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); + c_min_weight=REAL(min_weight)[0]; + c_max_weight=REAL(max_weight)[0]; + c_maximal=LOGICAL(maximal)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_minimum_size_separators(&c_graph, &c_separators)); + IGRAPH_R_CHECK(igraph_weighted_cliques(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res, c_min_weight, c_max_weight, c_maximal)); /* Convert output */ - PROTECT(separators=R_igraph_vectorlist_to_SEXP_p1(&c_separators)); - R_igraph_vectorlist_destroy(&c_separators); + PROTECT(res=R_igraph_vector_int_list_to_SEXP(&c_res)); + igraph_vector_int_list_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = separators; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_isoclass / +/ igraph_largest_weighted_cliques / /-------------------------------------------*/ -SEXP R_igraph_isoclass(SEXP graph) { +SEXP R_igraph_largest_weighted_cliques(SEXP graph, SEXP vertex_weights) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_isoclass; - SEXP isoclass; + igraph_vector_t c_vertex_weights; + igraph_vector_int_list_t c_res; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_isoclass=0; + if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } + if (0 != igraph_vector_int_list_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_isoclass(&c_graph, &c_isoclass)); + IGRAPH_R_CHECK(igraph_largest_weighted_cliques(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res)); /* Convert output */ - PROTECT(isoclass=NEW_INTEGER(1)); - INTEGER(isoclass)[0]=c_isoclass; - r_result = isoclass; + PROTECT(res=R_igraph_vector_int_list_to_SEXP(&c_res)); + igraph_vector_int_list_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_isomorphic / +/ igraph_weighted_clique_number / /-------------------------------------------*/ -SEXP R_igraph_isomorphic(SEXP graph1, SEXP graph2) { +SEXP R_igraph_weighted_clique_number(SEXP graph, SEXP vertex_weights) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_bool_t c_iso; - SEXP iso; + igraph_t c_graph; + igraph_vector_t c_vertex_weights; + igraph_real_t c_res; + SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_isomorphic(&c_graph1, &c_graph2, &c_iso)); + IGRAPH_R_CHECK(igraph_weighted_clique_number(&c_graph, (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), &c_res)); /* Convert output */ - PROTECT(iso=NEW_LOGICAL(1)); - LOGICAL(iso)[0]=c_iso; - r_result = iso; + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_isoclass_subgraph / +/ igraph_layout_star / /-------------------------------------------*/ -SEXP R_igraph_isoclass_subgraph(SEXP graph, SEXP vids) { +SEXP R_igraph_layout_star(SEXP graph, SEXP center, SEXP order) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_vids; - igraph_integer_t c_isoclass; - SEXP isoclass; + igraph_matrix_t c_res; + igraph_integer_t c_center; + igraph_vector_int_t c_order; + SEXP res; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_vector(vids, &c_vids); - c_isoclass=0; + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_center = (igraph_integer_t) REAL(center)[0]; + R_SEXP_to_vector_int(order, &c_order); /* Call igraph */ - IGRAPH_R_CHECK(igraph_isoclass_subgraph(&c_graph, &c_vids, &c_isoclass)); + IGRAPH_R_CHECK(igraph_layout_star(&c_graph, &c_res, c_center, &c_order)); /* Convert output */ - PROTECT(isoclass=NEW_INTEGER(1)); - INTEGER(isoclass)[0]=c_isoclass; - r_result = isoclass; + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_isoclass_create / +/ igraph_layout_grid / /-------------------------------------------*/ -SEXP R_igraph_isoclass_create(SEXP size, SEXP number, SEXP directed) { +SEXP R_igraph_layout_grid(SEXP graph, SEXP width) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_size; - igraph_integer_t c_number; - igraph_bool_t c_directed; - SEXP graph; + igraph_matrix_t c_res; + igraph_integer_t c_width; + SEXP res; SEXP r_result; /* Convert input */ - c_size=INTEGER(size)[0]; - c_number=INTEGER(number)[0]; - c_directed=LOGICAL(directed)[0]; + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_width=INTEGER(width)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_isoclass_create(&c_graph, c_size, c_number, c_directed)); + IGRAPH_R_CHECK(igraph_layout_grid(&c_graph, &c_res, c_width)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_isomorphic_vf2 / +/ igraph_layout_grid_3d / /-------------------------------------------*/ -SEXP R_igraph_isomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { +SEXP R_igraph_layout_grid_3d(SEXP graph, SEXP width, SEXP height) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_vector_int_t c_vertex_color1; - igraph_vector_int_t c_vertex_color2; - igraph_vector_int_t c_edge_color1; - igraph_vector_int_t c_edge_color2; - igraph_bool_t c_iso; - igraph_vector_t c_map12; - igraph_vector_t c_map21; + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_integer_t c_width; + igraph_integer_t c_height; + SEXP res; + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_width=INTEGER(width)[0]; + c_height=INTEGER(height)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_grid_3d(&c_graph, &c_res, c_width, c_height)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_roots_for_tree_layout / +/-------------------------------------------*/ +SEXP R_igraph_roots_for_tree_layout(SEXP graph, SEXP mode, SEXP heuristic) { + /* Declarations */ + igraph_t c_graph; + igraph_neimode_t c_mode; + igraph_vector_int_t c_roots; + igraph_root_choice_t c_heuristic; + SEXP roots; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + if (0 != igraph_vector_int_init(&c_roots, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_roots); + c_heuristic = (igraph_root_choice_t) Rf_asInteger(heuristic); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_roots_for_tree_layout(&c_graph, c_mode, &c_roots, c_heuristic)); + + /* Convert output */ + PROTECT(roots=R_igraph_vector_int_to_SEXP(&c_roots)); + igraph_vector_int_destroy(&c_roots); + IGRAPH_FINALLY_CLEAN(1); + r_result = roots; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_drl / +/-------------------------------------------*/ +SEXP R_igraph_layout_drl(SEXP graph, SEXP res, SEXP use_seed, SEXP options, SEXP weights) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_bool_t c_use_seed; + igraph_layout_drl_options_t c_options; + igraph_vector_t c_weights; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_use_seed=LOGICAL(use_seed)[0]; + R_SEXP_to_igraph_layout_drl_options(options, &c_options); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_drl(&c_graph, &c_res, c_use_seed, &c_options, (Rf_isNull(weights) ? 0 : &c_weights))); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_drl_3d / +/-------------------------------------------*/ +SEXP R_igraph_layout_drl_3d(SEXP graph, SEXP res, SEXP use_seed, SEXP options, SEXP weights) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_bool_t c_use_seed; + igraph_layout_drl_options_t c_options; + igraph_vector_t c_weights; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_use_seed=LOGICAL(use_seed)[0]; + R_SEXP_to_igraph_layout_drl_options(options, &c_options); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_drl_3d(&c_graph, &c_res, c_use_seed, &c_options, (Rf_isNull(weights) ? 0 : &c_weights))); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_sugiyama / +/-------------------------------------------*/ +SEXP R_igraph_layout_sugiyama(SEXP graph, SEXP layers, SEXP hgap, SEXP vgap, SEXP maxiter, SEXP weights) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_t c_extd_graph; + igraph_vector_int_t c_extd_to_orig_eids; + igraph_vector_int_t c_layers; + igraph_real_t c_hgap; + igraph_real_t c_vgap; + igraph_integer_t c_maxiter; + igraph_vector_t c_weights; + SEXP res; + SEXP extd_graph; + SEXP extd_to_orig_eids; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + if (0 != igraph_vector_int_init(&c_extd_to_orig_eids, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_extd_to_orig_eids); + R_SEXP_to_vector_int(layers, &c_layers); + c_hgap=REAL(hgap)[0]; + c_vgap=REAL(vgap)[0]; + c_maxiter=INTEGER(maxiter)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_sugiyama(&c_graph, &c_res, &c_extd_graph, &c_extd_to_orig_eids, &c_layers, c_hgap, c_vgap, c_maxiter, (Rf_isNull(weights) ? 0 : &c_weights))); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + IGRAPH_FINALLY(igraph_destroy, &c_extd_graph); + PROTECT(extd_graph=R_igraph_to_SEXP(&c_extd_graph)); + igraph_destroy(&c_extd_graph); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(extd_to_orig_eids=R_igraph_vector_int_to_SEXP(&c_extd_to_orig_eids)); + igraph_vector_int_destroy(&c_extd_to_orig_eids); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, extd_graph); + SET_VECTOR_ELT(r_result, 2, extd_to_orig_eids); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("extd_graph")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("extd_to_orig_eids")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_mds / +/-------------------------------------------*/ +SEXP R_igraph_layout_mds(SEXP graph, SEXP dist, SEXP dim) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_matrix_t c_dist; + igraph_integer_t c_dim; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + R_SEXP_to_matrix(dist, &c_dist); + c_dim=INTEGER(dim)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_mds(&c_graph, &c_res, &c_dist, c_dim)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_bipartite / +/-------------------------------------------*/ +SEXP R_igraph_layout_bipartite(SEXP graph, SEXP types, SEXP hgap, SEXP vgap, SEXP maxiter) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_bool_t c_types; + igraph_matrix_t c_res; + igraph_real_t c_hgap; + igraph_real_t c_vgap; + igraph_integer_t c_maxiter; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_hgap=REAL(hgap)[0]; + c_vgap=REAL(vgap)[0]; + c_maxiter=INTEGER(maxiter)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_bipartite(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_res, c_hgap, c_vgap, c_maxiter)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_gem / +/-------------------------------------------*/ +SEXP R_igraph_layout_gem(SEXP graph, SEXP res, SEXP use_seed, SEXP maxiter, SEXP temp_max, SEXP temp_min, SEXP temp_init) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_bool_t c_use_seed; + igraph_integer_t c_maxiter; + igraph_real_t c_temp_max; + igraph_real_t c_temp_min; + igraph_real_t c_temp_init; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_use_seed=LOGICAL(use_seed)[0]; + c_maxiter=INTEGER(maxiter)[0]; + c_temp_max=REAL(temp_max)[0]; + c_temp_min=REAL(temp_min)[0]; + c_temp_init=REAL(temp_init)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_gem(&c_graph, &c_res, c_use_seed, c_maxiter, c_temp_max, c_temp_min, c_temp_init)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_davidson_harel / +/-------------------------------------------*/ +SEXP R_igraph_layout_davidson_harel(SEXP graph, SEXP res, SEXP use_seed, SEXP maxiter, SEXP fineiter, SEXP cool_fact, SEXP weight_node_dist, SEXP weight_border, SEXP weight_edge_lengths, SEXP weight_edge_crossings, SEXP weight_node_edge_dist) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_bool_t c_use_seed; + igraph_integer_t c_maxiter; + igraph_integer_t c_fineiter; + igraph_real_t c_cool_fact; + igraph_real_t c_weight_node_dist; + igraph_real_t c_weight_border; + igraph_real_t c_weight_edge_lengths; + igraph_real_t c_weight_edge_crossings; + igraph_real_t c_weight_node_edge_dist; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_use_seed=LOGICAL(use_seed)[0]; + c_maxiter=INTEGER(maxiter)[0]; + c_fineiter=INTEGER(fineiter)[0]; + c_cool_fact=REAL(cool_fact)[0]; + c_weight_node_dist=REAL(weight_node_dist)[0]; + c_weight_border=REAL(weight_border)[0]; + c_weight_edge_lengths=REAL(weight_edge_lengths)[0]; + c_weight_edge_crossings=REAL(weight_edge_crossings)[0]; + c_weight_node_edge_dist=REAL(weight_node_edge_dist)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_davidson_harel(&c_graph, &c_res, c_use_seed, c_maxiter, c_fineiter, c_cool_fact, c_weight_node_dist, c_weight_border, c_weight_edge_lengths, c_weight_edge_crossings, c_weight_node_edge_dist)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_umap / +/-------------------------------------------*/ +SEXP R_igraph_layout_umap(SEXP graph, SEXP res, SEXP use_seed, SEXP distances, SEXP min_dist, SEXP epochs, SEXP distances_are_weights) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_bool_t c_use_seed; + igraph_vector_t c_distances; + igraph_real_t c_min_dist; + igraph_integer_t c_epochs; + igraph_bool_t c_distances_are_weights; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_use_seed=LOGICAL(use_seed)[0]; + R_SEXP_to_vector(distances, &c_distances); + c_min_dist=REAL(min_dist)[0]; + c_epochs=INTEGER(epochs)[0]; + c_distances_are_weights=LOGICAL(distances_are_weights)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_umap(&c_graph, &c_res, c_use_seed, &c_distances, c_min_dist, c_epochs, c_distances_are_weights)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_umap_3d / +/-------------------------------------------*/ +SEXP R_igraph_layout_umap_3d(SEXP graph, SEXP res, SEXP use_seed, SEXP distances, SEXP min_dist, SEXP epochs, SEXP distances_are_weights) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_bool_t c_use_seed; + igraph_vector_t c_distances; + igraph_real_t c_min_dist; + igraph_integer_t c_epochs; + igraph_bool_t c_distances_are_weights; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != R_SEXP_to_igraph_matrix_copy(res, &c_res)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_use_seed=LOGICAL(use_seed)[0]; + R_SEXP_to_vector(distances, &c_distances); + c_min_dist=REAL(min_dist)[0]; + c_epochs=INTEGER(epochs)[0]; + c_distances_are_weights=LOGICAL(distances_are_weights)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_umap_3d(&c_graph, &c_res, c_use_seed, &c_distances, c_min_dist, c_epochs, c_distances_are_weights)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_layout_umap_compute_weights / +/-------------------------------------------*/ +SEXP R_igraph_layout_umap_compute_weights(SEXP graph, SEXP distances, SEXP weights) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_distances; + igraph_vector_t c_weights; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + R_SEXP_to_vector(distances, &c_distances); + if (0 != R_SEXP_to_vector_copy(weights, &c_weights)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_weights); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_layout_umap_compute_weights(&c_graph, &c_distances, &c_weights)); + + /* Convert output */ + PROTECT(weights=R_igraph_vector_to_SEXP(&c_weights)); + igraph_vector_destroy(&c_weights); + IGRAPH_FINALLY_CLEAN(1); + r_result = weights; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_similarity_dice / +/-------------------------------------------*/ +SEXP R_igraph_similarity_dice(SEXP graph, SEXP vids, SEXP mode, SEXP loops) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_vs_t c_vids; + igraph_neimode_t c_mode; + igraph_bool_t c_loops; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_loops=LOGICAL(loops)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_similarity_dice(&c_graph, &c_res, c_vids, c_mode, c_loops)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_similarity_dice_es / +/-------------------------------------------*/ +SEXP R_igraph_similarity_dice_es(SEXP graph, SEXP es, SEXP mode, SEXP loops) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + igraph_es_t c_es; + igraph_neimode_t c_mode; + igraph_bool_t c_loops; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_loops=LOGICAL(loops)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_similarity_dice_es(&c_graph, &c_res, c_es, c_mode, c_loops)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_similarity_dice_pairs / +/-------------------------------------------*/ +SEXP R_igraph_similarity_dice_pairs(SEXP graph, SEXP pairs, SEXP mode, SEXP loops) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + igraph_vector_int_t c_pairs; + igraph_neimode_t c_mode; + igraph_bool_t c_loops; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + R_SEXP_to_vector_int(pairs, &c_pairs); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_loops=LOGICAL(loops)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_similarity_dice_pairs(&c_graph, &c_res, &c_pairs, c_mode, c_loops)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_similarity_inverse_log_weighted / +/-------------------------------------------*/ +SEXP R_igraph_similarity_inverse_log_weighted(SEXP graph, SEXP vids, SEXP mode) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_vs_t c_vids; + igraph_neimode_t c_mode; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_similarity_inverse_log_weighted(&c_graph, &c_res, c_vids, c_mode)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_similarity_jaccard / +/-------------------------------------------*/ +SEXP R_igraph_similarity_jaccard(SEXP graph, SEXP vids, SEXP mode, SEXP loops) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_vs_t c_vids; + igraph_neimode_t c_mode; + igraph_bool_t c_loops; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_loops=LOGICAL(loops)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_similarity_jaccard(&c_graph, &c_res, c_vids, c_mode, c_loops)); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_similarity_jaccard_es / +/-------------------------------------------*/ +SEXP R_igraph_similarity_jaccard_es(SEXP graph, SEXP es, SEXP mode, SEXP loops) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + igraph_es_t c_es; + igraph_neimode_t c_mode; + igraph_bool_t c_loops; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_loops=LOGICAL(loops)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_similarity_jaccard_es(&c_graph, &c_res, c_es, c_mode, c_loops)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_similarity_jaccard_pairs / +/-------------------------------------------*/ +SEXP R_igraph_similarity_jaccard_pairs(SEXP graph, SEXP pairs, SEXP mode, SEXP loops) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + igraph_vector_int_t c_pairs; + igraph_neimode_t c_mode; + igraph_bool_t c_loops; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + R_SEXP_to_vector_int(pairs, &c_pairs); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_loops=LOGICAL(loops)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_similarity_jaccard_pairs(&c_graph, &c_res, &c_pairs, c_mode, c_loops)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_compare_communities / +/-------------------------------------------*/ +SEXP R_igraph_compare_communities(SEXP comm1, SEXP comm2, SEXP method) { + /* Declarations */ + igraph_vector_int_t c_comm1; + igraph_vector_int_t c_comm2; + igraph_real_t c_res; + igraph_community_comparison_t c_method; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_vector_int(comm1, &c_comm1); + R_SEXP_to_vector_int(comm2, &c_comm2); + c_method = (igraph_community_comparison_t) Rf_asInteger(method); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_compare_communities(&c_comm1, &c_comm2, &c_res, c_method)); + + /* Convert output */ + PROTECT(res=NEW_NUMERIC(1)); + REAL(res)[0]=c_res; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_modularity / +/-------------------------------------------*/ +SEXP R_igraph_modularity(SEXP graph, SEXP membership, SEXP weights, SEXP resolution, SEXP directed) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_membership; + igraph_vector_t c_weights; + igraph_real_t c_resolution; + igraph_bool_t c_directed; + igraph_real_t c_modularity; + SEXP modularity; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + R_SEXP_to_vector_int(membership, &c_membership); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_resolution=REAL(resolution)[0]; + c_directed=LOGICAL(directed)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_modularity(&c_graph, &c_membership, (Rf_isNull(weights) ? 0 : &c_weights), c_resolution, c_directed, &c_modularity)); + + /* Convert output */ + PROTECT(modularity=NEW_NUMERIC(1)); + REAL(modularity)[0]=c_modularity; + r_result = modularity; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_modularity_matrix / +/-------------------------------------------*/ +SEXP R_igraph_modularity_matrix(SEXP graph, SEXP weights, SEXP resolution, SEXP directed) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_weights; + igraph_real_t c_resolution; + igraph_matrix_t c_modmat; + igraph_bool_t c_directed; + SEXP modmat; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_resolution=REAL(resolution)[0]; + if (0 != igraph_matrix_init(&c_modmat, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_modmat); + c_directed=LOGICAL(directed)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_modularity_matrix(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), c_resolution, &c_modmat, c_directed)); + + /* Convert output */ + PROTECT(modmat=R_igraph_matrix_to_SEXP(&c_modmat)); + igraph_matrix_destroy(&c_modmat); + IGRAPH_FINALLY_CLEAN(1); + r_result = modmat; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_community_fluid_communities / +/-------------------------------------------*/ +SEXP R_igraph_community_fluid_communities(SEXP graph, SEXP no_of_communities) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_no_of_communities; + igraph_vector_int_t c_membership; + SEXP membership; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_no_of_communities=INTEGER(no_of_communities)[0]; + if (0 != igraph_vector_int_init(&c_membership, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_community_fluid_communities(&c_graph, c_no_of_communities, &c_membership)); + + /* Convert output */ + PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); + igraph_vector_int_destroy(&c_membership); + IGRAPH_FINALLY_CLEAN(1); + r_result = membership; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_community_label_propagation / +/-------------------------------------------*/ +SEXP R_igraph_community_label_propagation(SEXP graph, SEXP mode, SEXP weights, SEXP initial, SEXP fixed) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_membership; + igraph_neimode_t c_mode; + igraph_vector_t c_weights; + igraph_vector_int_t c_initial; + igraph_vector_bool_t c_fixed; + SEXP membership; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_membership, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + R_SEXP_to_vector_int(initial, &c_initial); + R_SEXP_to_vector_bool(fixed, &c_fixed); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_community_label_propagation(&c_graph, &c_membership, c_mode, (Rf_isNull(weights) ? 0 : &c_weights), &c_initial, &c_fixed)); + + /* Convert output */ + PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); + igraph_vector_int_destroy(&c_membership); + IGRAPH_FINALLY_CLEAN(1); + r_result = membership; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_community_multilevel / +/-------------------------------------------*/ +SEXP R_igraph_community_multilevel(SEXP graph, SEXP weights, SEXP resolution) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_weights; + igraph_real_t c_resolution; + igraph_vector_int_t c_membership; + igraph_matrix_int_t c_memberships; + igraph_vector_t c_modularity; + SEXP membership; + SEXP memberships; + SEXP modularity; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_resolution=REAL(resolution)[0]; + if (0 != igraph_vector_int_init(&c_membership, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); + if (0 != igraph_matrix_int_init(&c_memberships, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_int_destroy, &c_memberships); + if (0 != igraph_vector_init(&c_modularity, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_modularity); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_community_multilevel(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), c_resolution, &c_membership, &c_memberships, &c_modularity)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); + igraph_vector_int_destroy(&c_membership); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(memberships=R_igraph_matrix_int_to_SEXP(&c_memberships)); + igraph_matrix_int_destroy(&c_memberships); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(modularity=R_igraph_vector_to_SEXP(&c_modularity)); + igraph_vector_destroy(&c_modularity); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, membership); + SET_VECTOR_ELT(r_result, 1, memberships); + SET_VECTOR_ELT(r_result, 2, modularity); + SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("memberships")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("modularity")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_community_optimal_modularity / +/-------------------------------------------*/ +SEXP R_igraph_community_optimal_modularity(SEXP graph, SEXP weights) { + /* Declarations */ + igraph_t c_graph; + igraph_real_t c_modularity; + igraph_vector_int_t c_membership; + igraph_vector_t c_weights; + SEXP modularity; + SEXP membership; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_membership, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_community_optimal_modularity(&c_graph, &c_modularity, &c_membership, (Rf_isNull(weights) ? 0 : &c_weights))); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(modularity=NEW_NUMERIC(1)); + REAL(modularity)[0]=c_modularity; + PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); + igraph_vector_int_destroy(&c_membership); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, modularity); + SET_VECTOR_ELT(r_result, 1, membership); + SET_STRING_ELT(r_names, 0, Rf_mkChar("modularity")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("membership")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_community_leiden / +/-------------------------------------------*/ +SEXP R_igraph_community_leiden(SEXP graph, SEXP weights, SEXP vertex_weights, SEXP resolution, SEXP beta, SEXP start, SEXP n_iterations, SEXP membership) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_weights; + igraph_vector_t c_vertex_weights; + igraph_real_t c_resolution; + igraph_real_t c_beta; + igraph_bool_t c_start; + igraph_integer_t c_n_iterations; + igraph_vector_int_t c_membership; + igraph_integer_t c_nb_clusters; + igraph_real_t c_quality; + SEXP nb_clusters; + SEXP quality; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(vertex_weights)) { R_SEXP_to_vector(vertex_weights, &c_vertex_weights); } + c_resolution=REAL(resolution)[0]; + c_beta=REAL(beta)[0]; + c_start=LOGICAL(start)[0]; + c_n_iterations=INTEGER(n_iterations)[0]; + R_SEXP_to_vector_int(membership, &c_membership); + c_nb_clusters=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_community_leiden(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), (Rf_isNull(vertex_weights) ? 0 : &c_vertex_weights), c_resolution, c_beta, c_start, c_n_iterations, &c_membership, &c_nb_clusters, &c_quality)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); + igraph_vector_int_destroy(&c_membership); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(nb_clusters=NEW_INTEGER(1)); + INTEGER(nb_clusters)[0]=c_nb_clusters; + PROTECT(quality=NEW_NUMERIC(1)); + REAL(quality)[0]=c_quality; + SET_VECTOR_ELT(r_result, 0, membership); + SET_VECTOR_ELT(r_result, 1, nb_clusters); + SET_VECTOR_ELT(r_result, 2, quality); + SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("nb_clusters")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("quality")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_split_join_distance / +/-------------------------------------------*/ +SEXP R_igraph_split_join_distance(SEXP comm1, SEXP comm2) { + /* Declarations */ + igraph_vector_int_t c_comm1; + igraph_vector_int_t c_comm2; + igraph_integer_t c_distance12; + igraph_integer_t c_distance21; + SEXP distance12; + SEXP distance21; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_vector_int(comm1, &c_comm1); + R_SEXP_to_vector_int(comm2, &c_comm2); + c_distance12=0; + c_distance21=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_split_join_distance(&c_comm1, &c_comm2, &c_distance12, &c_distance21)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(distance12=NEW_INTEGER(1)); + INTEGER(distance12)[0]=c_distance12; + PROTECT(distance21=NEW_INTEGER(1)); + INTEGER(distance21)[0]=c_distance21; + SET_VECTOR_ELT(r_result, 0, distance12); + SET_VECTOR_ELT(r_result, 1, distance21); + SET_STRING_ELT(r_names, 0, Rf_mkChar("distance12")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("distance21")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_community_infomap / +/-------------------------------------------*/ +SEXP R_igraph_community_infomap(SEXP graph, SEXP e_weights, SEXP v_weights, SEXP nb_trials) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_e_weights; + igraph_vector_t c_v_weights; + igraph_integer_t c_nb_trials; + igraph_vector_int_t c_membership; + igraph_real_t c_codelength; + SEXP membership; + SEXP codelength; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(e_weights)) { R_SEXP_to_vector(e_weights, &c_e_weights); } + if (!Rf_isNull(v_weights)) { R_SEXP_to_vector(v_weights, &c_v_weights); } + c_nb_trials=INTEGER(nb_trials)[0]; + if (0 != igraph_vector_int_init(&c_membership, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_community_infomap(&c_graph, (Rf_isNull(e_weights) ? 0 : &c_e_weights), (Rf_isNull(v_weights) ? 0 : &c_v_weights), c_nb_trials, &c_membership, &c_codelength)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); + igraph_vector_int_destroy(&c_membership); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(codelength=NEW_NUMERIC(1)); + REAL(codelength)[0]=c_codelength; + SET_VECTOR_ELT(r_result, 0, membership); + SET_VECTOR_ELT(r_result, 1, codelength); + SET_STRING_ELT(r_names, 0, Rf_mkChar("membership")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("codelength")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_fit / +/-------------------------------------------*/ +SEXP R_igraph_hrg_fit(SEXP graph, SEXP hrg, SEXP start, SEXP steps) { + /* Declarations */ + igraph_t c_graph; + igraph_hrg_t c_hrg; + igraph_bool_t c_start; + igraph_integer_t c_steps; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); + c_start=LOGICAL(start)[0]; + c_steps=INTEGER(steps)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_fit(&c_graph, &c_hrg, c_start, c_steps)); + + /* Convert output */ + PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); + igraph_hrg_destroy(&c_hrg); + IGRAPH_FINALLY_CLEAN(1); + r_result = hrg; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_sample / +/-------------------------------------------*/ +SEXP R_igraph_hrg_sample(SEXP hrg) { + /* Declarations */ + igraph_hrg_t c_hrg; + igraph_t c_sample; + SEXP sample; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_hrg(hrg, &c_hrg); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_sample(&c_hrg, &c_sample)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_sample); + PROTECT(sample=R_igraph_to_SEXP(&c_sample)); + igraph_destroy(&c_sample); + IGRAPH_FINALLY_CLEAN(1); + r_result = sample; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_sample_many / +/-------------------------------------------*/ +SEXP R_igraph_hrg_sample_many(SEXP hrg, SEXP num_samples) { + /* Declarations */ + igraph_hrg_t c_hrg; + igraph_graph_list_t c_samples; + igraph_integer_t c_num_samples; + SEXP samples; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_hrg(hrg, &c_hrg); + if (0 != igraph_graph_list_init(&c_samples, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_graph_list_destroy, &c_samples); + c_num_samples=INTEGER(num_samples)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_sample_many(&c_hrg, &c_samples, c_num_samples)); + + /* Convert output */ + PROTECT(samples=R_igraph_graphlist_to_SEXP(&c_samples)); + igraph_graph_list_destroy(&c_samples); + IGRAPH_FINALLY_CLEAN(1); + r_result = samples; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_game / +/-------------------------------------------*/ +SEXP R_igraph_hrg_game(SEXP hrg) { + /* Declarations */ + igraph_t c_graph; + igraph_hrg_t c_hrg; + SEXP graph; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_hrg(hrg, &c_hrg); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_game(&c_graph, &c_hrg)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_dendrogram / +/-------------------------------------------*/ +SEXP R_igraph_hrg_dendrogram(SEXP hrg) { + /* Declarations */ + igraph_t c_graph; + igraph_hrg_t c_hrg; + SEXP graph; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_hrg(hrg, &c_hrg); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_dendrogram(&c_graph, &c_hrg)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_consensus / +/-------------------------------------------*/ +SEXP R_igraph_hrg_consensus(SEXP graph, SEXP hrg, SEXP start, SEXP num_samples) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_parents; + igraph_vector_t c_weights; + igraph_hrg_t c_hrg; + igraph_bool_t c_start; + igraph_integer_t c_num_samples; + SEXP parents; + SEXP weights; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_parents, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_parents); + if (0 != igraph_vector_init(&c_weights, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_weights); + if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); + c_start=LOGICAL(start)[0]; + c_num_samples=INTEGER(num_samples)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_consensus(&c_graph, &c_parents, &c_weights, &c_hrg, c_start, c_num_samples)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(parents=R_igraph_vector_int_to_SEXP(&c_parents)); + igraph_vector_int_destroy(&c_parents); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(weights=R_igraph_vector_to_SEXP(&c_weights)); + igraph_vector_destroy(&c_weights); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); + igraph_hrg_destroy(&c_hrg); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, parents); + SET_VECTOR_ELT(r_result, 1, weights); + SET_VECTOR_ELT(r_result, 2, hrg); + SET_STRING_ELT(r_names, 0, Rf_mkChar("parents")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("weights")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("hrg")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_predict / +/-------------------------------------------*/ +SEXP R_igraph_hrg_predict(SEXP graph, SEXP hrg, SEXP start, SEXP num_samples, SEXP num_bins) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_edges; + igraph_vector_t c_prob; + igraph_hrg_t c_hrg; + igraph_bool_t c_start; + igraph_integer_t c_num_samples; + igraph_integer_t c_num_bins; + SEXP edges; + SEXP prob; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_edges, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edges); + if (0 != igraph_vector_init(&c_prob, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_prob); + if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); + c_start=LOGICAL(start)[0]; + c_num_samples=INTEGER(num_samples)[0]; + c_num_bins=INTEGER(num_bins)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_predict(&c_graph, &c_edges, &c_prob, &c_hrg, c_start, c_num_samples, c_num_bins)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(edges=R_igraph_vector_int_to_SEXP(&c_edges)); + igraph_vector_int_destroy(&c_edges); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(prob=R_igraph_vector_to_SEXP(&c_prob)); + igraph_vector_destroy(&c_prob); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); + igraph_hrg_destroy(&c_hrg); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, edges); + SET_VECTOR_ELT(r_result, 1, prob); + SET_VECTOR_ELT(r_result, 2, hrg); + SET_STRING_ELT(r_names, 0, Rf_mkChar("edges")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("prob")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("hrg")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_create / +/-------------------------------------------*/ +SEXP R_igraph_hrg_create(SEXP graph, SEXP prob) { + /* Declarations */ + igraph_hrg_t c_hrg; + igraph_t c_graph; + igraph_vector_t c_prob; + SEXP hrg; + + SEXP r_result; + /* Convert input */ + if (0 != igraph_hrg_init(&c_hrg, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); + R_SEXP_to_igraph(graph, &c_graph); + R_SEXP_to_vector(prob, &c_prob); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_create(&c_hrg, &c_graph, &c_prob)); + + /* Convert output */ + PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); + igraph_hrg_destroy(&c_hrg); + IGRAPH_FINALLY_CLEAN(1); + r_result = hrg; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_resize / +/-------------------------------------------*/ +SEXP R_igraph_hrg_resize(SEXP hrg, SEXP newsize) { + /* Declarations */ + igraph_hrg_t c_hrg; + igraph_integer_t c_newsize; + + SEXP r_result; + /* Convert input */ + if (0 != R_SEXP_to_hrg_copy(hrg, &c_hrg)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_hrg_destroy, &c_hrg); + c_newsize=INTEGER(newsize)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_hrg_resize(&c_hrg, c_newsize)); + + /* Convert output */ + PROTECT(hrg=R_igraph_hrg_to_SEXP(&c_hrg)); + igraph_hrg_destroy(&c_hrg); + IGRAPH_FINALLY_CLEAN(1); + r_result = hrg; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_hrg_size / +/-------------------------------------------*/ +SEXP R_igraph_hrg_size(SEXP hrg) { + /* Declarations */ + igraph_hrg_t c_hrg; + igraph_integer_t c_result; + SEXP r_result; + /* Convert input */ + R_SEXP_to_hrg(hrg, &c_hrg); + /* Call igraph */ + c_result=igraph_hrg_size(&c_hrg); + + /* Convert output */ + + PROTECT(r_result=NEW_INTEGER(1)); + INTEGER(r_result)[0]=c_result; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_get_adjacency_sparse / +/-------------------------------------------*/ +SEXP R_igraph_get_adjacency_sparse(SEXP graph, SEXP type, SEXP weights, SEXP loops) { + /* Declarations */ + igraph_t c_graph; + igraph_sparsemat_t c_sparsemat; + igraph_get_adjacency_t c_type; + igraph_vector_t c_weights; + igraph_loops_t c_loops; + SEXP sparsemat; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_sparsemat_init(&c_sparsemat, 0, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_sparsemat_destroy, &c_sparsemat); + c_type = (igraph_get_adjacency_t) Rf_asInteger(type); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_loops = (igraph_loops_t) Rf_asInteger(loops); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_get_adjacency_sparse(&c_graph, &c_sparsemat, c_type, (Rf_isNull(weights) ? 0 : &c_weights), c_loops)); + + /* Convert output */ + PROTECT(sparsemat=R_igraph_sparsemat_to_SEXP(&c_sparsemat)); + igraph_sparsemat_destroy(&c_sparsemat); + IGRAPH_FINALLY_CLEAN(1); + r_result = sparsemat; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_get_stochastic / +/-------------------------------------------*/ +SEXP R_igraph_get_stochastic(SEXP graph, SEXP column_wise, SEXP weights) { + /* Declarations */ + igraph_t c_graph; + igraph_matrix_t c_res; + igraph_bool_t c_column_wise; + igraph_vector_t c_weights; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_matrix_init(&c_res, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_res); + c_column_wise=LOGICAL(column_wise)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_get_stochastic(&c_graph, &c_res, c_column_wise, (Rf_isNull(weights) ? 0 : &c_weights))); + + /* Convert output */ + PROTECT(res=R_igraph_matrix_to_SEXP(&c_res)); + igraph_matrix_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_get_stochastic_sparse / +/-------------------------------------------*/ +SEXP R_igraph_get_stochastic_sparse(SEXP graph, SEXP column_wise, SEXP weights) { + /* Declarations */ + igraph_t c_graph; + igraph_sparsemat_t c_sparsemat; + igraph_bool_t c_column_wise; + igraph_vector_t c_weights; + SEXP sparsemat; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_sparsemat_init(&c_sparsemat, 0, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_sparsemat_destroy, &c_sparsemat); + c_column_wise=LOGICAL(column_wise)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_get_stochastic_sparse(&c_graph, &c_sparsemat, c_column_wise, (Rf_isNull(weights) ? 0 : &c_weights))); + + /* Convert output */ + PROTECT(sparsemat=R_igraph_sparsemat_to_SEXP(&c_sparsemat)); + igraph_sparsemat_destroy(&c_sparsemat); + IGRAPH_FINALLY_CLEAN(1); + r_result = sparsemat; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_to_directed / +/-------------------------------------------*/ +SEXP R_igraph_to_directed(SEXP graph, SEXP mode) { + /* Declarations */ + igraph_t c_graph; + igraph_to_directed_t c_mode; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + c_mode = (igraph_to_directed_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_to_directed(&c_graph, c_mode)); + + /* Convert output */ + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_to_undirected / +/-------------------------------------------*/ +SEXP R_igraph_to_undirected(SEXP graph, SEXP mode, SEXP edge_attr_comb) { + /* Declarations */ + igraph_t c_graph; + igraph_to_undirected_t c_mode; + igraph_attribute_combination_t c_edge_attr_comb; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + c_mode = (igraph_to_undirected_t) Rf_asInteger(mode); + R_SEXP_to_attr_comb(edge_attr_comb, &c_edge_attr_comb); + IGRAPH_FINALLY(igraph_attribute_combination_destroy, &c_edge_attr_comb); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_to_undirected(&c_graph, c_mode, &c_edge_attr_comb)); + + /* Convert output */ + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + igraph_attribute_combination_destroy(&c_edge_attr_comb); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_read_graph_dimacs_flow / +/-------------------------------------------*/ +SEXP R_igraph_read_graph_dimacs_flow(SEXP instream, SEXP directed) { + /* Declarations */ + igraph_t c_graph; + FILE* c_instream; + igraph_strvector_t c_problem; + igraph_vector_int_t c_label; + igraph_integer_t c_source; + igraph_integer_t c_target; + igraph_vector_t c_capacity; + igraph_bool_t c_directed; + SEXP graph; + SEXP problem; + SEXP label; + SEXP source; + SEXP target; + SEXP capacity; + + SEXP r_result, r_names; + /* Convert input */ + if (0 != igraph_strvector_init(&c_problem, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_strvector_destroy, &c_problem); + if (0 != igraph_vector_int_init(&c_label, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_label); + c_source=0; + c_target=0; + if (0 != igraph_vector_init(&c_capacity, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_capacity); + c_directed=LOGICAL(directed)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_read_graph_dimacs_flow(&c_graph, c_instream, &c_problem, &c_label, &c_source, &c_target, &c_capacity, c_directed)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(6)); + PROTECT(r_names=NEW_CHARACTER(6)); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(problem=R_igraph_strvector_to_SEXP(&c_problem)); + igraph_strvector_destroy(&c_problem); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(label=R_igraph_vector_int_to_SEXP(&c_label)); + igraph_vector_int_destroy(&c_label); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(source=NEW_INTEGER(1)); + INTEGER(source)[0]=c_source; + PROTECT(target=NEW_INTEGER(1)); + INTEGER(target)[0]=c_target; + PROTECT(capacity=R_igraph_vector_to_SEXP(&c_capacity)); + igraph_vector_destroy(&c_capacity); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, problem); + SET_VECTOR_ELT(r_result, 2, label); + SET_VECTOR_ELT(r_result, 3, source); + SET_VECTOR_ELT(r_result, 4, target); + SET_VECTOR_ELT(r_result, 5, capacity); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("problem")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("label")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("source")); + SET_STRING_ELT(r_names, 4, Rf_mkChar("target")); + SET_STRING_ELT(r_names, 5, Rf_mkChar("capacity")); + SET_NAMES(r_result, r_names); + UNPROTECT(7); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_write_graph_dimacs_flow / +/-------------------------------------------*/ +SEXP R_igraph_write_graph_dimacs_flow(SEXP graph, SEXP outstream, SEXP source, SEXP target, SEXP capacity) { + /* Declarations */ + igraph_t c_graph; + FILE* c_outstream; + igraph_integer_t c_source; + igraph_integer_t c_target; + igraph_vector_t c_capacity; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + c_source = (igraph_integer_t) REAL(source)[0]; + c_target = (igraph_integer_t) REAL(target)[0]; + R_SEXP_to_vector(capacity, &c_capacity); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_write_graph_dimacs_flow(&c_graph, c_outstream, c_source, c_target, &c_capacity)); + + /* Convert output */ + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_dyad_census / +/-------------------------------------------*/ +SEXP R_igraph_dyad_census(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_real_t c_mut; + igraph_real_t c_asym; + igraph_real_t c_null; + SEXP mut; + SEXP asym; + SEXP null; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_dyad_census(&c_graph, &c_mut, &c_asym, &c_null)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(mut=NEW_NUMERIC(1)); + REAL(mut)[0]=c_mut; + PROTECT(asym=NEW_NUMERIC(1)); + REAL(asym)[0]=c_asym; + PROTECT(null=NEW_NUMERIC(1)); + REAL(null)[0]=c_null; + SET_VECTOR_ELT(r_result, 0, mut); + SET_VECTOR_ELT(r_result, 1, asym); + SET_VECTOR_ELT(r_result, 2, null); + SET_STRING_ELT(r_names, 0, Rf_mkChar("mut")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("asym")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("null")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_triad_census / +/-------------------------------------------*/ +SEXP R_igraph_triad_census(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_triad_census(&c_graph, &c_res)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_adjacent_triangles / +/-------------------------------------------*/ +SEXP R_igraph_adjacent_triangles(SEXP graph, SEXP vids) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + igraph_vs_t c_vids; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_adjacent_triangles(&c_graph, &c_res, c_vids)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_local_scan_0 / +/-------------------------------------------*/ +SEXP R_igraph_local_scan_0(SEXP graph, SEXP weights, SEXP mode) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + igraph_vector_t c_weights; + igraph_neimode_t c_mode; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_local_scan_0(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_local_scan_0_them / +/-------------------------------------------*/ +SEXP R_igraph_local_scan_0_them(SEXP us, SEXP them, SEXP weights_them, SEXP mode) { + /* Declarations */ + igraph_t c_us; + igraph_t c_them; + igraph_vector_t c_res; + igraph_vector_t c_weights_them; + igraph_neimode_t c_mode; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(us, &c_us); + R_SEXP_to_igraph(them, &c_them); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (!Rf_isNull(weights_them)) { R_SEXP_to_vector(weights_them, &c_weights_them); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_local_scan_0_them(&c_us, &c_them, &c_res, (Rf_isNull(weights_them) ? 0 : &c_weights_them), c_mode)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_local_scan_1_ecount / +/-------------------------------------------*/ +SEXP R_igraph_local_scan_1_ecount(SEXP graph, SEXP weights, SEXP mode) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + igraph_vector_t c_weights; + igraph_neimode_t c_mode; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_local_scan_1_ecount(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_local_scan_1_ecount_them / +/-------------------------------------------*/ +SEXP R_igraph_local_scan_1_ecount_them(SEXP us, SEXP them, SEXP weights_them, SEXP mode) { + /* Declarations */ + igraph_t c_us; + igraph_t c_them; + igraph_vector_t c_res; + igraph_vector_t c_weights_them; + igraph_neimode_t c_mode; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(us, &c_us); + R_SEXP_to_igraph(them, &c_them); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (!Rf_isNull(weights_them)) { R_SEXP_to_vector(weights_them, &c_weights_them); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_local_scan_1_ecount_them(&c_us, &c_them, &c_res, (Rf_isNull(weights_them) ? 0 : &c_weights_them), c_mode)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_local_scan_k_ecount / +/-------------------------------------------*/ +SEXP R_igraph_local_scan_k_ecount(SEXP graph, SEXP k, SEXP weights, SEXP mode) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_k; + igraph_vector_t c_res; + igraph_vector_t c_weights; + igraph_neimode_t c_mode; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_k=INTEGER(k)[0]; + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_local_scan_k_ecount(&c_graph, c_k, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), c_mode)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_local_scan_k_ecount_them / +/-------------------------------------------*/ +SEXP R_igraph_local_scan_k_ecount_them(SEXP us, SEXP them, SEXP k, SEXP weights_them, SEXP mode) { + /* Declarations */ + igraph_t c_us; + igraph_t c_them; + igraph_integer_t c_k; + igraph_vector_t c_res; + igraph_vector_t c_weights_them; + igraph_neimode_t c_mode; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(us, &c_us); + R_SEXP_to_igraph(them, &c_them); + c_k=INTEGER(k)[0]; + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (!Rf_isNull(weights_them)) { R_SEXP_to_vector(weights_them, &c_weights_them); } + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_local_scan_k_ecount_them(&c_us, &c_them, c_k, &c_res, (Rf_isNull(weights_them) ? 0 : &c_weights_them), c_mode)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_local_scan_neighborhood_ecount / +/-------------------------------------------*/ +SEXP R_igraph_local_scan_neighborhood_ecount(SEXP graph, SEXP weights, SEXP neighborhoods) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + igraph_vector_t c_weights; + igraph_vector_int_list_t c_neighborhoods; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(neighborhoods)) { R_igraph_SEXP_to_vector_int_list(neighborhoods, &c_neighborhoods); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_local_scan_neighborhood_ecount(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), &c_neighborhoods)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_local_scan_subset_ecount / +/-------------------------------------------*/ +SEXP R_igraph_local_scan_subset_ecount(SEXP graph, SEXP weights, SEXP subsets) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_res; + igraph_vector_t c_weights; + igraph_vector_int_list_t c_subsets; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_res); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (!Rf_isNull(subsets)) { R_igraph_SEXP_to_vector_int_list(subsets, &c_subsets); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_local_scan_subset_ecount(&c_graph, &c_res, (Rf_isNull(weights) ? 0 : &c_weights), &c_subsets)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_to_SEXP(&c_res)); + igraph_vector_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_list_triangles / +/-------------------------------------------*/ +SEXP R_igraph_list_triangles(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_res; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_list_triangles(&c_graph, &c_res)); + + /* Convert output */ + PROTECT(res=R_igraph_vector_int_to_SEXP(&c_res)); + igraph_vector_int_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_induced_subgraph_map / +/-------------------------------------------*/ +SEXP R_igraph_induced_subgraph_map(SEXP graph, SEXP vids, SEXP impl) { + /* Declarations */ + igraph_t c_graph; + igraph_t c_res; + igraph_vs_t c_vids; + igraph_subgraph_implementation_t c_impl; + igraph_vector_int_t c_map; + igraph_vector_int_t c_invmap; + SEXP res; + SEXP map; + SEXP invmap; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_impl = (igraph_subgraph_implementation_t) Rf_asInteger(impl); + if (0 != igraph_vector_int_init(&c_map, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map); + if (0 != igraph_vector_int_init(&c_invmap, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_invmap); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_induced_subgraph_map(&c_graph, &c_res, c_vids, c_impl, &c_map, &c_invmap)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + igraph_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(map=R_igraph_vector_int_to_SEXP(&c_map)); + igraph_vector_int_destroy(&c_map); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(invmap=R_igraph_vector_int_to_SEXP(&c_invmap)); + igraph_vector_int_destroy(&c_invmap); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, map); + SET_VECTOR_ELT(r_result, 2, invmap); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("map")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("invmap")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_gomory_hu_tree / +/-------------------------------------------*/ +SEXP R_igraph_gomory_hu_tree(SEXP graph, SEXP capacity) { + /* Declarations */ + igraph_t c_graph; + igraph_t c_tree; + igraph_vector_t c_flows; + igraph_vector_t c_capacity; + SEXP tree; + SEXP flows; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_flows, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_flows); + if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_gomory_hu_tree(&c_graph, &c_tree, &c_flows, (Rf_isNull(capacity) ? 0 : &c_capacity))); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + IGRAPH_FINALLY(igraph_destroy, &c_tree); + PROTECT(tree=R_igraph_to_SEXP(&c_tree)); + igraph_destroy(&c_tree); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(flows=R_igraph_vector_to_SEXP(&c_flows)); + igraph_vector_destroy(&c_flows); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, tree); + SET_VECTOR_ELT(r_result, 1, flows); + SET_STRING_ELT(r_names, 0, Rf_mkChar("tree")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("flows")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_maxflow / +/-------------------------------------------*/ +SEXP R_igraph_maxflow(SEXP graph, SEXP source, SEXP target, SEXP capacity) { + /* Declarations */ + igraph_t c_graph; + igraph_real_t c_value; + igraph_vector_t c_flow; + igraph_vector_int_t c_cut; + igraph_vector_int_t c_partition1; + igraph_vector_int_t c_partition2; + igraph_integer_t c_source; + igraph_integer_t c_target; + igraph_vector_t c_capacity; + igraph_maxflow_stats_t c_stats; + SEXP value; + SEXP flow; + SEXP cut; + SEXP partition1; + SEXP partition2; + SEXP stats; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_flow, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_flow); + if (0 != igraph_vector_int_init(&c_cut, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_cut); + if (0 != igraph_vector_int_init(&c_partition1, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition1); + if (0 != igraph_vector_int_init(&c_partition2, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition2); + c_source = (igraph_integer_t) REAL(source)[0]; + c_target = (igraph_integer_t) REAL(target)[0]; + if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_maxflow(&c_graph, &c_value, &c_flow, &c_cut, &c_partition1, &c_partition2, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity), &c_stats)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(6)); + PROTECT(r_names=NEW_CHARACTER(6)); + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + PROTECT(flow=R_igraph_vector_to_SEXP(&c_flow)); + igraph_vector_destroy(&c_flow); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(cut=R_igraph_vector_int_to_SEXP(&c_cut)); + igraph_vector_int_destroy(&c_cut); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition1=R_igraph_vector_int_to_SEXP(&c_partition1)); + igraph_vector_int_destroy(&c_partition1); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition2=R_igraph_vector_int_to_SEXP(&c_partition2)); + igraph_vector_int_destroy(&c_partition2); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(stats=R_igraph_maxflow_stats_to_SEXP(&c_stats)); + SET_VECTOR_ELT(r_result, 0, value); + SET_VECTOR_ELT(r_result, 1, flow); + SET_VECTOR_ELT(r_result, 2, cut); + SET_VECTOR_ELT(r_result, 3, partition1); + SET_VECTOR_ELT(r_result, 4, partition2); + SET_VECTOR_ELT(r_result, 5, stats); + SET_STRING_ELT(r_names, 0, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("flow")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("cut")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("partition1")); + SET_STRING_ELT(r_names, 4, Rf_mkChar("partition2")); + SET_STRING_ELT(r_names, 5, Rf_mkChar("stats")); + SET_NAMES(r_result, r_names); + UNPROTECT(7); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_st_mincut / +/-------------------------------------------*/ +SEXP R_igraph_st_mincut(SEXP graph, SEXP source, SEXP target, SEXP capacity) { + /* Declarations */ + igraph_t c_graph; + igraph_real_t c_value; + igraph_vector_int_t c_cut; + igraph_vector_int_t c_partition1; + igraph_vector_int_t c_partition2; + igraph_integer_t c_source; + igraph_integer_t c_target; + igraph_vector_t c_capacity; + SEXP value; + SEXP cut; + SEXP partition1; + SEXP partition2; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_cut, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_cut); + if (0 != igraph_vector_int_init(&c_partition1, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition1); + if (0 != igraph_vector_int_init(&c_partition2, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_partition2); + c_source = (igraph_integer_t) REAL(source)[0]; + c_target = (igraph_integer_t) REAL(target)[0]; + if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_st_mincut(&c_graph, &c_value, &c_cut, &c_partition1, &c_partition2, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity))); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(4)); + PROTECT(r_names=NEW_CHARACTER(4)); + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + PROTECT(cut=R_igraph_vector_int_to_SEXP(&c_cut)); + igraph_vector_int_destroy(&c_cut); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition1=R_igraph_vector_int_to_SEXP(&c_partition1)); + igraph_vector_int_destroy(&c_partition1); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition2=R_igraph_vector_int_to_SEXP(&c_partition2)); + igraph_vector_int_destroy(&c_partition2); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, value); + SET_VECTOR_ELT(r_result, 1, cut); + SET_VECTOR_ELT(r_result, 2, partition1); + SET_VECTOR_ELT(r_result, 3, partition2); + SET_STRING_ELT(r_names, 0, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("cut")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("partition1")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("partition2")); + SET_NAMES(r_result, r_names); + UNPROTECT(5); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_residual_graph / +/-------------------------------------------*/ +SEXP R_igraph_residual_graph(SEXP graph, SEXP capacity, SEXP flow) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_capacity; + igraph_t c_residual; + igraph_vector_t c_residual_capacity; + igraph_vector_t c_flow; + SEXP residual; + SEXP residual_capacity; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + if (0 != igraph_vector_init(&c_residual_capacity, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_residual_capacity); + residual_capacity=R_GlobalEnv; /* hack to have a non-NULL value */ + R_SEXP_to_vector(flow, &c_flow); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_residual_graph(&c_graph, (Rf_isNull(capacity) ? 0 : &c_capacity), &c_residual, (Rf_isNull(residual_capacity) ? 0 : &c_residual_capacity), &c_flow)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + IGRAPH_FINALLY(igraph_destroy, &c_residual); + PROTECT(residual=R_igraph_to_SEXP(&c_residual)); + igraph_destroy(&c_residual); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(residual_capacity=R_igraph_0orvector_to_SEXP(&c_residual_capacity)); + igraph_vector_destroy(&c_residual_capacity); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, residual); + SET_VECTOR_ELT(r_result, 1, residual_capacity); + SET_STRING_ELT(r_names, 0, Rf_mkChar("residual")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("residual_capacity")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_reverse_residual_graph / +/-------------------------------------------*/ +SEXP R_igraph_reverse_residual_graph(SEXP graph, SEXP capacity, SEXP flow) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_t c_capacity; + igraph_t c_residual; + igraph_vector_t c_flow; + SEXP residual; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + R_SEXP_to_vector(flow, &c_flow); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_reverse_residual_graph(&c_graph, (Rf_isNull(capacity) ? 0 : &c_capacity), &c_residual, &c_flow)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_residual); + PROTECT(residual=R_igraph_to_SEXP(&c_residual)); + igraph_destroy(&c_residual); + IGRAPH_FINALLY_CLEAN(1); + r_result = residual; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_dominator_tree / +/-------------------------------------------*/ +SEXP R_igraph_dominator_tree(SEXP graph, SEXP root, SEXP mode) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_root; + igraph_vector_int_t c_dom; + igraph_t c_domtree; + igraph_vector_int_t c_leftout; + igraph_neimode_t c_mode; + SEXP dom; + SEXP domtree; + SEXP leftout; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_root = (igraph_integer_t) REAL(root)[0]; + if (0 != igraph_vector_int_init(&c_dom, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_dom); + if (0 != igraph_vector_int_init(&c_leftout, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_leftout); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_dominator_tree(&c_graph, c_root, &c_dom, &c_domtree, &c_leftout, c_mode)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(dom=R_igraph_vector_int_to_SEXP(&c_dom)); + igraph_vector_int_destroy(&c_dom); + IGRAPH_FINALLY_CLEAN(1); + IGRAPH_FINALLY(igraph_destroy, &c_domtree); + PROTECT(domtree=R_igraph_to_SEXP(&c_domtree)); + igraph_destroy(&c_domtree); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(leftout=R_igraph_vector_int_to_SEXP(&c_leftout)); + igraph_vector_int_destroy(&c_leftout); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, dom); + SET_VECTOR_ELT(r_result, 1, domtree); + SET_VECTOR_ELT(r_result, 2, leftout); + SET_STRING_ELT(r_names, 0, Rf_mkChar("dom")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("domtree")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("leftout")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_all_st_cuts / +/-------------------------------------------*/ +SEXP R_igraph_all_st_cuts(SEXP graph, SEXP source, SEXP target) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_list_t c_cuts; + igraph_vector_int_list_t c_partition1s; + igraph_integer_t c_source; + igraph_integer_t c_target; + SEXP cuts; + SEXP partition1s; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_list_init(&c_cuts, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_cuts); + if (0 != igraph_vector_int_list_init(&c_partition1s, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_partition1s); + c_source = (igraph_integer_t) REAL(source)[0]; + c_target = (igraph_integer_t) REAL(target)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_all_st_cuts(&c_graph, &c_cuts, &c_partition1s, c_source, c_target)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(cuts=R_igraph_vector_int_list_to_SEXP(&c_cuts)); + igraph_vector_int_list_destroy(&c_cuts); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition1s=R_igraph_vector_int_list_to_SEXP(&c_partition1s)); + igraph_vector_int_list_destroy(&c_partition1s); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, cuts); + SET_VECTOR_ELT(r_result, 1, partition1s); + SET_STRING_ELT(r_names, 0, Rf_mkChar("cuts")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("partition1s")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_all_st_mincuts / +/-------------------------------------------*/ +SEXP R_igraph_all_st_mincuts(SEXP graph, SEXP source, SEXP target, SEXP capacity) { + /* Declarations */ + igraph_t c_graph; + igraph_real_t c_value; + igraph_vector_int_list_t c_cuts; + igraph_vector_int_list_t c_partition1s; + igraph_integer_t c_source; + igraph_integer_t c_target; + igraph_vector_t c_capacity; + SEXP value; + SEXP cuts; + SEXP partition1s; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_list_init(&c_cuts, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_cuts); + if (0 != igraph_vector_int_list_init(&c_partition1s, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_partition1s); + c_source = (igraph_integer_t) REAL(source)[0]; + c_target = (igraph_integer_t) REAL(target)[0]; + if (!Rf_isNull(capacity)) { R_SEXP_to_vector(capacity, &c_capacity); } + /* Call igraph */ + IGRAPH_R_CHECK(igraph_all_st_mincuts(&c_graph, &c_value, &c_cuts, &c_partition1s, c_source, c_target, (Rf_isNull(capacity) ? 0 : &c_capacity))); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(value=NEW_NUMERIC(1)); + REAL(value)[0]=c_value; + PROTECT(cuts=R_igraph_vector_int_list_to_SEXP(&c_cuts)); + igraph_vector_int_list_destroy(&c_cuts); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(partition1s=R_igraph_vector_int_list_to_SEXP(&c_partition1s)); + igraph_vector_int_list_destroy(&c_partition1s); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, value); + SET_VECTOR_ELT(r_result, 1, cuts); + SET_VECTOR_ELT(r_result, 2, partition1s); + SET_STRING_ELT(r_names, 0, Rf_mkChar("value")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("cuts")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("partition1s")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_even_tarjan_reduction / +/-------------------------------------------*/ +SEXP R_igraph_even_tarjan_reduction(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_t c_graphbar; + igraph_vector_t c_capacity; + SEXP graphbar; + SEXP capacity; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_init(&c_capacity, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_capacity); + capacity=R_GlobalEnv; /* hack to have a non-NULL value */ + /* Call igraph */ + IGRAPH_R_CHECK(igraph_even_tarjan_reduction(&c_graph, &c_graphbar, (Rf_isNull(capacity) ? 0 : &c_capacity))); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + IGRAPH_FINALLY(igraph_destroy, &c_graphbar); + PROTECT(graphbar=R_igraph_to_SEXP(&c_graphbar)); + igraph_destroy(&c_graphbar); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(capacity=R_igraph_0orvector_to_SEXP(&c_capacity)); + igraph_vector_destroy(&c_capacity); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graphbar); + SET_VECTOR_ELT(r_result, 1, capacity); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graphbar")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("capacity")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_is_separator / +/-------------------------------------------*/ +SEXP R_igraph_is_separator(SEXP graph, SEXP candidate) { + /* Declarations */ + igraph_t c_graph; + igraph_vs_t c_candidate; + igraph_bool_t c_res; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_is_separator(&c_graph, c_candidate, &c_res)); + + /* Convert output */ + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_is_minimal_separator / +/-------------------------------------------*/ +SEXP R_igraph_is_minimal_separator(SEXP graph, SEXP candidate) { + /* Declarations */ + igraph_t c_graph; + igraph_vs_t c_candidate; + igraph_bool_t c_res; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_is_minimal_separator(&c_graph, c_candidate, &c_res)); + + /* Convert output */ + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_all_minimal_st_separators / +/-------------------------------------------*/ +SEXP R_igraph_all_minimal_st_separators(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_list_t c_separators; + SEXP separators; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_list_init(&c_separators, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_separators); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_all_minimal_st_separators(&c_graph, &c_separators)); + + /* Convert output */ + PROTECT(separators=R_igraph_vector_int_list_to_SEXP(&c_separators)); + igraph_vector_int_list_destroy(&c_separators); + IGRAPH_FINALLY_CLEAN(1); + r_result = separators; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_minimum_size_separators / +/-------------------------------------------*/ +SEXP R_igraph_minimum_size_separators(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_list_t c_separators; + SEXP separators; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_list_init(&c_separators, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_separators); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_minimum_size_separators(&c_graph, &c_separators)); + + /* Convert output */ + PROTECT(separators=R_igraph_vector_int_list_to_SEXP(&c_separators)); + igraph_vector_int_list_destroy(&c_separators); + IGRAPH_FINALLY_CLEAN(1); + r_result = separators; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_isoclass / +/-------------------------------------------*/ +SEXP R_igraph_isoclass(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_isoclass; + SEXP isoclass; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_isoclass=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_isoclass(&c_graph, &c_isoclass)); + + /* Convert output */ + PROTECT(isoclass=NEW_INTEGER(1)); + INTEGER(isoclass)[0]=c_isoclass; + r_result = isoclass; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_isomorphic / +/-------------------------------------------*/ +SEXP R_igraph_isomorphic(SEXP graph1, SEXP graph2) { + /* Declarations */ + igraph_t c_graph1; + igraph_t c_graph2; + igraph_bool_t c_iso; + SEXP iso; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph1, &c_graph1); + R_SEXP_to_igraph(graph2, &c_graph2); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_isomorphic(&c_graph1, &c_graph2, &c_iso)); + + /* Convert output */ + PROTECT(iso=NEW_LOGICAL(1)); + LOGICAL(iso)[0]=c_iso; + r_result = iso; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_isoclass_subgraph / +/-------------------------------------------*/ +SEXP R_igraph_isoclass_subgraph(SEXP graph, SEXP vids) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_vids; + igraph_integer_t c_isoclass; + SEXP isoclass; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + R_SEXP_to_vector_int(vids, &c_vids); + c_isoclass=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_isoclass_subgraph(&c_graph, &c_vids, &c_isoclass)); + + /* Convert output */ + PROTECT(isoclass=NEW_INTEGER(1)); + INTEGER(isoclass)[0]=c_isoclass; + r_result = isoclass; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_isoclass_create / +/-------------------------------------------*/ +SEXP R_igraph_isoclass_create(SEXP size, SEXP number, SEXP directed) { + /* Declarations */ + igraph_t c_graph; + igraph_integer_t c_size; + igraph_integer_t c_number; + igraph_bool_t c_directed; + SEXP graph; + + SEXP r_result; + /* Convert input */ + c_size=INTEGER(size)[0]; + c_number=INTEGER(number)[0]; + c_directed=LOGICAL(directed)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_isoclass_create(&c_graph, c_size, c_number, c_directed)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_isomorphic_vf2 / +/-------------------------------------------*/ +SEXP R_igraph_isomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { + /* Declarations */ + igraph_t c_graph1; + igraph_t c_graph2; + igraph_vector_int_t c_vertex_color1; + igraph_vector_int_t c_vertex_color2; + igraph_vector_int_t c_edge_color1; + igraph_vector_int_t c_edge_color2; + igraph_bool_t c_iso; + igraph_vector_int_t c_map12; + igraph_vector_int_t c_map21; + + + + SEXP iso; + SEXP map12; + SEXP map21; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph1, &c_graph1); + R_SEXP_to_igraph(graph2, &c_graph2); + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (0 != igraph_vector_int_init(&c_map12, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map12); + if (0 != igraph_vector_int_init(&c_map21, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map21); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_isomorphic_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_iso, &c_map12, &c_map21, 0, 0, 0)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(iso=NEW_LOGICAL(1)); + LOGICAL(iso)[0]=c_iso; + PROTECT(map12=R_igraph_vector_int_to_SEXP(&c_map12)); + igraph_vector_int_destroy(&c_map12); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(map21=R_igraph_vector_int_to_SEXP(&c_map21)); + igraph_vector_int_destroy(&c_map21); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, iso); + SET_VECTOR_ELT(r_result, 1, map12); + SET_VECTOR_ELT(r_result, 2, map21); + SET_STRING_ELT(r_names, 0, Rf_mkChar("iso")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("map12")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("map21")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_count_isomorphisms_vf2 / +/-------------------------------------------*/ +SEXP R_igraph_count_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { + /* Declarations */ + igraph_t c_graph1; + igraph_t c_graph2; + igraph_vector_int_t c_vertex_color1; + igraph_vector_int_t c_vertex_color2; + igraph_vector_int_t c_edge_color1; + igraph_vector_int_t c_edge_color2; + igraph_integer_t c_count; + + + + SEXP count; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph1, &c_graph1); + R_SEXP_to_igraph(graph2, &c_graph2); + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + c_count=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_count_isomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_count, 0, 0, 0)); + + /* Convert output */ + PROTECT(count=NEW_INTEGER(1)); + INTEGER(count)[0]=c_count; + r_result = count; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_get_isomorphisms_vf2 / +/-------------------------------------------*/ +SEXP R_igraph_get_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { + /* Declarations */ + igraph_t c_graph1; + igraph_t c_graph2; + igraph_vector_int_t c_vertex_color1; + igraph_vector_int_t c_vertex_color2; + igraph_vector_int_t c_edge_color1; + igraph_vector_int_t c_edge_color2; + igraph_vector_int_list_t c_maps; + + + + SEXP maps; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph1, &c_graph1); + R_SEXP_to_igraph(graph2, &c_graph2); + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (0 != igraph_vector_int_list_init(&c_maps, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_maps); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_get_isomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_maps, 0, 0, 0)); + + /* Convert output */ + PROTECT(maps=R_igraph_vector_int_list_to_SEXP(&c_maps)); + igraph_vector_int_list_destroy(&c_maps); + IGRAPH_FINALLY_CLEAN(1); + r_result = maps; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_subisomorphic / +/-------------------------------------------*/ +SEXP R_igraph_subisomorphic(SEXP graph1, SEXP graph2) { + /* Declarations */ + igraph_t c_graph1; + igraph_t c_graph2; + igraph_bool_t c_iso; + SEXP iso; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph1, &c_graph1); + R_SEXP_to_igraph(graph2, &c_graph2); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_subisomorphic(&c_graph1, &c_graph2, &c_iso)); + + /* Convert output */ + PROTECT(iso=NEW_LOGICAL(1)); + LOGICAL(iso)[0]=c_iso; + r_result = iso; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_subisomorphic_vf2 / +/-------------------------------------------*/ +SEXP R_igraph_subisomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { + /* Declarations */ + igraph_t c_graph1; + igraph_t c_graph2; + igraph_vector_int_t c_vertex_color1; + igraph_vector_int_t c_vertex_color2; + igraph_vector_int_t c_edge_color1; + igraph_vector_int_t c_edge_color2; + igraph_bool_t c_iso; + igraph_vector_int_t c_map12; + igraph_vector_int_t c_map21; + + + + SEXP iso; + SEXP map12; + SEXP map21; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph1, &c_graph1); + R_SEXP_to_igraph(graph2, &c_graph2); + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (0 != igraph_vector_int_init(&c_map12, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map12); + if (0 != igraph_vector_int_init(&c_map21, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map21); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_subisomorphic_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_iso, &c_map12, &c_map21, 0, 0, 0)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(iso=NEW_LOGICAL(1)); + LOGICAL(iso)[0]=c_iso; + PROTECT(map12=R_igraph_vector_int_to_SEXP(&c_map12)); + igraph_vector_int_destroy(&c_map12); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(map21=R_igraph_vector_int_to_SEXP(&c_map21)); + igraph_vector_int_destroy(&c_map21); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, iso); + SET_VECTOR_ELT(r_result, 1, map12); + SET_VECTOR_ELT(r_result, 2, map21); + SET_STRING_ELT(r_names, 0, Rf_mkChar("iso")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("map12")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("map21")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_subisomorphic_function_vf2 / +/-------------------------------------------*/ +SEXP R_igraph_subisomorphic_function_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { + /* Declarations */ + igraph_t c_graph1; + igraph_t c_graph2; + igraph_vector_int_t c_vertex_color1; + igraph_vector_int_t c_vertex_color2; + igraph_vector_int_t c_edge_color1; + igraph_vector_int_t c_edge_color2; + igraph_vector_int_t c_map12; + igraph_vector_int_t c_map21; + + + + + SEXP map12; + SEXP map21; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph1, &c_graph1); + R_SEXP_to_igraph(graph2, &c_graph2); + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (0 != igraph_vector_int_init(&c_map12, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map12); + if (0 != igraph_vector_int_init(&c_map21, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map21); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_subisomorphic_function_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_map12, &c_map21, 0, 0, 0, 0)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(map12=R_igraph_vector_int_to_SEXP(&c_map12)); + igraph_vector_int_destroy(&c_map12); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(map21=R_igraph_vector_int_to_SEXP(&c_map21)); + igraph_vector_int_destroy(&c_map21); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, map12); + SET_VECTOR_ELT(r_result, 1, map21); + SET_STRING_ELT(r_names, 0, Rf_mkChar("map12")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("map21")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_count_subisomorphisms_vf2 / +/-------------------------------------------*/ +SEXP R_igraph_count_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { + /* Declarations */ + igraph_t c_graph1; + igraph_t c_graph2; + igraph_vector_int_t c_vertex_color1; + igraph_vector_int_t c_vertex_color2; + igraph_vector_int_t c_edge_color1; + igraph_vector_int_t c_edge_color2; + igraph_integer_t c_count; + + + + SEXP count; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph1, &c_graph1); + R_SEXP_to_igraph(graph2, &c_graph2); + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + c_count=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_count_subisomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_count, 0, 0, 0)); + + /* Convert output */ + PROTECT(count=NEW_INTEGER(1)); + INTEGER(count)[0]=c_count; + r_result = count; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_get_subisomorphisms_vf2 / +/-------------------------------------------*/ +SEXP R_igraph_get_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { + /* Declarations */ + igraph_t c_graph1; + igraph_t c_graph2; + igraph_vector_int_t c_vertex_color1; + igraph_vector_int_t c_vertex_color2; + igraph_vector_int_t c_edge_color1; + igraph_vector_int_t c_edge_color2; + igraph_vector_int_list_t c_maps; + + + + SEXP maps; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph1, &c_graph1); + R_SEXP_to_igraph(graph2, &c_graph2); + if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } + if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } + if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } + if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } + if (0 != igraph_vector_int_list_init(&c_maps, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_maps); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_get_subisomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_maps, 0, 0, 0)); + + /* Convert output */ + PROTECT(maps=R_igraph_vector_int_list_to_SEXP(&c_maps)); + igraph_vector_int_list_destroy(&c_maps); + IGRAPH_FINALLY_CLEAN(1); + r_result = maps; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_canonical_permutation / +/-------------------------------------------*/ +SEXP R_igraph_canonical_permutation(SEXP graph, SEXP colors, SEXP sh) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_colors; + igraph_vector_int_t c_labeling; + igraph_bliss_sh_t c_sh; + igraph_bliss_info_t c_info; + SEXP labeling; + SEXP info; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(colors)) { R_SEXP_to_vector_int(colors, &c_colors); } + if (0 != igraph_vector_int_init(&c_labeling, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_labeling); + c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_canonical_permutation(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), &c_labeling, c_sh, &c_info)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(labeling=R_igraph_vector_int_to_SEXP(&c_labeling)); + igraph_vector_int_destroy(&c_labeling); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(info=R_igraph_bliss_info_to_SEXP(&c_info)); + if (c_info.group_size) { free(c_info.group_size); } + SET_VECTOR_ELT(r_result, 0, labeling); + SET_VECTOR_ELT(r_result, 1, info); + SET_STRING_ELT(r_names, 0, Rf_mkChar("labeling")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("info")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_permute_vertices / +/-------------------------------------------*/ +SEXP R_igraph_permute_vertices(SEXP graph, SEXP permutation) { + /* Declarations */ + igraph_t c_graph; + igraph_t c_res; + igraph_vector_int_t c_permutation; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + R_SEXP_to_vector_int(permutation, &c_permutation); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_permute_vertices(&c_graph, &c_res, &c_permutation)); + + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + igraph_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_isomorphic_bliss / +/-------------------------------------------*/ +SEXP R_igraph_isomorphic_bliss(SEXP graph1, SEXP graph2, SEXP colors1, SEXP colors2, SEXP sh) { + /* Declarations */ + igraph_t c_graph1; + igraph_t c_graph2; + igraph_vector_int_t c_colors1; + igraph_vector_int_t c_colors2; + igraph_bool_t c_iso; + igraph_vector_int_t c_map12; + igraph_vector_int_t c_map21; + igraph_bliss_sh_t c_sh; + igraph_bliss_info_t c_info1; + igraph_bliss_info_t c_info2; + SEXP iso; + SEXP map12; + SEXP map21; + SEXP info1; + SEXP info2; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph1, &c_graph1); + R_SEXP_to_igraph(graph2, &c_graph2); + if (!Rf_isNull(colors1)) { R_SEXP_to_vector_int(colors1, &c_colors1); } + if (!Rf_isNull(colors2)) { R_SEXP_to_vector_int(colors2, &c_colors2); } + if (0 != igraph_vector_int_init(&c_map12, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map12); + if (0 != igraph_vector_int_init(&c_map21, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map21); + c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_isomorphic_bliss(&c_graph1, &c_graph2, (Rf_isNull(colors1) ? 0 : &c_colors1), (Rf_isNull(colors2) ? 0 : &c_colors2), &c_iso, &c_map12, &c_map21, c_sh, &c_info1, &c_info2)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(5)); + PROTECT(r_names=NEW_CHARACTER(5)); + PROTECT(iso=NEW_LOGICAL(1)); + LOGICAL(iso)[0]=c_iso; + PROTECT(map12=R_igraph_vector_int_to_SEXP(&c_map12)); + igraph_vector_int_destroy(&c_map12); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(map21=R_igraph_vector_int_to_SEXP(&c_map21)); + igraph_vector_int_destroy(&c_map21); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(info1=R_igraph_bliss_info_to_SEXP(&c_info1)); + if (c_info1.group_size) { free(c_info1.group_size); } + PROTECT(info2=R_igraph_bliss_info_to_SEXP(&c_info2)); + if (c_info2.group_size) { free(c_info2.group_size); } + SET_VECTOR_ELT(r_result, 0, iso); + SET_VECTOR_ELT(r_result, 1, map12); + SET_VECTOR_ELT(r_result, 2, map21); + SET_VECTOR_ELT(r_result, 3, info1); + SET_VECTOR_ELT(r_result, 4, info2); + SET_STRING_ELT(r_names, 0, Rf_mkChar("iso")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("map12")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("map21")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("info1")); + SET_STRING_ELT(r_names, 4, Rf_mkChar("info2")); + SET_NAMES(r_result, r_names); + UNPROTECT(6); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_automorphisms / +/-------------------------------------------*/ +SEXP R_igraph_automorphisms(SEXP graph, SEXP colors, SEXP sh) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_colors; + igraph_bliss_sh_t c_sh; + igraph_bliss_info_t c_info; + SEXP info; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(colors)) { R_SEXP_to_vector_int(colors, &c_colors); } + c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_automorphisms(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), c_sh, &c_info)); + + /* Convert output */ + PROTECT(info=R_igraph_bliss_info_to_SEXP(&c_info)); + if (c_info.group_size) { free(c_info.group_size); } + r_result = info; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_automorphism_group / +/-------------------------------------------*/ +SEXP R_igraph_automorphism_group(SEXP graph, SEXP colors, SEXP sh) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_colors; + igraph_vector_int_list_t c_generators; + igraph_bliss_sh_t c_sh; + igraph_bliss_info_t c_info; + SEXP generators; + SEXP info; + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(colors)) { R_SEXP_to_vector_int(colors, &c_colors); } + if (0 != igraph_vector_int_list_init(&c_generators, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_generators); + c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_automorphism_group(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), &c_generators, c_sh, &c_info)); - SEXP iso; - SEXP map12; - SEXP map21; + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(generators=R_igraph_vector_int_list_to_SEXP(&c_generators)); + igraph_vector_int_list_destroy(&c_generators); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(info=R_igraph_bliss_info_to_SEXP(&c_info)); + if (c_info.group_size) { free(c_info.group_size); } + SET_VECTOR_ELT(r_result, 0, generators); + SET_VECTOR_ELT(r_result, 1, info); + SET_STRING_ELT(r_names, 0, Rf_mkChar("generators")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("info")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_simplify_and_colorize / +/-------------------------------------------*/ +SEXP R_igraph_simplify_and_colorize(SEXP graph) { + /* Declarations */ + igraph_t c_graph; + igraph_t c_res; + igraph_vector_int_t c_vertex_color; + igraph_vector_int_t c_edge_color; + SEXP res; + SEXP vertex_color; + SEXP edge_color; SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } - if (0 != igraph_vector_init(&c_map12, 0)) { + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_init(&c_vertex_color, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color); + if (0 != igraph_vector_int_init(&c_edge_color, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_simplify_and_colorize(&c_graph, &c_res, &c_vertex_color, &c_edge_color)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + IGRAPH_FINALLY(igraph_destroy, &c_res); + PROTECT(res=R_igraph_to_SEXP(&c_res)); + igraph_destroy(&c_res); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(vertex_color=R_igraph_vector_int_to_SEXP(&c_vertex_color)); + igraph_vector_int_destroy(&c_vertex_color); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(edge_color=R_igraph_vector_int_to_SEXP(&c_edge_color)); + igraph_vector_int_destroy(&c_edge_color); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, vertex_color); + SET_VECTOR_ELT(r_result, 2, edge_color); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("vertex_color")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("edge_color")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_graph_count / +/-------------------------------------------*/ +SEXP R_igraph_graph_count(SEXP n, SEXP directed) { + /* Declarations */ + igraph_integer_t c_n; + igraph_bool_t c_directed; + igraph_integer_t c_count; + SEXP count; + + SEXP r_result; + /* Convert input */ + c_n=INTEGER(n)[0]; + c_directed=LOGICAL(directed)[0]; + c_count=0; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_graph_count(c_n, c_directed, &c_count)); + + /* Convert output */ + PROTECT(count=NEW_INTEGER(1)); + INTEGER(count)[0]=c_count; + r_result = count; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_is_matching / +/-------------------------------------------*/ +SEXP R_igraph_is_matching(SEXP graph, SEXP types, SEXP matching) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_bool_t c_types; + igraph_vector_int_t c_matching; + igraph_bool_t c_res; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + R_SEXP_to_vector_int(matching, &c_matching); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_is_matching(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_matching, &c_res)); + + /* Convert output */ + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_is_maximal_matching / +/-------------------------------------------*/ +SEXP R_igraph_is_maximal_matching(SEXP graph, SEXP types, SEXP matching) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_bool_t c_types; + igraph_vector_int_t c_matching; + igraph_bool_t c_res; + SEXP res; + + SEXP r_result; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + R_SEXP_to_vector_int(matching, &c_matching); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_is_maximal_matching(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_matching, &c_res)); + + /* Convert output */ + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + r_result = res; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_maximum_bipartite_matching / +/-------------------------------------------*/ +SEXP R_igraph_maximum_bipartite_matching(SEXP graph, SEXP types, SEXP weights, SEXP eps) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_bool_t c_types; + igraph_integer_t c_matching_size; + igraph_real_t c_matching_weight; + igraph_vector_int_t c_matching; + igraph_vector_t c_weights; + igraph_real_t c_eps; + SEXP matching_size; + SEXP matching_weight; + SEXP matching; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } + c_matching_size=0; + if (0 != igraph_vector_int_init(&c_matching, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_matching); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + c_eps=REAL(eps)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_maximum_bipartite_matching(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_matching_size, &c_matching_weight, &c_matching, (Rf_isNull(weights) ? 0 : &c_weights), c_eps)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(matching_size=NEW_INTEGER(1)); + INTEGER(matching_size)[0]=c_matching_size; + PROTECT(matching_weight=NEW_NUMERIC(1)); + REAL(matching_weight)[0]=c_matching_weight; + PROTECT(matching=R_igraph_vector_int_to_SEXP(&c_matching)); + igraph_vector_int_destroy(&c_matching); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, matching_size); + SET_VECTOR_ELT(r_result, 1, matching_weight); + SET_VECTOR_ELT(r_result, 2, matching); + SET_STRING_ELT(r_names, 0, Rf_mkChar("matching_size")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("matching_weight")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("matching")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_eigen_adjacency / +/-------------------------------------------*/ +SEXP R_igraph_eigen_adjacency(SEXP graph, SEXP algorithm, SEXP which, SEXP options) { + /* Declarations */ + igraph_t c_graph; + igraph_eigen_algorithm_t c_algorithm; + igraph_eigen_which_t c_which; + igraph_arpack_options_t c_options; + + igraph_vector_t c_values; + igraph_matrix_t c_vectors; + igraph_vector_complex_t c_cmplxvalues; + igraph_matrix_complex_t c_cmplxvectors; + SEXP values; + SEXP vectors; + SEXP cmplxvalues; + SEXP cmplxvectors; + + SEXP r_result, r_names; + /* Convert input */ + R_SEXP_to_igraph(graph, &c_graph); + c_algorithm=REAL(algorithm)[0]; + R_SEXP_to_igraph_eigen_which(which, &c_which); + R_SEXP_to_igraph_arpack_options(options, &c_options); + if (0 != igraph_vector_init(&c_values, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_values); + if (0 != igraph_matrix_init(&c_vectors, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_map12); - map12=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_map21, 0)) { + IGRAPH_FINALLY(igraph_matrix_destroy, &c_vectors); + if (0 != igraph_vector_complex_init(&c_cmplxvalues, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_complex_destroy, &c_cmplxvalues); + cmplxvalues=R_GlobalEnv; /* hack to have a non-NULL value */ + if (0 != igraph_matrix_complex_init(&c_cmplxvectors, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_map21); - map21=R_GlobalEnv; /* hack to have a non-NULL value */ + IGRAPH_FINALLY(igraph_matrix_complex_destroy, &c_cmplxvectors); + cmplxvectors=R_GlobalEnv; /* hack to have a non-NULL value */ /* Call igraph */ - IGRAPH_R_CHECK(igraph_isomorphic_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_iso, (Rf_isNull(map12) ? 0 : &c_map12), (Rf_isNull(map21) ? 0 : &c_map21), 0, 0, 0)); + IGRAPH_R_CHECK(igraph_eigen_adjacency(&c_graph, c_algorithm, &c_which, &c_options, 0, &c_values, &c_vectors, (Rf_isNull(cmplxvalues) ? 0 : &c_cmplxvalues), (Rf_isNull(cmplxvectors) ? 0 : &c_cmplxvectors))); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(iso=NEW_LOGICAL(1)); - LOGICAL(iso)[0]=c_iso; - PROTECT(map12=R_igraph_0orvector_to_SEXPp1(&c_map12)); - igraph_vector_destroy(&c_map12); + PROTECT(r_result=NEW_LIST(5)); + PROTECT(r_names=NEW_CHARACTER(5)); + PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(values=R_igraph_vector_to_SEXP(&c_values)); + igraph_vector_destroy(&c_values); IGRAPH_FINALLY_CLEAN(1); - PROTECT(map21=R_igraph_0orvector_to_SEXPp1(&c_map21)); - igraph_vector_destroy(&c_map21); + PROTECT(vectors=R_igraph_matrix_to_SEXP(&c_vectors)); + igraph_matrix_destroy(&c_vectors); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, iso); - SET_VECTOR_ELT(r_result, 1, map12); - SET_VECTOR_ELT(r_result, 2, map21); - SET_STRING_ELT(r_names, 0, Rf_mkChar("iso")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("map12")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("map21")); + PROTECT(cmplxvalues=R_igraph_0orvector_complex_to_SEXP(&c_cmplxvalues)); + igraph_vector_complex_destroy(&c_cmplxvalues); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(cmplxvectors=R_igraph_0ormatrix_complex_to_SEXP(&c_cmplxvectors)); + igraph_matrix_complex_destroy(&c_cmplxvectors); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, options); + SET_VECTOR_ELT(r_result, 1, values); + SET_VECTOR_ELT(r_result, 2, vectors); + SET_VECTOR_ELT(r_result, 3, cmplxvalues); + SET_VECTOR_ELT(r_result, 4, cmplxvectors); + SET_STRING_ELT(r_names, 0, Rf_mkChar("options")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("values")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("vectors")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("cmplxvalues")); + SET_STRING_ELT(r_names, 4, Rf_mkChar("cmplxvectors")); SET_NAMES(r_result, r_names); - UNPROTECT(4); + UNPROTECT(6); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_count_isomorphisms_vf2 / +/ igraph_power_law_fit / /-------------------------------------------*/ -SEXP R_igraph_count_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { +SEXP R_igraph_power_law_fit(SEXP data, SEXP xmin, SEXP force_continuous) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_vector_int_t c_vertex_color1; - igraph_vector_int_t c_vertex_color2; - igraph_vector_int_t c_edge_color1; - igraph_vector_int_t c_edge_color2; - igraph_integer_t c_count; - - - - SEXP count; + igraph_vector_t c_data; + igraph_plfit_result_t c_res; + igraph_real_t c_xmin; + igraph_bool_t c_force_continuous; + SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } - c_count=0; + R_SEXP_to_vector(data, &c_data); + c_xmin=REAL(xmin)[0]; + c_force_continuous=LOGICAL(force_continuous)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_count_isomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_count, 0, 0, 0)); + IGRAPH_R_CHECK(igraph_power_law_fit(&c_data, &c_res, c_xmin, c_force_continuous)); /* Convert output */ - PROTECT(count=NEW_INTEGER(1)); - INTEGER(count)[0]=c_count; - r_result = count; + PROTECT(res=R_igraph_plfit_result_to_SEXP(&c_res)); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_get_isomorphisms_vf2 / +/ igraph_sir / /-------------------------------------------*/ -SEXP R_igraph_get_isomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { +SEXP R_igraph_sir(SEXP graph, SEXP beta, SEXP gamma, SEXP no_sim) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_vector_int_t c_vertex_color1; - igraph_vector_int_t c_vertex_color2; - igraph_vector_int_t c_edge_color1; - igraph_vector_int_t c_edge_color2; - igraph_vector_ptr_t c_maps; - - - - SEXP maps; + igraph_t c_graph; + igraph_real_t c_beta; + igraph_real_t c_gamma; + igraph_integer_t c_no_sim; + igraph_vector_ptr_t c_res; + SEXP res; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } - if (0 != igraph_vector_ptr_init(&c_maps, 0)) { + R_SEXP_to_igraph(graph, &c_graph); + c_beta=REAL(beta)[0]; + c_gamma=REAL(gamma)[0]; + c_no_sim=INTEGER(no_sim)[0]; + if (0 != igraph_vector_ptr_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_maps); + IGRAPH_FINALLY(R_igraph_sirlist_destroy, &c_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_isomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_maps, 0, 0, 0)); + IGRAPH_R_CHECK(igraph_sir(&c_graph, c_beta, c_gamma, c_no_sim, &c_res)); /* Convert output */ - PROTECT(maps=R_igraph_vectorlist_to_SEXP(&c_maps)); - R_igraph_vectorlist_destroy(&c_maps); + PROTECT(res=R_igraph_sirlist_to_SEXP(&c_res)); + R_igraph_sirlist_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - r_result = maps; + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_subisomorphic_vf2 / +/ igraph_convex_hull / /-------------------------------------------*/ -SEXP R_igraph_subisomorphic_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { +SEXP R_igraph_convex_hull(SEXP data) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_vector_int_t c_vertex_color1; - igraph_vector_int_t c_vertex_color2; - igraph_vector_int_t c_edge_color1; - igraph_vector_int_t c_edge_color2; - igraph_bool_t c_iso; - igraph_vector_t c_map12; - igraph_vector_t c_map21; - - - - SEXP iso; - SEXP map12; - SEXP map21; + igraph_matrix_t c_data; + igraph_vector_int_t c_resverts; + igraph_matrix_t c_rescoords; + SEXP resverts; + SEXP rescoords; SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } - if (0 != igraph_vector_init(&c_map12, 0)) { + R_SEXP_to_matrix(data, &c_data); + if (0 != igraph_vector_int_init(&c_resverts, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_map12); - map12=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_map21, 0)) { + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_resverts); + if (0 != igraph_matrix_init(&c_rescoords, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_map21); - map21=R_GlobalEnv; /* hack to have a non-NULL value */ + IGRAPH_FINALLY(igraph_matrix_destroy, &c_rescoords); /* Call igraph */ - IGRAPH_R_CHECK(igraph_subisomorphic_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_iso, (Rf_isNull(map12) ? 0 : &c_map12), (Rf_isNull(map21) ? 0 : &c_map21), 0, 0, 0)); + IGRAPH_R_CHECK(igraph_convex_hull(&c_data, &c_resverts, &c_rescoords)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(iso=NEW_LOGICAL(1)); - LOGICAL(iso)[0]=c_iso; - PROTECT(map12=R_igraph_0orvector_to_SEXPp1(&c_map12)); - igraph_vector_destroy(&c_map12); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(resverts=R_igraph_vector_int_to_SEXPp1(&c_resverts)); + igraph_vector_int_destroy(&c_resverts); IGRAPH_FINALLY_CLEAN(1); - PROTECT(map21=R_igraph_0orvector_to_SEXPp1(&c_map21)); - igraph_vector_destroy(&c_map21); + PROTECT(rescoords=R_igraph_matrix_to_SEXP(&c_rescoords)); + igraph_matrix_destroy(&c_rescoords); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, iso); - SET_VECTOR_ELT(r_result, 1, map12); - SET_VECTOR_ELT(r_result, 2, map21); - SET_STRING_ELT(r_names, 0, Rf_mkChar("iso")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("map12")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("map21")); + SET_VECTOR_ELT(r_result, 0, resverts); + SET_VECTOR_ELT(r_result, 1, rescoords); + SET_STRING_ELT(r_names, 0, Rf_mkChar("resverts")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("rescoords")); SET_NAMES(r_result, r_names); - UNPROTECT(4); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_count_subisomorphisms_vf2 / +/ igraph_dim_select / /-------------------------------------------*/ -SEXP R_igraph_count_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { +SEXP R_igraph_dim_select(SEXP sv) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_vector_int_t c_vertex_color1; - igraph_vector_int_t c_vertex_color2; - igraph_vector_int_t c_edge_color1; - igraph_vector_int_t c_edge_color2; - igraph_integer_t c_count; - - - - SEXP count; + igraph_vector_t c_sv; + igraph_integer_t c_dim; + SEXP dim; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } - c_count=0; + R_SEXP_to_vector(sv, &c_sv); + c_dim=0; /* Call igraph */ - IGRAPH_R_CHECK(igraph_count_subisomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_count, 0, 0, 0)); + IGRAPH_R_CHECK(igraph_dim_select(&c_sv, &c_dim)); /* Convert output */ - PROTECT(count=NEW_INTEGER(1)); - INTEGER(count)[0]=c_count; - r_result = count; + PROTECT(dim=NEW_INTEGER(1)); + INTEGER(dim)[0]=c_dim; + r_result = dim; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_get_subisomorphisms_vf2 / +/ igraph_almost_equals / /-------------------------------------------*/ -SEXP R_igraph_get_subisomorphisms_vf2(SEXP graph1, SEXP graph2, SEXP vertex_color1, SEXP vertex_color2, SEXP edge_color1, SEXP edge_color2) { +SEXP R_igraph_almost_equals(SEXP a, SEXP b, SEXP eps) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_vector_int_t c_vertex_color1; - igraph_vector_int_t c_vertex_color2; - igraph_vector_int_t c_edge_color1; - igraph_vector_int_t c_edge_color2; - igraph_vector_ptr_t c_maps; + double c_a; + double c_b; + double c_eps; + igraph_bool_t c_result; + SEXP r_result; + /* Convert input */ + /* Call igraph */ + c_result=igraph_almost_equals(c_a, c_b, c_eps); + + /* Convert output */ + PROTECT(r_result=NEW_LOGICAL(1)); + LOGICAL(r_result)[0]=c_result; - SEXP maps; + UNPROTECT(1); + return(r_result); +} +/*-------------------------------------------/ +/ igraph_cmp_epsilon / +/-------------------------------------------*/ +SEXP R_igraph_cmp_epsilon(SEXP a, SEXP b, SEXP eps) { + /* Declarations */ + double c_a; + double c_b; + double c_eps; + int c_result; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(vertex_color1)) { R_SEXP_to_vector_int(vertex_color1, &c_vertex_color1); } - if (!Rf_isNull(vertex_color2)) { R_SEXP_to_vector_int(vertex_color2, &c_vertex_color2); } - if (!Rf_isNull(edge_color1)) { R_SEXP_to_vector_int(edge_color1, &c_edge_color1); } - if (!Rf_isNull(edge_color2)) { R_SEXP_to_vector_int(edge_color2, &c_edge_color2); } - if (0 != igraph_vector_ptr_init(&c_maps, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_maps); + /* Call igraph */ - IGRAPH_R_CHECK(igraph_get_subisomorphisms_vf2(&c_graph1, &c_graph2, (Rf_isNull(vertex_color1) ? 0 : &c_vertex_color1), (Rf_isNull(vertex_color2) ? 0 : &c_vertex_color2), (Rf_isNull(edge_color1) ? 0 : &c_edge_color1), (Rf_isNull(edge_color2) ? 0 : &c_edge_color2), &c_maps, 0, 0, 0)); + c_result=igraph_cmp_epsilon(c_a, c_b, c_eps); /* Convert output */ - PROTECT(maps=R_igraph_vectorlist_to_SEXP(&c_maps)); - R_igraph_vectorlist_destroy(&c_maps); - IGRAPH_FINALLY_CLEAN(1); - r_result = maps; + + UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_isomorphic_34 / +/ igraph_eigen_matrix / /-------------------------------------------*/ -SEXP R_igraph_isomorphic_34(SEXP graph1, SEXP graph2) { +SEXP R_igraph_eigen_matrix(SEXP A, SEXP sA, SEXP n, SEXP algorithm, SEXP which, SEXP options) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_bool_t c_iso; - SEXP iso; + igraph_matrix_t c_A; + igraph_sparsemat_t c_sA; - SEXP r_result; + int c_n; + + igraph_eigen_algorithm_t c_algorithm; + igraph_eigen_which_t c_which; + igraph_arpack_options_t c_options; + + igraph_vector_complex_t c_values; + igraph_matrix_complex_t c_vectors; + SEXP values; + SEXP vectors; + + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); + R_SEXP_to_matrix(A, &c_A); + R_SEXP_to_sparsemat(sA, &c_sA); + c_n=INTEGER(n)[0]; + c_algorithm=REAL(algorithm)[0]; + R_SEXP_to_igraph_eigen_which(which, &c_which); + R_SEXP_to_igraph_arpack_options(options, &c_options); + if (0 != igraph_vector_complex_init(&c_values, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_complex_destroy, &c_values); + values=R_GlobalEnv; /* hack to have a non-NULL value */ + if (0 != igraph_matrix_complex_init(&c_vectors, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_complex_destroy, &c_vectors); + vectors=R_GlobalEnv; /* hack to have a non-NULL value */ /* Call igraph */ - IGRAPH_R_CHECK(igraph_isomorphic_34(&c_graph1, &c_graph2, &c_iso)); + IGRAPH_R_CHECK(igraph_eigen_matrix(&c_A, &c_sA, 0, c_n, 0, c_algorithm, &c_which, &c_options, 0, (Rf_isNull(values) ? 0 : &c_values), (Rf_isNull(vectors) ? 0 : &c_vectors))); /* Convert output */ - PROTECT(iso=NEW_LOGICAL(1)); - LOGICAL(iso)[0]=c_iso; - r_result = iso; + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(values=R_igraph_0orvector_complex_to_SEXP(&c_values)); + igraph_vector_complex_destroy(&c_values); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(vectors=R_igraph_0ormatrix_complex_to_SEXP(&c_vectors)); + igraph_matrix_complex_destroy(&c_vectors); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, options); + SET_VECTOR_ELT(r_result, 1, values); + SET_VECTOR_ELT(r_result, 2, vectors); + SET_STRING_ELT(r_names, 0, Rf_mkChar("options")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("values")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("vectors")); + SET_NAMES(r_result, r_names); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_canonical_permutation / +/ igraph_eigen_matrix_symmetric / /-------------------------------------------*/ -SEXP R_igraph_canonical_permutation(SEXP graph, SEXP colors, SEXP sh) { +SEXP R_igraph_eigen_matrix_symmetric(SEXP A, SEXP sA, SEXP n, SEXP algorithm, SEXP which, SEXP options) { /* Declarations */ - igraph_t c_graph; - igraph_vector_int_t c_colors; - igraph_vector_t c_labeling; - igraph_bliss_sh_t c_sh; - igraph_bliss_info_t c_info; - SEXP labeling; - SEXP info; + igraph_matrix_t c_A; + igraph_sparsemat_t c_sA; + + int c_n; + + igraph_eigen_algorithm_t c_algorithm; + igraph_eigen_which_t c_which; + igraph_arpack_options_t c_options; + + igraph_vector_t c_values; + igraph_matrix_t c_vectors; + SEXP values; + SEXP vectors; SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { R_SEXP_to_vector_int(colors, &c_colors); } - if (0 != igraph_vector_init(&c_labeling, 0)) { + R_SEXP_to_matrix(A, &c_A); + R_SEXP_to_sparsemat(sA, &c_sA); + c_n=INTEGER(n)[0]; + c_algorithm=REAL(algorithm)[0]; + R_SEXP_to_igraph_eigen_which(which, &c_which); + R_SEXP_to_igraph_arpack_options(options, &c_options); + if (0 != igraph_vector_init(&c_values, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_labeling); - c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + IGRAPH_FINALLY(igraph_vector_destroy, &c_values); + if (0 != igraph_matrix_init(&c_vectors, 0, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_vectors); /* Call igraph */ - IGRAPH_R_CHECK(igraph_canonical_permutation(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), &c_labeling, c_sh, &c_info)); + IGRAPH_R_CHECK(igraph_eigen_matrix_symmetric(&c_A, &c_sA, 0, c_n, 0, c_algorithm, &c_which, &c_options, 0, &c_values, &c_vectors)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(labeling=R_igraph_vector_to_SEXPp1(&c_labeling)); - igraph_vector_destroy(&c_labeling); + PROTECT(r_result=NEW_LIST(3)); + PROTECT(r_names=NEW_CHARACTER(3)); + PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); + PROTECT(values=R_igraph_vector_to_SEXP(&c_values)); + igraph_vector_destroy(&c_values); IGRAPH_FINALLY_CLEAN(1); - PROTECT(info=R_igraph_bliss_info_to_SEXP(&c_info)); - if (c_info.group_size) { free(c_info.group_size); } - SET_VECTOR_ELT(r_result, 0, labeling); - SET_VECTOR_ELT(r_result, 1, info); - SET_STRING_ELT(r_names, 0, Rf_mkChar("labeling")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("info")); + PROTECT(vectors=R_igraph_matrix_to_SEXP(&c_vectors)); + igraph_matrix_destroy(&c_vectors); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, options); + SET_VECTOR_ELT(r_result, 1, values); + SET_VECTOR_ELT(r_result, 2, vectors); + SET_STRING_ELT(r_names, 0, Rf_mkChar("options")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("values")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("vectors")); SET_NAMES(r_result, r_names); - UNPROTECT(3); + UNPROTECT(4); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_permute_vertices / +/ igraph_solve_lsap / /-------------------------------------------*/ -SEXP R_igraph_permute_vertices(SEXP graph, SEXP permutation) { +SEXP R_igraph_solve_lsap(SEXP c, SEXP n) { /* Declarations */ - igraph_t c_graph; - igraph_t c_res; - igraph_vector_t c_permutation; - SEXP res; + igraph_matrix_t c_c; + igraph_integer_t c_n; + igraph_vector_int_t c_p; + SEXP p; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - R_SEXP_to_vector(permutation, &c_permutation); + R_SEXP_to_matrix(c, &c_c); + c_n=INTEGER(n)[0]; + if (0 != igraph_vector_int_init(&c_p, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_p); /* Call igraph */ - IGRAPH_R_CHECK(igraph_permute_vertices(&c_graph, &c_res, &c_permutation)); + IGRAPH_R_CHECK(igraph_solve_lsap(&c_c, c_n, &c_p)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_res); - PROTECT(res=R_igraph_to_SEXP(&c_res)); - igraph_destroy(&c_res); + PROTECT(p=R_igraph_vector_int_to_SEXP(&c_p)); + igraph_vector_int_destroy(&c_p); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = p; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_isomorphic_bliss / +/ igraph_is_eulerian / /-------------------------------------------*/ -SEXP R_igraph_isomorphic_bliss(SEXP graph1, SEXP graph2, SEXP colors1, SEXP colors2, SEXP sh) { +SEXP R_igraph_is_eulerian(SEXP graph) { /* Declarations */ - igraph_t c_graph1; - igraph_t c_graph2; - igraph_vector_int_t c_colors1; - igraph_vector_int_t c_colors2; - igraph_bool_t c_iso; - igraph_vector_t c_map12; - igraph_vector_t c_map21; - igraph_bliss_sh_t c_sh; - igraph_bliss_info_t c_info1; - igraph_bliss_info_t c_info2; - SEXP iso; - SEXP map12; - SEXP map21; - SEXP info1; - SEXP info2; + igraph_t c_graph; + igraph_bool_t c_has_path; + igraph_bool_t c_has_cycle; + SEXP has_path; + SEXP has_cycle; SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_igraph(graph1, &c_graph1); - R_SEXP_to_igraph(graph2, &c_graph2); - if (!Rf_isNull(colors1)) { R_SEXP_to_vector_int(colors1, &c_colors1); } - if (!Rf_isNull(colors2)) { R_SEXP_to_vector_int(colors2, &c_colors2); } - if (0 != igraph_vector_init(&c_map12, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_map12); - map12=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_map21, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_map21); - map21=R_GlobalEnv; /* hack to have a non-NULL value */ - c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + R_SEXP_to_igraph(graph, &c_graph); /* Call igraph */ - IGRAPH_R_CHECK(igraph_isomorphic_bliss(&c_graph1, &c_graph2, (Rf_isNull(colors1) ? 0 : &c_colors1), (Rf_isNull(colors2) ? 0 : &c_colors2), &c_iso, (Rf_isNull(map12) ? 0 : &c_map12), (Rf_isNull(map21) ? 0 : &c_map21), c_sh, &c_info1, &c_info2)); + IGRAPH_R_CHECK(igraph_is_eulerian(&c_graph, &c_has_path, &c_has_cycle)); /* Convert output */ - PROTECT(r_result=NEW_LIST(5)); - PROTECT(r_names=NEW_CHARACTER(5)); - PROTECT(iso=NEW_LOGICAL(1)); - LOGICAL(iso)[0]=c_iso; - PROTECT(map12=R_igraph_0orvector_to_SEXPp1(&c_map12)); - igraph_vector_destroy(&c_map12); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(map21=R_igraph_0orvector_to_SEXPp1(&c_map21)); - igraph_vector_destroy(&c_map21); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(info1=R_igraph_bliss_info_to_SEXP(&c_info1)); - if (c_info1.group_size) { free(c_info1.group_size); } - PROTECT(info2=R_igraph_bliss_info_to_SEXP(&c_info2)); - if (c_info2.group_size) { free(c_info2.group_size); } - SET_VECTOR_ELT(r_result, 0, iso); - SET_VECTOR_ELT(r_result, 1, map12); - SET_VECTOR_ELT(r_result, 2, map21); - SET_VECTOR_ELT(r_result, 3, info1); - SET_VECTOR_ELT(r_result, 4, info2); - SET_STRING_ELT(r_names, 0, Rf_mkChar("iso")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("map12")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("map21")); - SET_STRING_ELT(r_names, 3, Rf_mkChar("info1")); - SET_STRING_ELT(r_names, 4, Rf_mkChar("info2")); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(has_path=NEW_LOGICAL(1)); + LOGICAL(has_path)[0]=c_has_path; + PROTECT(has_cycle=NEW_LOGICAL(1)); + LOGICAL(has_cycle)[0]=c_has_cycle; + SET_VECTOR_ELT(r_result, 0, has_path); + SET_VECTOR_ELT(r_result, 1, has_cycle); + SET_STRING_ELT(r_names, 0, Rf_mkChar("has_path")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("has_cycle")); SET_NAMES(r_result, r_names); - UNPROTECT(6); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_automorphisms / +/ igraph_eulerian_path / /-------------------------------------------*/ -SEXP R_igraph_automorphisms(SEXP graph, SEXP colors, SEXP sh) { +SEXP R_igraph_eulerian_path(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_int_t c_colors; - igraph_bliss_sh_t c_sh; - igraph_bliss_info_t c_info; - SEXP info; + igraph_vector_int_t c_edge_res; + igraph_vector_int_t c_vertex_res; + SEXP edge_res; + SEXP vertex_res; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { R_SEXP_to_vector_int(colors, &c_colors); } - c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + if (0 != igraph_vector_int_init(&c_edge_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_res); + if (0 != igraph_vector_int_init(&c_vertex_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_automorphisms(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), c_sh, &c_info)); + IGRAPH_R_CHECK(igraph_eulerian_path(&c_graph, &c_edge_res, &c_vertex_res)); /* Convert output */ - PROTECT(info=R_igraph_bliss_info_to_SEXP(&c_info)); - if (c_info.group_size) { free(c_info.group_size); } - r_result = info; + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(edge_res=R_igraph_vector_int_to_SEXP(&c_edge_res)); + igraph_vector_int_destroy(&c_edge_res); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(vertex_res=R_igraph_vector_int_to_SEXP(&c_vertex_res)); + igraph_vector_int_destroy(&c_vertex_res); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, edge_res); + SET_VECTOR_ELT(r_result, 1, vertex_res); + SET_STRING_ELT(r_names, 0, Rf_mkChar("epath")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("vpath")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_automorphism_group / +/ igraph_eulerian_cycle / /-------------------------------------------*/ -SEXP R_igraph_automorphism_group(SEXP graph, SEXP colors, SEXP sh) { +SEXP R_igraph_eulerian_cycle(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_int_t c_colors; - igraph_vector_ptr_t c_generators; - igraph_bliss_sh_t c_sh; - igraph_bliss_info_t c_info; - SEXP generators; - SEXP info; + igraph_vector_int_t c_edge_res; + igraph_vector_int_t c_vertex_res; + SEXP edge_res; + SEXP vertex_res; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(colors)) { R_SEXP_to_vector_int(colors, &c_colors); } - if (0 != igraph_vector_ptr_init(&c_generators, 0)) { + if (0 != igraph_vector_int_init(&c_edge_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_generators); - c_sh = (igraph_bliss_sh_t) Rf_asInteger(sh); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_res); + if (0 != igraph_vector_int_init(&c_vertex_res, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_res); /* Call igraph */ - IGRAPH_R_CHECK(igraph_automorphism_group(&c_graph, (Rf_isNull(colors) ? 0 : &c_colors), &c_generators, c_sh, &c_info)); + IGRAPH_R_CHECK(igraph_eulerian_cycle(&c_graph, &c_edge_res, &c_vertex_res)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(generators=R_igraph_vectorlist_to_SEXP_p1(&c_generators)); - R_igraph_vectorlist_destroy(&c_generators); + PROTECT(edge_res=R_igraph_vector_int_to_SEXP(&c_edge_res)); + igraph_vector_int_destroy(&c_edge_res); IGRAPH_FINALLY_CLEAN(1); - PROTECT(info=R_igraph_bliss_info_to_SEXP(&c_info)); - if (c_info.group_size) { free(c_info.group_size); } - SET_VECTOR_ELT(r_result, 0, generators); - SET_VECTOR_ELT(r_result, 1, info); - SET_STRING_ELT(r_names, 0, Rf_mkChar("generators")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("info")); + PROTECT(vertex_res=R_igraph_vector_int_to_SEXP(&c_vertex_res)); + igraph_vector_int_destroy(&c_vertex_res); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, edge_res); + SET_VECTOR_ELT(r_result, 1, vertex_res); + SET_STRING_ELT(r_names, 0, Rf_mkChar("epath")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("vpath")); SET_NAMES(r_result, r_names); UNPROTECT(3); @@ -6611,486 +10261,435 @@ SEXP R_igraph_automorphism_group(SEXP graph, SEXP colors, SEXP sh) { } /*-------------------------------------------/ -/ igraph_simplify_and_colorize / +/ igraph_fundamental_cycles / /-------------------------------------------*/ -SEXP R_igraph_simplify_and_colorize(SEXP graph) { +SEXP R_igraph_fundamental_cycles(SEXP graph, SEXP start, SEXP bfs_cutoff, SEXP weights) { /* Declarations */ igraph_t c_graph; - igraph_t c_res; - igraph_vector_int_t c_vertex_color; - igraph_vector_int_t c_edge_color; - SEXP res; - SEXP vertex_color; - SEXP edge_color; + igraph_vector_int_list_t c_basis; + igraph_integer_t c_start; + igraph_integer_t c_bfs_cutoff; + igraph_vector_t c_weights; + SEXP basis; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_vertex_color, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_color); - if (0 != igraph_vector_int_init(&c_edge_color, 0)) { + if (0 != igraph_vector_int_list_init(&c_basis, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_edge_color); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_basis); + c_start = (igraph_integer_t) REAL(start)[0]; + c_bfs_cutoff=INTEGER(bfs_cutoff)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_simplify_and_colorize(&c_graph, &c_res, &c_vertex_color, &c_edge_color)); + IGRAPH_R_CHECK(igraph_fundamental_cycles(&c_graph, &c_basis, c_start, c_bfs_cutoff, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - IGRAPH_FINALLY(igraph_destroy, &c_res); - PROTECT(res=R_igraph_to_SEXP(&c_res)); - igraph_destroy(&c_res); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(vertex_color=R_igraph_vector_int_to_SEXP(&c_vertex_color)); - igraph_vector_int_destroy(&c_vertex_color); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(edge_color=R_igraph_vector_int_to_SEXP(&c_edge_color)); - igraph_vector_int_destroy(&c_edge_color); + PROTECT(basis=R_igraph_vector_int_list_to_SEXP(&c_basis)); + igraph_vector_int_list_destroy(&c_basis); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, vertex_color); - SET_VECTOR_ELT(r_result, 2, edge_color); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("vertex_color")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("edge_color")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = basis; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_scg_grouping / +/ igraph_minimum_cycle_basis / /-------------------------------------------*/ -SEXP R_igraph_scg_grouping(SEXP V, SEXP nt, SEXP nt_vec, SEXP mtype, SEXP algo, SEXP p, SEXP maxiter) { +SEXP R_igraph_minimum_cycle_basis(SEXP graph, SEXP bfs_cutoff, SEXP complete, SEXP use_cycle_order, SEXP weights) { /* Declarations */ - igraph_matrix_t c_V; - igraph_vector_t c_groups; - igraph_integer_t c_nt; - igraph_vector_t c_nt_vec; - igraph_scg_matrix_t c_mtype; - igraph_scg_algorithm_t c_algo; - igraph_vector_t c_p; - igraph_integer_t c_maxiter; - SEXP groups; + igraph_t c_graph; + igraph_vector_int_list_t c_basis; + igraph_integer_t c_bfs_cutoff; + igraph_bool_t c_complete; + igraph_bool_t c_use_cycle_order; + igraph_vector_t c_weights; + SEXP basis; SEXP r_result; /* Convert input */ - R_SEXP_to_matrix(V, &c_V); - if (0 != igraph_vector_init(&c_groups, 0)) { + R_SEXP_to_igraph(graph, &c_graph); + if (0 != igraph_vector_int_list_init(&c_basis, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_groups); - c_nt=INTEGER(nt)[0]; - if (!Rf_isNull(nt_vec)) { R_SEXP_to_vector(nt_vec, &c_nt_vec); } - c_mtype = (igraph_scg_matrix_t) Rf_asInteger(mtype); - c_algo = (igraph_scg_algorithm_t) Rf_asInteger(algo); - if (!Rf_isNull(p)) { R_SEXP_to_vector(p, &c_p); } - c_maxiter=INTEGER(maxiter)[0]; + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_basis); + c_bfs_cutoff=INTEGER(bfs_cutoff)[0]; + c_complete=LOGICAL(complete)[0]; + c_use_cycle_order=LOGICAL(use_cycle_order)[0]; + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } /* Call igraph */ - IGRAPH_R_CHECK(igraph_scg_grouping(&c_V, &c_groups, c_nt, (Rf_isNull(nt_vec) ? 0 : &c_nt_vec), c_mtype, c_algo, (Rf_isNull(p) ? 0 : &c_p), c_maxiter)); + IGRAPH_R_CHECK(igraph_minimum_cycle_basis(&c_graph, &c_basis, c_bfs_cutoff, c_complete, c_use_cycle_order, (Rf_isNull(weights) ? 0 : &c_weights))); /* Convert output */ - PROTECT(groups=R_igraph_vector_to_SEXPp1(&c_groups)); - igraph_vector_destroy(&c_groups); + PROTECT(basis=R_igraph_vector_int_list_to_SEXP(&c_basis)); + igraph_vector_int_list_destroy(&c_basis); IGRAPH_FINALLY_CLEAN(1); - r_result = groups; + r_result = basis; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_scg_norm_eps / +/ igraph_is_tree / /-------------------------------------------*/ -SEXP R_igraph_scg_norm_eps(SEXP V, SEXP groups, SEXP mtype, SEXP p, SEXP norm) { +SEXP R_igraph_is_tree(SEXP graph, SEXP mode) { /* Declarations */ - igraph_matrix_t c_V; - igraph_vector_t c_groups; - igraph_vector_t c_eps; - igraph_scg_matrix_t c_mtype; - igraph_vector_t c_p; - igraph_scg_norm_t c_norm; - SEXP eps; + igraph_t c_graph; + igraph_bool_t c_res; + igraph_integer_t c_root; + igraph_neimode_t c_mode; + SEXP res; + SEXP root; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ - R_SEXP_to_matrix(V, &c_V); - R_SEXP_to_vector(groups, &c_groups); - if (0 != igraph_vector_init(&c_eps, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_eps); - c_mtype = (igraph_scg_matrix_t) Rf_asInteger(mtype); - if (!Rf_isNull(p)) { R_SEXP_to_vector(p, &c_p); } - c_norm = (igraph_scg_norm_t) Rf_asInteger(norm); + R_SEXP_to_igraph(graph, &c_graph); + c_root = -1; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_scg_norm_eps(&c_V, &c_groups, &c_eps, c_mtype, (Rf_isNull(p) ? 0 : &c_p), c_norm)); + IGRAPH_R_CHECK(igraph_is_tree(&c_graph, &c_res, &c_root, c_mode)); /* Convert output */ - PROTECT(eps=R_igraph_vector_to_SEXP(&c_eps)); - igraph_vector_destroy(&c_eps); - IGRAPH_FINALLY_CLEAN(1); - r_result = eps; + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(res=NEW_LOGICAL(1)); + LOGICAL(res)[0]=c_res; + PROTECT(root = NEW_INTEGER(1)); + INTEGER(root)[0] = c_root + 1; + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, root); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("root")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_matching / +/ igraph_is_forest / /-------------------------------------------*/ -SEXP R_igraph_is_matching(SEXP graph, SEXP types, SEXP matching) { +SEXP R_igraph_is_forest(SEXP graph, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_vector_long_t c_matching; igraph_bool_t c_res; + igraph_vector_int_t c_roots; + igraph_neimode_t c_mode; SEXP res; + SEXP roots; - SEXP r_result; + SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - R_SEXP_to_vector_long_copy(matching, &c_matching); + if (0 != igraph_vector_int_init(&c_roots, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_roots); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_matching(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_matching, &c_res)); + IGRAPH_R_CHECK(igraph_is_forest(&c_graph, &c_res, &c_roots, c_mode)); /* Convert output */ - igraph_vector_long_destroy(&c_matching); + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); PROTECT(res=NEW_LOGICAL(1)); LOGICAL(res)[0]=c_res; - r_result = res; + PROTECT(roots=R_igraph_vector_int_to_SEXP(&c_roots)); + igraph_vector_int_destroy(&c_roots); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, res); + SET_VECTOR_ELT(r_result, 1, roots); + SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("roots")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_maximal_matching / +/ igraph_from_prufer / /-------------------------------------------*/ -SEXP R_igraph_is_maximal_matching(SEXP graph, SEXP types, SEXP matching) { +SEXP R_igraph_from_prufer(SEXP prufer) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_vector_long_t c_matching; - igraph_bool_t c_res; - SEXP res; + igraph_vector_int_t c_prufer; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - R_SEXP_to_vector_long_copy(matching, &c_matching); + R_SEXP_to_vector_int(prufer, &c_prufer); /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_maximal_matching(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_matching, &c_res)); + IGRAPH_R_CHECK(igraph_from_prufer(&c_graph, &c_prufer)); /* Convert output */ - igraph_vector_long_destroy(&c_matching); - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; - r_result = res; + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_maximum_bipartite_matching / +/ igraph_to_prufer / /-------------------------------------------*/ -SEXP R_igraph_maximum_bipartite_matching(SEXP graph, SEXP types, SEXP weights, SEXP eps) { +SEXP R_igraph_to_prufer(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_vector_bool_t c_types; - igraph_integer_t c_matching_size; - igraph_real_t c_matching_weight; - igraph_vector_long_t c_matching; - igraph_vector_t c_weights; - igraph_real_t c_eps; - SEXP matching_size; - SEXP matching_weight; - SEXP matching; + igraph_vector_int_t c_prufer; + SEXP prufer; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - c_matching_size=0; - if (0 != igraph_vector_long_init(&c_matching, 0)) { + if (0 != igraph_vector_int_init(&c_prufer, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_long_destroy, &c_matching); - if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - c_eps=REAL(eps)[0]; + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_prufer); /* Call igraph */ - IGRAPH_R_CHECK(igraph_maximum_bipartite_matching(&c_graph, (Rf_isNull(types) ? 0 : &c_types), &c_matching_size, &c_matching_weight, &c_matching, (Rf_isNull(weights) ? 0 : &c_weights), c_eps)); + IGRAPH_R_CHECK(igraph_to_prufer(&c_graph, &c_prufer)); /* Convert output */ - PROTECT(r_result=NEW_LIST(3)); - PROTECT(r_names=NEW_CHARACTER(3)); - PROTECT(matching_size=NEW_INTEGER(1)); - INTEGER(matching_size)[0]=c_matching_size; - PROTECT(matching_weight=NEW_NUMERIC(1)); - REAL(matching_weight)[0]=c_matching_weight; - PROTECT(matching=R_igraph_vector_long_to_SEXPp1(&c_matching)); - igraph_vector_long_destroy(&c_matching); + PROTECT(prufer=R_igraph_vector_int_to_SEXP(&c_prufer)); + igraph_vector_int_destroy(&c_prufer); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, matching_size); - SET_VECTOR_ELT(r_result, 1, matching_weight); - SET_VECTOR_ELT(r_result, 2, matching); - SET_STRING_ELT(r_names, 0, Rf_mkChar("matching_size")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("matching_weight")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("matching")); - SET_NAMES(r_result, r_names); - UNPROTECT(4); + r_result = prufer; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_eigen_adjacency / +/ igraph_tree_from_parent_vector / /-------------------------------------------*/ -SEXP R_igraph_eigen_adjacency(SEXP graph, SEXP algorithm, SEXP which, SEXP options) { +SEXP R_igraph_tree_from_parent_vector(SEXP parents, SEXP type) { /* Declarations */ igraph_t c_graph; - igraph_eigen_algorithm_t c_algorithm; - igraph_eigen_which_t c_which; - igraph_arpack_options_t c_options; + igraph_vector_int_t c_parents; + igraph_tree_mode_t c_type; + SEXP graph; - igraph_vector_t c_values; - igraph_matrix_t c_vectors; - igraph_vector_complex_t c_cmplxvalues; - igraph_matrix_complex_t c_cmplxvectors; - SEXP values; - SEXP vectors; - SEXP cmplxvalues; - SEXP cmplxvectors; + SEXP r_result; + /* Convert input */ + R_SEXP_to_vector_int(parents, &c_parents); + c_type = (igraph_tree_mode_t) Rf_asInteger(type); + /* Call igraph */ + IGRAPH_R_CHECK(igraph_tree_from_parent_vector(&c_graph, &c_parents, c_type)); - SEXP r_result, r_names; + /* Convert output */ + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_random_spanning_tree / +/-------------------------------------------*/ +SEXP R_igraph_random_spanning_tree(SEXP graph, SEXP vid) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_int_t c_res; + igraph_integer_t c_vid; + SEXP res; + + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_algorithm=REAL(algorithm)[0]; - R_SEXP_to_igraph_eigen_which(which, &c_which); - R_SEXP_to_igraph_arpack_options(options, &c_options); - if (0 != igraph_vector_init(&c_values, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_values); - if (0 != igraph_matrix_init(&c_vectors, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_vectors); - if (0 != igraph_vector_complex_init(&c_cmplxvalues, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_complex_destroy, &c_cmplxvalues); - cmplxvalues=R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_matrix_complex_init(&c_cmplxvectors, 0, 0)) { + if (0 != igraph_vector_int_init(&c_res, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_complex_destroy, &c_cmplxvectors); - cmplxvectors=R_GlobalEnv; /* hack to have a non-NULL value */ + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_res); + c_vid = (igraph_integer_t) REAL(vid)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_eigen_adjacency(&c_graph, c_algorithm, &c_which, &c_options, 0, &c_values, &c_vectors, (Rf_isNull(cmplxvalues) ? 0 : &c_cmplxvalues), (Rf_isNull(cmplxvectors) ? 0 : &c_cmplxvectors))); + IGRAPH_R_CHECK(igraph_random_spanning_tree(&c_graph, &c_res, c_vid)); /* Convert output */ - PROTECT(r_result=NEW_LIST(5)); - PROTECT(r_names=NEW_CHARACTER(5)); - PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); - PROTECT(values=R_igraph_vector_to_SEXP(&c_values)); - igraph_vector_destroy(&c_values); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(vectors=R_igraph_matrix_to_SEXP(&c_vectors)); - igraph_matrix_destroy(&c_vectors); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(cmplxvalues=R_igraph_0orvector_complex_to_SEXP(&c_cmplxvalues)); - igraph_vector_complex_destroy(&c_cmplxvalues); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(cmplxvectors=R_igraph_0ormatrix_complex_to_SEXP(&c_cmplxvectors)); - igraph_matrix_complex_destroy(&c_cmplxvectors); + PROTECT(res=R_igraph_vector_int_to_SEXP(&c_res)); + igraph_vector_int_destroy(&c_res); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, options); - SET_VECTOR_ELT(r_result, 1, values); - SET_VECTOR_ELT(r_result, 2, vectors); - SET_VECTOR_ELT(r_result, 3, cmplxvalues); - SET_VECTOR_ELT(r_result, 4, cmplxvectors); - SET_STRING_ELT(r_names, 0, Rf_mkChar("options")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("values")); - SET_STRING_ELT(r_names, 2, Rf_mkChar("vectors")); - SET_STRING_ELT(r_names, 3, Rf_mkChar("cmplxvalues")); - SET_STRING_ELT(r_names, 4, Rf_mkChar("cmplxvectors")); - SET_NAMES(r_result, r_names); - UNPROTECT(6); + r_result = res; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_power_law_fit / +/ igraph_tree_game / /-------------------------------------------*/ -SEXP R_igraph_power_law_fit(SEXP data, SEXP xmin, SEXP force_continuous) { +SEXP R_igraph_tree_game(SEXP n, SEXP directed, SEXP method) { /* Declarations */ - igraph_vector_t c_data; - igraph_plfit_result_t c_res; - igraph_real_t c_xmin; - igraph_bool_t c_force_continuous; - SEXP res; + igraph_t c_graph; + igraph_integer_t c_n; + igraph_bool_t c_directed; + igraph_random_tree_t c_method; + SEXP graph; SEXP r_result; /* Convert input */ - R_SEXP_to_vector(data, &c_data); - c_xmin=REAL(xmin)[0]; - c_force_continuous=LOGICAL(force_continuous)[0]; + c_n=INTEGER(n)[0]; + c_directed=LOGICAL(directed)[0]; + c_method = (igraph_random_tree_t) Rf_asInteger(method); /* Call igraph */ - IGRAPH_R_CHECK(igraph_power_law_fit(&c_data, &c_res, c_xmin, c_force_continuous)); + IGRAPH_R_CHECK(igraph_tree_game(&c_graph, c_n, c_directed, c_method)); /* Convert output */ - PROTECT(res=R_igraph_plfit_result_to_SEXP(&c_res)); - r_result = res; + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + r_result = graph; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_sir / +/ igraph_vertex_coloring_greedy / /-------------------------------------------*/ -SEXP R_igraph_sir(SEXP graph, SEXP beta, SEXP gamma, SEXP no_sim) { +SEXP R_igraph_vertex_coloring_greedy(SEXP graph, SEXP heuristic) { /* Declarations */ igraph_t c_graph; - igraph_real_t c_beta; - igraph_real_t c_gamma; - igraph_integer_t c_no_sim; - igraph_vector_ptr_t c_res; - SEXP res; + igraph_vector_int_t c_colors; + igraph_coloring_greedy_t c_heuristic; + SEXP colors; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - c_beta=REAL(beta)[0]; - c_gamma=REAL(gamma)[0]; - c_no_sim=INTEGER(no_sim)[0]; - if (0 != igraph_vector_ptr_init(&c_res, 0)) { + if (0 != igraph_vector_int_init(&c_colors, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_sirlist_destroy, &c_res); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); + c_heuristic = (igraph_coloring_greedy_t) Rf_asInteger(heuristic); /* Call igraph */ - IGRAPH_R_CHECK(igraph_sir(&c_graph, c_beta, c_gamma, c_no_sim, &c_res)); + IGRAPH_R_CHECK(igraph_vertex_coloring_greedy(&c_graph, &c_colors, c_heuristic)); /* Convert output */ - PROTECT(res=R_igraph_sirlist_to_SEXP(&c_res)); - R_igraph_sirlist_destroy(&c_res); + PROTECT(colors=R_igraph_vector_int_to_SEXP(&c_colors)); + igraph_vector_int_destroy(&c_colors); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = colors; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_convex_hull / +/ igraph_deterministic_optimal_imitation / /-------------------------------------------*/ -SEXP R_igraph_convex_hull(SEXP data) { +SEXP R_igraph_deterministic_optimal_imitation(SEXP graph, SEXP vid, SEXP optimality, SEXP quantities, SEXP strategies, SEXP mode) { /* Declarations */ - igraph_matrix_t c_data; - igraph_vector_t c_resverts; - igraph_matrix_t c_rescoords; - SEXP resverts; - SEXP rescoords; + igraph_t c_graph; + igraph_integer_t c_vid; + igraph_optimal_t c_optimality; + igraph_vector_t c_quantities; + igraph_vector_int_t c_strategies; + igraph_neimode_t c_mode; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ - R_SEXP_to_matrix(data, &c_data); - if (0 != igraph_vector_init(&c_resverts, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_resverts); - if (0 != igraph_matrix_init(&c_rescoords, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_rescoords); + R_SEXP_to_igraph(graph, &c_graph); + c_vid = (igraph_integer_t) REAL(vid)[0]; + c_optimality = (igraph_optimal_t) Rf_asInteger(optimality); + R_SEXP_to_vector(quantities, &c_quantities); + R_SEXP_to_vector_int(strategies, &c_strategies); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_convex_hull(&c_data, &c_resverts, &c_rescoords)); + IGRAPH_R_CHECK(igraph_deterministic_optimal_imitation(&c_graph, c_vid, c_optimality, &c_quantities, &c_strategies, c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(resverts=R_igraph_vector_to_SEXPp1(&c_resverts)); - igraph_vector_destroy(&c_resverts); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(rescoords=R_igraph_matrix_to_SEXP(&c_rescoords)); - igraph_matrix_destroy(&c_rescoords); + PROTECT(strategies=R_igraph_vector_int_to_SEXP(&c_strategies)); + igraph_vector_int_destroy(&c_strategies); IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, resverts); - SET_VECTOR_ELT(r_result, 1, rescoords); - SET_STRING_ELT(r_names, 0, Rf_mkChar("resverts")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("rescoords")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = strategies; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_dim_select / +/ igraph_stochastic_imitation / /-------------------------------------------*/ -SEXP R_igraph_dim_select(SEXP sv) { +SEXP R_igraph_stochastic_imitation(SEXP graph, SEXP vid, SEXP algo, SEXP quantities, SEXP strategies, SEXP mode) { /* Declarations */ - igraph_vector_t c_sv; - igraph_integer_t c_dim; - SEXP dim; + igraph_t c_graph; + igraph_integer_t c_vid; + igraph_imitate_algorithm_t c_algo; + igraph_vector_t c_quantities; + igraph_vector_int_t c_strategies; + igraph_neimode_t c_mode; SEXP r_result; /* Convert input */ - R_SEXP_to_vector(sv, &c_sv); - c_dim=0; + R_SEXP_to_igraph(graph, &c_graph); + c_vid = (igraph_integer_t) REAL(vid)[0]; + c_algo = (igraph_imitate_algorithm_t) Rf_asInteger(algo); + R_SEXP_to_vector(quantities, &c_quantities); + R_SEXP_to_vector_int(strategies, &c_strategies); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_dim_select(&c_sv, &c_dim)); + IGRAPH_R_CHECK(igraph_stochastic_imitation(&c_graph, c_vid, c_algo, &c_quantities, &c_strategies, c_mode)); /* Convert output */ - PROTECT(dim=NEW_INTEGER(1)); - INTEGER(dim)[0]=c_dim; - r_result = dim; + PROTECT(strategies=R_igraph_vector_int_to_SEXP(&c_strategies)); + igraph_vector_int_destroy(&c_strategies); + IGRAPH_FINALLY_CLEAN(1); + r_result = strategies; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_eulerian / +/ igraph_moran_process / /-------------------------------------------*/ -SEXP R_igraph_is_eulerian(SEXP graph) { +SEXP R_igraph_moran_process(SEXP graph, SEXP weights, SEXP quantities, SEXP strategies, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_bool_t c_has_path; - igraph_bool_t c_has_cycle; - SEXP has_path; - SEXP has_cycle; + igraph_vector_t c_weights; + igraph_vector_t c_quantities; + igraph_vector_int_t c_strategies; + igraph_neimode_t c_mode; SEXP r_result, r_names; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); + if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } + if (0 != R_SEXP_to_vector_copy(quantities, &c_quantities)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &c_quantities); + R_SEXP_to_vector_int(strategies, &c_strategies); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_eulerian(&c_graph, &c_has_path, &c_has_cycle)); + IGRAPH_R_CHECK(igraph_moran_process(&c_graph, (Rf_isNull(weights) ? 0 : &c_weights), &c_quantities, &c_strategies, c_mode)); /* Convert output */ PROTECT(r_result=NEW_LIST(2)); PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(has_path=NEW_LOGICAL(1)); - LOGICAL(has_path)[0]=c_has_path; - PROTECT(has_cycle=NEW_LOGICAL(1)); - LOGICAL(has_cycle)[0]=c_has_cycle; - SET_VECTOR_ELT(r_result, 0, has_path); - SET_VECTOR_ELT(r_result, 1, has_cycle); - SET_STRING_ELT(r_names, 0, Rf_mkChar("has_path")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("has_cycle")); + PROTECT(quantities=R_igraph_vector_to_SEXP(&c_quantities)); + igraph_vector_destroy(&c_quantities); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(strategies=R_igraph_vector_int_to_SEXP(&c_strategies)); + igraph_vector_int_destroy(&c_strategies); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, quantities); + SET_VECTOR_ELT(r_result, 1, strategies); + SET_STRING_ELT(r_names, 0, Rf_mkChar("quantities")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("strategies")); SET_NAMES(r_result, r_names); UNPROTECT(3); @@ -7099,240 +10698,163 @@ SEXP R_igraph_is_eulerian(SEXP graph) { } /*-------------------------------------------/ -/ igraph_eulerian_path / +/ igraph_roulette_wheel_imitation / /-------------------------------------------*/ -SEXP R_igraph_eulerian_path(SEXP graph) { +SEXP R_igraph_roulette_wheel_imitation(SEXP graph, SEXP vid, SEXP is_local, SEXP quantities, SEXP strategies, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_t c_edge_res; - igraph_vector_t c_vertex_res; - SEXP edge_res; - SEXP vertex_res; + igraph_integer_t c_vid; + igraph_bool_t c_is_local; + igraph_vector_t c_quantities; + igraph_vector_int_t c_strategies; + igraph_neimode_t c_mode; - SEXP r_result, r_names; + SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_edge_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_edge_res); - if (0 != igraph_vector_init(&c_vertex_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_vertex_res); + c_vid = (igraph_integer_t) REAL(vid)[0]; + c_is_local=LOGICAL(is_local)[0]; + R_SEXP_to_vector(quantities, &c_quantities); + R_SEXP_to_vector_int(strategies, &c_strategies); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_eulerian_path(&c_graph, &c_edge_res, &c_vertex_res)); + IGRAPH_R_CHECK(igraph_roulette_wheel_imitation(&c_graph, c_vid, c_is_local, &c_quantities, &c_strategies, c_mode)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(edge_res=R_igraph_vector_to_SEXPp1(&c_edge_res)); - igraph_vector_destroy(&c_edge_res); + PROTECT(strategies=R_igraph_vector_int_to_SEXP(&c_strategies)); + igraph_vector_int_destroy(&c_strategies); IGRAPH_FINALLY_CLEAN(1); - PROTECT(vertex_res=R_igraph_vector_to_SEXPp1(&c_vertex_res)); - igraph_vector_destroy(&c_vertex_res); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, edge_res); - SET_VECTOR_ELT(r_result, 1, vertex_res); - SET_STRING_ELT(r_names, 0, Rf_mkChar("epath")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("vpath")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + r_result = strategies; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_eulerian_cycle / +/ igraph_has_attribute_table / /-------------------------------------------*/ -SEXP R_igraph_eulerian_cycle(SEXP graph) { +SEXP R_igraph_has_attribute_table() { /* Declarations */ - igraph_t c_graph; - igraph_vector_t c_edge_res; - igraph_vector_t c_vertex_res; - SEXP edge_res; - SEXP vertex_res; - - SEXP r_result, r_names; + igraph_bool_t c_result; + SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_edge_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_edge_res); - if (0 != igraph_vector_init(&c_vertex_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_vertex_res); + /* Call igraph */ - IGRAPH_R_CHECK(igraph_eulerian_cycle(&c_graph, &c_edge_res, &c_vertex_res)); + c_result=igraph_has_attribute_table(); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(edge_res=R_igraph_vector_to_SEXPp1(&c_edge_res)); - igraph_vector_destroy(&c_edge_res); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(vertex_res=R_igraph_vector_to_SEXPp1(&c_vertex_res)); - igraph_vector_destroy(&c_vertex_res); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(r_result, 0, edge_res); - SET_VECTOR_ELT(r_result, 1, vertex_res); - SET_STRING_ELT(r_names, 0, Rf_mkChar("epath")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("vpath")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + + PROTECT(r_result=NEW_LOGICAL(1)); + LOGICAL(r_result)[0]=c_result; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_is_tree / +/ igraph_progress / /-------------------------------------------*/ -SEXP R_igraph_is_tree(SEXP graph, SEXP mode) { +SEXP R_igraph_progress(SEXP message, SEXP percent) { /* Declarations */ - igraph_t c_graph; - igraph_bool_t c_res; - igraph_integer_t c_root; - igraph_neimode_t c_mode; - SEXP res; - SEXP root; + const char* c_message; + igraph_real_t c_percent; - SEXP r_result, r_names; + int c_result; + SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - c_root = -1; - c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_percent=REAL(percent)[0]; /* Call igraph */ - IGRAPH_R_CHECK(igraph_is_tree(&c_graph, &c_res, &c_root, c_mode)); + IGRAPH_R_CHECK(igraph_progress(c_message, c_percent, 0)); /* Convert output */ - PROTECT(r_result=NEW_LIST(2)); - PROTECT(r_names=NEW_CHARACTER(2)); - PROTECT(res=NEW_LOGICAL(1)); - LOGICAL(res)[0]=c_res; - PROTECT(root = NEW_INTEGER(1)); - INTEGER(root)[0] = c_root + 1; - SET_VECTOR_ELT(r_result, 0, res); - SET_VECTOR_ELT(r_result, 1, root); - SET_STRING_ELT(r_names, 0, Rf_mkChar("res")); - SET_STRING_ELT(r_names, 1, Rf_mkChar("root")); - SET_NAMES(r_result, r_names); - UNPROTECT(3); + + UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_from_prufer / +/ igraph_status / /-------------------------------------------*/ -SEXP R_igraph_from_prufer(SEXP prufer) { +SEXP R_igraph_status(SEXP message) { /* Declarations */ - igraph_t c_graph; - igraph_vector_int_t c_prufer; - SEXP graph; + const char* c_message; + int c_result; SEXP r_result; /* Convert input */ - R_SEXP_to_vector_int(prufer, &c_prufer); + /* Call igraph */ - IGRAPH_R_CHECK(igraph_from_prufer(&c_graph, &c_prufer)); + IGRAPH_R_CHECK(igraph_status(c_message, 0)); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); - PROTECT(graph=R_igraph_to_SEXP(&c_graph)); - igraph_destroy(&c_graph); - IGRAPH_FINALLY_CLEAN(1); - r_result = graph; + + UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_to_prufer / +/ igraph_strerror / /-------------------------------------------*/ -SEXP R_igraph_to_prufer(SEXP graph) { +SEXP R_igraph_strerror(SEXP igraph_errno) { /* Declarations */ - igraph_t c_graph; - igraph_vector_int_t c_prufer; - SEXP prufer; - + int c_igraph_errno; + const char* c_result; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_prufer, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_prufer); + /* Call igraph */ - IGRAPH_R_CHECK(igraph_to_prufer(&c_graph, &c_prufer)); + c_result=igraph_strerror(c_igraph_errno); /* Convert output */ - PROTECT(prufer=R_igraph_vector_int_to_SEXP(&c_prufer)); - igraph_vector_int_destroy(&c_prufer); - IGRAPH_FINALLY_CLEAN(1); - r_result = prufer; + + UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_random_spanning_tree / +/ igraph_expand_path_to_pairs / /-------------------------------------------*/ -SEXP R_igraph_random_spanning_tree(SEXP graph, SEXP vid) { +SEXP R_igraph_expand_path_to_pairs(SEXP path) { /* Declarations */ - igraph_t c_graph; - igraph_vector_t c_res; - igraph_integer_t c_vid; - SEXP res; + igraph_vector_int_t c_path; SEXP r_result; /* Convert input */ - R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_init(&c_res, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &c_res); - c_vid = (igraph_integer_t) REAL(vid)[0]; + R_SEXP_to_vector_int(path, &c_path); /* Call igraph */ - IGRAPH_R_CHECK(igraph_random_spanning_tree(&c_graph, &c_res, c_vid)); + IGRAPH_R_CHECK(igraph_expand_path_to_pairs(&c_path)); /* Convert output */ - PROTECT(res=R_igraph_vector_to_SEXPp1(&c_res)); - igraph_vector_destroy(&c_res); + PROTECT(path=R_igraph_vector_int_to_SEXP(&c_path)); + igraph_vector_int_destroy(&c_path); IGRAPH_FINALLY_CLEAN(1); - r_result = res; + r_result = path; UNPROTECT(1); return(r_result); } /*-------------------------------------------/ -/ igraph_tree_game / +/ igraph_invalidate_cache / /-------------------------------------------*/ -SEXP R_igraph_tree_game(SEXP n, SEXP directed, SEXP method) { +SEXP R_igraph_invalidate_cache(SEXP graph) { /* Declarations */ igraph_t c_graph; - igraph_integer_t c_n; - igraph_bool_t c_directed; - igraph_random_tree_t c_method; - SEXP graph; SEXP r_result; /* Convert input */ - c_n=INTEGER(n)[0]; - c_directed=LOGICAL(directed)[0]; - c_method = (igraph_random_tree_t) Rf_asInteger(method); + R_SEXP_to_igraph_copy(graph, &c_graph); + IGRAPH_FINALLY(igraph_destroy, &c_graph); /* Call igraph */ - IGRAPH_R_CHECK(igraph_tree_game(&c_graph, c_n, c_directed, c_method)); + igraph_invalidate_cache(&c_graph); /* Convert output */ - IGRAPH_FINALLY(igraph_destroy, &c_graph); PROTECT(graph=R_igraph_to_SEXP(&c_graph)); igraph_destroy(&c_graph); IGRAPH_FINALLY_CLEAN(1); @@ -7343,31 +10865,73 @@ SEXP R_igraph_tree_game(SEXP n, SEXP directed, SEXP method) { } /*-------------------------------------------/ -/ igraph_vertex_coloring_greedy / +/ igraph_vertex_path_from_edge_path / /-------------------------------------------*/ -SEXP R_igraph_vertex_coloring_greedy(SEXP graph, SEXP heuristic) { +SEXP R_igraph_vertex_path_from_edge_path(SEXP graph, SEXP start, SEXP edge_path, SEXP mode) { /* Declarations */ igraph_t c_graph; - igraph_vector_int_t c_colors; - igraph_coloring_greedy_t c_heuristic; - SEXP colors; + igraph_integer_t c_start; + igraph_vector_int_t c_edge_path; + igraph_vector_int_t c_vertex_path; + igraph_neimode_t c_mode; + SEXP vertex_path; SEXP r_result; /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_int_init(&c_colors, 0)) { + c_start = (igraph_integer_t) REAL(start)[0]; + R_SEXP_to_vector_int(edge_path, &c_edge_path); + if (0 != igraph_vector_int_init(&c_vertex_path, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_int_destroy, &c_colors); - c_heuristic = (igraph_coloring_greedy_t) Rf_asInteger(heuristic); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_vertex_path); + c_mode = (igraph_neimode_t) Rf_asInteger(mode); /* Call igraph */ - IGRAPH_R_CHECK(igraph_vertex_coloring_greedy(&c_graph, &c_colors, c_heuristic)); + IGRAPH_R_CHECK(igraph_vertex_path_from_edge_path(&c_graph, c_start, &c_edge_path, &c_vertex_path, c_mode)); /* Convert output */ - PROTECT(colors=R_igraph_vector_int_to_SEXP(&c_colors)); - igraph_vector_int_destroy(&c_colors); + PROTECT(vertex_path=R_igraph_vector_int_to_SEXP(&c_vertex_path)); + igraph_vector_int_destroy(&c_vertex_path); IGRAPH_FINALLY_CLEAN(1); - r_result = colors; + r_result = vertex_path; + + UNPROTECT(1); + return(r_result); +} + +/*-------------------------------------------/ +/ igraph_version / +/-------------------------------------------*/ +SEXP R_igraph_version() { + /* Declarations */ + const char* c_version_string; + int c_major; + int c_minor; + int c_subminor; + SEXP version_string; + SEXP major; + SEXP minor; + SEXP subminor; + + SEXP r_result, r_names; + /* Convert input */ + + /* Call igraph */ + igraph_version(&c_version_string, &c_major, &c_minor, &c_subminor); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(4)); + PROTECT(r_names=NEW_CHARACTER(4)); + SET_VECTOR_ELT(r_result, 0, version_string); + SET_VECTOR_ELT(r_result, 1, major); + SET_VECTOR_ELT(r_result, 2, minor); + SET_VECTOR_ELT(r_result, 3, subminor); + SET_STRING_ELT(r_names, 0, Rf_mkChar("version_string")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("major")); + SET_STRING_ELT(r_names, 2, Rf_mkChar("minor")); + SET_STRING_ELT(r_names, 3, Rf_mkChar("subminor")); + SET_NAMES(r_result, r_names); + UNPROTECT(5); UNPROTECT(1); return(r_result); diff --git a/src/rinterface_extra.c b/src/rinterface_extra.c index 867aee65387..40c607944fe 100644 --- a/src/rinterface_extra.c +++ b/src/rinterface_extra.c @@ -22,7 +22,7 @@ */ #include "igraph.h" -#include "graph/neighbors.h" +#include "igraph_neighborhood.h" #include "config.h" @@ -55,26 +55,23 @@ SEXP R_igraph_vector_to_SEXP(const igraph_vector_t *v); SEXP R_igraph_vector_int_to_SEXP(const igraph_vector_int_t *v); SEXP R_igraph_vector_int_to_SEXPp1(const igraph_vector_int_t *v); SEXP R_igraph_vector_bool_to_SEXP(const igraph_vector_bool_t *v); -SEXP R_igraph_vector_long_to_SEXP(const igraph_vector_long_t *v); SEXP R_igraph_vector_complex_to_SEXP(const igraph_vector_complex_t* v); SEXP R_igraph_0orvector_to_SEXP(const igraph_vector_t *v); SEXP R_igraph_0orvector_bool_to_SEXP(const igraph_vector_bool_t *v); -SEXP R_igraph_0orvector_long_to_SEXP(const igraph_vector_long_t *v); SEXP R_igraph_0orvector_complex_to_SEXP(const igraph_vector_complex_t *v); SEXP R_igraph_matrix_to_SEXP(const igraph_matrix_t *m); +SEXP R_igraph_matrix_int_to_SEXP(const igraph_matrix_int_t *m); SEXP R_igraph_matrix_complex_to_SEXP(const igraph_matrix_complex_t *m); SEXP R_igraph_0ormatrix_complex_to_SEXP(const igraph_matrix_complex_t *m); SEXP R_igraph_strvector_to_SEXP(const igraph_strvector_t *m); SEXP R_igraph_to_SEXP(const igraph_t *graph); -SEXP R_igraph_vectorlist_to_SEXP(const igraph_vector_ptr_t *ptr); -SEXP R_igraph_vectorlist_int_to_SEXP(const igraph_vector_ptr_t *ptr); -void R_igraph_vectorlist_int_destroy(igraph_vector_ptr_t *ptr); -SEXP R_igraph_0orvectorlist_to_SEXP(const igraph_vector_ptr_t *ptr); +SEXP R_igraph_vectorlist_to_SEXP(const igraph_vector_list_t *list); +SEXP R_igraph_vector_int_list_to_SEXP(const igraph_vector_int_list_t *list); +SEXP R_igraph_0orvector_int_list_to_SEXP(const igraph_vector_int_list_t *list); void R_igraph_vectorlist_destroy(igraph_vector_ptr_t *ptr); SEXP R_igraph_matrixlist_to_SEXP(const igraph_vector_ptr_t *ptr); void R_igraph_matrixlist_destroy(igraph_vector_ptr_t *ptr); -SEXP R_igraph_graphlist_to_SEXP(const igraph_vector_ptr_t *ptr); -void R_igraph_graphlist_destroy(igraph_vector_ptr_t *ptr); +SEXP R_igraph_graphlist_to_SEXP(const igraph_graph_list_t *list); SEXP R_igraph_hrg_to_SEXP(const igraph_hrg_t *hrg); SEXP R_igraph_plfit_result_to_SEXP(const igraph_plfit_result_t *plfit); SEXP R_igraph_sparsemat_to_SEXP(const igraph_sparsemat_t *sp); @@ -87,7 +84,9 @@ int R_igraph_SEXP_to_strvector(SEXP rval, igraph_strvector_t *sv); int R_igraph_SEXP_to_strvector_copy(SEXP rval, igraph_strvector_t *sv); int R_SEXP_to_vector(SEXP sv, igraph_vector_t *v); int R_SEXP_to_vector_copy(SEXP sv, igraph_vector_t *v); +int R_SEXP_to_vector_int_copy(SEXP sv, igraph_vector_int_t *v); int R_SEXP_to_matrix(SEXP pakl, igraph_matrix_t *akl); +int R_SEXP_to_matrix_int(SEXP pakl, igraph_matrix_int_t *akl); int R_SEXP_to_matrix_complex(SEXP pakl, igraph_matrix_complex_t *akl); int R_SEXP_to_igraph_matrix_copy(SEXP pakl, igraph_matrix_t *akl); int R_SEXP_to_igraph(SEXP graph, igraph_t *res); @@ -95,16 +94,15 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res); int R_SEXP_to_igraph_vs(SEXP rit, igraph_t *graph, igraph_vs_t *it); int R_SEXP_to_igraph_es(SEXP rit, igraph_t *graph, igraph_es_t *it); int R_SEXP_to_igraph_adjlist(SEXP vectorlist, igraph_adjlist_t *ptr); -int R_igraph_SEXP_to_0orvectorlist(SEXP vectorlist, - igraph_vector_ptr_t *ptr); -int R_igraph_SEXP_to_vectorlist(SEXP vectorlist, igraph_vector_ptr_t *ptr); -int R_igraph_SEXP_to_vectorlist_int(SEXP vectorlist, - igraph_vector_ptr_t *ptr); -int R_igraph_SEXP_to_matrixlist(SEXP matrixlist, igraph_vector_ptr_t *ptr); +int R_igraph_SEXP_to_0orvector_int_list(SEXP vectorlist, + igraph_vector_int_list_t *list); +int R_igraph_SEXP_to_vectorlist(SEXP vectorlist, igraph_vector_list_t *list); +int R_igraph_SEXP_to_vector_int_list(SEXP vectorlist, + igraph_vector_int_list_t *list); +int R_igraph_SEXP_to_matrixlist(SEXP matrixlist, igraph_matrix_list_t *list); int R_SEXP_to_vector_bool(SEXP sv, igraph_vector_bool_t *v); int R_SEXP_to_vector_bool_copy(SEXP sv, igraph_vector_bool_t *v); int R_SEXP_to_vector_int(SEXP sv, igraph_vector_int_t *v); -int R_SEXP_to_vector_long_copy(SEXP sv, igraph_vector_long_t *v); int R_SEXP_to_hrg(SEXP shrg, igraph_hrg_t *hrg); int R_SEXP_to_hrg_copy(SEXP shrg, igraph_hrg_t *hrg); int R_SEXP_to_sparsemat(SEXP pakl, igraph_sparsemat_t *akl); @@ -114,11 +112,11 @@ int R_SEXP_to_attr_comb(SEXP input, igraph_attribute_combination_t *comb); SEXP R_igraph_bliss_info_to_SEXP(const igraph_bliss_info_t *info); int R_SEXP_to_igraph_eigen_which(SEXP in, igraph_eigen_which_t *out); int R_SEXP_to_igraph_arpack_options(SEXP in, igraph_arpack_options_t *opt); -SEXP R_igraph_vector_long_to_SEXPp1(const igraph_vector_long_t *v); -SEXP R_igraph_vectorlist_to_SEXP_p1(const igraph_vector_ptr_t *ptr); -SEXP R_igraph_0orvector_to_SEXPp1(const igraph_vector_t *v); -SEXP R_igraph_0ormatrix_to_SEXP(const igraph_matrix_t *m); +SEXP R_igraph_vector_int_list_to_SEXP_p1(const igraph_vector_int_list_t *list); +SEXP R_igraph_0orvector_int_to_SEXPp1(const igraph_vector_int_t *v); +SEXP R_igraph_0ormatrix_int_to_SEXP(const igraph_matrix_int_t *m); SEXP R_igraph_vector_to_SEXPp1(const igraph_vector_t *v); +SEXP R_igraph_vector_int_to_SEXPp1(const igraph_vector_int_t *v); SEXP R_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt); @@ -318,7 +316,7 @@ void R_igraph_attribute_protected_destroy(void *dummy) { R_igraph_attribute_protected_size=0; } -int R_igraph_attribute_init(igraph_t *graph, igraph_vector_ptr_t *attr) { +igraph_error_t R_igraph_attribute_init(igraph_t *graph, igraph_vector_ptr_t *attr) { SEXP result, names, gal; long int i; long int attrno; @@ -392,12 +390,11 @@ int R_igraph_attribute_init(igraph_t *graph, igraph_vector_ptr_t *attr) { SET_STRING_ELT(VECTOR_ELT(gal,i), 0, Rf_mkChar(STR(*strvec, 0))); } break; - case IGRAPH_ATTRIBUTE_R_OBJECT: + case IGRAPH_ATTRIBUTE_OBJECT: UNPROTECT(px); IGRAPH_ERROR("R_objects not implemented yet", IGRAPH_UNIMPLEMENTED); break; case IGRAPH_ATTRIBUTE_DEFAULT: - case IGRAPH_ATTRIBUTE_PY_OBJECT: default: UNPROTECT(px); IGRAPH_ERROR("Unknown attribute type, this should not happen", @@ -428,7 +425,7 @@ void R_igraph_attribute_destroy(igraph_t *graph) { 2) the not-copied attributes will be set up by subsequent calls to permute_vertices and/or permute/edges anyway. */ -int R_igraph_attribute_copy(igraph_t *to, const igraph_t *from, +igraph_error_t R_igraph_attribute_copy(igraph_t *to, const igraph_t *from, igraph_bool_t ga, igraph_bool_t va, igraph_bool_t ea) { SEXP fromattr=from->attr; if (ga && va && ea) { @@ -471,7 +468,7 @@ SEXP R_igraph_attribute_add_vertices_append1(igraph_vector_ptr_t *nattr, case IGRAPH_ATTRIBUTE_STRING: len = igraph_strvector_size(tmprec->value); break; - case IGRAPH_ATTRIBUTE_R_OBJECT: + case IGRAPH_ATTRIBUTE_OBJECT: igraph_error("R objects not implemented yet", __FILE__, __LINE__, IGRAPH_UNIMPLEMENTED); return R_NilValue; @@ -592,7 +589,7 @@ SEXP R_igraph_attribute_add_vertices_dup(SEXP attr) { return newattr; } -int R_igraph_attribute_add_vertices(igraph_t *graph, long int nv, +igraph_error_t R_igraph_attribute_add_vertices(igraph_t *graph, igraph_integer_t nv, igraph_vector_ptr_t *nattr) { SEXP attr=graph->attr; SEXP val, rep=0, names, newnames; @@ -733,11 +730,11 @@ int R_igraph_attribute_add_vertices(igraph_t *graph, long int nv, int R_igraph_attribute_permute_vertices_same(const igraph_t *graph, igraph_t *newgraph, - const igraph_vector_t *idx) { + const igraph_vector_int_t *idx) { SEXP attr=newgraph->attr; SEXP val; long int i, valno; - long int idxlen=igraph_vector_size(idx); + long int idxlen=igraph_vector_int_size(idx); SEXP ss; int px = 0; @@ -784,7 +781,7 @@ int R_igraph_attribute_permute_vertices_same(const igraph_t *graph, /* Convert idx to an R object, we will use this for indexing */ PROTECT(ss=NEW_INTEGER(idxlen)); px++; for (i=0; iattr; SEXP toattr=newgraph->attr; SEXP val, toval; SEXP names; long int i, valno; - long int idxlen=igraph_vector_size(idx); + long int idxlen=igraph_vector_int_size(idx); SEXP ss; int px = 0; @@ -824,7 +821,7 @@ int R_igraph_attribute_permute_vertices_diff(const igraph_t *graph, /* Convert idx to an R object, we will use this for indexing */ PROTECT(ss=NEW_INTEGER(idxlen)); px++; for (i=0; ivalue); break; - case IGRAPH_ATTRIBUTE_R_OBJECT: + case IGRAPH_ATTRIBUTE_OBJECT: igraph_error("R objects not implemented yet", __FILE__, __LINE__, IGRAPH_UNIMPLEMENTED); return R_NilValue; @@ -948,11 +945,11 @@ SEXP R_igraph_attribute_add_edges_append1(igraph_vector_ptr_t *nattr, int j, } void R_igraph_attribute_add_edges_append(SEXP eal, - const igraph_vector_t *edges, + const igraph_vector_int_t *edges, igraph_vector_ptr_t *nattr) { SEXP names; long int ealno, i; - long int ne=igraph_vector_size(edges)/2, nattrno; + long int ne=igraph_vector_int_size(edges)/2, nattrno; SEXP rep = R_NilValue; int px = 0; @@ -997,14 +994,14 @@ void R_igraph_attribute_add_edges_append(SEXP eal, UNPROTECT(px); } -int R_igraph_attribute_add_edges(igraph_t *graph, - const igraph_vector_t *edges, +igraph_error_t R_igraph_attribute_add_edges(igraph_t *graph, + const igraph_vector_int_t *edges, igraph_vector_ptr_t *nattr) { SEXP attr=graph->attr; SEXP eal, names, newnames; igraph_vector_t news; long int ealno, i, origlen, nattrno, newattrs; - long int ne=igraph_vector_size(edges)/2; + long int ne=igraph_vector_int_size(edges)/2; int px = 0; if (igraph_vector_init(&news, 0)) Rf_error("Out of memory"); @@ -1116,12 +1113,12 @@ int R_igraph_attribute_add_edges(igraph_t *graph, int R_igraph_attribute_permute_edges_same(const igraph_t *graph, igraph_t *newgraph, - const igraph_vector_t *idx) { + const igraph_vector_int_t *idx) { SEXP attr=newgraph->attr; SEXP eal; long int i, ealno; - long int idxlen=igraph_vector_size(idx); + long int idxlen=igraph_vector_int_size(idx); SEXP ss; int px = 0; @@ -1168,7 +1165,7 @@ int R_igraph_attribute_permute_edges_same(const igraph_t *graph, /* Convert idx to an R object, we will use this for indexing */ PROTECT(ss=NEW_INTEGER(idxlen)); px++; for (i=0; iattr; SEXP toattr=newgraph->attr; SEXP eal, toeal; SEXP names; long int i, ealno; - long int idxlen=igraph_vector_size(idx); + long int idxlen=igraph_vector_int_size(idx); SEXP ss; eal=VECTOR_ELT(attr,3); @@ -1208,7 +1205,7 @@ int R_igraph_attribute_permute_edges_diff(const igraph_t *graph, /* Convert idx to an R object, we will use this for indexing */ PROTECT(ss=NEW_INTEGER(idxlen)); for (i=0; iattr; for (i=0; i<3; i++) { igraph_strvector_t *n=names[i]; - igraph_vector_t *t=types[i]; + igraph_vector_int_t *t=types[i]; SEXP al=VECTOR_ELT(attr, i+1); if (n) { /* return names */ @@ -1267,17 +1264,17 @@ int R_igraph_attribute_get_info(const igraph_t *graph, } if (t) { /* return types */ - igraph_vector_resize(t, GET_LENGTH(al)); + igraph_vector_int_resize(t, GET_LENGTH(al)); for (j=0; jattr, 1); @@ -1369,7 +1366,7 @@ int R_igraph_attribute_get_numeric_graph_attr(const igraph_t *graph, return 0; } -int R_igraph_attribute_get_bool_graph_attr(const igraph_t *graph, +igraph_error_t R_igraph_attribute_get_bool_graph_attr(const igraph_t *graph, const char *name, igraph_vector_bool_t *value) { SEXP gal=VECTOR_ELT(graph->attr, 1); @@ -1388,7 +1385,7 @@ int R_igraph_attribute_get_bool_graph_attr(const igraph_t *graph, return 0; } -int R_igraph_attribute_get_string_graph_attr(const igraph_t *graph, +igraph_error_t R_igraph_attribute_get_string_graph_attr(const igraph_t *graph, const char *name, igraph_strvector_t *value) { /* TODO: serialization */ @@ -1408,7 +1405,7 @@ int R_igraph_attribute_get_string_graph_attr(const igraph_t *graph, return 0; } -int R_igraph_attribute_get_numeric_vertex_attr(const igraph_t *graph, +igraph_error_t R_igraph_attribute_get_numeric_vertex_attr(const igraph_t *graph, const char *name, igraph_vs_t vs, igraph_vector_t *value) { @@ -1456,7 +1453,7 @@ int R_igraph_attribute_get_numeric_vertex_attr(const igraph_t *graph, return 0; } -int R_igraph_attribute_get_bool_vertex_attr(const igraph_t *graph, +igraph_error_t R_igraph_attribute_get_bool_vertex_attr(const igraph_t *graph, const char *name, igraph_vs_t vs, igraph_vector_bool_t *value) { @@ -1495,7 +1492,7 @@ int R_igraph_attribute_get_bool_vertex_attr(const igraph_t *graph, return 0; } -int R_igraph_attribute_get_string_vertex_attr(const igraph_t *graph, +igraph_error_t R_igraph_attribute_get_string_vertex_attr(const igraph_t *graph, const char *name, igraph_vs_t vs, igraph_strvector_t *value) { @@ -1533,7 +1530,7 @@ int R_igraph_attribute_get_string_vertex_attr(const igraph_t *graph, return 0; } -int R_igraph_attribute_get_numeric_edge_attr(const igraph_t *graph, +igraph_error_t R_igraph_attribute_get_numeric_edge_attr(const igraph_t *graph, const char *name, igraph_es_t es, igraph_vector_t *value) { @@ -1581,7 +1578,7 @@ int R_igraph_attribute_get_numeric_edge_attr(const igraph_t *graph, return 0; } -int R_igraph_attribute_get_bool_edge_attr(const igraph_t *graph, +igraph_error_t R_igraph_attribute_get_bool_edge_attr(const igraph_t *graph, const char *name, igraph_es_t es, igraph_vector_bool_t *value) { @@ -1620,7 +1617,7 @@ int R_igraph_attribute_get_bool_edge_attr(const igraph_t *graph, return 0; } -int R_igraph_attribute_get_string_edge_attr(const igraph_t *graph, +igraph_error_t R_igraph_attribute_get_string_edge_attr(const igraph_t *graph, const char *name, igraph_es_t es, igraph_strvector_t *value) { @@ -1658,20 +1655,20 @@ int R_igraph_attribute_get_string_edge_attr(const igraph_t *graph, } SEXP R_igraph_ac_sum_numeric(SEXP attr, - const igraph_vector_ptr_t *merges) { + const igraph_vector_int_list_t *merges) { SEXP res; SEXP attr2; - long int i, len=igraph_vector_ptr_size(merges); + long int i, len=igraph_vector_int_list_size(merges); PROTECT(attr2=AS_NUMERIC(attr)); PROTECT(res=NEW_NUMERIC(len)); for (i=0; i 0 ? REAL(attr2)[(long) VECTOR(*v)[0] ] : NA_REAL; + igraph_vector_int_t *v=igraph_vector_int_list_get_ptr(merges, i); + long int j, n=igraph_vector_int_size(v); + igraph_real_t m= n > 0 ? REAL(attr2)[igraph_vector_int_get(v, 0) ] : NA_REAL; for (j=1; j 0 ? REAL(attr2)[(long) VECTOR(*v)[0] ] : NA_REAL; + igraph_vector_int_t *v=igraph_vector_int_list_get_ptr(merges, i); + long int j, n=igraph_vector_int_size(v); + igraph_real_t m= n > 0 ? REAL(attr2)[igraph_vector_int_get(v, 0)] : NA_REAL; for (j=1; j m) { m=val; @@ -1760,10 +1757,10 @@ SEXP R_igraph_ac_max_numeric(SEXP attr, } SEXP R_igraph_ac_random_numeric(SEXP attr, - const igraph_vector_ptr_t *merges) { + const igraph_vector_int_list_t *merges) { SEXP res; SEXP attr2; - long int i, len=igraph_vector_ptr_size(merges); + long int i, len=igraph_vector_int_list_size(merges); PROTECT(attr2=AS_NUMERIC(attr)); PROTECT(res=NEW_NUMERIC(len)); @@ -1771,15 +1768,15 @@ SEXP R_igraph_ac_random_numeric(SEXP attr, RNG_BEGIN(); for (i=0; i0 ? 0.0 : NA_REAL; for (j=0; j0) { s=s/n; } @@ -1861,26 +1858,26 @@ SEXP R_igraph_ac_mean_numeric(SEXP attr, } SEXP R_igraph_ac_median_numeric(SEXP attr, - const igraph_vector_ptr_t *merges) { + const igraph_vector_int_list_t *merges) { SEXP res; SEXP attr2; - long int i, len=igraph_vector_ptr_size(merges); + long int i, len=igraph_vector_int_list_size(merges); PROTECT(attr2=AS_NUMERIC(attr)); PROTECT(res=NEW_NUMERIC(len)); for (i=0; iattr; @@ -2173,9 +2170,9 @@ int R_igraph_attribute_combine_vertices(const igraph_t *graph, return 0; } -int R_igraph_attribute_combine_edges(const igraph_t *graph, +igraph_error_t R_igraph_attribute_combine_edges(const igraph_t *graph, igraph_t *newgraph, - const igraph_vector_ptr_t *merges, + const igraph_vector_int_list_t *merges, const igraph_attribute_combination_t *comb) { SEXP attr=graph->attr; @@ -2439,7 +2436,7 @@ void R_igraph_fatal_handler(const char *reason, const char *file, int line) { } void R_igraph_error_handler(const char *reason, const char *file, - int line, int igraph_errno) { + int line, igraph_error_t igraph_errno) { /* We are not supposed to touch 'reason' after we have called * IGRAPH_FINALLY_FREE() because 'reason' might be allocated on the heap and @@ -2464,8 +2461,7 @@ void R_igraph_error_handler(const char *reason, const char *file, IGRAPH_FINALLY_FREE(); } -void R_igraph_warning_handler(const char *reason, const char *file, - int line, int igraph_errno) { +void R_igraph_warning_handler(const char *reason, const char *file, int line) { if (R_igraph_warnings_count == 0) { snprintf(R_igraph_warning_reason, sizeof(R_igraph_warning_reason), "At %s:%i : %s%s", file, line, reason, maybe_add_punctuation(reason, ".")); @@ -2481,7 +2477,7 @@ void checkInterruptFn(void *dummy) { R_CheckUserInterrupt(); } -int R_igraph_interrupt_handler(void *data) { +igraph_error_t R_igraph_interrupt_handler(void *data) { /* We need to call R_CheckUserInterrupt() regularly to enable interruptions. * However, if an interruption is pending, R_CheckUserInterrupt() will * longjmp back to the top level so we cannot clean up ourselves by calling @@ -2502,7 +2498,7 @@ int R_igraph_interrupt_handler(void *data) { return IGRAPH_SUCCESS; } -int R_igraph_progress_handler(const char *message, igraph_real_t percent, +igraph_error_t R_igraph_progress_handler(const char *message, igraph_real_t percent, void * data) { SEXP ec; int ecint; @@ -2521,7 +2517,7 @@ int R_igraph_progress_handler(const char *message, igraph_real_t percent, return ecint; } -int R_igraph_status_handler(const char *message, void *data) { +igraph_error_t R_igraph_status_handler(const char *message, void *data) { SEXP l4 = PROTECT(Rf_install(".igraph.status")); SEXP l5 = PROTECT(Rf_ScalarString(Rf_mkChar(message))); SEXP l6 = PROTECT(Rf_lang2(l4, l5)); @@ -2615,7 +2611,18 @@ SEXP R_igraph_vector_int_to_SEXPp1(const igraph_vector_int_t *v) { PROTECT(result=NEW_INTEGER(n)); for (i=0; idirected; - memcpy(REAL(VECTOR_ELT(result, 2)), graph->from.stor_begin, - sizeof(igraph_real_t)*(size_t) no_of_edges); - memcpy(REAL(VECTOR_ELT(result, 3)), graph->to.stor_begin, - sizeof(igraph_real_t)*(size_t) no_of_edges); - memcpy(REAL(VECTOR_ELT(result, 4)), graph->oi.stor_begin, - sizeof(igraph_real_t)*(size_t) no_of_edges); - memcpy(REAL(VECTOR_ELT(result, 5)), graph->ii.stor_begin, - sizeof(igraph_real_t)*(size_t) no_of_edges); - memcpy(REAL(VECTOR_ELT(result, 6)), graph->os.stor_begin, - sizeof(igraph_real_t)*(size_t) (no_of_nodes+1)); - memcpy(REAL(VECTOR_ELT(result, 7)), graph->is.stor_begin, - sizeof(igraph_real_t)*(size_t) (no_of_nodes+1)); + memcpy(INTEGER(VECTOR_ELT(result, 2)), graph->from.stor_begin, + sizeof(igraph_integer_t)*(size_t) no_of_edges); + memcpy(INTEGER(VECTOR_ELT(result, 3)), graph->to.stor_begin, + sizeof(igraph_integer_t)*(size_t) no_of_edges); + memcpy(INTEGER(VECTOR_ELT(result, 4)), graph->oi.stor_begin, + sizeof(igraph_integer_t)*(size_t) no_of_edges); + memcpy(INTEGER(VECTOR_ELT(result, 5)), graph->ii.stor_begin, + sizeof(igraph_integer_t)*(size_t) no_of_edges); + memcpy(INTEGER(VECTOR_ELT(result, 6)), graph->os.stor_begin, + sizeof(igraph_integer_t)*(size_t) (no_of_nodes+1)); + memcpy(INTEGER(VECTOR_ELT(result, 7)), graph->is.stor_begin, + sizeof(igraph_integer_t)*(size_t) (no_of_nodes+1)); SET_CLASS(result, Rf_ScalarString(Rf_mkChar("igraph"))); @@ -2883,13 +2862,13 @@ SEXP R_igraph_to_SEXP(const igraph_t *graph) { return result; } -SEXP R_igraph_vectorlist_to_SEXP(const igraph_vector_ptr_t *ptr) { +SEXP R_igraph_vectorlist_to_SEXP(const igraph_vector_list_t *list) { SEXP result; - long int i, n=igraph_vector_ptr_size(ptr); + long int i, n=igraph_vector_list_size(list); PROTECT(result=NEW_LIST(n)); for (i=0; ileft)); - SET_VECTOR_ELT(result, 1, R_igraph_vector_to_SEXP(&hrg->right)); + SET_VECTOR_ELT(result, 0, R_igraph_vector_int_to_SEXP(&hrg->left)); + SET_VECTOR_ELT(result, 1, R_igraph_vector_int_to_SEXP(&hrg->right)); SET_VECTOR_ELT(result, 2, R_igraph_vector_to_SEXP(&hrg->prob)); - SET_VECTOR_ELT(result, 3, R_igraph_vector_to_SEXP(&hrg->edges)); - SET_VECTOR_ELT(result, 4, R_igraph_vector_to_SEXP(&hrg->vertices)); + SET_VECTOR_ELT(result, 3, R_igraph_vector_int_to_SEXP(&hrg->edges)); + SET_VECTOR_ELT(result, 4, R_igraph_vector_int_to_SEXP(&hrg->vertices)); PROTECT(names=NEW_CHARACTER(5)); SET_STRING_ELT(names, 0, Rf_mkChar("left")); @@ -3060,20 +3017,20 @@ SEXP R_igraph_hrg_to_SEXP(const igraph_hrg_t *hrg) { } int R_SEXP_to_hrg(SEXP shrg, igraph_hrg_t *hrg) { - R_SEXP_to_vector(VECTOR_ELT(shrg, 0), &hrg->left); - R_SEXP_to_vector(VECTOR_ELT(shrg, 1), &hrg->right); + R_SEXP_to_vector_int(VECTOR_ELT(shrg, 0), &hrg->left); + R_SEXP_to_vector_int(VECTOR_ELT(shrg, 1), &hrg->right); R_SEXP_to_vector(VECTOR_ELT(shrg, 2), &hrg->prob); - R_SEXP_to_vector(VECTOR_ELT(shrg, 3), &hrg->edges); - R_SEXP_to_vector(VECTOR_ELT(shrg, 4), &hrg->vertices); + R_SEXP_to_vector_int(VECTOR_ELT(shrg, 3), &hrg->edges); + R_SEXP_to_vector_int(VECTOR_ELT(shrg, 4), &hrg->vertices); return 0; } int R_SEXP_to_hrg_copy(SEXP shrg, igraph_hrg_t *hrg) { - R_SEXP_to_vector_copy(VECTOR_ELT(shrg, 0), &hrg->left); - R_SEXP_to_vector_copy(VECTOR_ELT(shrg, 1), &hrg->right); + R_SEXP_to_vector_int_copy(VECTOR_ELT(shrg, 0), &hrg->left); + R_SEXP_to_vector_int_copy(VECTOR_ELT(shrg, 1), &hrg->right); R_SEXP_to_vector_copy(VECTOR_ELT(shrg, 2), &hrg->prob); - R_SEXP_to_vector_copy(VECTOR_ELT(shrg, 3), &hrg->edges); - R_SEXP_to_vector_copy(VECTOR_ELT(shrg, 4), &hrg->vertices); + R_SEXP_to_vector_int_copy(VECTOR_ELT(shrg, 3), &hrg->edges); + R_SEXP_to_vector_int_copy(VECTOR_ELT(shrg, 4), &hrg->vertices); return 0; } @@ -3086,7 +3043,8 @@ SEXP R_igraph_plfit_result_to_SEXP(const igraph_plfit_result_t *plfit) { SET_VECTOR_ELT(result, 2, Rf_ScalarReal(plfit->xmin)); SET_VECTOR_ELT(result, 3, Rf_ScalarReal(plfit->L)); SET_VECTOR_ELT(result, 4, Rf_ScalarReal(plfit->D)); - SET_VECTOR_ELT(result, 5, Rf_ScalarReal(plfit->p)); + //TODO: fixme + //SET_VECTOR_ELT(result, 5, Rf_ScalarReal(plfit->p)); PROTECT(names=NEW_CHARACTER(6)); SET_STRING_ELT(names, 0, Rf_mkChar("continuous")); @@ -3123,6 +3081,91 @@ SEXP R_igraph_maxflow_stats_to_SEXP(const igraph_maxflow_stats_t *st) { return result; } +SEXP R_igraph_incidence(SEXP incidence, SEXP directed, SEXP mode, SEXP multiple) { + /* Declarations */ + igraph_t c_graph; + igraph_vector_bool_t c_types; + igraph_matrix_t c_incidence; + igraph_bool_t c_directed; + igraph_neimode_t c_mode; + igraph_bool_t c_multiple; + SEXP graph; + SEXP types; + + SEXP r_result, r_names; + /* Convert input */ + if (0 != igraph_vector_bool_init(&c_types, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_bool_destroy, &c_types); + R_SEXP_to_matrix(incidence, &c_incidence); + c_directed=LOGICAL(directed)[0]; + c_mode = (igraph_neimode_t) Rf_asInteger(mode); + c_multiple=LOGICAL(multiple)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_incidence(&c_graph, &c_types, &c_incidence, c_directed, c_mode, c_multiple)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + IGRAPH_FINALLY(igraph_destroy, &c_graph); + PROTECT(graph=R_igraph_to_SEXP(&c_graph)); + igraph_destroy(&c_graph); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(types=R_igraph_vector_bool_to_SEXP(&c_types)); + igraph_vector_bool_destroy(&c_types); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, graph); + SET_VECTOR_ELT(r_result, 1, types); + SET_STRING_ELT(r_names, 0, Rf_mkChar("graph")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("types")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + +SEXP R_igraph_arpack_unpack_complex(SEXP vectors, SEXP values, SEXP nev) { + /* Declarations */ + igraph_matrix_t c_vectors; + igraph_matrix_t c_values; + igraph_integer_t c_nev; + + SEXP r_result, r_names; + /* Convert input */ + if (0 != R_SEXP_to_igraph_matrix_copy(vectors, &c_vectors)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_vectors); + if (0 != R_SEXP_to_igraph_matrix_copy(values, &c_values)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_matrix_destroy, &c_values); + c_nev=INTEGER(nev)[0]; + /* Call igraph */ + IGRAPH_R_CHECK(igraph_arpack_unpack_complex(&c_vectors, &c_values, c_nev)); + + /* Convert output */ + PROTECT(r_result=NEW_LIST(2)); + PROTECT(r_names=NEW_CHARACTER(2)); + PROTECT(vectors=R_igraph_matrix_to_SEXP(&c_vectors)); + igraph_matrix_destroy(&c_vectors); + IGRAPH_FINALLY_CLEAN(1); + PROTECT(values=R_igraph_matrix_to_SEXP(&c_values)); + igraph_matrix_destroy(&c_values); + IGRAPH_FINALLY_CLEAN(1); + SET_VECTOR_ELT(r_result, 0, vectors); + SET_VECTOR_ELT(r_result, 1, values); + SET_STRING_ELT(r_names, 0, Rf_mkChar("vectors")); + SET_STRING_ELT(r_names, 1, Rf_mkChar("values")); + SET_NAMES(r_result, r_names); + UNPROTECT(3); + + UNPROTECT(1); + return(r_result); +} + SEXP R_igraph_sirlist_to_SEXP(const igraph_vector_ptr_t *sl) { SEXP result, names; int i, n=igraph_vector_ptr_size(sl); @@ -3278,67 +3321,61 @@ int R_SEXP_to_igraph_adjlist(SEXP vectorlist, igraph_adjlist_t *ptr) { return 0; } -int R_igraph_SEXP_to_0orvectorlist(SEXP vectorlist, - igraph_vector_ptr_t *ptr) { +int R_igraph_SEXP_to_0orvector_int_list(SEXP vectorlist, + igraph_vector_int_list_t *list) { if (!Rf_isNull(vectorlist)) { - return R_igraph_SEXP_to_vectorlist(vectorlist, ptr); + return R_igraph_SEXP_to_vector_int_list(vectorlist, list); } return 0; } -int R_igraph_SEXP_to_vectorlist(SEXP vectorlist, igraph_vector_ptr_t *ptr) { +int R_igraph_SEXP_to_vectorlist(SEXP vectorlist, igraph_vector_list_t *list) { int length=GET_LENGTH(vectorlist); int i; igraph_vector_t *vecs; - igraph_vector_t **vecsptr; vecs = (igraph_vector_t *) R_alloc((size_t) length, sizeof(igraph_vector_t)); - vecsptr = (igraph_vector_t **) R_alloc((size_t) length, - sizeof(igraph_vector_t*)); - igraph_vector_ptr_view(ptr, (void**) vecsptr, length); + list->stor_begin=vecs; + list->stor_end=list->stor_begin+length; + list->end=list->stor_end; for (i=0; istor_begin=vecs; + list->stor_end=list->stor_begin+length; + list->end=list->stor_end; for (i=0; istor_begin=vecs; + list->stor_end=list->stor_begin+length; + list->end=list->stor_end; for (i=0; ilen=GET_LENGTH(rval); - sv->data=(char**) R_alloc((size_t) (sv->len), sizeof(char*)); - for (i=0; ilen; i++) { - sv->data[i]=(char*) CHAR(STRING_ELT(rval, i)); + sv->stor_begin=(char**) R_alloc((size_t) length, sizeof(char*)); + sv->stor_end=sv->stor_begin+length; + sv->end=sv->stor_end; + for (i=0; istor_begin[i]=(char*) CHAR(STRING_ELT(rval, i)); } return 0; @@ -3360,7 +3399,7 @@ int R_igraph_SEXP_to_strvector(SEXP rval, igraph_strvector_t *sv) { int R_igraph_SEXP_to_strvector_copy(SEXP rval, igraph_strvector_t *sv) { long int i; igraph_strvector_init(sv, GET_LENGTH(rval)); - for (i=0; ilen; i++) { + for (i=0; idata); + akl->nrow=INTEGER(GET_DIM(pakl))[0]; + akl->ncol=INTEGER(GET_DIM(pakl))[1]; + return 0; } -int R_SEXP_to_matrix(SEXP pakl, igraph_matrix_t *akl) { - R_SEXP_to_vector(pakl, &akl->data); +int R_SEXP_to_matrix_int(SEXP pakl, igraph_matrix_int_t *akl) { + R_SEXP_to_vector_int(pakl, &akl->data); akl->nrow=INTEGER(GET_DIM(pakl))[0]; akl->ncol=INTEGER(GET_DIM(pakl))[1]; @@ -3421,7 +3462,7 @@ int R_SEXP_to_matrix(SEXP pakl, igraph_matrix_t *akl) { } int R_SEXP_to_igraph_matrix_copy(SEXP pakl, igraph_matrix_t *akl) { - igraph_vector_init_copy(&akl->data, REAL(pakl), GET_LENGTH(pakl)); + igraph_vector_init_array(&akl->data, REAL(pakl), GET_LENGTH(pakl)); akl->nrow=INTEGER(GET_DIM(pakl))[0]; akl->ncol=INTEGER(GET_DIM(pakl))[1]; @@ -3436,7 +3477,7 @@ int R_SEXP_to_vector_complex(SEXP pv, igraph_vector_complex_t *v) { } int R_SEXP_to_vector_complex_copy(SEXP pv, igraph_vector_complex_t *v) { - igraph_vector_complex_init_copy(v, (igraph_complex_t*) COMPLEX(pv), + igraph_vector_complex_init_array(v, (igraph_complex_t*) COMPLEX(pv), GET_LENGTH(pv)); return 0; } @@ -3449,7 +3490,7 @@ int R_SEXP_to_matrix_complex(SEXP pakl, igraph_matrix_complex_t *akl) { } int R_SEXP_to_matrix_complex_copy(SEXP pakl, igraph_matrix_complex_t *akl) { - igraph_vector_complex_init_copy(&akl->data, + igraph_vector_complex_init_array(&akl->data, (igraph_complex_t*) COMPLEX(pakl), GET_LENGTH(pakl)); akl->nrow=INTEGER(GET_DIM(pakl))[0]; @@ -3468,7 +3509,7 @@ int R_igraph_SEXP_to_array3(SEXP rval, igraph_array3_t *a) { } int R_igraph_SEXP_to_array3_copy(SEXP rval, igraph_array3_t *a) { - igraph_vector_init_copy(&a->data, REAL(rval), GET_LENGTH(rval)); + igraph_vector_init_array(&a->data, REAL(rval), GET_LENGTH(rval)); a->n1=INTEGER(GET_DIM(rval))[0]; a->n2=INTEGER(GET_DIM(rval))[1]; a->n3=INTEGER(GET_DIM(rval))[2]; @@ -3481,12 +3522,12 @@ int R_SEXP_to_igraph(SEXP graph, igraph_t *res) { res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, 0))[0]; res->directed=LOGICAL(VECTOR_ELT(graph, 1))[0]; - R_SEXP_to_vector(VECTOR_ELT(graph, 2), &res->from); - R_SEXP_to_vector(VECTOR_ELT(graph, 3), &res->to); - R_SEXP_to_vector(VECTOR_ELT(graph, 4), &res->oi); - R_SEXP_to_vector(VECTOR_ELT(graph, 5), &res->ii); - R_SEXP_to_vector(VECTOR_ELT(graph, 6), &res->os); - R_SEXP_to_vector(VECTOR_ELT(graph, 7), &res->is); + R_SEXP_to_vector_int(VECTOR_ELT(graph, 2), &res->from); + R_SEXP_to_vector_int(VECTOR_ELT(graph, 3), &res->to); + R_SEXP_to_vector_int(VECTOR_ELT(graph, 4), &res->oi); + R_SEXP_to_vector_int(VECTOR_ELT(graph, 5), &res->ii); + R_SEXP_to_vector_int(VECTOR_ELT(graph, 6), &res->os); + R_SEXP_to_vector_int(VECTOR_ELT(graph, 7), &res->is); /* attributes */ REAL(VECTOR_ELT(VECTOR_ELT(graph, 8), 0))[0] = 1; /* R objects refcount */ @@ -3500,17 +3541,17 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, 0))[0]; res->directed=LOGICAL(VECTOR_ELT(graph, 1))[0]; - igraph_vector_init_copy(&res->from, REAL(VECTOR_ELT(graph, 2)), + igraph_vector_int_init_array(&res->from, INTEGER(VECTOR_ELT(graph, 2)), GET_LENGTH(VECTOR_ELT(graph, 2))); - igraph_vector_init_copy(&res->to, REAL(VECTOR_ELT(graph, 3)), + igraph_vector_int_init_array(&res->to, INTEGER(VECTOR_ELT(graph, 3)), GET_LENGTH(VECTOR_ELT(graph, 3))); - igraph_vector_init_copy(&res->oi, REAL(VECTOR_ELT(graph, 4)), + igraph_vector_int_init_array(&res->oi, INTEGER(VECTOR_ELT(graph, 4)), GET_LENGTH(VECTOR_ELT(graph, 4))); - igraph_vector_init_copy(&res->ii, REAL(VECTOR_ELT(graph, 5)), + igraph_vector_int_init_array(&res->ii, INTEGER(VECTOR_ELT(graph, 5)), GET_LENGTH(VECTOR_ELT(graph, 5))); - igraph_vector_init_copy(&res->os, REAL(VECTOR_ELT(graph, 6)), + igraph_vector_int_init_array(&res->os, INTEGER(VECTOR_ELT(graph, 6)), GET_LENGTH(VECTOR_ELT(graph, 6))); - igraph_vector_init_copy(&res->is, REAL(VECTOR_ELT(graph, 7)), + igraph_vector_int_init_array(&res->is, INTEGER(VECTOR_ELT(graph, 7)), GET_LENGTH(VECTOR_ELT(graph, 7))); /* attributes */ @@ -3527,9 +3568,8 @@ int R_SEXP_to_igraph_copy(SEXP graph, igraph_t *res) { int R_SEXP_to_igraph_vs(SEXP rit, igraph_t *graph, igraph_vs_t *it) { - igraph_vector_t *tmpv=(igraph_vector_t*)R_alloc(1,sizeof(igraph_vector_t)); - igraph_vs_vector(it, igraph_vector_view(tmpv, REAL(rit), - GET_LENGTH(rit))); + igraph_vector_int_t *tmpv=(igraph_vector_int_t*)R_alloc(1,sizeof(igraph_vector_int_t)); + igraph_vs_vector(it, igraph_vector_int_view(tmpv, INTEGER(rit), LENGTH(rit))); return 0; } @@ -3539,9 +3579,8 @@ int R_SEXP_to_igraph_vs(SEXP rit, igraph_t *graph, igraph_vs_t *it) { int R_SEXP_to_igraph_es(SEXP rit, igraph_t *graph, igraph_es_t *it) { - igraph_vector_t *tmpv=(igraph_vector_t*)R_alloc(1,sizeof(igraph_vector_t)); - igraph_es_vector(it, igraph_vector_view(tmpv, REAL(rit), - GET_LENGTH(rit))); + igraph_vector_int_t *tmpv=(igraph_vector_int_t*)R_alloc(1,sizeof(igraph_vector_int_t)); + igraph_es_vector(it, igraph_vector_int_view(tmpv, INTEGER(rit), LENGTH(rit))); return 0; } @@ -3833,11 +3872,11 @@ SEXP R_igraph_mybracket3_set(SEXP graph, SEXP pidx1, SEXP pidx2, SEXP R_igraph_add_edges(SEXP graph, SEXP edges) { - igraph_vector_t v; /* do NOT destroy! */ + igraph_vector_int_t v; /* do NOT destroy! */ igraph_t g; SEXP result; - R_SEXP_to_vector(edges, &v); + R_SEXP_to_vector_int(edges, &v); R_SEXP_to_igraph_copy(graph, &g); IGRAPH_FINALLY(igraph_destroy, &g); IGRAPH_R_CHECK(igraph_add_edges(&g, &v, 0)); @@ -3881,20 +3920,19 @@ SEXP R_igraph_ecount(SEXP graph) { SEXP R_igraph_neighbors(SEXP graph, SEXP pvid, SEXP pmode) { igraph_t g; - igraph_vector_t neis; + igraph_vector_int_t neis; SEXP result; igraph_real_t vid; igraph_neimode_t mode; - igraph_vector_init(&neis, 0); + igraph_vector_int_init(&neis, 0); vid=REAL(pvid)[0]; mode = (igraph_neimode_t) Rf_asInteger(pmode); R_SEXP_to_igraph(graph, &g); IGRAPH_R_CHECK(igraph_neighbors(&g, &neis, (igraph_integer_t) vid, mode)); - PROTECT(result=NEW_NUMERIC(igraph_vector_size(&neis))); - igraph_vector_copy_to(&neis, REAL(result)); - igraph_vector_destroy(&neis); + PROTECT(result=R_igraph_vector_int_to_SEXP(&neis)); + igraph_vector_int_destroy(&neis); UNPROTECT(1); return result; @@ -3903,20 +3941,19 @@ SEXP R_igraph_neighbors(SEXP graph, SEXP pvid, SEXP pmode) { SEXP R_igraph_incident(SEXP graph, SEXP pvid, SEXP pmode) { igraph_t g; - igraph_vector_t neis; + igraph_vector_int_t neis; SEXP result; igraph_real_t vid; igraph_neimode_t mode; - igraph_vector_init(&neis, 0); + igraph_vector_int_init(&neis, 0); vid=REAL(pvid)[0]; mode = (igraph_neimode_t) Rf_asInteger(pmode); R_SEXP_to_igraph(graph, &g); IGRAPH_R_CHECK(igraph_incident(&g, &neis, (igraph_integer_t) vid, mode)); - PROTECT(result=NEW_NUMERIC(igraph_vector_size(&neis))); - igraph_vector_copy_to(&neis, REAL(result)); - igraph_vector_destroy(&neis); + PROTECT(result=R_igraph_vector_int_to_SEXP(&neis)); + igraph_vector_int_destroy(&neis); UNPROTECT(1); return result; @@ -3971,12 +4008,12 @@ SEXP R_igraph_is_directed(SEXP graph) { SEXP R_igraph_create(SEXP edges, SEXP pn, SEXP pdirected) { igraph_t g; - igraph_vector_t v; + igraph_vector_int_t v; igraph_integer_t n=(igraph_integer_t) REAL(pn)[0]; igraph_bool_t directed=LOGICAL(pdirected)[0]; SEXP result; - R_SEXP_to_vector(edges, &v); + R_SEXP_to_vector_int(edges, &v); IGRAPH_R_CHECK(igraph_create(&g, &v, n, directed)); PROTECT(result=R_igraph_to_SEXP(&g)); igraph_destroy(&g); @@ -3989,19 +4026,18 @@ SEXP R_igraph_degree(SEXP graph, SEXP vids, SEXP pmode, SEXP ploops) { igraph_t g; igraph_vs_t vs; - igraph_vector_t res; + igraph_vector_int_t res; igraph_neimode_t mode = (igraph_neimode_t) Rf_asInteger(pmode); igraph_bool_t loops=LOGICAL(ploops)[0]; SEXP result; R_SEXP_to_igraph(graph, &g); R_SEXP_to_igraph_vs(vids, &g, &vs); - igraph_vector_init(&res, 0); + igraph_vector_int_init(&res, 0); IGRAPH_R_CHECK(igraph_degree(&g, &res, vs, mode, loops)); - PROTECT(result=NEW_NUMERIC(igraph_vector_size(&res))); - igraph_vector_copy_to(&res, REAL(result)); - igraph_vector_destroy(&res); + PROTECT(result=R_igraph_vector_int_to_SEXP(&res)); + igraph_vector_int_destroy(&res); igraph_vs_destroy(&vs); UNPROTECT(1); @@ -4022,7 +4058,7 @@ SEXP R_igraph_diameter(SEXP graph, SEXP pdirected, SEXP punconnected, if (!Rf_isNull(pweights)) { R_SEXP_to_vector(pweights, &weights); } - IGRAPH_R_CHECK(igraph_diameter_dijkstra(&g, Rf_isNull(pweights) ? 0 : &weights, &res, 0, 0, 0, directed, unconnected)); + IGRAPH_R_CHECK(igraph_diameter_dijkstra(&g, Rf_isNull(pweights) ? 0 : &weights, &res, 0, 0, 0, 0, directed, unconnected)); PROTECT(result=NEW_NUMERIC(1)); REAL(result)[0]=res; @@ -4038,7 +4074,7 @@ SEXP R_igraph_get_diameter(SEXP graph, SEXP pdirected, SEXP punconnected, igraph_bool_t directed=LOGICAL(pdirected)[0]; igraph_bool_t unconnected=LOGICAL(punconnected)[0]; igraph_vector_t weights; - igraph_vector_t res; + igraph_vector_int_t res; igraph_real_t dialen; SEXP result; @@ -4046,12 +4082,11 @@ SEXP R_igraph_get_diameter(SEXP graph, SEXP pdirected, SEXP punconnected, if (!Rf_isNull(pweights)) { R_SEXP_to_vector(pweights, &weights); } - igraph_vector_init(&res, 0); - IGRAPH_R_CHECK(igraph_diameter_dijkstra(&g, Rf_isNull(pweights) ? 0 : &weights, &dialen, 0, 0, &res, directed, unconnected)); + igraph_vector_int_init(&res, 0); + IGRAPH_R_CHECK(igraph_diameter_dijkstra(&g, Rf_isNull(pweights) ? 0 : &weights, &dialen, 0, 0, &res, 0, directed, unconnected)); - PROTECT(result=NEW_NUMERIC(igraph_vector_size(&res))); - igraph_vector_copy_to(&res, REAL(result)); - igraph_vector_destroy(&res); + PROTECT(result=R_igraph_vector_int_to_SEXP(&res)); + igraph_vector_int_destroy(&res); UNPROTECT(1); return result; @@ -4072,7 +4107,7 @@ SEXP R_igraph_farthest_points(SEXP graph, SEXP pdirected, SEXP punconnected, if (!Rf_isNull(pweights)) { R_SEXP_to_vector(pweights, &weights); } - IGRAPH_R_CHECK(igraph_diameter_dijkstra(&g, Rf_isNull(pweights) ? 0 : &weights, &len, &from, &to, 0, directed, unconnected)); + IGRAPH_R_CHECK(igraph_diameter_dijkstra(&g, Rf_isNull(pweights) ? 0 : &weights, &len, &from, &to, 0, 0, directed, unconnected)); PROTECT(result=NEW_NUMERIC(3)); if (from < 0) { @@ -4092,16 +4127,15 @@ SEXP R_igraph_subcomponent(SEXP graph, SEXP pvertex, SEXP pmode) { igraph_t g; igraph_real_t vertex=REAL(pvertex)[0]; igraph_neimode_t mode = (igraph_neimode_t) Rf_asInteger(pmode); - igraph_vector_t res; + igraph_vector_int_t res; SEXP result; R_SEXP_to_igraph(graph, &g); - igraph_vector_init(&res, 0); + igraph_vector_int_init(&res, 0); IGRAPH_R_CHECK(igraph_subcomponent(&g, &res, vertex, mode)); - PROTECT(result=NEW_NUMERIC(igraph_vector_size(&res))); - igraph_vector_copy_to(&res, REAL(result)); - igraph_vector_destroy(&res); + PROTECT(result=R_igraph_vector_int_to_SEXP(&res)); + igraph_vector_int_destroy(&res); UNPROTECT(1); return result; @@ -4301,14 +4335,14 @@ SEXP R_igraph_lattice(SEXP pdimvector, SEXP pnei, SEXP pdirected, SEXP pmutual, SEXP pcircular) { igraph_t g; - igraph_vector_t dimvector; + igraph_vector_int_t dimvector; igraph_integer_t nei=(igraph_integer_t) REAL(pnei)[0]; igraph_bool_t directed=LOGICAL(pdirected)[0]; igraph_bool_t mutual=LOGICAL(pmutual)[0]; igraph_bool_t circular=LOGICAL(pcircular)[0]; SEXP result; - R_SEXP_to_vector(pdimvector, &dimvector); + R_SEXP_to_vector_int(pdimvector, &dimvector); IGRAPH_R_CHECK(igraph_lattice(&g, &dimvector, nei, directed, mutual, circular)); PROTECT(result=R_igraph_to_SEXP(&g)); @@ -4326,7 +4360,7 @@ SEXP R_igraph_barabasi_game(SEXP pn, SEXP ppower, SEXP pm, SEXP poutseq, igraph_integer_t n=(igraph_integer_t) REAL(pn)[0]; igraph_real_t power=REAL(ppower)[0]; igraph_integer_t m=Rf_isNull(pm) ? 0 : (igraph_integer_t) REAL(pm)[0]; - igraph_vector_t outseq, *myoutseq=0; + igraph_vector_int_t outseq, *myoutseq=0; igraph_bool_t outpref=LOGICAL(poutpref)[0]; igraph_real_t A=REAL(pA)[0]; igraph_bool_t directed=LOGICAL(pdirected)[0]; @@ -4335,7 +4369,7 @@ SEXP R_igraph_barabasi_game(SEXP pn, SEXP ppower, SEXP pm, SEXP poutseq, SEXP result; if (!Rf_isNull(poutseq)) { - R_SEXP_to_vector(poutseq, &outseq); + R_SEXP_to_vector_int(poutseq, &outseq); myoutseq=&outseq; } @@ -4361,13 +4395,13 @@ SEXP R_igraph_recent_degree_game(SEXP pn, SEXP ppower, SEXP pwindow, igraph_real_t power=REAL(ppower)[0]; igraph_integer_t window=(igraph_integer_t) REAL(pwindow)[0]; igraph_integer_t m=(igraph_integer_t) REAL(pm)[0]; - igraph_vector_t outseq; + igraph_vector_int_t outseq; igraph_bool_t outpref=LOGICAL(poutpref)[0]; igraph_bool_t directed=LOGICAL(pdirected)[0]; igraph_real_t zero_appeal=REAL(pzero_appeal)[0]; SEXP result; - R_SEXP_to_vector(poutseq, &outseq); + R_SEXP_to_vector_int(poutseq, &outseq); IGRAPH_R_CHECK(igraph_recent_degree_game(&g, n, power, window, m, &outseq, outpref, zero_appeal, directed)); PROTECT(result=R_igraph_to_SEXP(&g)); @@ -4676,9 +4710,9 @@ SEXP R_igraph_get_shortest_paths(SEXP graph, SEXP pfrom, SEXP pto, igraph_integer_t from=(igraph_integer_t) REAL(pfrom)[0]; igraph_vs_t to; igraph_integer_t mode=(igraph_integer_t) REAL(pmode)[0]; - igraph_vector_t *vects, *evects; + igraph_vector_int_t *vects, *evects; long int i; - igraph_vector_ptr_t ptrvec, ptrevec; + igraph_vector_int_list_t ptrvec, ptrevec; igraph_vector_t w, *pw=&w; igraph_bool_t negw=0; SEXP result, result1, result2, names; @@ -4687,7 +4721,7 @@ SEXP R_igraph_get_shortest_paths(SEXP graph, SEXP pfrom, SEXP pto, igraph_bool_t pred=LOGICAL(ppred)[0]; igraph_bool_t inbound=LOGICAL(pinbound)[0]; long int algo=(long int) REAL(palgo)[0]; - igraph_vector_long_t predvec, inboundvec; + igraph_vector_int_t predvec, inboundvec; long int no=(long int) REAL(pno)[0]; @@ -4695,21 +4729,23 @@ SEXP R_igraph_get_shortest_paths(SEXP graph, SEXP pfrom, SEXP pto, R_SEXP_to_igraph_vs(pto, &g, &to); if (verts) { - igraph_vector_ptr_init(&ptrvec, no); - vects=(igraph_vector_t*) R_alloc((size_t) GET_LENGTH(pto), - sizeof(igraph_vector_t)); + igraph_vector_int_list_init(&ptrvec, no); + vects=(igraph_vector_int_t*) R_alloc((size_t) GET_LENGTH(pto), + sizeof(igraph_vector_int_t)); for (i=0; i 0 && igraph_vector_min(&w) < 0; } - if (pred) { igraph_vector_long_init(&predvec, no); } - if (inbound) { igraph_vector_long_init(&inboundvec, no); } + if (pred) { igraph_vector_int_init(&predvec, no); } + if (inbound) { igraph_vector_int_init(&inboundvec, no); } switch (algo) { case 0: /* automatic */ @@ -4748,11 +4784,11 @@ SEXP R_igraph_get_shortest_paths(SEXP graph, SEXP pfrom, SEXP pto, SET_VECTOR_ELT(result, 0, NEW_LIST(no)); result1=VECTOR_ELT(result, 0); for (i=0; ifun, data->graph, args, data->extra)); @@ -7781,46 +7713,46 @@ SEXP R_igraph_bfs(SEXP graph, SEXP proot, SEXP proots, SEXP pneimode, SEXP result, names; igraph_integer_t root=(igraph_integer_t) REAL(proot)[0]; - igraph_vector_t roots; + igraph_vector_int_t roots; igraph_bool_t unreachable=LOGICAL(punreachable)[0]; - igraph_vector_t restricted; + igraph_vector_int_t restricted; igraph_integer_t neimode=(igraph_integer_t) REAL(pneimode)[0]; - igraph_vector_t order, rank, father, pred, succ, dist; - igraph_vector_t *p_order=0, *p_rank=0, *p_father=0, *p_pred=0, + igraph_vector_int_t order, rank, father, pred, succ, dist; + igraph_vector_int_t *p_order=0, *p_rank=0, *p_father=0, *p_pred=0, *p_succ=0, *p_dist=0; igraph_bfshandler_t *callback=0; R_igraph_i_bfs_data_t cb_data, *p_cb_data=0; R_SEXP_to_igraph(graph, &g); if (!Rf_isNull(proots)) { - R_SEXP_to_vector(proots, &roots); + R_SEXP_to_vector_int(proots, &roots); } if (!Rf_isNull(prestricted)) { - R_SEXP_to_vector(prestricted, &restricted); + R_SEXP_to_vector_int(prestricted, &restricted); } if (LOGICAL(porder)[0]) { - igraph_vector_init(&order, 0); IGRAPH_FINALLY(igraph_vector_destroy, &order); + igraph_vector_int_init(&order, 0); IGRAPH_FINALLY(igraph_vector_int_destroy, &order); p_order=ℴ } if (LOGICAL(prank)[0]) { - igraph_vector_init(&rank, 0); IGRAPH_FINALLY(igraph_vector_destroy, &rank); + igraph_vector_int_init(&rank, 0); IGRAPH_FINALLY(igraph_vector_int_destroy, &rank); p_rank=&rank; } if (LOGICAL(pfather)[0]) { - igraph_vector_init(&father, 0); IGRAPH_FINALLY(igraph_vector_destroy, &father); + igraph_vector_int_init(&father, 0); IGRAPH_FINALLY(igraph_vector_int_destroy, &father); p_father=&father; } if (LOGICAL(ppred)[0]) { - igraph_vector_init(&pred, 0); IGRAPH_FINALLY(igraph_vector_destroy, &pred); + igraph_vector_int_init(&pred, 0); IGRAPH_FINALLY(igraph_vector_int_destroy, &pred); p_pred=&pred; } if (LOGICAL(psucc)[0]) { - igraph_vector_init(&succ, 0); IGRAPH_FINALLY(igraph_vector_destroy, &succ); + igraph_vector_int_init(&succ, 0); IGRAPH_FINALLY(igraph_vector_int_destroy, &succ); p_succ=≻ } if (LOGICAL(pdist)[0]) { - igraph_vector_init(&dist, 0); IGRAPH_FINALLY(igraph_vector_destroy, &dist); + igraph_vector_int_init(&dist, 0); IGRAPH_FINALLY(igraph_vector_int_destroy, &dist); p_dist=&dist; } @@ -7853,28 +7785,28 @@ SEXP R_igraph_bfs(SEXP graph, SEXP proot, SEXP proots, SEXP pneimode, } SET_STRING_ELT(names, 2, Rf_mkChar("order")); - SET_VECTOR_ELT(result, 2, R_igraph_0orvector_to_SEXP_d(p_order)); + SET_VECTOR_ELT(result, 2, R_igraph_0orvector_int_to_SEXP_d(p_order)); SET_STRING_ELT(names, 3, Rf_mkChar("rank")); - SET_VECTOR_ELT(result, 3, R_igraph_0orvector_to_SEXP_d(p_rank)); + SET_VECTOR_ELT(result, 3, R_igraph_0orvector_int_to_SEXP_d(p_rank)); SET_STRING_ELT(names, 4, Rf_mkChar("father")); - SET_VECTOR_ELT(result, 4, R_igraph_0orvector_to_SEXP_d(p_father)); + SET_VECTOR_ELT(result, 4, R_igraph_0orvector_int_to_SEXP_d(p_father)); SET_STRING_ELT(names, 5, Rf_mkChar("pred")); - SET_VECTOR_ELT(result, 5, R_igraph_0orvector_to_SEXP_d(p_pred)); + SET_VECTOR_ELT(result, 5, R_igraph_0orvector_int_to_SEXP_d(p_pred)); SET_STRING_ELT(names, 6, Rf_mkChar("succ")); - SET_VECTOR_ELT(result, 6, R_igraph_0orvector_to_SEXP_d(p_succ)); + SET_VECTOR_ELT(result, 6, R_igraph_0orvector_int_to_SEXP_d(p_succ)); SET_STRING_ELT(names, 7, Rf_mkChar("dist")); - SET_VECTOR_ELT(result, 7, R_igraph_0orvector_to_SEXP_d(p_dist)); + SET_VECTOR_ELT(result, 7, R_igraph_0orvector_int_to_SEXP_d(p_dist)); SET_NAMES(result, names); UNPROTECT(2); - if (p_dist) { igraph_vector_destroy(p_dist); IGRAPH_FINALLY_CLEAN(1); p_dist = 0; } - if (p_succ) { igraph_vector_destroy(p_succ); IGRAPH_FINALLY_CLEAN(1); p_succ = 0; } - if (p_pred) { igraph_vector_destroy(p_pred); IGRAPH_FINALLY_CLEAN(1); p_pred = 0; } - if (p_father) { igraph_vector_destroy(p_father); IGRAPH_FINALLY_CLEAN(1); p_father = 0; } - if (p_rank) { igraph_vector_destroy(p_rank); IGRAPH_FINALLY_CLEAN(1); p_rank = 0; } - if (p_order) { igraph_vector_destroy(p_order); IGRAPH_FINALLY_CLEAN(1); p_order = 0; } + if (p_dist) { igraph_vector_int_destroy(p_dist); IGRAPH_FINALLY_CLEAN(1); p_dist = 0; } + if (p_succ) { igraph_vector_int_destroy(p_succ); IGRAPH_FINALLY_CLEAN(1); p_succ = 0; } + if (p_pred) { igraph_vector_int_destroy(p_pred); IGRAPH_FINALLY_CLEAN(1); p_pred = 0; } + if (p_father) { igraph_vector_int_destroy(p_father); IGRAPH_FINALLY_CLEAN(1); p_father = 0; } + if (p_rank) { igraph_vector_int_destroy(p_rank); IGRAPH_FINALLY_CLEAN(1); p_rank = 0; } + if (p_order) { igraph_vector_int_destroy(p_order); IGRAPH_FINALLY_CLEAN(1); p_order = 0; } return result; } @@ -7883,7 +7815,7 @@ typedef struct { SEXP graph, fun_in, fun_out, extra, rho; } R_igraph_i_dfs_data_t; -igraph_bool_t R_igraph_dfshandler(const igraph_t *graph, +igraph_error_t R_igraph_dfshandler(const igraph_t *graph, igraph_integer_t vid, igraph_integer_t dist, void *extra, @@ -7891,7 +7823,7 @@ igraph_bool_t R_igraph_dfshandler(const igraph_t *graph, R_igraph_i_dfs_data_t *data=extra; SEXP args, R_fcall, result, names; - igraph_bool_t cres; + igraph_error_t cres; PROTECT(args=NEW_NUMERIC(2)); PROTECT(names=NEW_CHARACTER(2)); @@ -7905,22 +7837,22 @@ igraph_bool_t R_igraph_dfshandler(const igraph_t *graph, PROTECT(R_fcall = Rf_lang4(which==0 ? data->fun_in : data->fun_out, data->graph, args, data->extra)); PROTECT(result = R_igraph_safe_eval_in_env(R_fcall, data->rho, NULL)); - cres = Rf_asLogical(R_igraph_handle_safe_eval_result_in_env(result, data->rho)); + cres = Rf_asInteger(R_igraph_handle_safe_eval_result_in_env(result, data->rho)); UNPROTECT(4); return cres; } -igraph_bool_t R_igraph_dfshandler_in(const igraph_t *graph, - igraph_integer_t vid, - igraph_integer_t dist, - void *extra) { +igraph_error_t R_igraph_dfshandler_in(const igraph_t *graph, + igraph_integer_t vid, + igraph_integer_t dist, + void *extra) { return R_igraph_dfshandler(graph, vid, dist, extra, 0); } -igraph_bool_t R_igraph_dfshandler_out(const igraph_t *graph, +igraph_error_t R_igraph_dfshandler_out(const igraph_t *graph, igraph_integer_t vid, igraph_integer_t dist, void *extra) { @@ -7939,24 +7871,24 @@ SEXP R_igraph_dfs(SEXP graph, SEXP proot, SEXP pneimode, SEXP punreachable, igraph_integer_t root=(igraph_integer_t) REAL(proot)[0]; igraph_integer_t neimode=(igraph_integer_t) REAL(pneimode)[0]; igraph_bool_t unreachable=LOGICAL(punreachable)[0]; - igraph_vector_t order, order_out, father, dist; - igraph_vector_t *p_order=0, *p_order_out=0, *p_father=0, *p_dist=0; + igraph_vector_int_t order, order_out, father, dist; + igraph_vector_int_t *p_order=0, *p_order_out=0, *p_father=0, *p_dist=0; igraph_dfshandler_t *in_callback=0, *out_callback=0; R_igraph_i_dfs_data_t cb_data, *p_cb_data=0; R_SEXP_to_igraph(graph, &g); if (LOGICAL(porder)[0]) { - igraph_vector_init(&order, 0); p_order=ℴ + igraph_vector_int_init(&order, 0); p_order=ℴ } if (LOGICAL(porder_out)[0]) { - igraph_vector_init(&order_out, 0); p_order_out=&order_out; + igraph_vector_int_init(&order_out, 0); p_order_out=&order_out; } if (LOGICAL(pfather)[0]) { - igraph_vector_init(&father, 0); p_father=&father; + igraph_vector_int_init(&father, 0); p_father=&father; } if (LOGICAL(pdist)[0]) { - igraph_vector_init(&dist, 0); p_dist=&dist; + igraph_vector_int_init(&dist, 0); p_dist=&dist; } if (!Rf_isNull(pin_callback) || !Rf_isNull(pout_callback)) { @@ -7994,13 +7926,13 @@ SEXP R_igraph_dfs(SEXP graph, SEXP proot, SEXP pneimode, SEXP punreachable, } SET_STRING_ELT(names, 2, Rf_mkChar("order")); - SET_VECTOR_ELT(result, 2, R_igraph_0orvector_to_SEXP_d(p_order)); + SET_VECTOR_ELT(result, 2, R_igraph_0orvector_int_to_SEXP_d(p_order)); SET_STRING_ELT(names, 3, Rf_mkChar("order.out")); - SET_VECTOR_ELT(result, 3, R_igraph_0orvector_to_SEXP_d(p_order_out)); + SET_VECTOR_ELT(result, 3, R_igraph_0orvector_int_to_SEXP_d(p_order_out)); SET_STRING_ELT(names, 4, Rf_mkChar("father")); - SET_VECTOR_ELT(result, 4, R_igraph_0orvector_to_SEXP_d(p_father)); + SET_VECTOR_ELT(result, 4, R_igraph_0orvector_int_to_SEXP_d(p_father)); SET_STRING_ELT(names, 5, Rf_mkChar("dist")); - SET_VECTOR_ELT(result, 5, R_igraph_0orvector_to_SEXP_d(p_dist)); + SET_VECTOR_ELT(result, 5, R_igraph_0orvector_int_to_SEXP_d(p_dist)); SET_NAMES(result, names); @@ -8010,9 +7942,9 @@ SEXP R_igraph_dfs(SEXP graph, SEXP proot, SEXP pneimode, SEXP punreachable, SEXP R_igraph_cohesive_blocks(SEXP graph) { - igraph_vector_ptr_t c_blocks; - igraph_vector_t c_cohesion; - igraph_vector_t c_parent; + igraph_vector_int_list_t c_blocks; + igraph_vector_int_t c_cohesion; + igraph_vector_int_t c_parent; igraph_t c_blockTree; igraph_t c_graph; SEXP blocks; @@ -8023,31 +7955,31 @@ SEXP R_igraph_cohesive_blocks(SEXP graph) { SEXP names; R_SEXP_to_igraph(graph, &c_graph); - if (0 != igraph_vector_ptr_init(&c_blocks, 0)) { + if (0 != igraph_vector_int_list_init(&c_blocks, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_blocks); - if (0 != igraph_vector_init(&c_cohesion, 0)) { + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_blocks); + if (0 != igraph_vector_int_init(&c_cohesion, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_cohesion); - if (0 != igraph_vector_init(&c_parent, 0)) { + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_cohesion); + if (0 != igraph_vector_int_init(&c_parent, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_parent); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_parent); IGRAPH_R_CHECK(igraph_cohesive_blocks(&c_graph, &c_blocks, &c_cohesion, &c_parent, &c_blockTree)); PROTECT(result=NEW_LIST(4)); PROTECT(names=NEW_CHARACTER(4)); - PROTECT(blocks=R_igraph_vectorlist_to_SEXP_p1(&c_blocks)); - R_igraph_vectorlist_destroy(&c_blocks); + PROTECT(blocks=R_igraph_vector_int_list_to_SEXP_p1(&c_blocks)); + igraph_vector_int_list_destroy(&c_blocks); IGRAPH_FINALLY_CLEAN(1); - PROTECT(cohesion=R_igraph_vector_to_SEXP(&c_cohesion)); - igraph_vector_destroy(&c_cohesion); + PROTECT(cohesion=R_igraph_vector_int_to_SEXP(&c_cohesion)); + igraph_vector_int_destroy(&c_cohesion); IGRAPH_FINALLY_CLEAN(1); - PROTECT(parent=R_igraph_vector_to_SEXPp1(&c_parent)); - igraph_vector_destroy(&c_parent); + PROTECT(parent=R_igraph_vector_int_to_SEXPp1(&c_parent)); + igraph_vector_int_destroy(&c_parent); IGRAPH_FINALLY_CLEAN(1); IGRAPH_FINALLY(igraph_destroy, &c_blockTree); PROTECT(blockTree=R_igraph_to_SEXP(&c_blockTree)); @@ -8091,13 +8023,13 @@ typedef struct R_igraph_i_levc_data_t { SEXP rho2; } R_igraph_i_levc_data_t; -int R_igraph_i_levc_callback(const igraph_vector_t *membership, - long int comm, - igraph_real_t eigenvalue, - const igraph_vector_t *eigenvector, - igraph_arpack_function_t *arpack_multiplier, - void *arpack_extra, - void *extra) { +igraph_error_t R_igraph_i_levc_callback(const igraph_vector_int_t *membership, + igraph_integer_t comm, + igraph_real_t eigenvalue, + const igraph_vector_t *eigenvector, + igraph_arpack_function_t *arpack_multiplier, + void *arpack_extra, + void *extra) { SEXP s_memb, s_comm, s_evalue, s_evector, s_multip; SEXP R_fcall, R_multip_call; @@ -8106,7 +8038,7 @@ int R_igraph_i_levc_callback(const igraph_vector_t *membership, R_igraph_i_levc_data_t *data=extra; R_igraph_i_function_container_t cont = { arpack_multiplier }; - PROTECT(s_memb=R_igraph_vector_to_SEXP(membership)); + PROTECT(s_memb=R_igraph_vector_int_to_SEXP(membership)); PROTECT(s_comm=NEW_NUMERIC(1)); REAL(s_comm)[0]=comm; PROTECT(s_evalue=NEW_NUMERIC(1)); REAL(s_evalue)[0]=eigenvalue; PROTECT(s_evector=R_igraph_vector_to_SEXP(eigenvector)); @@ -8136,15 +8068,15 @@ SEXP R_igraph_community_leading_eigenvector(SEXP graph, SEXP steps, SEXP callback_env2) { /* Declarations */ igraph_t c_graph; - igraph_matrix_t c_merges; - igraph_vector_t c_membership; + igraph_matrix_int_t c_merges; + igraph_vector_int_t c_membership; igraph_integer_t c_steps; igraph_vector_t v_weights, *pweights=0; igraph_bool_t c_start=!Rf_isNull(pstart); igraph_arpack_options_t c_options; igraph_real_t c_modularity; igraph_vector_t c_eigenvalues; - igraph_vector_ptr_t c_eigenvectors; + igraph_vector_list_t c_eigenvectors; igraph_vector_t c_history; SEXP merges; SEXP membership; @@ -8162,24 +8094,24 @@ SEXP R_igraph_community_leading_eigenvector(SEXP graph, SEXP steps, if (!Rf_isNull(weights)) { pweights=&v_weights; R_SEXP_to_vector(weights, &v_weights); } - if (0 != igraph_matrix_init(&c_merges, 0, 0)) { + if (0 != igraph_matrix_int_init(&c_merges, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_merges); + IGRAPH_FINALLY(igraph_matrix_int_destroy, &c_merges); if (c_start) { - R_SEXP_to_vector_copy(pstart, &c_membership); + R_SEXP_to_vector_int_copy(pstart, &c_membership); } else { - if (0 != igraph_vector_init(&c_membership, 0)) { + if (0 != igraph_vector_int_init(&c_membership, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } } - IGRAPH_FINALLY(igraph_vector_destroy, &c_membership); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_membership); c_steps=INTEGER(steps)[0]; R_SEXP_to_igraph_arpack_options(options, &c_options); if (0 != igraph_vector_init(&c_eigenvalues, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - if (0 != igraph_vector_ptr_init(&c_eigenvectors, 0)) { + if (0 != igraph_vector_list_init(&c_eigenvectors, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } if (0 != igraph_vector_init(&c_history, 0)) { @@ -8191,11 +8123,11 @@ SEXP R_igraph_community_leading_eigenvector(SEXP graph, SEXP steps, /* Convert output */ PROTECT(result=NEW_LIST(7)); PROTECT(names=NEW_CHARACTER(7)); - PROTECT(merges=R_igraph_matrix_to_SEXP(&c_merges)); - igraph_matrix_destroy(&c_merges); + PROTECT(merges=R_igraph_matrix_int_to_SEXP(&c_merges)); + igraph_matrix_int_destroy(&c_merges); IGRAPH_FINALLY_CLEAN(1); - PROTECT(membership=R_igraph_vector_to_SEXP(&c_membership)); - igraph_vector_destroy(&c_membership); + PROTECT(membership=R_igraph_vector_int_to_SEXP(&c_membership)); + igraph_vector_int_destroy(&c_membership); IGRAPH_FINALLY_CLEAN(1); PROTECT(options=R_igraph_arpack_options_to_SEXP(&c_options)); PROTECT(modularity=NEW_NUMERIC(1)); @@ -8203,7 +8135,7 @@ SEXP R_igraph_community_leading_eigenvector(SEXP graph, SEXP steps, PROTECT(eigenvalues=R_igraph_vector_to_SEXP(&c_eigenvalues)); igraph_vector_destroy(&c_eigenvalues); PROTECT(eigenvectors=R_igraph_vectorlist_to_SEXP(&c_eigenvectors)); - R_igraph_vectorlist_destroy(&c_eigenvectors); + igraph_vector_list_destroy(&c_eigenvectors); PROTECT(history=R_igraph_vector_to_SEXP(&c_history)); igraph_vector_destroy(&c_history); SET_VECTOR_ELT(result, 0, merges); @@ -8229,100 +8161,27 @@ SEXP R_igraph_community_leading_eigenvector(SEXP graph, SEXP steps, } SEXP R_igraph_get_eids(SEXP graph, SEXP pvp, SEXP pdirected, - SEXP perror, SEXP pmulti) { + SEXP perror) { igraph_t g; - igraph_vector_t vp; - igraph_vector_t res; + igraph_vector_int_t vp; + igraph_vector_int_t res; igraph_bool_t directed=LOGICAL(pdirected)[0]; igraph_bool_t err=LOGICAL(perror)[0]; - igraph_bool_t multi=LOGICAL(pmulti)[0]; SEXP result; R_SEXP_to_igraph(graph, &g); - R_SEXP_to_vector(pvp, &vp); - igraph_vector_init(&res, 0); + R_SEXP_to_vector_int(pvp, &vp); + igraph_vector_int_init(&res, 0); - if (multi) { - igraph_get_eids_multi(&g, &res, /*pairs=*/ &vp, /*path=*/ 0, directed, - err); - } else { - IGRAPH_R_CHECK(igraph_get_eids(&g, &res, /*pairs=*/ &vp, /*path=*/ 0, directed, err)); - } + IGRAPH_R_CHECK(igraph_get_eids(&g, &res, /*pairs=*/ &vp, directed, err)); - PROTECT(result=R_igraph_vector_to_SEXP(&res)); - igraph_vector_destroy(&res); + PROTECT(result=R_igraph_vector_int_to_SEXP(&res)); + igraph_vector_int_destroy(&res); UNPROTECT(1); return result; } -SEXP R_igraph_scg_semiprojectors(SEXP groups, SEXP matrix_type, SEXP p, - SEXP norm, SEXP psparse) { - /* Declarations */ - igraph_vector_t c_groups; - igraph_integer_t c_matrix_type; - igraph_matrix_t c_L; - igraph_matrix_t c_R; - igraph_sparsemat_t c_Lsparse; - igraph_sparsemat_t c_Rsparse; - igraph_vector_t c_p; - igraph_integer_t c_norm; - SEXP L; - SEXP R; - SEXP Lsparse; - SEXP Rsparse; - igraph_bool_t sparse=LOGICAL(psparse)[0]; - SEXP result, names; - /* Convert input */ - R_SEXP_to_vector(groups, &c_groups); - c_matrix_type=(igraph_integer_t) REAL(matrix_type)[0]; - if (!sparse) { - if (0 != igraph_matrix_init(&c_L, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_L); - if (0 != igraph_matrix_init(&c_R, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_matrix_destroy, &c_R); - } else { - /* Nothing to do, because igraph_scg_semiprojectors - expect uninitialized sparse matrices */ - } - if (!Rf_isNull(p)) { R_SEXP_to_vector(p, &c_p); } - c_norm=(igraph_integer_t) REAL(norm)[0]; - /* Call igraph */ - IGRAPH_R_CHECK(igraph_scg_semiprojectors(&c_groups, (igraph_scg_matrix_t) c_matrix_type, (sparse ? 0 : &c_L), (sparse ? 0 : &c_R), (sparse ? &c_Lsparse : 0), (sparse ? &c_Rsparse : 0), (Rf_isNull(p) ? 0 : &c_p), (igraph_scg_norm_t) c_norm)); - - /* Convert output */ - PROTECT(result=NEW_LIST(2)); - PROTECT(names=NEW_CHARACTER(2)); - if (!sparse) { - PROTECT(L=R_igraph_0ormatrix_to_SEXP(&c_L)); - igraph_matrix_destroy(&c_L); - IGRAPH_FINALLY_CLEAN(1); - PROTECT(R=R_igraph_0ormatrix_to_SEXP(&c_R)); - igraph_matrix_destroy(&c_R); - IGRAPH_FINALLY_CLEAN(1); - SET_VECTOR_ELT(result, 0, L); - SET_VECTOR_ELT(result, 1, R); - } else { - PROTECT(Lsparse=R_igraph_0orsparsemat_to_SEXP(&c_Lsparse)); - igraph_sparsemat_destroy(&c_Lsparse); - PROTECT(Rsparse=R_igraph_0orsparsemat_to_SEXP(&c_Rsparse)); - igraph_sparsemat_destroy(&c_Rsparse); - SET_VECTOR_ELT(result, 0, Lsparse); - SET_VECTOR_ELT(result, 1, Rsparse); - } - SET_STRING_ELT(names, 0, Rf_mkChar("L")); - SET_STRING_ELT(names, 1, Rf_mkChar("R")); - SET_NAMES(result, names); - UNPROTECT(3); - - UNPROTECT(1); - return(result); -} - SEXP R_igraph_laplacian(SEXP graph, SEXP normalized, SEXP weights, SEXP psparse) { /* Declarations */ @@ -8367,558 +8226,16 @@ SEXP R_igraph_laplacian(SEXP graph, SEXP normalized, SEXP weights, return(result); } -SEXP R_igraph_scg_adjacency(SEXP graph, SEXP matrix, SEXP sparsmat, SEXP ev, - SEXP intervals_vector, - SEXP algorithm, SEXP evec, - SEXP groups, SEXP use_arpack, SEXP maxiter, - SEXP sparse, SEXP output, SEXP semproj, - SEXP epairs) { - - /* Declarations */ - igraph_t c_graph; - igraph_matrix_t c_matrix; - igraph_sparsemat_t c_sparsmat; - igraph_vector_t c_ev; - igraph_vector_t c_intervals_vector; - igraph_integer_t c_algorithm=(igraph_integer_t) REAL(algorithm)[0]; - igraph_vector_t c_eval; - igraph_matrix_t c_evec; - igraph_vector_t c_groups; - igraph_bool_t c_use_arpack=LOGICAL(use_arpack)[0]; - igraph_integer_t c_maxiter=INTEGER(maxiter)[0]; - igraph_bool_t c_sparse=LOGICAL(sparse)[0]; - igraph_real_t c_output=REAL(output)[0]; - igraph_bool_t c_semproj=LOGICAL(semproj)[0]; - igraph_bool_t c_epairs=LOGICAL(epairs)[0]; - igraph_t c_scg_graph; - igraph_matrix_t c_scg_matrix; - igraph_sparsemat_t c_scg_sparsemat; - igraph_matrix_t c_L; - igraph_matrix_t c_R; - igraph_sparsemat_t c_Lsparse; - igraph_sparsemat_t c_Rsparse; - SEXP scg_graph; - SEXP scg_matrix; - SEXP scg_sparsemat; - SEXP L; - SEXP R; - SEXP Lsparse; - SEXP Rsparse; - SEXP result, names; - SEXP eval; - /* What to return */ - igraph_bool_t do_scg_graph= - (!Rf_isNull(graph) && c_output==1 /*default*/) || c_output==3 /*graph*/; - igraph_bool_t do_scg_matrix=!c_sparse && - ((Rf_isNull(graph) && c_output==1 /*default*/) || c_output==2 /*matrix*/); - igraph_bool_t do_scg_sparsemat=c_sparse && - ((Rf_isNull(graph) && c_output==1 /*default*/) || c_output==2 /*matrix*/); - igraph_bool_t do_L=c_semproj && !c_sparse; - igraph_bool_t do_R=c_semproj && !c_sparse; - igraph_bool_t do_Lsparse=c_semproj && c_sparse; - igraph_bool_t do_Rsparse=c_semproj && c_sparse; - igraph_bool_t do_eval=c_epairs; - igraph_bool_t do_evec=c_epairs; - - /* Convert input */ - if (!Rf_isNull(graph)) { R_SEXP_to_igraph(graph, &c_graph); } - if (!Rf_isNull(matrix)) { R_SEXP_to_matrix(matrix, &c_matrix); } - if (!Rf_isNull(sparsmat)) { R_SEXP_to_sparsemat(sparsmat, &c_sparsmat); } - - R_SEXP_to_vector(ev, &c_ev); - R_SEXP_to_vector(intervals_vector, &c_intervals_vector); - - if (do_eval) { igraph_vector_init(&c_eval, 0); } - if (!Rf_isNull(evec)) { - R_SEXP_to_igraph_matrix_copy(evec, &c_evec); - } else if (do_evec) { - igraph_matrix_init(&c_evec, 0, 0); - } - if (!Rf_isNull(groups)) { - R_SEXP_to_vector_copy(groups, &c_groups); - } else { - igraph_vector_init(&c_groups, 0); - } - - if (do_scg_matrix) { igraph_matrix_init(&c_scg_matrix, 0, 0); } - if (do_L) { igraph_matrix_init(&c_L, 0, 0); } - if (do_R) { igraph_matrix_init(&c_R, 0, 0); } - - if (do_scg_sparsemat) { igraph_sparsemat_init(&c_scg_sparsemat, 0, 0, 0); } - - /* Call igraph */ - IGRAPH_R_CHECK(igraph_scg_adjacency((Rf_isNull(graph) ? 0 : &c_graph), (Rf_isNull(matrix) ? 0 : &c_matrix), (Rf_isNull(sparsmat) ? 0 : &c_sparsmat), &c_ev, /*intervals=*/ 0, &c_intervals_vector, (igraph_scg_algorithm_t) c_algorithm, (do_eval ? &c_eval : 0), (!Rf_isNull(evec) || do_evec ? &c_evec : 0), &c_groups, c_use_arpack, c_maxiter, (do_scg_graph ? &c_scg_graph : 0), (do_scg_matrix ? &c_scg_matrix : 0), (do_scg_sparsemat ? &c_scg_sparsemat : 0), (do_L ? &c_L : 0), (do_R ? &c_R : 0), (do_Lsparse ? &c_Lsparse : 0), (do_Rsparse ? &c_Rsparse : 0))); - - if (!Rf_isNull(sparsmat)) { igraph_free(c_sparsmat.cs); } - - /* Convert output */ - PROTECT(result=NEW_LIST(6)); - PROTECT(names=NEW_CHARACTER(6)); - - if (do_eval) { - eval=R_igraph_vector_to_SEXP(&c_eval); - igraph_vector_destroy(&c_eval); - } else { - eval=R_NilValue; - } - PROTECT(eval); - - if (do_evec) { - evec=R_igraph_matrix_to_SEXP(&c_evec); - igraph_matrix_destroy(&c_evec); - } else { - evec=R_NilValue; - } - PROTECT(evec); - - PROTECT(groups=R_igraph_vector_to_SEXPp1(&c_groups)); - igraph_vector_destroy(&c_groups); - - if (do_scg_graph) { - PROTECT(scg_graph=R_igraph_to_SEXP(&c_scg_graph)); - igraph_destroy(&c_scg_graph); - UNPROTECT(1); - } else { - scg_graph=R_NilValue; - } - PROTECT(scg_graph); - - if (do_scg_matrix) { - scg_matrix=R_igraph_matrix_to_SEXP(&c_scg_matrix); - igraph_matrix_destroy(&c_scg_matrix); - } else { - scg_matrix=R_NilValue; - } - PROTECT(scg_matrix); - - if (do_scg_sparsemat) { - scg_sparsemat=R_igraph_sparsemat_to_SEXP(&c_scg_sparsemat); - igraph_sparsemat_destroy(&c_scg_sparsemat); - } else { - scg_sparsemat=R_NilValue; - } - PROTECT(scg_sparsemat); - - if (do_L) { - L=R_igraph_matrix_to_SEXP(&c_L); - igraph_matrix_destroy(&c_L); - } else { - L=R_NilValue; - } - PROTECT(L); - - if (do_R) { - R=R_igraph_matrix_to_SEXP(&c_R); - igraph_matrix_destroy(&c_R); - } else { - R=R_NilValue; - } - PROTECT(R); - - if (do_Lsparse) { - Lsparse=R_igraph_sparsemat_to_SEXP(&c_Lsparse); - igraph_sparsemat_destroy(&c_Lsparse); - } else { - Lsparse=R_NilValue; - } - PROTECT(Lsparse); - - if (do_Rsparse) { - Rsparse=R_igraph_sparsemat_to_SEXP(&c_Rsparse); - igraph_sparsemat_destroy(&c_Rsparse); - } else { - Rsparse=R_NilValue; - } - PROTECT(Rsparse); - - if (do_scg_graph) { SET_VECTOR_ELT(result, 0, scg_graph); } - if (do_scg_matrix) { SET_VECTOR_ELT(result, 0, scg_matrix); } - if (do_scg_sparsemat) { SET_VECTOR_ELT(result, 0, scg_sparsemat); } - SET_VECTOR_ELT(result, 1, groups); - if (do_L) { SET_VECTOR_ELT(result, 2, L); } - if (do_Lsparse) { SET_VECTOR_ELT(result, 2, Lsparse); } - if (do_R) { SET_VECTOR_ELT(result, 3, R); } - if (do_Rsparse) { SET_VECTOR_ELT(result, 3, Rsparse); } - SET_VECTOR_ELT(result, 4, eval); - SET_VECTOR_ELT(result, 5, evec); - SET_STRING_ELT(names, 0, Rf_mkChar("Xt")); - SET_STRING_ELT(names, 1, Rf_mkChar("groups")); - SET_STRING_ELT(names, 2, Rf_mkChar("L")); - SET_STRING_ELT(names, 3, Rf_mkChar("R")); - SET_STRING_ELT(names, 4, Rf_mkChar("values")); - SET_STRING_ELT(names, 5, Rf_mkChar("vectors")); - SET_NAMES(result, names); - - UNPROTECT(12); - return(result); -} - -SEXP R_igraph_scg_stochastic(SEXP graph, SEXP matrix, SEXP sparsmat, SEXP ev, - SEXP intervals_vector, SEXP algorithm, SEXP norm, - SEXP evec, SEXP groups, SEXP p, SEXP use_arpack, - SEXP maxiter, SEXP sparse, SEXP output, - SEXP semproj, SEXP epairs, SEXP stat_prob) { - - /* Declarations */ - igraph_t c_graph; - igraph_matrix_t c_matrix; - igraph_sparsemat_t c_sparsmat; - igraph_vector_t c_ev; - igraph_vector_t c_intervals_vector; - igraph_integer_t c_algorithm=(igraph_integer_t) REAL(algorithm)[0]; - igraph_integer_t c_norm=(igraph_integer_t) REAL(norm)[0]; - igraph_vector_complex_t c_eval; - igraph_matrix_complex_t c_evec; - igraph_vector_t c_groups; - igraph_vector_t c_p; - igraph_bool_t c_use_arpack=LOGICAL(use_arpack)[0]; - igraph_integer_t c_maxiter=INTEGER(maxiter)[0]; - igraph_bool_t c_sparse=LOGICAL(sparse)[0]; - igraph_real_t c_output=REAL(output)[0]; - igraph_bool_t c_semproj=LOGICAL(semproj)[0]; - igraph_bool_t c_epairs=LOGICAL(epairs)[0]; - igraph_bool_t c_stat_prob=LOGICAL(stat_prob)[0]; - igraph_t c_scg_graph; - igraph_matrix_t c_scg_matrix; - igraph_sparsemat_t c_scg_sparsemat; - igraph_matrix_t c_L; - igraph_matrix_t c_R; - igraph_sparsemat_t c_Lsparse; - igraph_sparsemat_t c_Rsparse; - SEXP scg_graph; - SEXP scg_matrix; - SEXP scg_sparsemat; - SEXP L; - SEXP R; - SEXP Lsparse; - SEXP Rsparse; - SEXP result, names; - SEXP eval; - /* What to return */ - igraph_bool_t do_scg_graph= - (!Rf_isNull(graph) && c_output==1 /*default*/) || c_output==3 /*graph*/; - igraph_bool_t do_scg_matrix=!c_sparse && - ((Rf_isNull(graph) && c_output==1 /*default*/) || c_output==2 /*matrix*/); - igraph_bool_t do_scg_sparsemat=c_sparse && - ((Rf_isNull(graph) && c_output==1 /*default*/) || c_output==2 /*matrix*/); - igraph_bool_t do_L=c_semproj && !c_sparse; - igraph_bool_t do_R=c_semproj && !c_sparse; - igraph_bool_t do_Lsparse=c_semproj && c_sparse; - igraph_bool_t do_Rsparse=c_semproj && c_sparse; - igraph_bool_t do_eval=c_epairs; - igraph_bool_t do_evec=c_epairs; - igraph_bool_t do_p=c_stat_prob; - - /* Convert input */ - if (!Rf_isNull(graph)) { R_SEXP_to_igraph(graph, &c_graph); } - if (!Rf_isNull(matrix)) { R_SEXP_to_matrix(matrix, &c_matrix); } - if (!Rf_isNull(sparsmat)) { R_SEXP_to_sparsemat(sparsmat, &c_sparsmat); } - - R_SEXP_to_vector(ev, &c_ev); - R_SEXP_to_vector(intervals_vector, &c_intervals_vector); - if (do_eval) { igraph_vector_complex_init(&c_eval, 0); } - if (!Rf_isNull(evec)) { - R_SEXP_to_matrix_complex_copy(evec, &c_evec); - } else if (do_evec) { - igraph_matrix_complex_init(&c_evec, 0, 0); - } - if (!Rf_isNull(groups)) { - R_SEXP_to_vector_copy(groups, &c_groups); - } else { - igraph_vector_init(&c_groups, 0); - } - - if (!Rf_isNull(p)) { - R_SEXP_to_vector_copy(p, &c_p); - } else if (do_p) { - igraph_vector_init(&c_p, 0); - } - - if (do_scg_matrix) { igraph_matrix_init(&c_scg_matrix, 0, 0); } - if (do_L) { igraph_matrix_init(&c_L, 0, 0); } - if (do_R) { igraph_matrix_init(&c_R, 0, 0); } - - /* Call igraph */ - IGRAPH_R_CHECK(igraph_scg_stochastic((Rf_isNull(graph) ? 0 : &c_graph), (Rf_isNull(matrix) ? 0 : &c_matrix), (Rf_isNull(sparsmat) ? 0 : &c_sparsmat), &c_ev, /*intervals=*/ 0, &c_intervals_vector, (igraph_scg_algorithm_t) c_algorithm, (igraph_scg_norm_t) c_norm, (do_eval ? &c_eval : 0), (!Rf_isNull(evec) || do_evec ? &c_evec : 0), &c_groups, (!Rf_isNull(p) || do_p ? &c_p : 0), c_use_arpack, c_maxiter, (do_scg_graph ? &c_scg_graph : 0), (do_scg_matrix ? &c_scg_matrix : 0), (do_scg_sparsemat ? &c_scg_sparsemat : 0), (do_L ? &c_L : 0), (do_R ? &c_R : 0), (do_Lsparse ? &c_Lsparse : 0), (do_Rsparse ? &c_Rsparse : 0))); - - if (!Rf_isNull(sparsmat)) { igraph_free(c_sparsmat.cs); } - - /* Convert output */ - PROTECT(result=NEW_LIST(7)); - PROTECT(names=NEW_CHARACTER(7)); - - if (do_eval) { - PROTECT(eval=R_igraph_vector_complex_to_SEXP(&c_eval)); - igraph_vector_complex_destroy(&c_eval); - } else { - PROTECT(eval=R_NilValue); - } - - if (do_evec) { - PROTECT(evec=R_igraph_matrix_complex_to_SEXP(&c_evec)); - igraph_matrix_complex_destroy(&c_evec); - } else { - PROTECT(evec=R_NilValue); - } - - if (do_p) { - PROTECT(p=R_igraph_vector_to_SEXP(&c_p)); - igraph_vector_destroy(&c_p); - } else { - PROTECT(p=R_NilValue); - } - - PROTECT(groups=R_igraph_vector_to_SEXPp1(&c_groups)); - igraph_vector_destroy(&c_groups); - - if (do_scg_graph) { - PROTECT(scg_graph=R_igraph_to_SEXP(&c_scg_graph)); - igraph_destroy(&c_scg_graph); - } else { - PROTECT(scg_graph=R_NilValue); - } - if (do_scg_matrix) { - PROTECT(scg_matrix=R_igraph_matrix_to_SEXP(&c_scg_matrix)); - igraph_matrix_destroy(&c_scg_matrix); - } else { - PROTECT(scg_matrix=R_NilValue); - } - if (do_scg_sparsemat) { - PROTECT(scg_sparsemat=R_igraph_sparsemat_to_SEXP(&c_scg_sparsemat)); - igraph_sparsemat_destroy(&c_scg_sparsemat); - } else { - PROTECT(scg_sparsemat=R_NilValue); - } - if (do_L) { - PROTECT(L=R_igraph_matrix_to_SEXP(&c_L)); - igraph_matrix_destroy(&c_L); - } else { - PROTECT(L=R_NilValue); - } - if (do_R) { - PROTECT(R=R_igraph_matrix_to_SEXP(&c_R)); - igraph_matrix_destroy(&c_R); - } else { - PROTECT(R=R_NilValue); - } - if (do_Lsparse) { - PROTECT(Lsparse=R_igraph_sparsemat_to_SEXP(&c_Lsparse)); - igraph_sparsemat_destroy(&c_Lsparse); - } else { - PROTECT(Lsparse=R_NilValue); - } - if (do_Rsparse) { - PROTECT(Rsparse=R_igraph_sparsemat_to_SEXP(&c_Rsparse)); - igraph_sparsemat_destroy(&c_Rsparse); - } else { - PROTECT(Rsparse=R_NilValue); - } - - if (do_scg_graph) { SET_VECTOR_ELT(result, 0, scg_graph); } - if (do_scg_matrix) { SET_VECTOR_ELT(result, 0, scg_matrix); } - if (do_scg_sparsemat) { SET_VECTOR_ELT(result, 0, scg_sparsemat); } - SET_VECTOR_ELT(result, 1, groups); - if (do_L) { SET_VECTOR_ELT(result, 2, L); } - if (do_Lsparse) { SET_VECTOR_ELT(result, 2, Lsparse); } - if (do_R) { SET_VECTOR_ELT(result, 3, R); } - if (do_Rsparse) { SET_VECTOR_ELT(result, 3, Rsparse); } - SET_VECTOR_ELT(result, 4, eval); - SET_VECTOR_ELT(result, 5, evec); - if (do_p) { SET_VECTOR_ELT(result, 6, p); } - SET_STRING_ELT(names, 0, Rf_mkChar("Xt")); - SET_STRING_ELT(names, 1, Rf_mkChar("groups")); - SET_STRING_ELT(names, 2, Rf_mkChar("L")); - SET_STRING_ELT(names, 3, Rf_mkChar("R")); - SET_STRING_ELT(names, 4, Rf_mkChar("values")); - SET_STRING_ELT(names, 5, Rf_mkChar("vectors")); - SET_STRING_ELT(names, 6, Rf_mkChar("p")); - SET_NAMES(result, names); - UNPROTECT(12); - - UNPROTECT(1); - return(result); -} - -SEXP R_igraph_scg_laplacian(SEXP graph, SEXP matrix, SEXP sparsmat, SEXP ev, - SEXP intervals_vector, SEXP algorithm, SEXP norm, - SEXP direction, SEXP evec, SEXP groups, - SEXP use_arpack, SEXP maxiter, SEXP sparse, - SEXP output, SEXP semproj, SEXP epairs) { - - /* Declarations */ - igraph_t c_graph; - igraph_matrix_t c_matrix; - igraph_sparsemat_t c_sparsmat; - igraph_vector_t c_ev; - igraph_vector_t c_intervals_vector; - igraph_integer_t c_algorithm=(igraph_integer_t) REAL(algorithm)[0]; - igraph_integer_t c_norm=(igraph_integer_t) REAL(norm)[0]; - igraph_integer_t c_direction=(igraph_integer_t) REAL(direction)[0]; - igraph_vector_complex_t c_eval; - igraph_matrix_complex_t c_evec; - igraph_vector_t c_groups; - igraph_bool_t c_use_arpack=LOGICAL(use_arpack)[0]; - igraph_integer_t c_maxiter=INTEGER(maxiter)[0]; - igraph_bool_t c_sparse=LOGICAL(sparse)[0]; - igraph_real_t c_output=REAL(output)[0]; - igraph_bool_t c_semproj=LOGICAL(semproj)[0]; - igraph_bool_t c_epairs=LOGICAL(epairs)[0]; - igraph_t c_scg_graph; - igraph_matrix_t c_scg_matrix; - igraph_sparsemat_t c_scg_sparsemat; - igraph_matrix_t c_L; - igraph_matrix_t c_R; - igraph_sparsemat_t c_Lsparse; - igraph_sparsemat_t c_Rsparse; - SEXP eval; - SEXP scg_graph; - SEXP scg_matrix; - SEXP scg_sparsemat; - SEXP L; - SEXP R; - SEXP Lsparse; - SEXP Rsparse; - SEXP result, names; - /* What to return */ - igraph_bool_t do_scg_graph= - (!Rf_isNull(graph) && c_output==1 /*default*/) || c_output==3 /*graph*/; - igraph_bool_t do_scg_matrix=!c_sparse && - ((Rf_isNull(graph) && c_output==1 /*default*/) || c_output==2 /*matrix*/); - igraph_bool_t do_scg_sparsemat=c_sparse && - ((Rf_isNull(graph) && c_output==1 /*default*/) || c_output==2 /*matrix*/); - igraph_bool_t do_L=c_semproj && !c_sparse; - igraph_bool_t do_R=c_semproj && !c_sparse; - igraph_bool_t do_Lsparse=c_semproj && c_sparse; - igraph_bool_t do_Rsparse=c_semproj && c_sparse; - igraph_bool_t do_eval=c_epairs; - igraph_bool_t do_evec=c_epairs; - - /* Convert input */ - if (!Rf_isNull(graph)) { R_SEXP_to_igraph(graph, &c_graph); } - if (!Rf_isNull(matrix)) { R_SEXP_to_matrix(matrix, &c_matrix); } - if (!Rf_isNull(sparsmat)) { R_SEXP_to_sparsemat(sparsmat, &c_sparsmat); } - - R_SEXP_to_vector(ev, &c_ev); - R_SEXP_to_vector(intervals_vector, &c_intervals_vector); - - if (do_eval) { igraph_vector_complex_init(&c_eval, 0); } - if (!Rf_isNull(evec)) { - R_SEXP_to_matrix_complex_copy(evec, &c_evec); - } else if (do_evec) { - igraph_matrix_complex_init(&c_evec, 0, 0); - } - if (!Rf_isNull(groups)) { - R_SEXP_to_vector_copy(groups, &c_groups); - } else { - igraph_vector_init(&c_groups, 0); - } - - if (do_scg_matrix) { igraph_matrix_init(&c_scg_matrix, 0, 0); } - if (do_L) { igraph_matrix_init(&c_L, 0, 0); } - if (do_R) { igraph_matrix_init(&c_R, 0, 0); } - - /* Call igraph */ - IGRAPH_R_CHECK(igraph_scg_laplacian((Rf_isNull(graph) ? 0 : &c_graph), (Rf_isNull(matrix) ? 0 : &c_matrix), (Rf_isNull(sparsmat) ? 0 : &c_sparsmat), &c_ev, /*intervals=*/ 0, &c_intervals_vector, (igraph_scg_algorithm_t) c_algorithm, (igraph_scg_norm_t) c_norm, (igraph_scg_direction_t) c_direction, (do_eval ? &c_eval : 0), (!Rf_isNull(evec) || do_evec ? &c_evec : 0), &c_groups, c_use_arpack, c_maxiter, (do_scg_graph ? &c_scg_graph : 0), (do_scg_matrix ? &c_scg_matrix : 0), (do_scg_sparsemat ? &c_scg_sparsemat : 0), (do_L ? &c_L : 0), (do_R ? &c_R : 0), (do_Lsparse ? &c_Lsparse : 0), (do_Rsparse ? &c_Rsparse : 0))); - - if (!Rf_isNull(sparsmat)) { igraph_free(c_sparsmat.cs); } - - /* Convert output */ - PROTECT(result=NEW_LIST(6)); - PROTECT(names=NEW_CHARACTER(6)); - - if (do_eval) { - PROTECT(eval=R_igraph_vector_complex_to_SEXP(&c_eval)); - igraph_vector_complex_destroy(&c_eval); - } else { - PROTECT(eval=R_NilValue); - } - - if (do_evec) { - PROTECT(evec=R_igraph_matrix_complex_to_SEXP(&c_evec)); - igraph_matrix_complex_destroy(&c_evec); - } else { - PROTECT(evec=R_NilValue); - } - - PROTECT(groups=R_igraph_vector_to_SEXPp1(&c_groups)); - igraph_vector_destroy(&c_groups); - - if (do_scg_graph) { - PROTECT(scg_graph=R_igraph_to_SEXP(&c_scg_graph)); - igraph_destroy(&c_scg_graph); - } else { - PROTECT(scg_graph=R_NilValue); - } - if (do_scg_matrix) { - PROTECT(scg_matrix=R_igraph_matrix_to_SEXP(&c_scg_matrix)); - igraph_matrix_destroy(&c_scg_matrix); - } else { - PROTECT(scg_matrix=R_NilValue); - } - if (do_scg_sparsemat) { - PROTECT(scg_sparsemat=R_igraph_sparsemat_to_SEXP(&c_scg_sparsemat)); - igraph_sparsemat_destroy(&c_scg_sparsemat); - } else { - PROTECT(scg_sparsemat=R_NilValue); - } - if (do_L) { - PROTECT(L=R_igraph_matrix_to_SEXP(&c_L)); - igraph_matrix_destroy(&c_L); - } else { - PROTECT(L=R_NilValue); - } - if (do_R) { - PROTECT(R=R_igraph_matrix_to_SEXP(&c_R)); - igraph_matrix_destroy(&c_R); - } else { - PROTECT(R=R_NilValue); - } - if (do_Lsparse) { - PROTECT(Lsparse=R_igraph_sparsemat_to_SEXP(&c_Lsparse)); - igraph_sparsemat_destroy(&c_Lsparse); - } else { - PROTECT(Lsparse=R_NilValue); - } - if (do_Rsparse) { - PROTECT(Rsparse=R_igraph_sparsemat_to_SEXP(&c_Rsparse)); - igraph_sparsemat_destroy(&c_Rsparse); - } else { - PROTECT(Rsparse=R_NilValue); - } - - if (do_scg_graph) { SET_VECTOR_ELT(result, 0, scg_graph); } - if (do_scg_matrix) { SET_VECTOR_ELT(result, 0, scg_matrix); } - if (do_scg_sparsemat) { SET_VECTOR_ELT(result, 0, scg_sparsemat); } - SET_VECTOR_ELT(result, 1, groups); - if (do_L) { SET_VECTOR_ELT(result, 2, L); } - if (do_Lsparse) { SET_VECTOR_ELT(result, 2, Lsparse); } - if (do_R) { SET_VECTOR_ELT(result, 3, R); } - if (do_Rsparse) { SET_VECTOR_ELT(result, 3, Rsparse); } - SET_VECTOR_ELT(result, 4, eval); - SET_VECTOR_ELT(result, 5, evec); - SET_STRING_ELT(names, 0, Rf_mkChar("Xt")); - SET_STRING_ELT(names, 1, Rf_mkChar("groups")); - SET_STRING_ELT(names, 2, Rf_mkChar("L")); - SET_STRING_ELT(names, 3, Rf_mkChar("R")); - SET_STRING_ELT(names, 4, Rf_mkChar("values")); - SET_STRING_ELT(names, 5, Rf_mkChar("vectors")); - SET_NAMES(result, names); - UNPROTECT(11); - - UNPROTECT(1); - return(result); -} - SEXP R_igraph_subisomorphic_lad(SEXP pattern, SEXP target, SEXP domains, SEXP induced, SEXP time_limit, SEXP pqmap, SEXP pqall_maps) { /* Declarations */ igraph_t c_pattern; igraph_t c_target; - igraph_vector_ptr_t c_domains; + igraph_vector_int_list_t c_domains; igraph_bool_t c_iso; - igraph_vector_t c_map; - igraph_vector_ptr_t c_maps; + igraph_vector_int_t c_map; + igraph_vector_int_list_t c_maps; igraph_bool_t c_induced; int c_time_limit; igraph_bool_t c_qmap; @@ -8932,25 +8249,25 @@ SEXP R_igraph_subisomorphic_lad(SEXP pattern, SEXP target, SEXP domains, R_SEXP_to_igraph(pattern, &c_pattern); R_SEXP_to_igraph(target, &c_target); - R_igraph_SEXP_to_0orvectorlist(domains, &c_domains); + R_igraph_SEXP_to_0orvector_int_list(domains, &c_domains); c_qmap=LOGICAL(pqmap)[0]; c_qall_maps=LOGICAL(pqall_maps)[0]; if (c_qmap) { - if (0 != igraph_vector_init(&c_map, 0)) { + if (0 != igraph_vector_int_init(&c_map, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_map); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_map); map=R_GlobalEnv; /* hack to have a non-NULL value */ } else { map=R_NilValue; } if (c_qall_maps) { - if (0 != igraph_vector_ptr_init(&c_maps, 0)) { + if (0 != igraph_vector_int_list_init(&c_maps, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_maps); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_maps); maps=R_GlobalEnv; /* hack to have a non-NULL value */ } else { maps=R_NilValue; @@ -8967,15 +8284,15 @@ SEXP R_igraph_subisomorphic_lad(SEXP pattern, SEXP target, SEXP domains, PROTECT(iso=NEW_LOGICAL(1)); LOGICAL(iso)[0]=c_iso; if (!Rf_isNull(map)) { - PROTECT(map=R_igraph_0orvector_to_SEXP(&c_map)); - igraph_vector_destroy(&c_map); + PROTECT(map=R_igraph_0orvector_int_to_SEXP(&c_map)); + igraph_vector_int_destroy(&c_map); IGRAPH_FINALLY_CLEAN(1); } else { PROTECT(map=R_NilValue); } if (!Rf_isNull(maps)) { - PROTECT(maps=R_igraph_0orvectorlist_to_SEXP(&c_maps)); - R_igraph_vectorlist_destroy(&c_maps); + PROTECT(maps=R_igraph_0orvector_int_list_to_SEXP(&c_maps)); + igraph_vector_int_list_destroy(&c_maps); IGRAPH_FINALLY_CLEAN(1); } else { PROTECT(maps=R_NilValue); @@ -9000,7 +8317,7 @@ SEXP R_igraph_graphlets(SEXP graph, SEXP weights, SEXP niter) { /* Declarations */ igraph_t c_graph; igraph_vector_t c_weights; - igraph_vector_ptr_t c_cliques; + igraph_vector_int_list_t c_cliques; igraph_vector_t c_Mu; int c_niter; SEXP cliques; @@ -9014,10 +8331,10 @@ SEXP R_igraph_graphlets(SEXP graph, SEXP weights, SEXP niter) { /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_vector_ptr_init(&c_cliques, 0)) { + if (0 != igraph_vector_int_list_init(&c_cliques, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_cliques); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_cliques); if (0 != igraph_vector_init(&c_Mu, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -9029,8 +8346,8 @@ SEXP R_igraph_graphlets(SEXP graph, SEXP weights, SEXP niter) { /* Convert output */ PROTECT(result=NEW_LIST(2)); PROTECT(names=NEW_CHARACTER(2)); - PROTECT(cliques=R_igraph_vectorlist_to_SEXP_p1(&c_cliques)); - R_igraph_vectorlist_destroy(&c_cliques); + PROTECT(cliques=R_igraph_vector_int_list_to_SEXP_p1(&c_cliques)); + igraph_vector_int_list_destroy(&c_cliques); IGRAPH_FINALLY_CLEAN(1); PROTECT(Mu=R_igraph_vector_to_SEXP(&c_Mu)); igraph_vector_destroy(&c_Mu); @@ -9055,7 +8372,7 @@ SEXP R_igraph_graphlets_candidate_basis(SEXP graph, SEXP weights) { /* Declarations */ igraph_t c_graph; igraph_vector_t c_weights; - igraph_vector_ptr_t c_cliques; + igraph_vector_int_list_t c_cliques; igraph_vector_t c_thresholds; SEXP cliques; SEXP thresholds; @@ -9069,10 +8386,10 @@ SEXP R_igraph_graphlets_candidate_basis(SEXP graph, SEXP weights) { /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (0 != igraph_vector_ptr_init(&c_cliques, 0)) { + if (0 != igraph_vector_int_list_init(&c_cliques, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &c_cliques); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &c_cliques); if (0 != igraph_vector_init(&c_thresholds, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -9083,8 +8400,8 @@ SEXP R_igraph_graphlets_candidate_basis(SEXP graph, SEXP weights) { /* Convert output */ PROTECT(result=NEW_LIST(2)); PROTECT(names=NEW_CHARACTER(2)); - PROTECT(cliques=R_igraph_vectorlist_to_SEXP_p1(&c_cliques)); - R_igraph_vectorlist_destroy(&c_cliques); + PROTECT(cliques=R_igraph_vector_int_list_to_SEXP_p1(&c_cliques)); + igraph_vector_int_list_destroy(&c_cliques); IGRAPH_FINALLY_CLEAN(1); PROTECT(thresholds=R_igraph_vector_to_SEXP(&c_thresholds)); igraph_vector_destroy(&c_thresholds); @@ -9104,7 +8421,7 @@ SEXP R_igraph_graphlets_candidate_basis(SEXP graph, SEXP weights) { int igraph_i_graphlets_project(const igraph_t *graph, const igraph_vector_t *weights, - const igraph_vector_ptr_t *cliques, + const igraph_vector_int_list_t *cliques, igraph_vector_t *Mu, igraph_bool_t startMu, int niter, int vid1); @@ -9117,7 +8434,7 @@ SEXP R_igraph_graphlets_project(SEXP graph, SEXP weights, SEXP cliques, /* Declarations */ igraph_t c_graph; igraph_vector_t c_weights; - igraph_vector_ptr_t c_cliques; + igraph_vector_int_list_t c_cliques; igraph_vector_t c_Mu; int c_niter; @@ -9126,7 +8443,7 @@ SEXP R_igraph_graphlets_project(SEXP graph, SEXP weights, SEXP cliques, /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); if (!Rf_isNull(weights)) { R_SEXP_to_vector(weights, &c_weights); } - if (!Rf_isNull(cliques)) { R_igraph_SEXP_to_vectorlist(cliques, &c_cliques); } + if (!Rf_isNull(cliques)) { R_igraph_SEXP_to_vector_int_list(cliques, &c_cliques); } if (0 != R_SEXP_to_vector_copy(Mu, &c_Mu)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } @@ -9331,16 +8648,6 @@ SEXP R_igraph_simple_interconnected_islands_game(SEXP islands_n, SEXP islands_si return result; } -SEXP R_igraph_version(void) { - const char *version; - SEXP result; - igraph_version(&version, /*major=*/ 0, /*minor=*/ 0, /*patch=*/ 0); - PROTECT(result=NEW_CHARACTER(1)); - SET_STRING_ELT(result, 0, Rf_mkChar(version)); - UNPROTECT(1); - return result; -} - SEXP R_igraph_bipartite_projection(SEXP graph, SEXP types, SEXP probe1, SEXP pwhich) { /* Declarations */ @@ -9348,8 +8655,8 @@ SEXP R_igraph_bipartite_projection(SEXP graph, SEXP types, SEXP probe1, igraph_vector_bool_t c_types; igraph_t c_proj1; igraph_t c_proj2; - igraph_vector_t c_multiplicity1; - igraph_vector_t c_multiplicity2; + igraph_vector_int_t c_multiplicity1; + igraph_vector_int_t c_multiplicity2; igraph_integer_t c_probe1; igraph_integer_t which=INTEGER(pwhich)[0]; igraph_bool_t do_1=(which == 0 || which == 1); @@ -9363,15 +8670,15 @@ SEXP R_igraph_bipartite_projection(SEXP graph, SEXP types, SEXP probe1, /* Convert input */ R_SEXP_to_igraph(graph, &c_graph); if (!Rf_isNull(types)) { R_SEXP_to_vector_bool(types, &c_types); } - if (0 != igraph_vector_init(&c_multiplicity1, 0)) { + if (0 != igraph_vector_int_init(&c_multiplicity1, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_multiplicity1); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_multiplicity1); multiplicity1 = R_GlobalEnv; /* hack to have a non-NULL value */ - if (0 != igraph_vector_init(&c_multiplicity2, 0)) { + if (0 != igraph_vector_int_init(&c_multiplicity2, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &c_multiplicity2); + IGRAPH_FINALLY(igraph_vector_int_destroy, &c_multiplicity2); multiplicity2=R_GlobalEnv; /* hack to have a non-NULL value */ c_probe1=INTEGER(probe1)[0]; /* Call igraph */ @@ -9396,11 +8703,11 @@ SEXP R_igraph_bipartite_projection(SEXP graph, SEXP types, SEXP probe1, } else { PROTECT(proj2=R_NilValue); } - PROTECT(multiplicity1=R_igraph_0orvector_to_SEXP(&c_multiplicity1)); - igraph_vector_destroy(&c_multiplicity1); + PROTECT(multiplicity1=R_igraph_0orvector_int_to_SEXP(&c_multiplicity1)); + igraph_vector_int_destroy(&c_multiplicity1); IGRAPH_FINALLY_CLEAN(1); - PROTECT(multiplicity2=R_igraph_0orvector_to_SEXP(&c_multiplicity2)); - igraph_vector_destroy(&c_multiplicity2); + PROTECT(multiplicity2=R_igraph_0orvector_int_to_SEXP(&c_multiplicity2)); + igraph_vector_int_destroy(&c_multiplicity2); IGRAPH_FINALLY_CLEAN(1); SET_VECTOR_ELT(result, 0, proj1); SET_VECTOR_ELT(result, 1, proj2); @@ -9417,28 +8724,6 @@ SEXP R_igraph_bipartite_projection(SEXP graph, SEXP types, SEXP probe1, return(result); } -SEXP R_igraph_solve_lsap(SEXP px, SEXP pnc) { - - igraph_matrix_t x; - igraph_integer_t nc = INTEGER(pnc)[0]; - igraph_vector_int_t p; - SEXP result; - - R_SEXP_to_matrix(px, &x); - - igraph_vector_int_init(&p, nc); - IGRAPH_FINALLY(igraph_vector_int_destroy, &p); - - igraph_solve_lsap(&x, nc, &p); - - PROTECT(result = R_igraph_vector_int_to_SEXP(&p)); - igraph_vector_int_destroy(&p); - IGRAPH_FINALLY_CLEAN(1); - - UNPROTECT(1); - return result; -} - SEXP R_igraph_adjacent_vertices(SEXP pgraph, SEXP pv, SEXP pmode) { igraph_t graph; diff --git a/src/rrandom.c b/src/rrandom.c index 7d1d0319dc3..629b8f48e4e 100644 --- a/src/rrandom.c +++ b/src/rrandom.c @@ -33,8 +33,6 @@ #include "igraph_vector.h" #include "igraph_memory.h" -#include "core/math.h" - #include "config.h" #include #include @@ -46,21 +44,21 @@ double Rf_rgeom(double); double Rf_rbinom(double, double); double Rf_rgamma(double, double); -static int igraph_rng_R_init(void **state) { +static igraph_error_t igraph_rng_R_init(void **state) { return IGRAPH_SUCCESS; } static void igraph_rng_R_destroy(void *state) { } -static int igraph_rng_R_seed(void *state, unsigned long int seed) { +static igraph_error_t igraph_rng_R_seed(void *state, igraph_uint_t seed) { IGRAPH_ERROR("R RNG error, unsupported function called", IGRAPH_EINTERNAL); return IGRAPH_SUCCESS; } -static unsigned long int igraph_rng_R_get(void *state) { - return (unsigned long) (unif_rand() * 0x7FFFFFFFUL); +static igraph_uint_t igraph_rng_R_get(void *state) { + return (unif_rand() * 0x7FFFFFFFUL); } static igraph_real_t igraph_rng_R_get_real(void *state) { @@ -75,14 +73,14 @@ static igraph_real_t igraph_rng_R_get_geom(void *state, igraph_real_t p) { return Rf_rgeom(p); } -static igraph_real_t igraph_rng_R_get_binom(void *state, long int n, +static igraph_real_t igraph_rng_R_get_binom(void *state, igraph_integer_t n, igraph_real_t p) { return Rf_rbinom(n, p); } static igraph_real_t igraph_rng_R_get_exp(void *state, igraph_real_t rate) { igraph_real_t scale = 1.0 / rate; - if (!IGRAPH_FINITE(scale) || scale <= 0.0) { + if (!isfinite(scale) || scale <= 0.0) { if (scale == 0.0) { return 0.0; } @@ -93,17 +91,19 @@ static igraph_real_t igraph_rng_R_get_exp(void *state, igraph_real_t rate) { static igraph_rng_type_t igraph_rng_R_type = { /* name= */ "GNU R", - /* min= */ 0, - /* max= */ 0x7FFFFFFFUL, + /* bits = */ 31, /* init= */ igraph_rng_R_init, /* destroy= */ igraph_rng_R_destroy, /* seed= */ igraph_rng_R_seed, /* get= */ igraph_rng_R_get, + /* get_int= */ NULL, /* get_real= */ igraph_rng_R_get_real, /* get_norm= */ igraph_rng_R_get_norm, /* get_geom= */ igraph_rng_R_get_geom, /* get_binom= */ igraph_rng_R_get_binom, - /* get_exp= */ igraph_rng_R_get_exp + /* get_exp= */ igraph_rng_R_get_exp, + /* get_gamma= */ NULL, // TODO + /* get_pois= */ NULL // TODO }; igraph_rng_t igraph_rng_R_instance; diff --git a/src/vendor/cigraph/CMakeLists.txt b/src/vendor/cigraph/CMakeLists.txt index faef69dcdd1..32292ab8030 100644 --- a/src/vendor/cigraph/CMakeLists.txt +++ b/src/vendor/cigraph/CMakeLists.txt @@ -15,6 +15,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/etc/cmake) # Note that we must do this only if PROJECT_NAME is not set at this point. If # it is set, it means that igraph is being used as a subproject of another # project. +message(${PROJECT_NAME}) if(NOT PROJECT_NAME) include(BuildType) endif() diff --git a/src/vendor/simpleraytracer/CMakeLists.txt b/src/vendor/simpleraytracer/CMakeLists.txt new file mode 100644 index 00000000000..72af04d746f --- /dev/null +++ b/src/vendor/simpleraytracer/CMakeLists.txt @@ -0,0 +1,23 @@ +set(SOURCES + Color.cpp + Light.cpp + Point.cpp + RIgraphRay.cpp + Ray.cpp + RayTracer.cpp + RayVector.cpp + Shape.cpp + Sphere.cpp + Triangle.cpp + unit_limiter.cpp +) + +add_library(simpleraytracer ${SOURCES}) +target_include_directories(simpleraytracer PRIVATE ${igraph_BINARY_DIR}/include ${rigraph_SOURCE_DIR}) + +install( + TARGETS simpleraytracer + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/src/vendor/uuid/CMakeLists.txt b/src/vendor/uuid/CMakeLists.txt new file mode 100644 index 00000000000..994356d0483 --- /dev/null +++ b/src/vendor/uuid/CMakeLists.txt @@ -0,0 +1,22 @@ +set(SOURCES + R.c + clear.c + compare.c + copy.c + gen_uuid.c + isnull.c + pack.c + parse.c + unpack.c + unparse.c +) + +add_library(uuid ${SOURCES}) +target_include_directories(uuid PRIVATE ${igraph_BINARY_DIR}/include ${rigraph_SOURCE_DIR}) + +install( + TARGETS uuid + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/tools/stimulus/Makevars.in b/tools/stimulus/Makevars.in index 1481b386484..be155fdd618 100644 --- a/tools/stimulus/Makevars.in +++ b/tools/stimulus/Makevars.in @@ -6,7 +6,7 @@ PKG_CPPFLAGS=-DUSING_R -I. -Icore -Iinclude -Ivendor \ @XML2_CPPFLAGS@ -DNDEBUG -DNTIMER -DNPRINT \ -DINTERNAL_ARPACK \ -DPRPACK_IGRAPH_SUPPORT -DIGRAPH_THREAD_LOCAL=/**/ -PKG_LIBS=@XML2_LIBS@ @GMP_LIBS@ @GLPK_LIBS@ $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) +PKG_LIBS=$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) all: $(SHLIB) diff --git a/tools/stimulus/functions-R.yaml b/tools/stimulus/functions-R.yaml index 1d815470784..fa0b6ba1d15 100644 --- a/tools/stimulus/functions-R.yaml +++ b/tools/stimulus/functions-R.yaml @@ -122,7 +122,7 @@ igraph_full_bipartite: igraph_realize_degree_sequence: PARAMS: |- - OUT GRAPH graph, VECTOR out_deg, VECTOR_OR_0 in_deg=NULL, + OUT GRAPH graph, VECTOR_INT out_deg, VECTOR_INT_OR_0 in_deg=NULL, EDGE_TYPE_SW allowed_edge_types=SIMPLE, REALIZE_DEGSEQ_METHOD method=SMALLEST R: GATTR: @@ -341,9 +341,6 @@ igraph_rewire: igraph_induced_subgraph: IGNORE: RR -igraph_subgraph_edges: - IGNORE: RR - igraph_average_path_length: # No need for it, igraph_average_path_length_dijkstra takes care of the # unweighted case as well @@ -435,9 +432,6 @@ igraph_arpack_rssolve: igraph_arpack_rnsolve: IGNORE: RR, RC, RInit -igraph_arpack_unpack_complex: - IGNORE: RR - igraph_unfold_tree: IGNORE: RR @@ -492,12 +486,6 @@ igraph_bipartite_projection: igraph_create_bipartite: IGNORE: RR -igraph_incidence: - IGNORE: RR - -igraph_get_incidence: - IGNORE: RR - igraph_bipartite_game_gnp: IGNORE: RR @@ -515,7 +503,7 @@ igraph_laplacian: # Components ####################################### -igraph_clusters: +igraph_connected_components: IGNORE: RR igraph_decompose: @@ -755,6 +743,16 @@ igraph_get_adjacency: igraph_get_edgelist: IGNORE: RR, RC +igraph_invalidate_cache: + PARAMS: INOUT GRAPH graph + IGNORE: RR + +igraph_write_graph_dimacs_flow: + PARAMS: |- + INOUT GRAPH graph, OUTFILE outstream, VERTEX source=0, VERTEX target=0, + VECTOR capacity + IGNORE: RR + igraph_to_directed: PARAMS: INOUT GRAPH graph, TODIRECTED mode=MUTUAL @@ -764,9 +762,6 @@ igraph_to_undirected: igraph_get_stochastic: IGNORE: RR -igraph_get_stochastic_sparsemat: - IGNORE: RR - ####################################### # Read and write foreign formats ####################################### @@ -977,20 +972,23 @@ igraph_simplify_and_colorize: # SCG ####################################### -igraph_scg_grouping: - IGNORE: RR +# TODO: define what to do with SCG +# scg is in separate repository from -igraph_scg_semiprojectors: - IGNORE: RR, RC, RInit +# igraph_scg_grouping: +# IGNORE: RR -igraph_scg_adjacency: - IGNORE: RR, RC, RInit +# igraph_scg_semiprojectors: +# IGNORE: RR, RC, RInit -igraph_scg_stochastic: - IGNORE: RR, RC, RInit +# igraph_scg_adjacency: +# IGNORE: RR, RC, RInit -igraph_scg_laplacian: - IGNORE: RR, RC, RInit +# igraph_scg_stochastic: +# IGNORE: RR, RC, RInit + +# igraph_scg_laplacian: +# IGNORE: RR, RC, RInit ####################################### # Matching @@ -1076,7 +1074,7 @@ igraph_from_prufer: GATTR-PARAM: prufer igraph_random_spanning_tree: - PARAMS: GRAPH graph, OUT EDGESET res, OPTIONAL VERTEX vid=0 + PARAMS: GRAPH graph, OUT EDGE_INDICES res, OPTIONAL VERTEX vid=0 ####################################### # Coloring diff --git a/tools/stimulus/rinterface.c.in b/tools/stimulus/rinterface.c.in index 985201ea519..18949b8dc63 100644 --- a/tools/stimulus/rinterface.c.in +++ b/tools/stimulus/rinterface.c.in @@ -22,7 +22,7 @@ */ #include "igraph.h" -#include "graph/neighbors.h" +#include "igraph_neighborhood.h" #include "config.h" @@ -55,25 +55,24 @@ SEXP R_igraph_vector_to_SEXP(const igraph_vector_t *v); SEXP R_igraph_vector_int_to_SEXP(const igraph_vector_int_t *v); SEXP R_igraph_vector_int_to_SEXPp1(const igraph_vector_int_t *v); SEXP R_igraph_vector_bool_to_SEXP(const igraph_vector_bool_t *v); -SEXP R_igraph_vector_long_to_SEXP(const igraph_vector_long_t *v); SEXP R_igraph_vector_complex_to_SEXP(const igraph_vector_complex_t* v); SEXP R_igraph_0orvector_to_SEXP(const igraph_vector_t *v); +SEXP R_igraph_0orvector_int_to_SEXP(const igraph_vector_int_t *v); SEXP R_igraph_0orvector_bool_to_SEXP(const igraph_vector_bool_t *v); -SEXP R_igraph_0orvector_long_to_SEXP(const igraph_vector_long_t *v); SEXP R_igraph_0orvector_complex_to_SEXP(const igraph_vector_complex_t *v); SEXP R_igraph_matrix_to_SEXP(const igraph_matrix_t *m); +SEXP R_igraph_matrix_int_to_SEXP(const igraph_matrix_int_t *m); SEXP R_igraph_matrix_complex_to_SEXP(const igraph_matrix_complex_t *m); SEXP R_igraph_0ormatrix_complex_to_SEXP(const igraph_matrix_complex_t *m); SEXP R_igraph_strvector_to_SEXP(const igraph_strvector_t *m); SEXP R_igraph_to_SEXP(const igraph_t *graph); SEXP R_igraph_vectorlist_to_SEXP(const igraph_vector_ptr_t *ptr); -SEXP R_igraph_vectorlist_int_to_SEXP(const igraph_vector_ptr_t *ptr); -void R_igraph_vectorlist_int_destroy(igraph_vector_ptr_t *ptr); +SEXP R_igraph_vector_int_list_to_SEXP(const igraph_vector_int_list_t *list); SEXP R_igraph_0orvectorlist_to_SEXP(const igraph_vector_ptr_t *ptr); void R_igraph_vectorlist_destroy(igraph_vector_ptr_t *ptr); SEXP R_igraph_matrixlist_to_SEXP(const igraph_vector_ptr_t *ptr); void R_igraph_matrixlist_destroy(igraph_vector_ptr_t *ptr); -SEXP R_igraph_graphlist_to_SEXP(const igraph_vector_ptr_t *ptr); +SEXP R_igraph_graphlist_to_SEXP(const igraph_graph_list_t *list); void R_igraph_graphlist_destroy(igraph_vector_ptr_t *ptr); SEXP R_igraph_hrg_to_SEXP(const igraph_hrg_t *hrg); SEXP R_igraph_plfit_result_to_SEXP(const igraph_plfit_result_t *plfit); @@ -87,7 +86,9 @@ int R_igraph_SEXP_to_strvector(SEXP rval, igraph_strvector_t *sv); int R_igraph_SEXP_to_strvector_copy(SEXP rval, igraph_strvector_t *sv); int R_SEXP_to_vector(SEXP sv, igraph_vector_t *v); int R_SEXP_to_vector_copy(SEXP sv, igraph_vector_t *v); +int R_SEXP_to_vector_int_copy(SEXP sv, igraph_vector_int_t *v); int R_SEXP_to_matrix(SEXP pakl, igraph_matrix_t *akl); +int R_SEXP_to_matrix_int(SEXP pakl, igraph_matrix_int_t *akl); int R_SEXP_to_matrix_complex(SEXP pakl, igraph_matrix_complex_t *akl); int R_SEXP_to_igraph_matrix_copy(SEXP pakl, igraph_matrix_t *akl); int R_SEXP_to_igraph(SEXP graph, igraph_t *res); @@ -97,14 +98,13 @@ int R_SEXP_to_igraph_es(SEXP rit, igraph_t *graph, igraph_es_t *it); int R_SEXP_to_igraph_adjlist(SEXP vectorlist, igraph_adjlist_t *ptr); int R_igraph_SEXP_to_0orvectorlist(SEXP vectorlist, igraph_vector_ptr_t *ptr); -int R_igraph_SEXP_to_vectorlist(SEXP vectorlist, igraph_vector_ptr_t *ptr); -int R_igraph_SEXP_to_vectorlist_int(SEXP vectorlist, - igraph_vector_ptr_t *ptr); -int R_igraph_SEXP_to_matrixlist(SEXP matrixlist, igraph_vector_ptr_t *ptr); +int R_igraph_SEXP_to_vectorlist(SEXP vectorlist, igraph_vector_list_t *list); +int R_igraph_SEXP_to_vector_int_list(SEXP vectorlist, + igraph_vector_int_list_t *list); +int R_igraph_SEXP_to_matrixlist(SEXP matrixlist, igraph_matrix_list_t *list); int R_SEXP_to_vector_bool(SEXP sv, igraph_vector_bool_t *v); int R_SEXP_to_vector_bool_copy(SEXP sv, igraph_vector_bool_t *v); int R_SEXP_to_vector_int(SEXP sv, igraph_vector_int_t *v); -int R_SEXP_to_vector_long_copy(SEXP sv, igraph_vector_long_t *v); int R_SEXP_to_hrg(SEXP shrg, igraph_hrg_t *hrg); int R_SEXP_to_hrg_copy(SEXP shrg, igraph_hrg_t *hrg); int R_SEXP_to_sparsemat(SEXP pakl, igraph_sparsemat_t *akl); @@ -114,11 +114,11 @@ int R_SEXP_to_attr_comb(SEXP input, igraph_attribute_combination_t *comb); SEXP R_igraph_bliss_info_to_SEXP(const igraph_bliss_info_t *info); int R_SEXP_to_igraph_eigen_which(SEXP in, igraph_eigen_which_t *out); int R_SEXP_to_igraph_arpack_options(SEXP in, igraph_arpack_options_t *opt); -SEXP R_igraph_vector_long_to_SEXPp1(const igraph_vector_long_t *v); SEXP R_igraph_vectorlist_to_SEXP_p1(const igraph_vector_ptr_t *ptr); -SEXP R_igraph_0orvector_to_SEXPp1(const igraph_vector_t *v); -SEXP R_igraph_0ormatrix_to_SEXP(const igraph_matrix_t *m); +SEXP R_igraph_0orvector_int_to_SEXPp1(const igraph_vector_int_t *v); +SEXP R_igraph_0ormatrix_int_to_SEXP(const igraph_matrix_t *m); SEXP R_igraph_vector_to_SEXPp1(const igraph_vector_t *v); +SEXP R_igraph_vector_int_to_SEXPp1(const igraph_vector_int_t *v); SEXP R_igraph_arpack_options_to_SEXP(const igraph_arpack_options_t *opt); /***********************************************/ diff --git a/tools/stimulus/types-RC.yaml b/tools/stimulus/types-RC.yaml index 2fd36f3073f..bcf2232c9b2 100644 --- a/tools/stimulus/types-RC.yaml +++ b/tools/stimulus/types-RC.yaml @@ -37,6 +37,21 @@ GRAPH_OR_0: igraph_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); +GRAPH_LIST: + CALL: '&%C%' + CTYPE: igraph_graph_list_t + INCONV: + OUT: |- + if (0 != igraph_graph_list_init(&%C%, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_graph_list_destroy, &%C%); + OUTCONV: + OUT: |- + PROTECT(%I%=R_igraph_graphlist_to_SEXP(&%C%)); + igraph_graph_list_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); + INTEGER: CTYPE: igraph_integer_t CALL: @@ -53,9 +68,20 @@ INTEGER: INT: CTYPE: int + CALL: + IN: '%C%' + OUT: '&%C%' + INOUT: '&%C%' INCONV: IN: '%C%=INTEGER(%I%)[0];' +CSTRING: + CTYPE: const char* + CALL: + IN: '%C%' + OUT: '&%C%' + INOUT: '&%C%' + LONGINT: CTYPE: long int INCONV: @@ -135,23 +161,23 @@ VECTOR: VECTORM1: CALL: '&%C%' - CTYPE: igraph_vector_t + CTYPE: igraph_vector_int_t INCONV: - IN: R_SEXP_to_vector(%I%, &%C%); + IN: R_SEXP_to_vector_int(%I%, &%C%); INOUT: |- - if (0 != R_SEXP_to_vector_copy(%I%, &%C%)) { + if (0 != R_SEXP_to_vector_int_copy(%I%, &%C%)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { + if (0 != igraph_vector_int_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: OUT: |- - PROTECT(%I%=R_igraph_vector_to_SEXPp1(&%C%)); - igraph_vector_destroy(&%C%); + PROTECT(%I%=R_igraph_vector_int_to_SEXPp1(&%C%)); + igraph_vector_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); VECTOR_BOOL: @@ -225,63 +251,74 @@ VECTOR_LONG_M1: igraph_vector_long_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VECTORLIST: +MATRIX_LIST: CALL: '&%C%' - CTYPE: igraph_vector_ptr_t + CTYPE: igraph_matrix_list_t + INCONV: + IN: R_igraph_SEXP_to_matrixlist(%I%, &%C%); + +VECTOR_LIST: + CALL: '&%C%' + CTYPE: igraph_vector_list_t INCONV: IN: R_igraph_SEXP_to_vectorlist(%I%, &%C%); OUT: |- - if (0 != igraph_vector_ptr_init(&%C%, 0)) { + if (0 != igraph_vector_list_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_list_destroy, &%C%); OUTCONV: OUT: |- PROTECT(%I%=R_igraph_vectorlist_to_SEXP(&%C%)); - R_igraph_vectorlist_destroy(&%C%); + igraph_vector_list_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -MATRIXLIST: +VECTOR_INT_LIST: CALL: '&%C%' - CTYPE: igraph_vector_ptr_t + CTYPE: igraph_vector_int_list_t INCONV: - IN: R_igraph_SEXP_to_matrixlist(%I%, &%C%); - -VERTEXSETLIST: - CALL: '&%C%' - CTYPE: igraph_vector_ptr_t - INCONV: - IN: if (!Rf_isNull(%I%)) { R_igraph_SEXP_to_vectorlist(%I%, &%C%); } + IN: if (!Rf_isNull(%I%)) { R_igraph_SEXP_to_vector_int_list(%I%, &%C%); } OUT: |- - if (0 != igraph_vector_ptr_init(&%C%, 0)) { + if (0 != igraph_vector_int_list_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &%C%); OUTCONV: OUT: |- - PROTECT(%I%=R_igraph_vectorlist_to_SEXP_p1(&%C%)); - R_igraph_vectorlist_destroy(&%C%); + PROTECT(%I%=R_igraph_vector_int_list_to_SEXP(&%C%)); + igraph_vector_int_list_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VERTEXSETLIST_INT: +VERTEXSET_LIST: CALL: '&%C%' - CTYPE: igraph_vector_ptr_t + CTYPE: igraph_vector_int_list_t INCONV: - IN: if (!Rf_isNull(%I%)) { R_igraph_SEXP_to_vectorlist_int(%I%, &%C%); } + IN: if (!Rf_isNull(%I%)) { R_igraph_SEXP_to_vector_int_list(%I%, &%C%); } + OUT: |- + if (0 != igraph_vector_int_list_init(&%C%, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &%C%); + OUTCONV: + OUT: |- + PROTECT(%I%=R_igraph_vector_int_list_to_SEXP(&%C%)); + igraph_vector_int_list_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); -EDGESETLIST: +EDGESET_LIST: CALL: '&%C%' - CTYPE: igraph_vector_ptr_t + CTYPE: igraph_vector_int_list_t INCONV: + IN: if (!Rf_isNull(%I%)) { R_igraph_SEXP_to_vector_int_list(%I%, &%C%); } OUT: |- - if (0 != igraph_vector_ptr_init(&%C%, 0)) { + if (0 != igraph_vector_int_list_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(R_igraph_vectorlist_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_int_list_destroy, &%C%); OUTCONV: OUT: |- - PROTECT(%I%=R_igraph_vectorlist_to_SEXP_p1(&%C%)); - R_igraph_vectorlist_destroy(&%C%); + PROTECT(%I%=R_igraph_vector_int_list_to_SEXP(&%C%)); + igraph_vector_int_list_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); ADJLIST: @@ -293,62 +330,33 @@ ADJLIST: igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } -VECTOR_OR_0: - CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' - CTYPE: igraph_vector_t - INCONV: - IN: if (!Rf_isNull(%I%)) { R_SEXP_to_vector(%I%, &%C%); } - INOUT: |- - if (!Rf_isNull(%I%)) { - if (0 != R_SEXP_to_vector_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - } else { - if (0 != igraph_vector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - } - IGRAPH_FINALLY(igraph_vector_destroy, &%C%); - %I%=NEW_NUMERIC(0); - OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - IGRAPH_FINALLY(igraph_vector_destroy, &%C%); - %I%=R_GlobalEnv; /* hack to have a non-NULL value */ - OUTCONV: - OUT: |- - PROTECT(%I%=R_igraph_0orvector_to_SEXP(&%C%)); - igraph_vector_destroy(&%C%); - IGRAPH_FINALLY_CLEAN(1); - -VECTORM1_OR_0: +VECTOR_INT_OR_0: CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' - CTYPE: igraph_vector_t + CTYPE: igraph_vector_int_t INCONV: - IN: if (!Rf_isNull(%I%)) { R_SEXP_to_vector(%I%, &%C%); } + IN: if (!Rf_isNull(%I%)) { R_SEXP_to_vector_int(%I%, &%C%); } INOUT: |- if (!Rf_isNull(%I%)) { - if (0 != R_SEXP_to_vector_copy(%I%, &%C%)) { + if (0 != R_SEXP_to_vector_int_copy(%I%, &%C%)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } } else { - if (0 != igraph_vector_init(&%C%, 0)) { + if (0 != igraph_vector_int_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } } - IGRAPH_FINALLY(igraph_vector_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); %I%=NEW_NUMERIC(0); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { + if (0 != igraph_vector_int_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); %I%=R_GlobalEnv; /* hack to have a non-NULL value */ OUTCONV: OUT: |- - PROTECT(%I%=R_igraph_0orvector_to_SEXPp1(&%C%)); - igraph_vector_destroy(&%C%); + PROTECT(%I%=R_igraph_0orvector_int_to_SEXP(&%C%)); + igraph_vector_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); EDGEWEIGHTS: @@ -385,7 +393,7 @@ VERTEXWEIGHTS: igraph_vector_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -EDGECAPACITY: +EDGE_CAPACITY: CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' CTYPE: igraph_vector_t INCONV: @@ -440,33 +448,25 @@ MATRIX: igraph_matrix_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -MATRIX_OR_0: - CALL: '(Rf_isNull(%I%) ? 0 : &%C%)' - CTYPE: igraph_matrix_t +MATRIX_INT: + CALL: '&%C%' + CTYPE: igraph_matrix_int_t INCONV: - IN: if (!Rf_isNull(%I%)) { R_SEXP_to_matrix(%I%, &%C%); } + IN: R_SEXP_to_matrix_int(%I%, &%C%); INOUT: |- - if (!Rf_isNull(%I%)) { - if (0 != R_SEXP_to_igraph_matrix_copy(%I%, &%C%)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } - } else { - if (0 != igraph_matrix_init(&%C%, 0, 0)) { - igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); - } + if (0 != R_SEXP_to_igraph_matrix_int_copy(%I%, &%C%)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &%C%); - %I%=NEW_NUMERIC(0); + IGRAPH_FINALLY(igraph_matrix_int_destroy, &%C%); OUT: |- - if (0 != igraph_matrix_init(&%C%, 0, 0)) { + if (0 != igraph_matrix_int_init(&%C%, 0, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_matrix_destroy, &%C%); - %I%=R_GlobalEnv; /* hack to have a non-NULL value */ + IGRAPH_FINALLY(igraph_matrix_int_destroy, &%C%); OUTCONV: OUT: |- - PROTECT(%I%=R_igraph_0ormatrix_to_SEXP(&%C%)); - igraph_matrix_destroy(&%C%); + PROTECT(%I%=R_igraph_matrix_int_to_SEXP(&%C%)); + igraph_matrix_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); ARRAY3: @@ -517,6 +517,27 @@ VERTEX: PROTECT(%I% = NEW_INTEGER(1)); INTEGER(%I%)[0] = %C% + 1; +VERTEX_QTY: + CALL: '&%C%' + CTYPE: igraph_vector_t + INCONV: + IN: R_SEXP_to_vector(%I%, &%C%); + INOUT: |- + if (0 != R_SEXP_to_vector_copy(%I%, &%C%)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &%C%); + OUT: |- + if (0 != igraph_vector_init(&%C%, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_destroy, &%C%); + OUTCONV: + OUT: |- + PROTECT(%I%=R_igraph_vector_to_SEXP(&%C%)); + igraph_vector_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); + VERTEXSET: CALL: IN: '%C%' @@ -538,14 +559,11 @@ VERTEXSET: igraph_vector_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -VERTEXSET_INT: - CALL: - OUT: '&%C%' - CTYPE: - IN: disallowed - INOUT: disallowed - OUT: igraph_vector_int_t +VERTEX_INDICES: + CALL: '&%C%' + CTYPE: igraph_vector_int_t INCONV: + IN: R_SEXP_to_vector_int(%I%, &%C%); OUT: |- if (0 != igraph_vector_int_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); @@ -553,29 +571,40 @@ VERTEXSET_INT: IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: OUT: |- - PROTECT(%I%=R_igraph_vector_int_to_SEXPp1(&%C%)); + PROTECT(%I%=R_igraph_vector_int_to_SEXP(&%C%)); igraph_vector_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); -EDGESET: - CALL: - IN: '%C%' - OUT: '&%C%' - CTYPE: - IN: igraph_es_t - OUT: igraph_vector_t +VERTEX_INDEX_PAIRS: + CALL: '&%C%' + CTYPE: igraph_vector_int_t INCONV: - IN: R_SEXP_to_igraph_es(%I%, &%C1%, &%C%); + IN: R_SEXP_to_vector_int(%I%, &%C%); OUT: |- - if (0 != igraph_vector_init(&%C%, 0)) { + if (0 != igraph_vector_int_init(&%C%, 0)) { igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); } - IGRAPH_FINALLY(igraph_vector_destroy, &%C%); + IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); OUTCONV: - IN: igraph_es_destroy(&%C%); OUT: |- - PROTECT(%I%=R_igraph_vector_to_SEXPp1(&%C%)); - igraph_vector_destroy(&%C%); + PROTECT(%I%=R_igraph_vector_int_to_SEXP(&%C%)); + igraph_vector_int_destroy(&%C%); + IGRAPH_FINALLY_CLEAN(1); + +EDGE_INDICES: + CALL: '&%C%' + CTYPE: igraph_vector_int_t + INCONV: + IN: R_SEXP_to_vector_int(%I%, &%C%); + OUT: |- + if (0 != igraph_vector_int_init(&%C%, 0)) { + igraph_error("", __FILE__, __LINE__, IGRAPH_ENOMEM); + } + IGRAPH_FINALLY(igraph_vector_int_destroy, &%C%); + OUTCONV: + OUT: |- + PROTECT(%I%=R_igraph_vector_int_to_SEXP(&%C%)); + igraph_vector_int_destroy(&%C%); IGRAPH_FINALLY_CLEAN(1); 'NULL': @@ -593,6 +622,21 @@ ISOCOMPAT_FUNC: CTYPE: ~ HEADER: {} +ISOMORPHISM_FUNC: + CALL: '0' + CTYPE: ~ + HEADER: {} + +ASTAR_HEURISTIC_FUNC: + CALL: '0' + CTYPE: ~ + HEADER: {} + +ATTRIBUTES: + CALL: '0' + CTYPE: ~ + HEADER: {} + ARPACKOPT: CALL: '&%C%' INCONV: @@ -605,6 +649,11 @@ ARPACKSTORAGE: CTYPE: ~ HEADER: {} +ARPACKFUNC: + CALL: '0' + CTYPE: ~ + HEADER: {} + DRL_OPTIONS: CALL: '&%C%' INCONV: @@ -617,7 +666,7 @@ BLISSINFO: PROTECT(%I%=R_igraph_bliss_info_to_SEXP(&%C%)); if (%C%.group_size) { free(%C%.group_size); } -STRVECTOR: +VECTOR_STR: CALL: '&%C%' CTYPE: igraph_strvector_t INCONV: @@ -881,7 +930,7 @@ EIGENWHICHPOS: INCONV: IN: '%C%=INTEGER(%I%)[0];' -SIRLIST: +SIR_LIST: CALL: '&%C%' CTYPE: igraph_vector_ptr_t INCONV: diff --git a/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index f56dc0047c6..7217d3b4e35 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -52,12 +52,9 @@ VECTOR_INT: VECTORM1: INCONV: '%I% <- as.numeric(%I%)-1' -VECTOR_OR_0: +VECTOR_INT_OR_0: INCONV: if (!is.null(%I%)) %I% <- as.numeric(%I%) -VECTORM1_OR_0: - INCONV: if (!is.null(%I%)) %I% <- as.numeric(%I%)-1 - VECTOR_LONG_M1: INCONV: '%I% <- as.numeric(%I%)-1' @@ -70,6 +67,9 @@ VECTOR_BOOL_OR_0: MATRIX: INCONV: '%I% <- as.matrix(structure(as.double(%I%), dim=dim(%I%)))' +MATRIX_INT: + INCONV: '%I% <- as.matrix(structure(as.integer(%I%), dim=dim(%I%)))' + MATRIX_OR_0: INCONV: if (!is.null(%I%)) %I% <- structure(as.double(%I%), dim=dim(%I%)) @@ -136,7 +136,18 @@ VERTEXSET: %I% <- create_vs(%I1%, %I%) } -VERTEXSET_INT: +VERTEX_INDICES: + CALL: '%I%-1' + DEFAULT: + ALL: V(%I1%) + INCONV: '%I% <- as.igraph.vs(%I1%, %I%)' + OUTCONV: + OUT: |- + if (igraph_opt("return.vs.es")) { + %I% <- create_vs(%I1%, %I%) + } + +VERTEX_INDEX_PAIRS: CALL: '%I%-1' DEFAULT: ALL: V(%I1%) @@ -147,15 +158,15 @@ VERTEXSET_INT: %I% <- create_vs(%I1%, %I%) } -EDGESET: +EDGE_INDICES: CALL: '%I%-1' DEFAULT: - ALL: E(%I1%) - INCONV: '%I% <- as.igraph.es(%I1%, %I%)' + ALL: V(%I1%) + INCONV: '%I% <- as.igraph.vs(%I1%, %I%)' OUTCONV: OUT: |- if (igraph_opt("return.vs.es")) { - %I% <- create_es(%I1%, %I%) + %I% <- create_vs(%I1%, %I%) } EDGEWEIGHTS: @@ -180,7 +191,7 @@ VERTEXWEIGHTS: %I% <- NULL } -EDGECAPACITY: +EDGE_CAPACITY: INCONV: |- if (is.null(%I%) && "capacity" %in% edge_attr_names(%I1%)) { %I% <- E(%I1%)$capacity @@ -249,7 +260,7 @@ ISOCOMPAT_FUNC: VECTORLIST: {} -MATRIXLIST: +MATRIX_LIST: INCONV: IN: |- if (!all(sapply(%I%, is.matrix))) { @@ -266,20 +277,6 @@ VERTEXSETLIST: } } -VERTEXSETLIST_INT: - INCONV: - IN: '%I% <- lapply(%I%, function(x) as.integer(x)-1L)' - -EDGESETLIST: - OUTCONV: - OUT: |- - if (igraph_opt("return.vs.es")) { - es <- E(%I1%) - for (i_ in seq_along(%I%)) { - %I%[[i_]] <- unsafe_create_es(%I1%, %I%[[i_]], es = es) - } - } - 'ARPACKSTORAGE': CALL: {} HEADER: ~ @@ -292,7 +289,7 @@ DRL_OPTIONS: INCONV: IN: '%I%.tmp <- drl_defaults$default; %I%.tmp [names(%I%)] <- %I%; %I% <- %I%.tmp' -STRVECTOR: {} +VECTOR_STR: {} BLISSSH: DEFAULT: @@ -410,7 +407,7 @@ EIGENWHICHPOS: ASE: c("lm", "la", "sa") INCONV: '%I% <- switch(igraph.match.arg(%I%), "lm"=0L, "la"=2L, "sa"=3L)' -SIRLIST: {} +SIR_LIST: {} PAGERANKALGO: DEFAULT: